Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#9,417 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
72/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
php
Lĩnh vực
developer-experience

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện ví dụ PHP trong trình chỉnh sửa NetBeans và kiểm tra việc phân giải kiểu được sử dụng cho parent::make() khi phương thức lớp cha trả về static. Bản sửa lỗi hoàn tất khi thuộc tính của lớp con xuất hiện trong tính năng tự động hoàn tất và Ctrl-hover xác định biến được trả về là một thể hiện của Foo2.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
Java
Star
3.1k
Fork
939
Merge trung bình
5 ngày 3 giờ
Pull request đã merge (30 ngày)
22

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của apache/netbeans

Tất cả issue của apache/netbeans

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.