1 | <?php |
||
2 | |||
3 | namespace src; |
||
4 | |||
5 | use src\{ |
||
6 | AcontecimientoTraumaticoSevero, |
||
0 ignored issues
–
show
|
|||
7 | RecuerdosPersistentesSobreElAcontecimiento, |
||
0 ignored issues
–
show
This use statement conflicts with another class in this namespace,
src\RecuerdosPersistentesSobreElAcontecimiento . Consider defining an alias.
Let?s assume that you have a directory layout like this: .
|-- OtherDir
| |-- Bar.php
| `-- Foo.php
`-- SomeDir
`-- Foo.php
and let?s assume the following content of // Bar.php
namespace OtherDir;
use SomeDir\Foo; // This now conflicts the class OtherDir\Foo
If both files PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as // Bar.php
namespace OtherDir;
use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
![]() |
|||
8 | EsfuerzoPorEvitarCircunstanciasParecidasOAsociadasAlAcontecimiento, |
||
0 ignored issues
–
show
This use statement conflicts with another class in this namespace,
src\EsfuerzoPorEvitarCir...ociadasAlAcontecimiento . Consider defining an alias.
Let?s assume that you have a directory layout like this: .
|-- OtherDir
| |-- Bar.php
| `-- Foo.php
`-- SomeDir
`-- Foo.php
and let?s assume the following content of // Bar.php
namespace OtherDir;
use SomeDir\Foo; // This now conflicts the class OtherDir\Foo
If both files PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as // Bar.php
namespace OtherDir;
use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
![]() |
|||
9 | Afectacion |
||
0 ignored issues
–
show
This use statement conflicts with another class in this namespace,
src\Afectacion . Consider defining an alias.
Let?s assume that you have a directory layout like this: .
|-- OtherDir
| |-- Bar.php
| `-- Foo.php
`-- SomeDir
`-- Foo.php
and let?s assume the following content of // Bar.php
namespace OtherDir;
use SomeDir\Foo; // This now conflicts the class OtherDir\Foo
If both files PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as // Bar.php
namespace OtherDir;
use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
![]() |
|||
10 | }; |
||
11 | |||
12 | class CuestionarioEts |
||
13 | { |
||
14 | private $_acontecimientoTraumaticoSevero; |
||
15 | |||
16 | private $_recuerdosPersistentesSobreElAcontecimiento; |
||
17 | |||
18 | private $_esfuerzoPorEvitarCircunstanciasParecidasOAsociadasAlAcontecimiento; |
||
19 | |||
20 | private $_afectacion; |
||
21 | |||
22 | public function __construct |
||
23 | ( |
||
24 | AcontecimientoTraumaticoSevero $AcontecimientoTraumaticoSevero, |
||
25 | RecuerdosPersistentesSobreElAcontecimiento $RecuerdosPersistentesSobreElAcontecimiento, |
||
26 | EsfuerzoPorEvitarCircunstanciasParecidasOAsociadasAlAcontecimiento $EsfuerzoPorEvitarCircunstanciasParecidasOAsociadasAlAcontecimiento, |
||
27 | Afectacion $Afectacion |
||
28 | ) |
||
29 | { |
||
30 | $this->_acontecimientoTraumaticoSevero = $AcontecimientoTraumaticoSevero; |
||
31 | $this->_recuerdosPersistentesSobreElAcontecimiento = $RecuerdosPersistentesSobreElAcontecimiento; |
||
32 | $this->_esfuerzoPorEvitarCircunstanciasParecidasOAsociadasAlAcontecimiento = $EsfuerzoPorEvitarCircunstanciasParecidasOAsociadasAlAcontecimiento; |
||
33 | $this->_afectacion = $Afectacion; |
||
34 | } |
||
35 | |||
36 | public function acontecimientoTraumaticoSevero(): AcontecimientoTraumaticoSevero |
||
37 | { |
||
38 | return $this->_acontecimientoTraumaticoSevero; |
||
39 | } |
||
40 | |||
41 | public function recuerdosPersistentesSobreElAcontecimiento(): RecuerdosPersistentesSobreElAcontecimiento |
||
42 | { |
||
43 | return $this->_recuerdosPersistentesSobreElAcontecimiento; |
||
44 | } |
||
45 | |||
46 | public function esfuerzoPorEvitarCircunstanciasParecidasOAsociadasAlAcontecimiento(): EsfuerzoPorEvitarCircunstanciasParecidasOAsociadasAlAcontecimiento |
||
47 | { |
||
48 | return $this->_esfuerzoPorEvitarCircunstanciasParecidasOAsociadasAlAcontecimiento; |
||
49 | } |
||
50 | |||
51 | public function afectacion(): Afectacion |
||
52 | { |
||
53 | return $this->_afectacion; |
||
54 | } |
||
55 | |||
56 | } |
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: