D7018: Allow optional parameters before non-optional ones in PHP

Kevin Funk noreply at phabricator.kde.org
Mon Jul 31 13:55:49 UTC 2017

kfunk requested changes to this revision.
kfunk added inline comments.
This revision now requires changes to proceed.


> declarationbuilder.cpp:754
> +        forever {
> +            if (it->element->defaultValue) {
> +                //If it's a optional parameter, so increase the count

This looks a bit like a hack.

And it also introduces a regression for e.g.:
`function x($b, $a = 1)`  -> Won't show the default arg anymore.

Maybe this issue should be addresses at the DUChain-level in kdevplatform? You can probably add a `addEmptyDefaultParameter()` method in `FunctionDefinition` in kdevplatform.

Then here (pseudo-algo), do two passes over the param list:

- first pass: check if it has default args at all
- second pass: if it has default args:
  - if param has default value: `addDefaultParameter(...)`
  - else: `addEmptyDefaultParameter()`

(Or some similar approach..., I don't know the exact DUChain API of the top of my head)

  R52 KDevelop: PHP Support


To: mtijink, #kdevelop, kfunk
Cc: kfunk, kdevelop-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20170731/acc805f0/attachment-0001.html>

More information about the KDevelop-devel mailing list