This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /* |
||
4 | * This file is part of Laravel Service Provider. |
||
5 | * |
||
6 | * (c) DraperStudio <[email protected]> |
||
7 | * |
||
8 | * For the full copyright and license information, please view the LICENSE |
||
9 | * file that was distributed with this source code. |
||
10 | */ |
||
11 | |||
12 | namespace DraperStudio\ServiceProvider\Publisher; |
||
13 | |||
14 | use Illuminate\Filesystem\Filesystem; |
||
15 | |||
16 | abstract class Publisher |
||
17 | { |
||
18 | /** |
||
19 | * The filesystem instance. |
||
20 | * |
||
21 | * @var \Illuminate\Filesystem\Filesystem |
||
22 | */ |
||
23 | protected $files; |
||
24 | |||
25 | /** |
||
26 | * The destination of the config files. |
||
27 | * |
||
28 | * @var string |
||
29 | */ |
||
30 | protected $publishPath; |
||
31 | |||
32 | /** |
||
33 | * The path to the application's packages. |
||
34 | * |
||
35 | * @var string |
||
36 | */ |
||
37 | protected $packagePath; |
||
38 | |||
39 | /** |
||
40 | * The destination paths for source files. |
||
41 | * |
||
42 | * @var string |
||
43 | */ |
||
44 | protected $destinationPaths; |
||
45 | |||
46 | /** |
||
47 | * Create a new publisher instance. |
||
48 | * |
||
49 | * @param \Illuminate\Filesystem\Filesystem $files |
||
50 | * @param string $publishPath |
||
51 | */ |
||
52 | public function __construct(Filesystem $files, $publishPath) |
||
53 | { |
||
54 | $this->files = $files; |
||
55 | $this->publishPath = $publishPath; |
||
56 | |||
57 | $this->destinationPaths = [ |
||
0 ignored issues
–
show
|
|||
58 | 'migrations' => database_path('/migrations/%s_%s'), |
||
59 | 'seeds' => database_path('/seeds/%s'), |
||
60 | 'config' => config_path('%s'), |
||
61 | 'views' => base_path('resources/views/vendor/%s'), |
||
62 | 'translations' => base_path('resources/lang/%s'), |
||
63 | 'assets' => public_path('vendor/%s'), |
||
64 | 'routes' => null, |
||
65 | ]; |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * Publish files from a given path. |
||
70 | * |
||
71 | * @param string $package |
||
72 | * @param string $source |
||
0 ignored issues
–
show
There is no parameter named
$source . Was it maybe removed?
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. Consider the following example. The parameter /**
* @param array $germany
* @param array $island
* @param array $italy
*/
function finale($germany, $island) {
return "2:1";
}
The most likely cause is that the parameter was removed, but the annotation was not. ![]() |
|||
73 | * |
||
74 | * @return bool |
||
75 | */ |
||
76 | public function getFileList($package) |
||
77 | { |
||
78 | return $this->getSource($package, $this->packagePath); |
||
0 ignored issues
–
show
The call to
Publisher::getSource() has too many arguments starting with $this->packagePath .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the ![]() |
|||
79 | } |
||
80 | |||
81 | /** |
||
82 | * Set the default package path. |
||
83 | * |
||
84 | * @param string $packagePath |
||
85 | */ |
||
86 | public function setPackagePath($packagePath) |
||
87 | { |
||
88 | $this->packagePath = $packagePath; |
||
89 | } |
||
90 | |||
91 | /** |
||
92 | * Set the default package name. |
||
93 | * |
||
94 | * @param string $packageName |
||
95 | */ |
||
96 | public function setPackageName($packageName) |
||
97 | { |
||
98 | $this->packageName = $packageName; |
||
0 ignored issues
–
show
The property
packageName does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
![]() |
|||
99 | } |
||
100 | |||
101 | /** |
||
102 | * Get the source directory to publish. |
||
103 | * |
||
104 | * @param string $packagePath |
||
105 | * |
||
106 | * @return string |
||
107 | * |
||
108 | * @throws \InvalidArgumentException |
||
109 | */ |
||
110 | abstract protected function getSource($packagePath); |
||
111 | |||
112 | /** |
||
113 | * @param $file |
||
114 | * |
||
115 | * @return string |
||
116 | */ |
||
117 | protected function getFileName($file) |
||
118 | { |
||
119 | $file = basename($file); |
||
120 | |||
121 | if (!ends_with($file, '.php')) { |
||
122 | $file = $file.'.php'; |
||
123 | } |
||
124 | |||
125 | return $file; |
||
126 | } |
||
127 | |||
128 | /** |
||
129 | * Get the target destination path for the files. |
||
130 | * |
||
131 | * @param string $package |
||
0 ignored issues
–
show
There is no parameter named
$package . Was it maybe removed?
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. Consider the following example. The parameter /**
* @param array $germany
* @param array $island
* @param array $italy
*/
function finale($germany, $island) {
return "2:1";
}
The most likely cause is that the parameter was removed, but the annotation was not. ![]() |
|||
132 | * |
||
133 | * @return string |
||
134 | */ |
||
135 | protected function getDestinationPath($type, $args) |
||
136 | { |
||
137 | return vsprintf($this->destinationPaths[$type], $args); |
||
138 | } |
||
139 | |||
140 | /** |
||
141 | * @param $type |
||
142 | * @param $files |
||
143 | * |
||
144 | * @return array |
||
145 | */ |
||
146 | protected function getSourceFiles($path) |
||
147 | { |
||
148 | $files = []; |
||
149 | foreach (glob($path.'/*.php') as $file) { |
||
150 | $files[] = $file; |
||
151 | } |
||
152 | |||
153 | return $files; |
||
154 | } |
||
155 | |||
156 | /** |
||
157 | * @param $path |
||
158 | * |
||
159 | * @return mixed |
||
160 | */ |
||
161 | protected function getClassFromFile($path) |
||
162 | { |
||
163 | $count = count($tokens = token_get_all(file_get_contents($path))); |
||
164 | |||
165 | for ($i = 2; $i < $count; ++$i) { |
||
166 | if ($tokens[$i - 2][0] == T_CLASS && $tokens[$i - 1][0] == T_WHITESPACE && $tokens[$i][0] == T_STRING) { |
||
167 | return $tokens[$i][1]; |
||
168 | } |
||
169 | } |
||
170 | } |
||
171 | } |
||
172 |
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..