Author Topic: php7 methods with returnType not imported in classes  (Read 7317 times)

flexjoly

  • EA User
  • **
  • Posts: 27
  • Karma: +1/-0
  • Divaeloper
    • View Profile
    • Female Divaeloper
php7 methods with returnType not imported in classes
« on: June 04, 2019, 08:55:31 pm »
Hi,

I have many function/methods with a returntype specified, as is possible in php7.

Code: [Select]
class test{
  protected function myTest():bool{
    // some coding
  }
}

But these methods are not imported by reverse engineering. Anything else seems to work nicely from php7.
I found the code-templates and the grammar framework. Changing the operation-template does not help. I tried finding the php-grammar file, but I guess the internal grammar-files cannot be changed in the grammar-framework.

Can the returntype be added for EA class diagrams?

Thanks in advance!
flexJoly
« Last Edit: June 05, 2019, 01:07:05 am by flexjoly »

flexjoly

  • EA User
  • **
  • Posts: 27
  • Karma: +1/-0
  • Divaeloper
    • View Profile
    • Female Divaeloper
Re: php7 methods with returnType not imported in classes
« Reply #1 on: October 23, 2019, 04:22:03 am »
Hello,

Is there any change that this get fixed in the near future?
That the returntype is not recognized is no problem, but that the class is not imported at all thát is a problem.
Can this please be fixed?

We have the corporate version. Is it possible and not too difficult to script around it?
Does anyone have a scripting solution for this? (I am really a newby on scripting in EA)

@geertbellekens > do you have something for this?

Thanks in advance!
Lydia

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8607
  • Karma: +257/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: php7 methods with returnType not imported in classes
« Reply #2 on: October 23, 2019, 09:15:42 am »
Hi Lydia,

NOTHING gets fixed without a formal request using one of the links at the bottom.

Even then, it seems to be a lottery, but certainly, not request/ report, no fix!

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

flexjoly

  • EA User
  • **
  • Posts: 27
  • Karma: +1/-0
  • Divaeloper
    • View Profile
    • Female Divaeloper
Re: php7 methods with returnType not imported in classes
« Reply #3 on: October 23, 2019, 06:24:05 pm »
Hi Paolo,

Thanks for pointing this out.

I did another feature request a while ago.... except from the confirmation mail you hear nothing on it...
So i did not thing of that anymore.

But on your advice, I looked at it again and see that you can post a bug report as registered user. So I did that now on this. I hope that EA will at least respond.

Greetz, Lydia

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: php7 methods with returnType not imported in classes
« Reply #4 on: October 24, 2019, 06:30:58 pm »
Yes, feature requests usually disappear in the Sparx void never to be heard of again.
But sometimes they do implement these, unfortunately without letting you know.

So what I do is check the release notes with every release to see if any of my feature requests made it.

Bug reports are a bit different. Usually I get a confirmation saying "yes, we confirm it's a bug and it is planned to be fixed some day in the future"
(or "no this is by design, we are not willing to change that just because you seem to think that 1 + 1 = 2)

Sometimes you even get a message saying "we fixed the bug you reported in version x", but that is rare.

Geert

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8083
  • Karma: +118/-20
    • View Profile
Re: php7 methods with returnType not imported in classes
« Reply #5 on: October 28, 2019, 10:31:43 am »
Copy this code into a text/xml file.

Code: [Select]
<MDG.Technology version="1.0">
    <Documentation id="PHP7" name="PHP 7" version="1.0" notes="Temporary and partial support for PHP 7."/>
    <CodeModules>
        <CodeModule language="PHP" notes="">
            <CodeOptions>
        <CodeOption name="PrependGrammarDefinitions">
        <![CDATA[
<paramType> ::= <actualType:TYPE>
| <"":TYPE="var">
| <fail>;
<functionDec:DECLARATION>
::= <funcModifier>* <scope> <funcModifier>* "function" <identifier:NAME> <params> ":" <actualType>
| <funcModifier>* <scope> <funcModifier>* "function" <functionType> <identifier:NAME> <params>
| <identifier:NAME> <params>
| <fail>;
                    ]]>
        </CodeOption>
        <CodeOption name="AppendGrammarDefinitions">
        <![CDATA[
<nullableType> ::= "?" <qualifiedName>;
<actualType> ::= <variadicParamType>
| <nullableType>;
                    ]]>
        </CodeOption>
            </CodeOptions>
        </CodeModule>
     </CodeModules>
</MDG.Technology>

Import it as an MDG technology.

In v15 I think you also need to create a custom perspective containing this technology.

flexjoly

  • EA User
  • **
  • Posts: 27
  • Karma: +1/-0
  • Divaeloper
    • View Profile
    • Female Divaeloper
Re: php7 methods with returnType not imported in classes
« Reply #6 on: November 28, 2019, 06:28:44 am »
Hi Eve,

Thank you so much for your effort!
Sorry I did not see this sooner.

I tried to import your xml as mdg. And did also:
- select 'php 7' as required (https://sparxsystems.com/enterprise_architect_user_guide/15.0/modeling/specify_reqd_mdg_technologies.html)
- php7 is also shown in configure > resources > mdg techn.
- set it to active here: https://sparxsystems.com/enterprise_architect_user_guide/15.0/modeling/manage_mdg_technologies.html
- restarted EA several times
- made a new test project
- (re-)imported/synchronized some php7
- language of the package is 'PHP'


In v15 I think you also need to create a custom perspective containing this technology.
I overlooked this at first and I have no experience here so far with this.  :o
But I tried to make one,  then I needed to choose a model (wizard) to make a diagram. So does this have to do with importing source?

So far I cannot get it to work.
The classes are imported (from a directory), but the methods with a returnType are not.
I hope you can help me here again.

Thanks in advance, Lydia


NB! Until now, I did not hear anything on my bug report.

« Last Edit: November 29, 2019, 08:12:58 pm by flexjoly »

flexjoly

  • EA User
  • **
  • Posts: 27
  • Karma: +1/-0
  • Divaeloper
    • View Profile
    • Female Divaeloper
Re: php7 methods with returnType not imported in classes
« Reply #7 on: November 29, 2019, 08:19:19 pm »
Hi,

I also tried again to change the grammer for 'Operation Declaration' like:

Code: [Select]
%PI=" "%
%if genOptPHPVersion >= "5.0"%
%if elemType=="Interface"%
public
%else%
%opAbstract == "T" ? "abstract" : ""%
%CONVERT_SCOPE(opScope)%
%endIf%
%endIf%
%opStatic=="T" ? "static" : ""%
%if genOptPHPVersion >= "5.0"%
%opTag:"final" != "" ? "final" : ""%
%endIf%
function
%PI=""%
%opName%(%list="Parameter" @separator=", "%)
%PI=""%
:
%opReturnType=="var*" ? "&" : ""%

I tried different things with 'opReturnType', but so far no luck.

Any suggestions?

Thanks in advance, Lydia

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8083
  • Karma: +118/-20
    • View Profile
Re: php7 methods with returnType not imported in classes
« Reply #8 on: December 02, 2019, 09:28:52 am »
Changing the code generation templates won't change the import behavior at all. Neither will setting required or active, but required could prevent other people from accessing your model.

The behavior with perspectives was not intentional, and I believe it has been corrected in the latest builds. So the easiest approach is updating to the latest build.

In the perspectives menu, select manage perspectives. On the second page create a new perspective and select the php7 technology. Save it and you're done. As long as you are in 'All' or your new technology when first importing PHP in an EA session it should take effect.

flexjoly

  • EA User
  • **
  • Posts: 27
  • Karma: +1/-0
  • Divaeloper
    • View Profile
    • Female Divaeloper
Re: php7 methods with returnType not imported in classes
« Reply #9 on: June 13, 2020, 05:59:29 am »
Hi Eve,

I tried this again, but it is still not working :(
Methods with type-hinting return, are not imported into the class-elements.

EA is not an cheap application.... (at least for our small company). And with the much praised MDG, why is it so hard for sparx to update the php to version 7 ???  :-[
Can something please be done on this?!?

It is that other uml-tools are worse.... else....

Sorry, I am very frustrated after 2 days with EA and not getting done simple things (also struggling with namespaces).

Greetz, flexjoly

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: php7 methods with returnType not imported in classes
« Reply #10 on: June 13, 2020, 06:11:46 am »
Well, you "can" get EA to work. If you know how (can be tricky to, well, just vomiting awful work arounds). And over time it's getting worse. EA suffers from feature creep. Rather than getting bugs fixed they add new stuff with even more bugs.

Now, for other tools: They are differently worse. Many are much more expensive and do not offer the expected added value :-/ The world is a sad place.

q.