Total Complexity | 8 |
Total Lines | 53 |
Duplicated Lines | 0 % |
Coverage | 92.59% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | class midgard_query_builder extends query |
||
12 | { |
||
13 | 1 | public function add_constraint_with_property(string $name, string $operator, string $property) : bool |
|
21 | } |
||
22 | |||
23 | 49 | public function add_constraint(string $name, string $operator, $value) : bool |
|
24 | { |
||
25 | try { |
||
26 | 49 | parent::add_constraint($name, $operator, $value); |
|
27 | 2 | } catch (exception) { |
|
28 | 2 | return false; |
|
29 | } |
||
30 | 47 | return true; |
|
31 | } |
||
32 | |||
33 | /** |
||
34 | * @return midgard\portable\api\mgdobject[] |
||
35 | */ |
||
36 | 37 | public function execute() |
|
37 | { |
||
38 | 37 | $query = $this->prepare_query(); |
|
39 | 37 | $result = $query->getResult(); |
|
40 | 37 | $this->post_execution(); |
|
41 | 37 | return $result; |
|
42 | } |
||
43 | |||
44 | /** |
||
45 | * @return midgard\portable\api\mgdobject[] |
||
46 | */ |
||
47 | 1 | public function iterate() |
|
55 | } |
||
56 | } |
||
57 | |||
58 | 38 | private function prepare_query() : \Doctrine\ORM\Query |
|
64 | } |
||
65 | } |
||
66 |
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: