apache / apache/netbeans

PHP: Parent class method 'static' type declaration not recognised when called by child class using parent::

Open
#9,417 0 comments 0 reactions 0 assignees View on GitHub
kind:bug needs:triage PHP
Dominant language
Java
Stars
3.1k
Forks
935
Avg merge
2d 3h
Merged PRs (30d)
17

Description

### Apache NetBeans version

Apache NetBeans 30

### What happened

When an overriding method in a PHP child class calls the parent class's overridden method using the `parent::` identifier, and that method's return-type is `static`, NetBeans fails to resolve the variable returned by that call to an instance of the current (that is, child) class. Other members of the child class are not available in autocomplete, and the tooltip displayed by Ctrl+hover gives simply `VARIABLE: $whatever`.

### Language / Project Type / NetBeans Component

PHP project

### How to reproduce

```php
//<-- Start typing 'property' here
return $f;
}
}
```
Place the cursor before the inline comment on line 16 and start to type 'property'. The `$property` property of class `Foo2` should be available in autocomplete popup; instead, only general completions are offered.

Calling `parent::make()` in the child scope returns a `Foo2` object; this is knowable from the `static` return type declared by `Foo1::make()` and NetBeans should make this determination.

### Did this work correctly in an earlier version?

No / Don't know

### Operating System

Gentoo Linux

### JDK

Adoptium openjdk-21.0.10_p7

### Apache NetBeans packaging

Apache NetBeans binary zip

### Anything else

_No response_

### Are you willing to submit a pull request?

No

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the PHP example in the NetBeans editor and inspect the type resolution used for parent::make() when the parent method returns static. The fix is done when the child property appears in autocomplete and Ctrl-hover identifies the returned variable as a Foo2 instance.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
developer-experience
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.