Skip to content

Remove unnecessary FQDN in generated proxy trait adoption#573

Merged
lisachenko merged 1 commit into
masterfrom
feature/remove-extra-fqdn
May 11, 2026
Merged

Remove unnecessary FQDN in generated proxy trait adoption#573
lisachenko merged 1 commit into
masterfrom
feature/remove-extra-fqdn

Conversation

@lisachenko
Copy link
Copy Markdown
Member

Summary

  • Use short (unqualified) trait names in generated proxies when the trait and proxy share the same namespace
  • Keep FQCN when namespaces differ, so cross-namespace trait adoption works correctly
  • Make TraitGenerator consistently wrap cross-namespace names in Name\FullyQualified (was using plain Name)

Before

class CacheableDemo implements \Go\Aop\Proxy
{
    use \Demo\Example\CacheableDemo__AopProxied {
        \Demo\Example\CacheableDemo__AopProxied::getReport as private __aop__getReport;
    }

After

class CacheableDemo implements \Go\Aop\Proxy
{
    use CacheableDemo__AopProxied {
        CacheableDemo__AopProxied::getReport as private __aop__getReport;
    }

Files changed

  • src/Proxy/ClassProxyGenerator.php — namespace-aware short name for class proxy
  • src/Proxy/EnumProxyGenerator.php — same for enum proxy
  • src/Proxy/TraitProxyGenerator.php — same for trait proxy
  • src/Proxy/Generator/TraitGenerator.php — wrap cross-namespace names in FullyQualified
  • 5 test fixture files — updated expected proxy output
  • 3 test files — 6 new tests covering same/different namespace scenarios

Closes #572

Test plan

  • Full suite: 2477 tests, 0 failures
  • 6 new tests: short name when same namespace, FQCN when different namespace (×3 generators)

🤖 Generated with Claude Code

When the generated proxy and the trait being adopted share the same
namespace, use the short (unqualified) trait name instead of the
fully-qualified domain name. This makes generated proxy code cleaner
and more readable.

Also makes TraitGenerator consistently wrap cross-namespace names in
Name\FullyQualified, matching ClassGenerator and EnumGenerator behavior.

Closes #572

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@lisachenko lisachenko added this to the 4.0.0 milestone May 11, 2026
@lisachenko lisachenko merged commit 4516123 into master May 11, 2026
5 checks passed
@lisachenko lisachenko deleted the feature/remove-extra-fqdn branch May 11, 2026 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

[Improvement] Remove unnecessarily FQDN in generated proxies

1 participant