Class that uses a trait is not found when instantiated before its declaration
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- C
- Estrellas
- 40.7k
- Forks
- 8.3k
- Merge medio
- 2 d 16 h
- PR fusionados (30 d)
- 151
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de php/php-src
-
sapi/fpm/tests/tester.inc can send SIGUSR2 to pid 0, killing run-tests.phpPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. AbiertoBug Status: Needs Triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
zend_set_local_var() overwrites existing compiled variable (CV) zval without calling zval_ptr_dtor()Posiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. AbiertoBug Status: Needs Triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Case-insensitive substr_compare, ksort, krsort are still locale-dependentPosiblemente ocupada @lazerg la tomó hace 3 días. AbiertoBug Extension: standard Status: Verified
Dificultad 2/5 1-3 horas Aptitud para principiantes 73/100
php/php-src#24552 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
master: part of the mbstring bailout fix got lost in a mergePosiblemente ocupada @lazerg la tomó hace 4 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
Todos los issues de php/php-src
Issues similares
-
Add `CPC_TAKE_TILL_CHARS`Abiertodifficulty: easy
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
-
performance solver
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
ChefKissInc/Inferno#319 ·
-
llvm-tools
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
llvm/llvm-project#235522 ·
Los mantenedores suelen responder en 1 día