Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭
#9,417 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
冷清
技术栈
php

调研方向

首先在 NetBeans 编辑器中重现 PHP 示例,并检查父方法返回 static 时 parent::make() 所使用的类型解析。子类属性出现在自动补全中,并且 Ctrl-hover 将返回的变量识别为 Foo2 实例后,修复就完成了。

由索引模型根据 Issue 内容生成。

描述

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

主要语言
Java
星标
3.1k
派生
939
平均合并
5 天 12 小时
30 天内合并 PR
23

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/netbeans 的其他 Issue

查看 apache/netbeans 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。