Bug 242194 - PHP parser shows an error on valid type hinting usage
Summary: PHP parser shows an error on valid type hinting usage
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: Language Support: PHP (show other bugs)
Version: git master
Platform: Unlisted Binaries Linux
: NOR normal
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-19 20:25 UTC by Alexander
Modified: 2018-06-06 08:18 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.3.0
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander 2010-06-19 20:25:11 UTC
Version:           SVN (using KDE 4.4.3) 
OS:                Linux

I'm using KDevelop & friends git master (2010-06-14).

The following code inhibits an error:

class A {
}

function func(A $a = NULL, array $b = NULL, $c)  // $c is highlighted as an error
{
	print $c;
}

The "A $a = NULL" part means that $a can be an instance of A, or NULL.
Without "= NULL" only an instance of A would be accepted. Same for "array $b = NULL".
See more at http://www.php.net/manual/en/language.oop5.typehinting.php .

KDevelop assumes that if a parameter has a default value, all the following parameters must also have ones, which is incorrect in this case.

Thanks

Reproducible: Always



Expected Results:  
Type-hinted parameters with default values should not cause the following parameters without default values to be treated like errors.

openSUSE 11.1 x86_64.
Comment 1 Niko Sams 2010-06-19 20:38:15 UTC
confirmed. Not so easy to fix as the default arguments in FunctionDeclaration don't support that.
Php sucks!
Comment 2 Heinz Wiesinger 2018-06-01 18:18:32 UTC
This was fixed in https://cgit.kde.org/kdev-php.git/commit/?id=4b10347f367cf1224829fd9ae6ae9f4f07fc54bd and works with kdev-php 5.2
Comment 3 Kevin Funk 2018-06-06 06:32:54 UTC
@Heinz: Patch is in master only though. So the fixed version is 5.3.0 (unreleased atm).
Comment 4 Heinz Wiesinger 2018-06-06 08:18:10 UTC
Sorry, checked the wrong branch. It's indeed in master only