Class that uses a trait is not found when instantiated before its declaration
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- C
- Stelle
- 40.7k
- Fork
- 8.3k
- Merge medio
- 2g 17h
- PR unite (30g)
- 159
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di php/php-src
-
ext/odbc, ext/pdo_odbc: php_odbc_connstr_is_quoted() treats a value with no closing brace as "already quoted," skipping UID/PWD escapingForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
Bug Status: Needs Triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
zend_set_local_var() overwrites existing compiled variable (CV) zval without calling zval_ptr_dtor()Forse già presa Una pull request collegata a questa issue è aperta o già unita. ApertaBug Status: Needs Triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Case-insensitive substr_compare, ksort, krsort are still locale-dependentForse già presa @lazerg l’ha presa 5 giorni fa. ApertaBug Extension: standard Status: Verified
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
php/php-src#24552 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Issue simili
-
bug intrinsic medium priority rt_lib
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
[CLI] Clarify distinction between 'capture camera' and 'capture screen' in help text and outputAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
espressif/esp-vision#18 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
sumatrapdfreader/sumatrapdf#6417 · 3 commenti ·
-
[BUG] Cython cache evicts most recent instead of oldest entry on cleanupForse già presa @scoder l’ha presa oggi. ApertaBuild System defect
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 61/100
HexaCluster/credcheck#94 ·