Repository: tighten/tlint (php)

Issue:
NoRequestAll incorrectly identifies $request->user()
I have recently created a new Laravel 9.6.0 project, installed Jetstream Inertia, then added Tighten/TLint. I created a custom Preset to include more linters including Linters\NoRequestAll.

This linter now identifies the following code as violating NoRequestAll:

```
Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
    return $request->user();
});
```


Pull request description:
Fix no `$request-all()` check
This PR aims to fix #285.



Patch:
diff --git a/src/Linters/NoRequestAll.php b/src/Linters/NoRequestAll.php
index 96c2a73..1fe487e 100644
--- a/src/Linters/NoRequestAll.php
+++ b/src/Linters/NoRequestAll.php
@@ -19,9 +19,10 @@ class NoRequestAll extends BaseLinter
         $traverser = new NodeTraverser;
 
         $traverser->addVisitor($visitor = new FindingVisitor(function (Node $node) {
-            return ($node instanceof MethodCall && (string) $node->var->name === 'request')
-                || ($node instanceof StaticCall && (string) $node->class === 'Request')
-                && $node->name->name === 'all';
+            $isRequestMethodCall = $node instanceof MethodCall && (string) $node->var->name === 'request';
+            $isRequestStaticCall = $node instanceof StaticCall && (string) $node->class === 'Request';
+
+            return ($isRequestMethodCall || $isRequestStaticCall) && $node->name->name === 'all';
         }));
 
         $traverser->traverse($parser->parse($this->code));


Test patch:
diff --git a/tests/Linting/Linters/NoRequestAllTest.php b/tests/Linting/Linters/NoRequestAllTest.php
index 4432b89..90b1bd3 100644
--- a/tests/Linting/Linters/NoRequestAllTest.php
+++ b/tests/Linting/Linters/NoRequestAllTest.php
@@ -83,4 +83,24 @@ file;
 
         $this->assertEquals(11, $lints[0]->getNode()->getLine());
     }
+
+    /** @test */
+    public function allows_other_request_methods()
+    {
+        $file = <<<'file'
+<?php
+
+Route::get('/user', function (Request $request) {
+    $user = $request->user();
+    $method = $request->method();
+    $keys = $request->keys();
+
+    return [$user, $method, $keys];
+});
+file;
+
+        $lints = (new TLint)->lint(new NoRequestAll($file));
+
+        $this->assertEmpty($lints);
+    }
 }