1 | <?php |
||
13 | class CleanUpModelsCommand extends Command |
||
14 | { |
||
15 | /** |
||
16 | * The console command name. |
||
17 | * |
||
18 | * @var string |
||
19 | */ |
||
20 | protected $signature = 'clean:models'; |
||
21 | /** |
||
22 | * The console command description. |
||
23 | * |
||
24 | * @var string |
||
25 | */ |
||
26 | protected $description = 'Clean up models.'; |
||
27 | |||
28 | protected $filesystem; |
||
29 | |||
30 | public function __construct(Filesystem $filesystem) |
||
36 | |||
37 | public function handle() |
||
47 | |||
48 | protected function getModelsThatShouldBeCleanedUp() : Collection |
||
60 | |||
61 | protected function cleanUp(Collection $cleanableModels) |
||
71 | |||
72 | protected function getAllModelsFromEachDirectory(array $directories) : Collection |
||
73 | { |
||
74 | return collect($directories) |
||
75 | ->map(function ($directory) { |
||
76 | return $this->getClassNamesInDirectory($directory)->all(); |
||
77 | }) |
||
78 | ->flatten(); |
||
79 | } |
||
80 | |||
81 | protected function getClassNamesInDirectory(string $directory) : Collection |
||
89 | |||
90 | protected function getFullyQualifiedClassNameFromFile(string $path) : string |
||
113 | } |
||
114 |
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: