nunomaduro /
laravel-code-analyse
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | /** |
||
| 6 | * This file is part of Laravel Code Analyse. |
||
| 7 | * |
||
| 8 | * (c) Nuno Maduro <[email protected]> |
||
| 9 | * |
||
| 10 | * For the full copyright and license information, please view the LICENSE |
||
| 11 | * file that was distributed with this source code. |
||
| 12 | */ |
||
| 13 | |||
| 14 | namespace NunoMaduro\LaravelCodeAnalyse\Support\Facades; |
||
| 15 | |||
| 16 | use function get_class; |
||
| 17 | use InvalidArgumentException; |
||
| 18 | use Illuminate\Support\Manager; |
||
| 19 | use Illuminate\Support\Facades\Facade; |
||
| 20 | use PHPStan\Reflection\ClassReflection; |
||
| 21 | use NunoMaduro\LaravelCodeAnalyse\AbstractExtension; |
||
| 22 | use NunoMaduro\LaravelCodeAnalyse\FacadeConcreteClassResolver; |
||
| 23 | |||
| 24 | final class FacadeMethodExtension extends AbstractExtension |
||
| 25 | { |
||
| 26 | /** |
||
| 27 | * {@inheritdoc} |
||
| 28 | */ |
||
| 29 | protected $staticAccess = true; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * {@inheritdoc} |
||
| 33 | */ |
||
| 34 | protected function subject(): string |
||
| 35 | { |
||
| 36 | return Facade::class; |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * {@inheritdoc} |
||
| 41 | */ |
||
| 42 | protected function searchIn(ClassReflection $classReflection): array |
||
| 43 | { |
||
| 44 | $facadeClass = $classReflection->getName(); |
||
| 45 | |||
| 46 | if ($concrete = $facadeClass::getFacadeRoot()) { |
||
| 47 | |||
| 48 | $classes = [get_class($concrete)]; |
||
| 49 | |||
| 50 | if ($concrete instanceof Manager) { |
||
| 51 | |||
| 52 | $driver = null; |
||
|
0 ignored issues
–
show
Unused Code
introduced
by
Loading history...
|
|||
| 53 | |||
| 54 | try { |
||
| 55 | $driver = $concrete->driver(); |
||
| 56 | } catch (InvalidArgumentException $exception) { |
||
| 57 | // .. |
||
| 58 | } |
||
| 59 | |||
| 60 | if ($driver !== null) { |
||
| 61 | $classes[] = get_class($driver); |
||
| 62 | } |
||
| 63 | } |
||
| 64 | |||
| 65 | return $classes; |
||
| 66 | } |
||
| 67 | |||
| 68 | return [NullConcreteClass::class]; |
||
| 69 | } |
||
| 70 | } |
||
| 71 |