Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
98 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace NunoMaduro\Larastan\Collectors; | ||
|
||
use Illuminate\Support\Facades\Route; | ||
use Illuminate\View\ViewName; | ||
use PhpParser\Node; | ||
use PHPStan\Analyser\Scope; | ||
use PHPStan\Collectors\Collector; | ||
use PHPStan\Type\ObjectType; | ||
|
||
/** @implements Collector<Node\Expr\StaticCall, string> */ | ||
final class UsedRouteFacadeViewCollector implements Collector | ||
{ | ||
public function getNodeType(): string | ||
{ | ||
return Node\Expr\StaticCall::class; | ||
} | ||
|
||
/** @param Node\Expr\StaticCall $node */ | ||
public function processNode(Node $node, Scope $scope): ?string | ||
{ | ||
$name = $node->name; | ||
|
||
if (! $name instanceof Node\Identifier) { | ||
return null; | ||
} | ||
|
||
if ($name->name !== 'view') { | ||
return null; | ||
} | ||
|
||
if (count($node->getArgs()) < 2) { | ||
return null; | ||
} | ||
|
||
$class = $node->class; | ||
|
||
if (! $class instanceof Node\Name) { | ||
return null; | ||
} | ||
|
||
$class = $scope->resolveName($class); | ||
|
||
if (! (new ObjectType(Route::class))->isSuperTypeOf(new ObjectType($class))->yes()) { | ||
return null; | ||
} | ||
|
||
$template = $node->getArgs()[1]->value; | ||
|
||
if (! $template instanceof Node\Scalar\String_) { | ||
return null; | ||
} | ||
|
||
return ViewName::normalize($template->value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,4 @@ | |
|
||
Lorem ipsum | ||
|
||
@include('home') | ||
@include("home") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This is used in a Route::view |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters