Class that uses a trait is not found when instantiated before its declaration
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 35/100
Direção de pesquisa
Start by reproducing the example with the PHP CLI and compare behavior when class B uses a trait declared later. The issue names no source files or tests, so trace class and trait declaration handling in the Zend Engine and locate the relevant regression tests. Done when the first new B instance succeeds and calls traitfunc(), with a test covering the declaration order.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Description
This is the same report as bugs.php.net #75771, which is still open.
The following code:
<?php
new A; // good.
new B; // fatal error.
class A {
function __construct() {
echo "constructed A\n";
}
}
class B {
use T;
function __construct() {
echo "constructed B\n";
$this->traitfunc();
}
}
new B; // good.
trait T {
function traitfunc() {
echo "traitfunc called\n";
}
}
Resulted in this output:
constructed A
Fatal error: Uncaught Error: Class "B" not found in /mnt/c/Users/sybre/AppData/Local/Temp/bug75771.php:3
Stack trace:
#0 {main}
thrown in /mnt/c/Users/sybre/AppData/Local/Temp/bug75771.php on line 3
But I expected this output instead:
constructed A
constructed B
traitfunc called
PHP Version
PHP 8.5.12 (cli) (built: Oct 21 2026 22:48:15) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.5.12, Copyright (c) Zend Technologies
with Zend OPcache v8.5.12, Copyright (c), by Zend Technologies
Operating System
Ubuntu 24.04 (WSL2). Also reproduced on PHP 8.4.4 on Windows.
- Linguagem predominante
- C
- Estrelas
- 40.7k
- Forks
- 8.3k
- Merge médio
- 2d 20h
- PRs com merge (30d)
- 147
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de php/php-src
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
Mantenedores costumam responder em até 1 dia
-
sapi/fpm/tests/tester.inc can send SIGUSR2 to pid 0, killing run-tests.phpTalvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. AbertaBug Status: Needs Triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
zend_set_local_var() overwrites existing compiled variable (CV) zval without calling zval_ptr_dtor()Talvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. AbertaBug Status: Needs Triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 1 dia
-
Case-insensitive substr_compare, ksort, krsort are still locale-dependentTalvez já em andamento @lazerg assumiu há 4 dias. AbertaBug Extension: standard Status: Verified
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 73/100
php/php-src#24552 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
Todas as issues de php/php-src
Issues semelhantes
-
dependency component: oneMKL module: dpclang
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
intel/torch-xpu-ops#5880 ·
Mantenedores costumam responder em até 2 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
Mantenedores costumam responder em até 1 dia
-
CVE-2026-111497Aberta
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 82/100
fink/fink-distributions#1322 ·
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 83/100
openvehicles/Open-Vehicle-Monitoring-System-3#1563 ·
Mantenedores costumam responder em até 2 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100