Use null default types for determining argument type in PHP

Authored by mtijink on Jul 26 2017, 9:33 AM.



PHP allows default values for function arguments, even with typehints set. This does not affect the type given to the function because PHP converts it to declared type.

There is one exception: when the default value is null, PHP changes the allowed types to be passed to typehint|null. In fact, before PHP 7.1, this was the only way to allow passing null instead of an object when a typehint was used.

This diff implements this: when a null default type is passed, the argument type will be typehint|null.

Diff Detail

R52 KDevelop: PHP Support
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.
mtijink created this revision.Jul 26 2017, 9:33 AM
Restricted Application added a subscriber: kdevelop-devel. · View Herald TranscriptJul 26 2017, 9:33 AM
This revision was automatically updated to reflect the committed changes.