Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta
#9,417 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Tranquilla
Stack tecnologico
php

Direzione di ricerca

Inizia riproducendo l'esempio PHP nell'editor NetBeans e ispeziona la risoluzione dei tipi usata per parent::make() quando il metodo padre restituisce static. La correzione è completa quando la proprietà del figlio appare nel completamento automatico e Ctrl-hover identifica la variabile restituita come un'istanza di Foo2.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

kind:bug needs:triage PHP
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

class Foo1 {

	public static function make(): static {
		return new static();
	}
}

class Foo2 extends Foo1 {
	
	public $property = 1;
	
	public static function make(): static {
		$f = parent::make();
		echo $f->//<-- 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

Lingua principale
Java
Stelle
3.1k
Fork
939
Merge medio
5g 12h
PR unite (30g)
23

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di apache/netbeans

Tutte le issue di apache/netbeans

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.