| Conditions | 4 |
| Paths | 3 |
| Total Lines | 21 |
| Code Lines | 12 |
| Lines | 21 |
| Ratio | 100 % |
| Tests | 10 |
| CRAP Score | 4.0119 |
| Changes | 0 | ||
| 1 | <?php |
||
| 35 | 2 | function __call( $method_name, $args = array() ) { |
|
| 36 | 2 | $value = null; |
|
| 37 | |||
| 38 | do { |
||
| 39 | |||
| 40 | 2 | if ( property_exists( $this, "_{$method_name}" ) ) { |
|
| 41 | 1 | $property = "_{$method_name}"; |
|
| 42 | 1 | $value = $this->{$property}; |
|
| 43 | 1 | break; |
|
| 44 | } |
||
| 45 | |||
| 46 | 2 | if ( ! isset( $this->_map ) ) { |
|
| 47 | break; |
||
| 48 | } |
||
| 49 | |||
| 50 | 2 | $value = call_user_func_array( array( $this->_map, $method_name ), $args ); |
|
| 51 | |||
| 52 | 2 | } while ( false ); |
|
| 53 | |||
| 54 | 2 | return $value; |
|
| 55 | } |
||
| 56 | } |
||
| 57 |
Let’s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let’s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare 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.phpHowever, as
OtherDir/Foo.phpdoes 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: