Total Complexity | 7 |
Total Lines | 62 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
16 | class CalendarEvent extends BaseEvent |
||
17 | { |
||
18 | /** |
||
19 | * @var DateTimeInterface |
||
20 | */ |
||
21 | protected $start; |
||
22 | |||
23 | /** |
||
24 | * @var DateTimeInterface |
||
25 | */ |
||
26 | protected $end; |
||
27 | |||
28 | /** |
||
29 | * @var array |
||
30 | */ |
||
31 | protected $filters; |
||
32 | |||
33 | /** |
||
34 | * @var Event[] |
||
35 | */ |
||
36 | protected $events = []; |
||
37 | |||
38 | 4 | public function __construct( |
|
46 | 4 | } |
|
47 | |||
48 | 1 | public function getStart(): DateTimeInterface |
|
49 | { |
||
50 | 1 | return $this->start; |
|
51 | } |
||
52 | |||
53 | 1 | public function getEnd(): DateTimeInterface |
|
54 | { |
||
55 | 1 | return $this->end; |
|
56 | } |
||
57 | |||
58 | 1 | public function getFilters(): array |
|
59 | { |
||
60 | 1 | return $this->filters; |
|
61 | } |
||
62 | |||
63 | 1 | public function addEvent(Event $event): self |
|
64 | { |
||
65 | 1 | if (!\in_array($event, $this->events, true)) { |
|
66 | 1 | $this->events[] = $event; |
|
67 | } |
||
68 | |||
69 | 1 | return $this; |
|
70 | } |
||
71 | |||
72 | /** |
||
73 | * @return Event[] |
||
74 | */ |
||
75 | 1 | public function getEvents(): array |
|
78 | } |
||
79 | } |
||
80 |
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: