Total Complexity | 2 |
Total Lines | 35 |
Duplicated Lines | 0 % |
Coverage | 60% |
Changes | 0 |
1 | <?php |
||
21 | #[API\Filter(field: 'custom', operator: ExcludeSelfAndDescendantsOperatorType::class, type: 'id')] |
||
22 | #[ORM\Entity(PeriodRepository::class)] |
||
23 | class Period extends Thesaurus implements HasParentInterface |
||
24 | { |
||
25 | use HasParent; |
||
26 | use HasSorting; |
||
27 | use HasYearRange; |
||
28 | |||
29 | /** |
||
30 | * @var null|Period |
||
31 | */ |
||
32 | #[ORM\JoinColumn(onDelete: 'CASCADE')] |
||
33 | #[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')] |
||
34 | private $parent; |
||
35 | |||
36 | /** |
||
37 | * @var Collection<Period> |
||
38 | */ |
||
39 | #[ORM\OneToMany(targetEntity: self::class, mappedBy: 'parent')] |
||
40 | #[ORM\OrderBy(['name' => 'ASC', 'id' => 'ASC'])] |
||
41 | private $children; |
||
42 | |||
43 | 6 | public function __construct() |
|
47 | } |
||
48 | |||
49 | /** |
||
50 | * Get children periods. |
||
51 | */ |
||
52 | #[API\Field(type: 'Period[]')] |
||
58 |
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: