[KDevelop/PHP] Add support for "array of type"
ClosedPublic

Authored by hmitonneau on Oct 24 2019, 1:47 PM.

Details

Summary

When you use foreach ( $a as $e ), when $a is an 'iterator of x', then type of $e is set to 'x'.

This patch add a syntax in @param and @return to specifiy that $a is an 'array of x`: @param x[].
This patch add support when $a is an 'array of x'.

Diff Detail

Repository
R52 KDevelop: PHP Support
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
hmitonneau created this revision.Oct 24 2019, 1:47 PM
Restricted Application added a subscriber: kdevelop-devel. · View Herald TranscriptOct 24 2019, 1:47 PM
hmitonneau requested review of this revision.Oct 24 2019, 1:47 PM
pprkut added a subscriber: pprkut.Oct 27 2019, 7:39 AM

Conceptually, this looks fine. However, like this we end up with two different descriptions of "Array of" types in the navigation popups.
While this shows integer arrays as int[], for variadics it will show array of (int). I think at the very least both should be displayed the same.

In the end I think the simplest solution here might just be moving variadics from IndexedContainer to ArrayType (I didn't know about ArrayType back when I added support for variadics), as IndexedContainer seems a bit overkill for what PHP supports.
Could you perhaps have a look at that?

Move variadics from IndexedContainer to ArrayType

Is there something wrong with the second diff ?

Hi! Sorry, I was just really busy and didn't have time to take a closer look.

I was a bit unsure about the different handling for normal arrays and variadics, but after thinking about it for a bit that's probably good that way. Either way it's something we could revisit at a later point, so this is good to go :)

Do you have commit access to the repo or should I push it for you?

pprkut accepted this revision.Dec 14 2019, 9:32 AM
This revision is now accepted and ready to land.Dec 14 2019, 9:32 AM

No, I don't have commit access.

Sorry this took so long! I have it ready to merge, just need to know the email you'd like me to use for the commit author

No problem.
You can use hugues@mitonneau.me
Thanks

This revision was automatically updated to reflect the committed changes.