These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace LaravelPlus\Extension\Generators; |
||
4 | |||
5 | use Jumilla\Addomnipot\Laravel\Environment as AddonEnvironment; |
||
6 | use Jumilla\Addomnipot\Laravel\Addon; |
||
7 | use UnexpectedValueException; |
||
8 | |||
9 | trait GeneratorCommandTrait |
||
10 | { |
||
11 | /** |
||
12 | * addon. |
||
13 | * |
||
14 | * @var \LaravelPlus\Extension\Addons\Addon |
||
15 | */ |
||
16 | protected $addon; |
||
17 | |||
18 | /** |
||
19 | * Execute the console command. |
||
20 | * |
||
21 | * @return bool |
||
22 | */ |
||
23 | 38 | public function handle() |
|
24 | { |
||
25 | 38 | if (!$this->processArguments()) { |
|
26 | 1 | return false; |
|
27 | } |
||
28 | |||
29 | 36 | $this->addon = $this->getAddon(); |
|
0 ignored issues
–
show
|
|||
30 | |||
31 | 24 | return parent::handle(); |
|
32 | } |
||
33 | |||
34 | /** |
||
35 | * Process command line arguments |
||
36 | * |
||
37 | * @return bool |
||
38 | */ |
||
39 | 33 | protected function processArguments() |
|
40 | { |
||
41 | 33 | return true; |
|
42 | } |
||
43 | |||
44 | /** |
||
45 | * Get addon. |
||
46 | * |
||
47 | * @return string |
||
48 | */ |
||
49 | 40 | protected function getAddon() |
|
50 | { |
||
51 | 40 | if ($addon = $this->option('addon')) { |
|
52 | 27 | $env = app(AddonEnvironment::class); |
|
53 | |||
54 | 27 | if (!$env->exists($addon)) { |
|
55 | 13 | throw new UnexpectedValueException("Addon '$addon' is not found."); |
|
56 | } |
||
57 | |||
58 | 14 | return $env->addon($addon); |
|
59 | } else { |
||
60 | 13 | return; |
|
61 | } |
||
62 | 1 | } |
|
63 | |||
64 | /** |
||
65 | * Get the application namespace. |
||
66 | * |
||
67 | * @return $string |
||
68 | */ |
||
69 | 17 | protected function getAppNamespace() |
|
70 | { |
||
71 | 17 | return trim($this->laravel->getNamespace(), '\\'); |
|
72 | } |
||
73 | |||
74 | /** |
||
75 | * Get the addon namespace. |
||
76 | * |
||
77 | * @return $string |
||
78 | */ |
||
79 | 13 | protected function getAddonNamespace() |
|
80 | { |
||
81 | 13 | return $this->addon->phpNamespace(); |
|
82 | } |
||
83 | |||
84 | /** |
||
85 | * Get the default namespace for the class. |
||
86 | * |
||
87 | * @return $string |
||
88 | */ |
||
89 | 25 | protected function getRootNamespace() |
|
90 | { |
||
91 | 25 | return $this->addon ? $this->getAddonNamespace() : $this->getAppNamespace(); |
|
92 | } |
||
93 | |||
94 | /** |
||
95 | * Get the directory path for root namespace. |
||
96 | * |
||
97 | * @return string |
||
98 | */ |
||
99 | 25 | protected function getRootDirectory() |
|
100 | { |
||
101 | 25 | if ($this->addon) { |
|
102 | 13 | $directories = $this->addon->config('addon.directories'); |
|
103 | |||
104 | 13 | if (! $directories) { |
|
105 | 13 | $directories = ['classes']; |
|
106 | 13 | } |
|
107 | |||
108 | 13 | return $this->addon->path($directories[0]); |
|
109 | } |
||
110 | else { |
||
111 | 12 | return parent::getRootDirectory(); |
|
112 | } |
||
113 | } |
||
114 | } |
||
115 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..