Conditions | 2 |
Paths | 2 |
Total Lines | 17 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 2 |
Changes | 0 |
1 | <?php |
||
36 | 5 | public function invoke(MethodInvocation $invocation) |
|
37 | { |
||
38 | 5 | $ssr = $invocation->getMethod()->getAnnotation(Ssr::class); |
|
39 | /* @var $ssr Ssr */ |
||
40 | 5 | $app = $ssr->app; |
|
41 | 5 | if ($app === null) { |
|
42 | 1 | throw new NoAppValueException(); |
|
43 | } |
||
44 | 4 | $state = array_values($ssr->state); |
|
45 | 4 | $metas = array_values($ssr->metas); |
|
46 | 4 | $renderer = $this->factory->newInstance($app, $state, $metas); |
|
47 | 4 | $ro = $invocation->getThis(); |
|
48 | /* @var $ro ResourceObject */ |
||
49 | 4 | $ro->setRenderer($renderer); |
|
50 | |||
51 | 4 | return $invocation->proceed(); |
|
52 | } |
||
53 | } |
||
54 |
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: