Proxy of a namespaced class extending a global class references the parent unqualified (Class "Ns\ArrayObject" not found)
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- PHP
- スター
- 1.7k
- フォーク
- 166
- 平均マージ
- 21時間 16分
- マージ済み PR(30日)
- 51
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
goaop/framework のほかの issue
-
Enhancement Performance
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
goaop/framework#747 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Enhancement Performance To Be Discussed
難易度 3/5 半日 初心者へのやさしさ 55/100
メンテナーはふだん 1 日以内に返信
-
Feature
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
メンテナーはふだん 1 日以内に返信
-
To Be Discussed
難易度 1/5 1時間未満 初心者へのやさしさ 10/100
goaop/framework#154 · コメント 53 件 · リアクション 15 件 ·
メンテナーはふだん 1 日以内に返信
goaop/framework の issue をすべて見る
似ている issue
-
mobile-app
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
Open-Locker/Open-Locker#352 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: SCIM Users groups[].value is returned as an integer, causing authentik user discovery to failオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
grokability/snipe-it#20006 ·
メンテナーはふだん 1 日以内に返信
-
fixed
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
firefly-iii/firefly-iii#13150 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
TYPO3-Solr/ext-solr#4828 ·
メンテナーはふだん 5 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 3 日以内に返信