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 PragmaRX\Health\Checkers; |
||
4 | |||
5 | use PragmaRX\Health\Support\Result; |
||
6 | use Illuminate\Filesystem\Filesystem; |
||
0 ignored issues
–
show
|
|||
7 | |||
8 | class Writable extends Base |
||
9 | { |
||
10 | protected $filesystem; |
||
11 | |||
12 | /** |
||
13 | * Check resource. |
||
14 | * |
||
15 | * @return Result |
||
16 | */ |
||
17 | public function check() |
||
18 | { |
||
19 | foreach ($this->target->paths as $path) { |
||
0 ignored issues
–
show
The property
paths does not seem to exist in PragmaRX\Health\Support\Target .
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name. If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.
Loading history...
|
|||
20 | if (!$this->getFilesystem()->isWritable($path)) { |
||
21 | return $this->makeResult( |
||
22 | false, |
||
23 | sprintf($this->target->getErrorMessage(), $path) |
||
24 | ); |
||
25 | } |
||
26 | } |
||
27 | |||
28 | return $this->makeHealthyResult(); |
||
29 | } |
||
30 | |||
31 | public function getFilesystem() |
||
32 | { |
||
33 | if ($this->filesystem) { |
||
34 | return $this->filesystem; |
||
35 | } |
||
36 | |||
37 | return $this->filesystem = app(Filesystem::class); |
||
38 | } |
||
39 | } |
||
40 |
Let’s assume that you have a directory layout like this:
and let’s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: