Proxy of a namespaced class extending a global class references the parent unqualified (Class "Ns\ArrayObject" not found)
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 62/100
Direzione di ricerca
Start with ClassGenerator::classNameNode() in src/Proxy/Generator/ClassGenerator.php, which only emits a fully qualified name when there is a leading backslash or a namespace separator, then trace the parent name passed from src/Proxy/ClassProxyGenerator.php around line 187. Reproduce with a namespaced class extending \ArrayObject and check that the generated proxy loads. Done when the extends clause and trait names are always fully qualified and the fixture and snapshot tests pass.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
A woven class in a namespace that extends a class from the global namespace gets a proxy whose extends clause names the parent unqualified. The name then resolves inside the proxy's namespace, and including the proxy fails. This affects any extends \Exception, \RuntimeException, \ArrayObject, \DateTimeImmutable, and so on.
Reproduce (master 4e95fdd)
// app/Coll.php
namespace Bug2;
class Coll extends \ArrayObject implements \Countable
{
public function hello(): string { return 'coll'; }
}
The aspect is #[Before('execution(public Bug2\**->hello(*))')]. The kernel uses appDir = app/; debug mode makes no difference.
Generated proxy (cache/Coll.php):
namespace Bug2;
// …
class Coll extends ArrayObject implements \IteratorAggregate, \Traversable, \ArrayAccess, \Serializable, \Countable, \Go\Aop\Proxy
Result: Error: Class "Bug2\ArrayObject" not found in cache/Coll.php:9 when the woven file includes the proxy.
Cause
src/Proxy/ClassProxyGenerator.php:187passes$parentClass->getName()(ArrayObject, with no leading\) toClassGenerator.ClassGenerator::classNameNode()(src/Proxy/Generator/ClassGenerator.php:127-134) only emitsName\FullyQualifiedwhen the name has a leading\or contains a namespace separator. A global class name therefore becomes a relativeName.- Interfaces are not affected, because they are prefixed with
\explicitly (ClassProxyGenerator.php:180). - Used traits (
ClassGenerator.php:176,184) go through the sameclassNameNode(), so a trait declared in the global namespace is probably affected the same way.
Expected
extends \ArrayObject. Reflection always returns fully qualified names, so the parent (and the trait names) should always be emitted fully qualified. This also applies to the enum and trait proxy generators, if they pass reflection names through the same helper.
Acceptance
- Weaving fixture and snapshot test: a namespaced class extending a global class (
\ArrayObjector\Exception), and a class using a trait from the global namespace. - A functional or compile check that the generated proxy loads.
- Generated code stays clean: the short-alias rules from AGENTS.md apply. A global name written as
\ArrayObjectis fine.
- Lingua principale
- PHP
- Stelle
- 1.7k
- Fork
- 166
- Merge medio
- 11h 30m
- PR unite (30g)
- 40
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
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 goaop/framework
-
Intercepting a method imported from a trait with #[\Override] fails: OriginalAlias "has #[\Override] attribute, but no matching parent method exists"Forse già presa @lisachenko l’ha presa 9 giorni fa. ApertaBug PHP8.4
Difficoltà 3/5 Mezza giornata Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
Several woven classes in one file: their proxies overwrite each other, all but the last class are lost (Class not found)Forse già presa @lisachenko l’ha presa 9 giorni fa. ApertaBug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 38/100
I maintainer di solito rispondono entro 1 giorno
-
Enhancement Performance
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
goaop/framework#747 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Enhancement Performance To Be Discussed
Difficoltà 3/5 Mezza giornata Idoneità per principianti 55/100
I maintainer di solito rispondono entro 1 giorno
-
Feature
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di goaop/framework
Issue simili
-
sync-en
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 83/100
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
nextcloud/integration_openai#446 ·
-
bug customer-reported
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
MagnaCapax/PMSS#1101 ·
I maintainer di solito rispondono entro 5 giorni
-
Installation / Upgrade Platform: Docker
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
I maintainer di solito rispondono entro 1 giorno