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

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

Details

Reviewers
pprkut
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
Lint Skipped
Unit
Unit Tests Skipped
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.Sat, Dec 14, 9:32 AM
This revision is now accepted and ready to land.Sat, Dec 14, 9:32 AM

No, I don't have commit access.