Skip to content

Add PHP Scoper configuration for PHAR namespace isolation#602

Open
fain182 wants to merge 4 commits intomainfrom
claude/add-php-scoper-phar-J56O3
Open

Add PHP Scoper configuration for PHAR namespace isolation#602
fain182 wants to merge 4 commits intomainfrom
claude/add-php-scoper-phar-J56O3

Conversation

@fain182
Copy link
Copy Markdown
Collaborator

@fain182 fain182 commented Mar 29, 2026

Summary

This PR adds PHP Scoper configuration to the PHAR build process, enabling automatic namespace prefixing of dependencies to prevent conflicts when PHPArkitect is used as a library.

Key Changes

  • Added scoper.inc.php: New PHP Scoper configuration file that:

    • Prefixes all dependencies with _PhpArkitect namespace
    • Exposes global constants, classes, and functions to maintain compatibility
    • Excludes the Arkitect namespace from prefixing to preserve the public API
  • Updated box.json: Added KevinGH\Box\Compactor\PhpScoper compactor to the build pipeline to apply namespace scoping during PHAR compilation

  • Updated Makefile: Modified the phar target to include scoper.inc.php in the temporary build directory

Implementation Details

The scoping configuration ensures that when PHPArkitect is distributed as a PHAR file, all third-party dependencies are automatically namespaced under _PhpArkitect, preventing namespace collisions with user code while keeping the main Arkitect namespace accessible as the public API.

https://claude.ai/code/session_01R4VMqad8oVQw3g1HPwPp8G

claude added 2 commits March 29, 2026 21:32
All vendor dependencies (nikic/php-parser, symfony/*, phpstan/phpdoc-parser,
webmozart/assert, ondram/ci-detector) are prefixed with PhpArkitect\ inside the
phar, eliminating conflicts when the host project uses the same libraries.
The Arkitect\ namespace is excluded from scoping so end-user config files
remain unaffected.

https://claude.ai/code/session_01R4VMqad8oVQw3g1HPwPp8G
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.31%. Comparing base (9498feb) to head (dd0e142).

Additional details and impacted files
@@            Coverage Diff            @@
##               main     #602   +/-   ##
=========================================
  Coverage     98.31%   98.31%           
  Complexity      681      681           
=========================================
  Files            86       86           
  Lines          1960     1960           
=========================================
  Hits           1927     1927           
  Misses           33       33           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

claude added 2 commits March 29, 2026 22:04
Composer\InstalledVersions is a Composer runtime class used by our own
(non-scoped) Arkitect code. Prefixing it breaks the reference at runtime.

https://claude.ai/code/session_01R4VMqad8oVQw3g1HPwPp8G
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants