Author Topic: Php namespaces not recognized?  (Read 2058 times)

flexjoly

  • EA User
  • **
  • Posts: 27
  • Karma: +1/-0
  • Divaeloper
    • View Profile
    • Female Divaeloper
Php namespaces not recognized?
« on: June 13, 2020, 05:52:07 am »
Hi,

Lately I started to work more actively with namespaces in php. I expected that EA would love that and would recognize the connection between classes even beter. But the opposite seems to be true :-(

Because of namespaces it is possible to have the same classnames. But EA does not recognize (nor generate) the correct namespace-path. And EA seems to have never heard of namespaces aliases  :-[

I set some packages as root namespace:
  • rh
  • ls
Some of the classes I have are:
Base Data class
Code: [Select]
<?php
namespace rh\data\data;

class 
Data implements DataInterface{}
?>


Config Data class
Code: [Select]
<?php
namespace rh\config\db;
use 
rh\data\listdata\ListAbstract;

class 
Data extends ListAbstract{}
?>



A Class which extends the base Data class
Code: [Select]
<?php
namespace ls\api;
use 
rh\data\data\Data;

class 
Params extends Data{}
?>



The class are imported as by directories and the packages are created on namespaces.

But a class like Params is connected to the Config-Data class and not to rh\data\data\Data  :o :-\
And when looking into the relations or find-window only classnames without their namespaces are shown.

I tried to change the extend to:
  • use rh\data\data and ... extends data\Data
  • extends \rh\data\data\Data
I searched and read many pages in the tutorials. Downloaded the latest version 15.2 beta.

I also tried:
  • setting an alias in the class-element properties[/font]
  • deleted the generated connector (but it comes back after source-synchronisation)[/font]
  • drawing the generalize connector between Params and data\Data  >> source-generation just makes php to multi-extend ;D
What am I doing wrong??? What can I do to get EA to recognize the namespace paths and make the right connections.

And what about namespace aliases? I use "use my\namespaced\Class as Base;" a lot.... but EA just connects to the first "class Base{}" it finds  :-[


I hope someone can help me.
Thanks in advance.
Flexjoly
« Last Edit: June 13, 2020, 06:06:31 am by flexjoly »