adjust PHP #[\Override] hint to handle parent method with incompatible function signature #7766
Labels
kind:feature
A feature request
needs:triage
Requires attention from one of the committers
PHP
[ci] enable extra PHP tests (php/php.editor)
Description
#6701 added support for PHP 8.3 #[\Override] attribute. This feature works nicely.
However if the parent method has a function signature which is "incompatible" with the child method (i.e. the parent method has more arguments), then adding the #[\Override] attribute results in a PHP runtime error:
PHP Fatal error: {CLASSNAME}::__construct() has #[\Override] attribute, but no matching parent method exists
The wording of this runtime error is misleading because the parent method DOES exist, but has more arguments than the child.
We went through a large code base, adding the #[\Override] attribute according the NB hinting, only to find that our code was breaking. Now we have to review every instance of #[\Override] checking to be sure that the parent class is compatible.
It would be nice if NetBeans detected this situation and either did not offer the "Override" hint (or) offered a warning about too-few-arguments.
p.s. this is on PHP 8.3.10, NetBeans 22
Use case/motivation
No response
Related issues
No response
Are you willing to submit a pull request?
No
The text was updated successfully, but these errors were encountered: