Skip to content

Commit f0e7bba

Browse files
committed
Add php-scoper to phar build to prevent namespace conflicts
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
1 parent 9498feb commit f0e7bba

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ test_%: ## it launches a test
1717

1818
phar: ## it creates phar
1919
rm -rf ${TMP_DIR} && mkdir -p ${TMP_DIR}
20-
cp -R src bin-stub box.json README.md composer.json phparkitect-stub.php bin ${TMP_DIR}
20+
cp -R src bin-stub box.json README.md composer.json phparkitect-stub.php bin scoper.inc.php ${TMP_DIR}
2121
cd ${TMP_DIR} && composer install --prefer-source --no-dev -o
2222
bin/box.phar compile -c ${TMP_DIR}/box.json
2323
cp ${TMP_DIR}/phparkitect.phar .

box.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
],
1313
"compression": "GZ",
1414
"compactors": [
15+
"KevinGH\\Box\\Compactor\\PhpScoper",
1516
"KevinGH\\Box\\Compactor\\Json"
1617
],
1718
"main": "bin-stub/phparkitect",

scoper.inc.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
return [
6+
'prefix' => 'PhpArkitect',
7+
8+
'expose-global-constants' => true,
9+
'expose-global-classes' => true,
10+
'expose-global-functions' => true,
11+
12+
'exclude-namespaces' => [
13+
'Arkitect',
14+
],
15+
];

0 commit comments

Comments
 (0)