Conditions | 4 |
Paths | 3 |
Total Lines | 21 |
Code Lines | 12 |
Lines | 21 |
Ratio | 100 % |
Tests | 4 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
34 | function __call( $method_name, $args = array() ) { |
||
35 | $value = null; |
||
36 | |||
37 | do { |
||
38 | |||
39 | 3 | if ( property_exists( $this, "_{$method_name}" ) ) { |
|
40 | $property = "_{$method_name}"; |
||
41 | 3 | $value = $this->{$property}; |
|
42 | break; |
||
43 | } |
||
44 | |||
45 | if ( ! isset( $this->_label ) ) { |
||
46 | break; |
||
47 | } |
||
48 | 3 | ||
49 | $value = call_user_func_array( array( $this->_label, $method_name ), $args ); |
||
50 | 3 | ||
51 | } while ( false ); |
||
52 | |||
53 | return $value; |
||
54 | } |
||
55 | |||
57 |
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: