Closed unkind closed 5 years ago
Hello :-),
The purpose of flex entities is to keep BC when a class is moved into a namespace of the same name. This happens sometimes, and flex entities are here to solve this issue.
When using PHPStorm, you might take a look at https://github.com/hoaproject/Devtools#expandflexentities. Running hoa devtools:expandflexentities
will generate a file that will fix all the issues for PHPStorm.
I close the issue because I answered it, but feel free to re-open if you still have a question.
moved into a namespace of the same name
I don't get it. Do you mean \Acme\A
-> \Acme\B
? class_alias
has the same effect, doesn't it?
Let's consider A\B\C
is initiallly located is A/B/C.php
, but then the namespace A\B\C
is created, then following our standards, the file must be moved in A/B/C/C.php
, and with the name A\B\C\C
. So A\B\C
is an alias to A\B\C\C
, to keep BC.
@Hywan OK, but it still solves with class_alias
, doesn't require additional code (Consistency::flexEntity()
) and IDE is able to resolve real exception class without plugins and doesn't produce bloody errors.
If I understand it right, it's better to refactor it.
Maybe it's just a PhpStorm's bug, but I really didn't find the root
Exception
class.— what is that? Aliasing sub-namespace or aliasing class
Exception
in the namespaceHoa
?If first, how does it work:
?
If second, I see no class
Exception
in the namespaceHoa
(onlyHoa\Exception\Exception
).It looks like black magic. What's the purpose?
And aliasing is still supported by most popular IDE (PhpStorm) quite bad, e.g. find usages ignores aliased classes. I know that it's not an argument ("they should fix it"), but it also leads to confusions when reading code. Is it possible to resolve all aliases?
And I still don't get purpose of
Consistency::flexEntity
.