Interfaces are not copied into the Phar
Bug report
| Question | Answer |
|---|---|
| Box version | 3.16.0 |
| PHP version | 8.0.16 |
| Platform with version | macOS 12.2.1 |
| Github Repo | n/a |
I'm encountering an issue where it appears some of the interfaces from the vendor/ directory are not being copied into the generated Phar file.
box.json.dist
My box.json.dist is empty, for the sake of this reproducible example.
{}
Steps to reproduce
mkdir box-test/
cd box-test/
composer require phpunit/phpunit humbug/box
echo "<?php echo 'Hello';" > index.php
./vendor/bin/box compile --debug
# Get a list of all files in `vendor/` that contain a line matching `'^interface '`
ack --nocolor --sort-files --files-with-matches '^interface ' vendor/ > interfaces-pre-build.txt
# Get a list of all files in `.box_dump/vendor/` that contain a line matching `'^interface '`
ack --nocolor --sort-files --files-with-matches '^interface ' .box_dump/vendor/ > interfaces-post-build.txt
# Remove the `.box_dump/` prefix from paths in `interfaces-post-build.txt` for easier comparison
sed -i -e 's/\.box_dump\///' interfaces-post-build.txt
# Compare the files
diff -u interfaces-pre-build.txt interfaces-post-build.txt
You'll see output like this:
--- interfaces-pre-build.txt 2022-03-13 14:59:11.000000000 -0500
+++ interfaces-post-build.txt 2022-03-13 15:01:36.000000000 -0500
@@ -3,8 +3,6 @@
vendor/amphp/amp/lib/Promise.php
vendor/amphp/byte-stream/lib/InputStream.php
vendor/amphp/byte-stream/lib/OutputStream.php
-vendor/amphp/parallel/docs/worker-pool.md
-vendor/amphp/parallel/docs/workers.md
vendor/amphp/parallel/lib/Context/Context.php
vendor/amphp/parallel/lib/Context/ContextFactory.php
vendor/amphp/parallel/lib/Sync/Channel.php
@@ -34,8 +32,6 @@
vendor/fidry/console/src/Command/LazyCommand.php
vendor/fidry/console/src/Internal/Type/InputType.php
vendor/fidry/console/src/Internal/Type/ScalarType.php
-vendor/humbug/box/.requirement-checker/src/IsFulfilled.php
-vendor/humbug/box/.requirement-checker/vendor/composer/semver/src/Constraint/ConstraintInterface.php
vendor/humbug/box/fixtures/composer-dump/dir002/vendor/beberlei/assert/lib/Assert/AssertionFailedException.php
vendor/humbug/box/fixtures/configuration/dir001/vendor/beberlei/assert/lib/Assert/AssertionFailedException.php
vendor/humbug/box/fixtures/configuration/dir002/vendor/beberlei/assert/lib/Assert/AssertionFailedException.php
@@ -66,7 +62,6 @@
vendor/jetbrains/phpstorm-stubs/pq/pq.php
vendor/jetbrains/phpstorm-stubs/pthreads/pthreads.php
vendor/jetbrains/phpstorm-stubs/session/SessionHandler.php
-vendor/jetbrains/phpstorm-stubs/tests/Model/StubProblemType.php
vendor/jetbrains/phpstorm-stubs/yaf/yaf.php
vendor/jetbrains/phpstorm-stubs/yaf/yaf_namespace.php
vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/ConstraintInterface.php
@@ -125,7 +120,6 @@
vendor/phpunit/php-text-template/src/exceptions/Exception.php
vendor/phpunit/php-timer/src/exceptions/Exception.php
vendor/phpunit/phpunit/src/Exception.php
-vendor/phpunit/phpunit/src/Framework/IncompleteTest.php
vendor/phpunit/phpunit/src/Framework/MockObject/Builder/Identity.php
vendor/phpunit/phpunit/src/Framework/MockObject/Builder/InvocationStubber.php
vendor/phpunit/phpunit/src/Framework/MockObject/Builder/MethodNameMatch.php
@@ -140,8 +134,6 @@
vendor/phpunit/phpunit/src/Framework/MockObject/Verifiable.php
vendor/phpunit/phpunit/src/Framework/Reorderable.php
vendor/phpunit/phpunit/src/Framework/SelfDescribing.php
-vendor/phpunit/phpunit/src/Framework/SkippedTest.php
-vendor/phpunit/phpunit/src/Framework/Test.php
vendor/phpunit/phpunit/src/Framework/TestListener.php
vendor/phpunit/phpunit/src/Runner/Hook/AfterIncompleteTestHook.php
vendor/phpunit/phpunit/src/Runner/Hook/AfterLastTestHook.php
What's important to note is that the vendor directory in .box_dump is missing the following interfaces:
vendor/jetbrains/phpstorm-stubs/tests/Model/StubProblemType.phpvendor/phpunit/phpunit/src/Framework/IncompleteTest.phpvendor/phpunit/phpunit/src/Framework/SkippedTest.phpvendor/phpunit/phpunit/src/Framework/Test.php
This seems to happen every time I run it, so I don't think this is an intermittent issue.
Weird indeed, could you also print out the resolved configuration? (it should be in .box_dump
Apparently, GitHub has a limit to the size of comments: 65,536 characters. π
Here's the .box_configuration: https://gist.github.com/ramsey/711387b710852213a54bf6446f9ebf0f
I'm curious whether you (or others) have been able to reproduce this.
I tried debugging this a bit, but Iβm unable to figure out whatβs different about these files that makes them consistently excluded from the Phar.
Finally had the time to take a look. I am pretty sure this is caused by https://github.com/box-project/box/blob/main/src/Configuration/Configuration.php#L1519.
Thanks for looking. It's been a long time since I've looked at this (I gave up trying π). That line wouldn't explain why StubProblemType.php was excluded.
It's in the same group:
-vendor/jetbrains/phpstorm-stubs/tests/Model/StubProblemType.php
Notice it's in the tests directory which is also excluded. I think the intent is good and it's there since forever and has been improved but removing the test PHP classes seems to be too much. At the very least there should be an option to disable this optimization.