├── fixtures ├── info │ ├── foo │ ├── simple-phar │ ├── simple-phar.phar │ ├── tree-phar.phar │ ├── hidden-files.phar │ ├── simple-phar.tar.gz │ ├── new-simple-phar.zip │ └── simple-phar.tar.bz2 ├── extract │ ├── invalid │ ├── invalid.phar │ ├── simple-phar │ ├── simple-phar.phar │ └── compressed-phar.phar ├── build │ ├── dir000 │ │ ├── test.phar │ │ ├── bootstrap.php │ │ ├── one │ │ │ └── test.php │ │ ├── test.phar.pubkey │ │ ├── two │ │ │ └── test.png │ │ ├── unknown │ │ ├── a │ │ │ └── deep │ │ │ │ └── test │ │ │ │ └── directory │ │ │ │ └── test.php │ │ ├── binary │ │ ├── test-symlink.php │ │ ├── composer.json │ │ ├── run.php │ │ ├── test.php │ │ └── private.key │ ├── dir002 │ │ ├── test.phar │ │ ├── box.json │ │ └── test.php │ ├── dir004 │ │ ├── test.php │ │ ├── box.json │ │ └── stub.php │ ├── dir005 │ │ ├── index.php │ │ ├── test.php │ │ └── box.json │ ├── dir003 │ │ ├── banner │ │ ├── box.json │ │ └── test.php │ ├── dir012 │ │ ├── src │ │ │ ├── Controller │ │ │ │ └── .gitignore │ │ │ └── Kernel.php │ │ ├── expected-output │ │ ├── config │ │ │ ├── packages │ │ │ │ ├── dev │ │ │ │ │ └── routing.yaml │ │ │ │ ├── prod │ │ │ │ │ └── routing.yaml │ │ │ │ ├── test │ │ │ │ │ ├── routing.yaml │ │ │ │ │ └── framework.yaml │ │ │ │ ├── routing.yaml │ │ │ │ ├── framework.yaml │ │ │ │ └── cache.yaml │ │ │ ├── routes.yaml │ │ │ ├── routes │ │ │ │ └── dev │ │ │ │ │ └── framework.yaml │ │ │ ├── bundles.php │ │ │ ├── preload.php │ │ │ └── services.yaml │ │ ├── .gitignore │ │ ├── box.json.dist │ │ ├── public │ │ │ └── index.php │ │ ├── .env │ │ ├── bin │ │ │ └── console │ │ └── composer.json │ ├── dir013 │ │ ├── expected-output │ │ ├── .gitignore │ │ ├── composer.json │ │ ├── box.json │ │ ├── bin │ │ │ └── run │ │ └── composer.lock │ ├── dir009 │ │ ├── box.json │ │ ├── index.php │ │ └── main.php │ ├── dir010 │ │ ├── box.json │ │ ├── index.php │ │ ├── scoper.inc.php │ │ └── scoper-fixed-prefix.inc.php │ ├── dir011 │ │ ├── box.json │ │ ├── composer.json │ │ ├── scoper.inc.php │ │ ├── src │ │ │ ├── X.php │ │ │ ├── Y.php │ │ │ └── functions.php │ │ └── index.php │ ├── dir006 │ │ ├── box.json │ │ └── test.php │ ├── dir007 │ │ ├── box.json │ │ └── test.php │ ├── dir008 │ │ ├── box.json │ │ └── index.php │ └── dir001 │ │ ├── box.json │ │ └── test.php ├── check-requirements │ ├── pass-no-config │ │ ├── composer.json │ │ ├── index.php │ │ ├── expected-output-53-dist │ │ └── expected-output-73-dist │ ├── fail-complete │ │ ├── vendor │ │ │ └── composer │ │ │ │ └── installed.json │ │ ├── composer.json │ │ ├── expected-output-53-dist-skipped │ │ ├── index.php │ │ ├── composer.lock │ │ ├── expected-output-53-dist │ │ └── expected-output-73-dist │ └── pass-complete │ │ ├── vendor │ │ └── composer │ │ │ └── installed.json │ │ ├── composer.json │ │ ├── index.php │ │ ├── expected-output-53-dist │ │ ├── expected-output-73-dist │ │ └── composer.lock ├── configuration │ ├── dir000 │ │ ├── box.json │ │ ├── composer.json │ │ └── src │ │ │ └── Main.php │ ├── dir001 │ │ ├── box.json │ │ ├── composer.json │ │ ├── vendor │ │ │ ├── autoload.php │ │ │ ├── composer │ │ │ │ ├── autoload_classmap.php │ │ │ │ ├── autoload_namespaces.php │ │ │ │ ├── autoload_psr4.php │ │ │ │ ├── autoload_files.php │ │ │ │ ├── autoload_static.php │ │ │ │ └── LICENSE │ │ │ └── beberlei │ │ │ │ └── assert │ │ │ │ ├── LICENSE │ │ │ │ ├── lib │ │ │ │ └── Assert │ │ │ │ │ ├── AssertionFailedException.php │ │ │ │ │ ├── LazyAssertionException.php │ │ │ │ │ └── InvalidArgumentException.php │ │ │ │ └── composer.json │ │ └── src │ │ │ └── Main.php │ ├── dir002 │ │ ├── box.json │ │ ├── composer.json │ │ ├── src │ │ │ └── Main.php │ │ └── vendor │ │ │ └── beberlei │ │ │ └── assert │ │ │ ├── LICENSE │ │ │ ├── lib │ │ │ └── Assert │ │ │ │ ├── AssertionFailedException.php │ │ │ │ ├── LazyAssertionException.php │ │ │ │ └── InvalidArgumentException.php │ │ │ └── composer.json │ ├── dir003 │ │ ├── box.json │ │ ├── composer.json │ │ ├── vendor │ │ │ ├── autoload.php │ │ │ ├── composer │ │ │ │ ├── autoload_classmap.php │ │ │ │ ├── autoload_namespaces.php │ │ │ │ ├── autoload_psr4.php │ │ │ │ ├── autoload_files.php │ │ │ │ ├── autoload_static.php │ │ │ │ └── LICENSE │ │ │ └── beberlei │ │ │ │ ├── autoload.php │ │ │ │ ├── composer │ │ │ │ ├── autoload_classmap.php │ │ │ │ ├── autoload_namespaces.php │ │ │ │ ├── autoload_psr4.php │ │ │ │ ├── autoload_files.php │ │ │ │ ├── LICENSE │ │ │ │ └── autoload_static.php │ │ │ │ └── assert │ │ │ │ ├── LICENSE │ │ │ │ ├── lib │ │ │ │ └── Assert │ │ │ │ │ ├── AssertionFailedException.php │ │ │ │ │ ├── LazyAssertionException.php │ │ │ │ │ └── InvalidArgumentException.php │ │ │ │ └── composer.json │ │ └── src │ │ │ └── Main.php │ └── dir004 │ │ ├── box.json │ │ ├── composer.json │ │ ├── vendor │ │ ├── autoload.php │ │ ├── composer │ │ │ ├── autoload_classmap.php │ │ │ ├── autoload_namespaces.php │ │ │ ├── autoload_psr4.php │ │ │ ├── autoload_files.php │ │ │ ├── autoload_static.php │ │ │ └── LICENSE │ │ └── beberlei │ │ │ ├── autoload.php │ │ │ ├── composer │ │ │ ├── autoload_classmap.php │ │ │ ├── autoload_namespaces.php │ │ │ ├── autoload_psr4.php │ │ │ ├── autoload_files.php │ │ │ ├── LICENSE │ │ │ └── autoload_static.php │ │ │ └── assert │ │ │ ├── LICENSE │ │ │ ├── lib │ │ │ └── Assert │ │ │ │ ├── AssertionFailedException.php │ │ │ │ ├── LazyAssertionException.php │ │ │ │ └── InvalidArgumentException.php │ │ │ └── composer.json │ │ └── src │ │ └── Main.php ├── diff │ ├── not-a-phar.phar │ ├── simple-phar │ ├── openssl.phar │ ├── simple-phar-bar.phar │ ├── simple-phar-baz.phar │ ├── simple-phar-foo.phar │ ├── simple-phar-bar-compressed.phar │ └── openssl.phar.pubkey ├── verify │ ├── not-a-phar.phar │ ├── simple-phar │ ├── simple-phar.phar │ ├── simple-corrupted-phar.phar │ ├── openssl-signed │ │ ├── php-scoper.phar │ │ └── php-scoper.phar.pubkey │ ├── openssl-signed-without-pubkey │ │ └── php-scoper.phar │ └── openssl-signed-with-corrupted-pubkey │ │ ├── php-scoper.phar │ │ └── php-scoper.phar.pubkey ├── signed_phars │ ├── md5.phar │ ├── empty.phar │ ├── mixed.phar │ ├── sha1.phar │ ├── example.phar │ ├── invalid.phar │ ├── missing.phar │ ├── openssl.phar │ ├── sha256.phar │ ├── sha512.phar │ └── openssl.phar.pubkey ├── docker │ ├── simple-phar.phar │ ├── simple-corrupted-phar.phar │ └── simple-phar-without-requirements.phar ├── composer-dump │ ├── dir000 │ │ └── composer.json │ ├── dir001 │ │ └── composer.json │ ├── dir002 │ │ ├── composer.json │ │ └── vendor │ │ │ └── beberlei │ │ │ └── assert │ │ │ ├── LICENSE │ │ │ ├── lib │ │ │ └── Assert │ │ │ │ ├── AssertionFailedException.php │ │ │ │ ├── LazyAssertionException.php │ │ │ │ └── InvalidArgumentException.php │ │ │ └── composer.json │ └── dir003 │ │ └── composer.json ├── php-settings-checker │ ├── output-all-clear │ ├── output-min-memory-limit │ ├── output-set-memory-limit │ ├── index.php │ ├── create-expected-output │ ├── output-pharreadonly-enabled │ └── output-xdebug-enabled.tpl ├── Compactor │ ├── InvalidCompactor.php │ ├── DummyCompactor.php │ ├── FakeCompactor.php │ └── DummyFileExtensionCompactor.php ├── Console │ └── Command │ │ └── TestConfigurableCommand.php ├── Verifier │ ├── DummyPublicKey.php │ └── DummyBufferedHash.php ├── NotCallable.php └── PhpScoper │ ├── FakePhpScoper.php │ ├── CallRecorderScoper.php │ ├── UnserializableScoper.php │ └── FakeScoper.php ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── Support_question.md │ ├── Feature_request.md │ └── Bug_report.md └── tap-release.yml ├── bin ├── box.bat ├── generate_default_stub └── box ├── doc └── img │ ├── box.png │ └── requirement-checker.png ├── vendor-bin ├── psalm │ └── composer.json ├── infection │ └── composer.json ├── doctrine-cs │ └── composer.json └── php-cs-fixer │ └── composer.json ├── .docker ├── php53 ├── php73 ├── php73_xdebug └── build ├── .requirement-checker ├── src │ ├── IsFulfilled.php │ ├── IsExtensionFulfilled.php │ ├── IsPhpVersionFulfilled.php │ ├── Requirement.php │ └── RequirementCollection.php ├── vendor │ ├── autoload.php │ └── composer │ │ ├── autoload_namespaces.php │ │ ├── autoload_psr4.php │ │ ├── semver │ │ └── src │ │ │ ├── Constraint │ │ │ └── ConstraintInterface.php │ │ │ └── Comparator.php │ │ ├── LICENSE │ │ └── autoload_real.php └── bin │ └── check-requirements.php ├── requirement-checker ├── box.json.dist ├── tests │ ├── ConditionIsFulfilled.php │ └── ConditionIsNotFulfilled.php ├── src │ ├── IsFulfilled.php │ ├── IsExtensionFulfilled.php │ └── IsPhpVersionFulfilled.php ├── phpunit.xml.dist ├── bin │ └── check-requirements.php ├── composer.json └── scoper.inc.php ├── infection.json.dist ├── src ├── NotInstantiable.php ├── Annotation │ ├── MalformedTagException.php │ └── CompactedFormatter.php ├── consts.php ├── Configuration │ ├── NoConfigurationFound.php │ └── ConfigurationLogger.php ├── Test │ └── RequiresPharReadonlyOff.php ├── Compactor │ ├── Compactor.php │ ├── BaseCompactor.php │ ├── PhpScoper.php │ ├── Placeholder.php │ ├── Json.php │ └── FileExtensionCompactor.php ├── PhpScoper │ ├── Scoper.php │ ├── NullScoper.php │ ├── WhitelistManipulator.php │ └── SimpleScoper.php ├── Composer │ ├── ComposerFile.php │ └── ComposerFiles.php ├── Console │ ├── OutputFormatterConfigurator.php │ ├── Command │ │ ├── Build.php │ │ ├── BaseCommand.php │ │ └── ConfigurationExporter.php │ └── IO │ │ └── IO.php ├── Json │ └── JsonValidationException.php ├── PharInfo │ └── Pharaoh.php └── MapFile.php ├── tests ├── bootstrap.php ├── PhpScoper │ ├── DummyScoper.php │ └── NullScoperTest.php ├── Console │ ├── Command │ │ └── CommandTester.php │ └── DisplayNormalizer.php ├── PhpUnitAnnotationsTest.php ├── Configuration │ └── NoConfigurationFoundTest.php └── Annotation │ └── DocblockAnnotationParserTest.php ├── box.json.dist ├── LICENSE ├── .gitignore ├── psalm.xml ├── phpcs.xml.dist └── phpunit.xml.dist /fixtures/info/foo: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/extract/invalid: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/build/dir000/test.phar: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/build/dir002/test.phar: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/build/dir004/test.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/build/dir005/index.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/build/dir005/test.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/extract/invalid.phar: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/build/dir000/bootstrap.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/build/dir000/one/test.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/build/dir000/test.phar.pubkey: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/build/dir000/two/test.png: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/build/dir000/unknown: -------------------------------------------------------------------------------- 1 | unknown -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [theofidry] 2 | -------------------------------------------------------------------------------- /bin/box.bat: -------------------------------------------------------------------------------- 1 | @ECHO off 2 | php %~dp0/box %* -------------------------------------------------------------------------------- /fixtures/build/dir003/banner: -------------------------------------------------------------------------------- 1 | custom banner -------------------------------------------------------------------------------- /fixtures/build/dir012/src/Controller/.gitignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/build/dir013/expected-output: -------------------------------------------------------------------------------- 1 | OK 2 | -------------------------------------------------------------------------------- /fixtures/build/dir000/a/deep/test/directory/test.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/build/dir000/binary: -------------------------------------------------------------------------------- 1 | Unreadable content, get out! -------------------------------------------------------------------------------- /fixtures/build/dir000/test-symlink.php: -------------------------------------------------------------------------------- 1 | a/deep/test/directory/test.php -------------------------------------------------------------------------------- /fixtures/check-requirements/pass-no-config/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | } 3 | -------------------------------------------------------------------------------- /fixtures/build/dir009/box.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "main.php" 3 | } 4 | -------------------------------------------------------------------------------- /doc/img/box.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatie/box/master/doc/img/box.png -------------------------------------------------------------------------------- /fixtures/build/dir013/.gitignore: -------------------------------------------------------------------------------- 1 | vendor/ 2 | bin/run.phar 3 | actual-output -------------------------------------------------------------------------------- /fixtures/build/dir012/expected-output: -------------------------------------------------------------------------------- 1 | Symfony 5.1.5 (env: prod, debug: false) 2 | -------------------------------------------------------------------------------- /fixtures/configuration/dir000/box.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "src/Main.php" 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/diff/not-a-phar.phar: -------------------------------------------------------------------------------- 1 | This file is not a real PHAR file! Fake! 2 | 3 | -------------------------------------------------------------------------------- /fixtures/verify/not-a-phar.phar: -------------------------------------------------------------------------------- 1 | This file is not a real PHAR file! Fake! 2 | 3 | -------------------------------------------------------------------------------- /fixtures/check-requirements/fail-complete/vendor/composer/installed.json: -------------------------------------------------------------------------------- 1 | { 2 | } 3 | -------------------------------------------------------------------------------- /fixtures/check-requirements/pass-complete/vendor/composer/installed.json: -------------------------------------------------------------------------------- 1 | { 2 | } 3 | -------------------------------------------------------------------------------- /fixtures/build/dir013/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "bin": [ 3 | "bin/run" 4 | ] 5 | } -------------------------------------------------------------------------------- /fixtures/build/dir013/box.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "bin/run", 3 | "force-autodiscovery": true 4 | } -------------------------------------------------------------------------------- /fixtures/diff/simple-phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatie/box/master/fixtures/diff/simple-phar -------------------------------------------------------------------------------- /fixtures/info/simple-phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatie/box/master/fixtures/info/simple-phar -------------------------------------------------------------------------------- /fixtures/diff/openssl.phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatie/box/master/fixtures/diff/openssl.phar -------------------------------------------------------------------------------- /fixtures/verify/simple-phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatie/box/master/fixtures/verify/simple-phar -------------------------------------------------------------------------------- /fixtures/build/dir000/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "autoload": { 3 | "classmap": ["./"] 4 | } 5 | } -------------------------------------------------------------------------------- /fixtures/extract/simple-phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatie/box/master/fixtures/extract/simple-phar -------------------------------------------------------------------------------- /fixtures/info/simple-phar.phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatie/box/master/fixtures/info/simple-phar.phar -------------------------------------------------------------------------------- /fixtures/info/tree-phar.phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatie/box/master/fixtures/info/tree-phar.phar -------------------------------------------------------------------------------- /fixtures/signed_phars/md5.phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatie/box/master/fixtures/signed_phars/md5.phar -------------------------------------------------------------------------------- /doc/img/requirement-checker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatie/box/master/doc/img/requirement-checker.png -------------------------------------------------------------------------------- /fixtures/docker/simple-phar.phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatie/box/master/fixtures/docker/simple-phar.phar -------------------------------------------------------------------------------- /fixtures/info/hidden-files.phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatie/box/master/fixtures/info/hidden-files.phar -------------------------------------------------------------------------------- /fixtures/info/simple-phar.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatie/box/master/fixtures/info/simple-phar.tar.gz -------------------------------------------------------------------------------- /fixtures/signed_phars/empty.phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatie/box/master/fixtures/signed_phars/empty.phar -------------------------------------------------------------------------------- /fixtures/signed_phars/mixed.phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatie/box/master/fixtures/signed_phars/mixed.phar -------------------------------------------------------------------------------- /fixtures/signed_phars/sha1.phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatie/box/master/fixtures/signed_phars/sha1.phar -------------------------------------------------------------------------------- /fixtures/verify/simple-phar.phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatie/box/master/fixtures/verify/simple-phar.phar -------------------------------------------------------------------------------- /vendor-bin/psalm/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "require-dev": { 3 | "vimeo/psalm": "^1.1" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /.docker/php53: -------------------------------------------------------------------------------- 1 | FROM helder/php-5.3 2 | 3 | RUN echo '' | pecl install phar; \ 4 | echo '' | pecl install json 5 | -------------------------------------------------------------------------------- /fixtures/diff/simple-phar-bar.phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatie/box/master/fixtures/diff/simple-phar-bar.phar -------------------------------------------------------------------------------- /fixtures/diff/simple-phar-baz.phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatie/box/master/fixtures/diff/simple-phar-baz.phar -------------------------------------------------------------------------------- /fixtures/diff/simple-phar-foo.phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatie/box/master/fixtures/diff/simple-phar-foo.phar -------------------------------------------------------------------------------- /fixtures/extract/simple-phar.phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatie/box/master/fixtures/extract/simple-phar.phar -------------------------------------------------------------------------------- /fixtures/info/new-simple-phar.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatie/box/master/fixtures/info/new-simple-phar.zip -------------------------------------------------------------------------------- /fixtures/info/simple-phar.tar.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatie/box/master/fixtures/info/simple-phar.tar.bz2 -------------------------------------------------------------------------------- /fixtures/signed_phars/example.phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatie/box/master/fixtures/signed_phars/example.phar -------------------------------------------------------------------------------- /fixtures/signed_phars/invalid.phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatie/box/master/fixtures/signed_phars/invalid.phar -------------------------------------------------------------------------------- /fixtures/signed_phars/missing.phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatie/box/master/fixtures/signed_phars/missing.phar -------------------------------------------------------------------------------- /fixtures/signed_phars/openssl.phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatie/box/master/fixtures/signed_phars/openssl.phar -------------------------------------------------------------------------------- /fixtures/signed_phars/sha256.phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatie/box/master/fixtures/signed_phars/sha256.phar -------------------------------------------------------------------------------- /fixtures/signed_phars/sha512.phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatie/box/master/fixtures/signed_phars/sha512.phar -------------------------------------------------------------------------------- /fixtures/build/dir012/config/packages/dev/routing.yaml: -------------------------------------------------------------------------------- 1 | framework: 2 | router: 3 | strict_requirements: true 4 | -------------------------------------------------------------------------------- /fixtures/extract/compressed-phar.phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatie/box/master/fixtures/extract/compressed-phar.phar -------------------------------------------------------------------------------- /fixtures/build/dir010/box.json: -------------------------------------------------------------------------------- 1 | { 2 | "compactors": [ 3 | "KevinGH\\Box\\Compactor\\PhpScoper" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /fixtures/build/dir011/box.json: -------------------------------------------------------------------------------- 1 | { 2 | "compactors": [ 3 | "KevinGH\\Box\\Compactor\\PhpScoper" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /fixtures/build/dir012/config/packages/prod/routing.yaml: -------------------------------------------------------------------------------- 1 | framework: 2 | router: 3 | strict_requirements: null 4 | -------------------------------------------------------------------------------- /fixtures/build/dir012/config/packages/test/routing.yaml: -------------------------------------------------------------------------------- 1 | framework: 2 | router: 3 | strict_requirements: true 4 | -------------------------------------------------------------------------------- /fixtures/check-requirements/pass-complete/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": { 3 | "ext-phar": "*" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /fixtures/composer-dump/dir000/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": { 3 | "beberlei/assert": "^2.8" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /fixtures/composer-dump/dir001/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": { 3 | "beberlei/assert": "^2.8" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /fixtures/composer-dump/dir002/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": { 3 | "beberlei/assert": "^2.8" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /fixtures/composer-dump/dir003/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "require-dev": { 3 | "beberlei/assert": "^2.8" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /vendor-bin/infection/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "require-dev": { 3 | "infection/infection": "^0.20" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /fixtures/build/dir004/box.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": ["test.php"], 3 | "main": "test.php", 4 | "stub": "stub.php" 5 | } 6 | 7 | -------------------------------------------------------------------------------- /fixtures/build/dir012/config/routes.yaml: -------------------------------------------------------------------------------- 1 | #index: 2 | # path: / 3 | # controller: App\Controller\DefaultController::index 4 | -------------------------------------------------------------------------------- /fixtures/docker/simple-corrupted-phar.phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatie/box/master/fixtures/docker/simple-corrupted-phar.phar -------------------------------------------------------------------------------- /fixtures/verify/simple-corrupted-phar.phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatie/box/master/fixtures/verify/simple-corrupted-phar.phar -------------------------------------------------------------------------------- /vendor-bin/doctrine-cs/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "require-dev": { 3 | "doctrine/coding-standard": "^6.0" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /fixtures/build/dir005/box.json: -------------------------------------------------------------------------------- 1 | { 2 | "alias": "test.phar", 3 | "files": ["test.php"], 4 | "output": "test.phar" 5 | } 6 | 7 | -------------------------------------------------------------------------------- /fixtures/diff/simple-phar-bar-compressed.phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatie/box/master/fixtures/diff/simple-phar-bar-compressed.phar -------------------------------------------------------------------------------- /fixtures/verify/openssl-signed/php-scoper.phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatie/box/master/fixtures/verify/openssl-signed/php-scoper.phar -------------------------------------------------------------------------------- /fixtures/build/dir012/config/packages/test/framework.yaml: -------------------------------------------------------------------------------- 1 | framework: 2 | test: true 3 | session: 4 | storage_id: session.storage.mock_file 5 | -------------------------------------------------------------------------------- /fixtures/docker/simple-phar-without-requirements.phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatie/box/master/fixtures/docker/simple-phar-without-requirements.phar -------------------------------------------------------------------------------- /fixtures/build/dir006/box.json: -------------------------------------------------------------------------------- 1 | { 2 | "alias": "test.phar", 3 | "compression": "GZ", 4 | "files": ["test.php"], 5 | "main": "test.php" 6 | } 7 | -------------------------------------------------------------------------------- /fixtures/check-requirements/fail-complete/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": { 3 | "ext-phar": "*", 4 | "ext-pdo_dblib": "*" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /fixtures/configuration/dir001/box.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "src/Main.php", 3 | "directories": [ 4 | "src/", 5 | "vendor/" 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/Support_question.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 🤗 Support Question 3 | about: If you have a question 💬, please also check out our Slack! 4 | 5 | --- 6 | -------------------------------------------------------------------------------- /fixtures/build/dir002/box.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": ["test.php"], 3 | "main": "test.php", 4 | "replacements": { 5 | "name": "world" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /fixtures/build/dir003/box.json: -------------------------------------------------------------------------------- 1 | { 2 | "alias": "test.phar", 3 | "banner-file": "banner", 4 | "files": ["test.php"], 5 | "main": "test.php" 6 | } 7 | 8 | -------------------------------------------------------------------------------- /fixtures/build/dir012/config/routes/dev/framework.yaml: -------------------------------------------------------------------------------- 1 | _errors: 2 | resource: '@FrameworkBundle/Resources/config/routing/errors.xml' 3 | prefix: /_error 4 | -------------------------------------------------------------------------------- /fixtures/configuration/dir002/box.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "src/Main.php", 3 | "directories": [ 4 | "src/", 5 | "vendor/beberlei/" 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /fixtures/build/dir007/box.json: -------------------------------------------------------------------------------- 1 | { 2 | "alias": "test.phar", 3 | "files": ["test.php"], 4 | "main": "test.php", 5 | "output": "foo/bar/test.phar" 6 | } 7 | -------------------------------------------------------------------------------- /fixtures/build/dir008/box.json: -------------------------------------------------------------------------------- 1 | { 2 | "alias": "test.phar", 3 | "files": ["test.php"], 4 | "main": "test.php", 5 | "output": "foo/bar/test.phar" 6 | } 7 | -------------------------------------------------------------------------------- /fixtures/verify/openssl-signed-without-pubkey/php-scoper.phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatie/box/master/fixtures/verify/openssl-signed-without-pubkey/php-scoper.phar -------------------------------------------------------------------------------- /fixtures/build/dir001/box.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": ["test.php"], 3 | "main": "test.php", 4 | "replacements": { 5 | "name": "world" 6 | }, 7 | "stub": true 8 | } -------------------------------------------------------------------------------- /fixtures/verify/openssl-signed-with-corrupted-pubkey/php-scoper.phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatie/box/master/fixtures/verify/openssl-signed-with-corrupted-pubkey/php-scoper.phar -------------------------------------------------------------------------------- /.requirement-checker/src/IsFulfilled.php: -------------------------------------------------------------------------------- 1 | symfony/framework-bundle ### 3 | /.env.local 4 | /.env.local.php 5 | /.env.*.local 6 | /config/secrets/prod/prod.decrypt.private.php 7 | /public/bundles/ 8 | /var/ 9 | /vendor/ 10 | ###< symfony/framework-bundle ### 11 | -------------------------------------------------------------------------------- /fixtures/configuration/dir003/vendor/beberlei/composer/autoload_classmap.php: -------------------------------------------------------------------------------- 1 | array($vendorDir . '/beberlei/assert/lib/Assert'), 10 | ); 11 | -------------------------------------------------------------------------------- /fixtures/configuration/dir003/vendor/composer/autoload_psr4.php: -------------------------------------------------------------------------------- 1 | array($vendorDir . '/beberlei/assert/lib/Assert'), 10 | ); 11 | -------------------------------------------------------------------------------- /fixtures/configuration/dir004/vendor/composer/autoload_psr4.php: -------------------------------------------------------------------------------- 1 | array($vendorDir . '/beberlei/assert/lib/Assert'), 10 | ); 11 | -------------------------------------------------------------------------------- /fixtures/build/dir012/config/packages/routing.yaml: -------------------------------------------------------------------------------- 1 | framework: 2 | router: 3 | utf8: true 4 | 5 | # Configure how to generate URLs in non-HTTP contexts, such as CLI commands. 6 | # See https://symfony.com/doc/current/routing.html#generating-urls-in-commands 7 | #default_uri: http://localhost 8 | -------------------------------------------------------------------------------- /fixtures/configuration/dir003/vendor/beberlei/composer/autoload_psr4.php: -------------------------------------------------------------------------------- 1 | array($vendorDir . '/beberlei/assert/lib/Assert'), 10 | ); 11 | -------------------------------------------------------------------------------- /fixtures/configuration/dir004/vendor/beberlei/composer/autoload_psr4.php: -------------------------------------------------------------------------------- 1 | array($vendorDir . '/beberlei/assert/lib/Assert'), 10 | ); 11 | -------------------------------------------------------------------------------- /fixtures/check-requirements/fail-complete/expected-output-53-dist-skipped: -------------------------------------------------------------------------------- 1 | 2 | Fatal error: Uncaught exception 'Exception' with message 'Should not be executed!' in phar:///opt/box/index.phar/index.php:13 3 | Stack trace: 4 | #0 /opt/box/index.phar(14): require() 5 | #1 {main} 6 | thrown in phar:///opt/box/index.phar/index.php on line 13 7 | -------------------------------------------------------------------------------- /fixtures/build/dir012/box.json.dist: -------------------------------------------------------------------------------- 1 | { 2 | "files-bin": [ 3 | ".env.local.php", 4 | "src/Controller/.gitignore" 5 | ], 6 | "directories": [ 7 | "config", 8 | "var" 9 | ], 10 | "force-autodiscovery": true, 11 | "check-requirements": false, 12 | "exclude-composer-files": false 13 | } 14 | -------------------------------------------------------------------------------- /fixtures/configuration/dir001/vendor/composer/autoload_files.php: -------------------------------------------------------------------------------- 1 | $vendorDir . '/beberlei/assert/lib/Assert/functions.php', 10 | ); 11 | -------------------------------------------------------------------------------- /fixtures/configuration/dir003/vendor/composer/autoload_files.php: -------------------------------------------------------------------------------- 1 | $vendorDir . '/beberlei/assert/lib/Assert/functions.php', 10 | ); 11 | -------------------------------------------------------------------------------- /fixtures/configuration/dir004/vendor/composer/autoload_files.php: -------------------------------------------------------------------------------- 1 | $vendorDir . '/beberlei/assert/lib/Assert/functions.php', 10 | ); 11 | -------------------------------------------------------------------------------- /fixtures/configuration/dir003/vendor/beberlei/composer/autoload_files.php: -------------------------------------------------------------------------------- 1 | $vendorDir . '/beberlei/assert/lib/Assert/functions.php', 10 | ); 11 | -------------------------------------------------------------------------------- /fixtures/configuration/dir004/vendor/beberlei/composer/autoload_files.php: -------------------------------------------------------------------------------- 1 | $vendorDir . '/beberlei/assert/lib/Assert/functions.php', 10 | ); 11 | -------------------------------------------------------------------------------- /requirement-checker/tests/ConditionIsFulfilled.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | -------------------------------------------------------------------------------- /infection.json.dist: -------------------------------------------------------------------------------- 1 | { 2 | "timeout": 10, 3 | "source": { 4 | "directories": [ 5 | "src" 6 | ] 7 | }, 8 | "logs": { 9 | "text": "dist/infection-log.txt" 10 | }, 11 | "mutators": { 12 | "@default": true, 13 | "IdenticalEqual": true, 14 | "NotIdenticalNotEqual": true 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/Feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 🚀 Feature Request 3 | about: I have a suggestion (and may want to implement it 🙂)! 4 | 5 | --- 6 | 7 | ## Feature Request 8 | 9 | 13 | -------------------------------------------------------------------------------- /fixtures/check-requirements/pass-complete/index.php: -------------------------------------------------------------------------------- 1 | 7 | * Théo Fidry 8 | * 9 | * This source file is subject to the MIT license that is bundled 10 | * with this source code in the file LICENSE. 11 | */ 12 | 13 | echo 'Success!'.PHP_EOL; 14 | -------------------------------------------------------------------------------- /fixtures/check-requirements/pass-no-config/index.php: -------------------------------------------------------------------------------- 1 | 7 | * Théo Fidry 8 | * 9 | * This source file is subject to the MIT license that is bundled 10 | * with this source code in the file LICENSE. 11 | */ 12 | 13 | echo 'Success!'.PHP_EOL; 14 | -------------------------------------------------------------------------------- /fixtures/build/dir003/test.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | echo 'Hello!'; 16 | -------------------------------------------------------------------------------- /fixtures/build/dir006/test.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | echo 'Hello!'; 16 | -------------------------------------------------------------------------------- /fixtures/build/dir007/test.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | echo 'Hello!'; 16 | -------------------------------------------------------------------------------- /fixtures/build/dir009/index.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | echo 'Index'; 16 | -------------------------------------------------------------------------------- /fixtures/build/dir009/main.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | echo 'Main'; 16 | -------------------------------------------------------------------------------- /fixtures/build/dir010/index.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | echo 'Index'; 16 | -------------------------------------------------------------------------------- /fixtures/build/dir000/run.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | require 'test.php'; 16 | -------------------------------------------------------------------------------- /fixtures/build/dir000/test.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | echo "Hello, world!\n"; 16 | -------------------------------------------------------------------------------- /fixtures/build/dir001/test.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | echo "Hello, @name@!\n"; 16 | -------------------------------------------------------------------------------- /fixtures/build/dir002/test.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | echo "Hello, @name@!\n"; 16 | -------------------------------------------------------------------------------- /fixtures/php-settings-checker/index.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | echo 'Hello world!'; 16 | -------------------------------------------------------------------------------- /.requirement-checker/vendor/composer/autoload_psr4.php: -------------------------------------------------------------------------------- 1 | array($baseDir . '/src'), 10 | 'HumbugBox3100\\Composer\\Semver\\' => array($vendorDir . '/composer/semver/src'), 11 | ); 12 | -------------------------------------------------------------------------------- /fixtures/check-requirements/fail-complete/index.php: -------------------------------------------------------------------------------- 1 | 7 | * Théo Fidry 8 | * 9 | * This source file is subject to the MIT license that is bundled 10 | * with this source code in the file LICENSE. 11 | */ 12 | 13 | throw new Exception('Should not be executed!'); 14 | -------------------------------------------------------------------------------- /fixtures/build/dir004/stub.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | echo 'Hello!'; 16 | __halt_compiler(); 17 | -------------------------------------------------------------------------------- /fixtures/configuration/dir000/src/Main.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace Acme; 16 | 17 | final class Main 18 | { 19 | } 20 | -------------------------------------------------------------------------------- /fixtures/configuration/dir001/src/Main.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace Acme; 16 | 17 | final class Main 18 | { 19 | } 20 | -------------------------------------------------------------------------------- /fixtures/configuration/dir002/src/Main.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace Acme; 16 | 17 | final class Main 18 | { 19 | } 20 | -------------------------------------------------------------------------------- /fixtures/configuration/dir003/src/Main.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace Acme; 16 | 17 | final class Main 18 | { 19 | } 20 | -------------------------------------------------------------------------------- /fixtures/configuration/dir004/src/Main.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace Acme; 16 | 17 | final class Main 18 | { 19 | } 20 | -------------------------------------------------------------------------------- /fixtures/Compactor/InvalidCompactor.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box\Compactor; 16 | 17 | class InvalidCompactor 18 | { 19 | } 20 | -------------------------------------------------------------------------------- /fixtures/build/dir011/scoper.inc.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | return [ 16 | 'whitelist' => ['Foo\back'], 17 | 'files-whitelist' => ['src/Y.php'], 18 | ]; 19 | -------------------------------------------------------------------------------- /fixtures/build/dir012/config/bundles.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | return [ 16 | Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], 17 | ]; 18 | -------------------------------------------------------------------------------- /fixtures/build/dir011/src/X.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | final class X 16 | { 17 | public static function salute(): void 18 | { 19 | echo 'World'; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /fixtures/build/dir011/src/Y.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | final class Y 16 | { 17 | public static function salute(): void 18 | { 19 | echo 'World'; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /fixtures/php-settings-checker/create-expected-output: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -Eeuox pipefail 4 | 5 | readonly OS=$(uname); 6 | readonly XDEBUG_VERSION=$(docker run -i --rm -w /opt/box box_php73_xdebug php -r "echo phpversion('xdebug');"); 7 | readonly CURRENT_DIR=$(dirname $0); 8 | readonly TEMPLATE_FILE="${CURRENT_DIR}/output-xdebug-enabled.tpl"; 9 | readonly DUMPED_FILE="${CURRENT_DIR}/output-xdebug-enabled"; 10 | 11 | sed "s/__XDEBUG_VERSION__/${XDEBUG_VERSION}/g" ${TEMPLATE_FILE} > ${DUMPED_FILE}; 12 | -------------------------------------------------------------------------------- /.requirement-checker/src/IsExtensionFulfilled.php: -------------------------------------------------------------------------------- 1 | requiredExtension = $requiredExtension; 11 | } 12 | public function __invoke() 13 | { 14 | return \extension_loaded($this->requiredExtension); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/NotInstantiable.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box; 16 | 17 | /** 18 | * @private 19 | */ 20 | trait NotInstantiable 21 | { 22 | private function __construct() 23 | { 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /fixtures/build/dir011/index.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | use function Foo\back; 16 | 17 | require __DIR__.'/vendor/autoload.php'; 18 | 19 | salute(); 20 | echo ' '; 21 | X::salute(); 22 | back(); 23 | echo \PHP_EOL; 24 | -------------------------------------------------------------------------------- /fixtures/build/dir013/bin/run: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | use Isolated\Symfony\Component\Finder\Finder; 16 | 17 | return [ 18 | 'finders' => [ 19 | Finder::create()->files()->in(__DIR__), 20 | ], 21 | ]; 22 | -------------------------------------------------------------------------------- /requirement-checker/src/IsFulfilled.php: -------------------------------------------------------------------------------- 1 | 7 | * Théo Fidry 8 | * 9 | * This source file is subject to the MIT license that is bundled 10 | * with this source code in the file LICENSE. 11 | */ 12 | 13 | namespace KevinGH\RequirementChecker; 14 | 15 | /** 16 | * @private 17 | */ 18 | interface IsFulfilled 19 | { 20 | /** 21 | * @return bool 22 | */ 23 | public function __invoke(); 24 | } 25 | -------------------------------------------------------------------------------- /.requirement-checker/vendor/composer/semver/src/Constraint/ConstraintInterface.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | if (file_exists(dirname(__DIR__).'/var/cache/prod/App_KernelProdContainer.preload.php')) { 16 | require dirname(__DIR__).'/var/cache/prod/App_KernelProdContainer.preload.php'; 17 | } 18 | -------------------------------------------------------------------------------- /fixtures/build/dir010/scoper-fixed-prefix.inc.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | use Isolated\Symfony\Component\Finder\Finder; 16 | 17 | return [ 18 | 'prefix' => 'Acme', 19 | 'finders' => [ 20 | Finder::create()->files()->in(__DIR__), 21 | ], 22 | ]; 23 | -------------------------------------------------------------------------------- /fixtures/check-requirements/pass-no-config/expected-output-53-dist: -------------------------------------------------------------------------------- 1 | 2 | Box Requirements Checker 3 | ======================== 4 | 5 | > Using PHP PHP_VERSION 6 | > PHP is using the following php.ini file: 7 | WARNING: No configuration file (php.ini) used by PHP! 8 | 9 | > No requirements found. 10 | 11 | 12 | [OK] Your system is ready to run the application. 13 | 14 | 15 | Success! 16 | -------------------------------------------------------------------------------- /fixtures/check-requirements/pass-no-config/expected-output-73-dist: -------------------------------------------------------------------------------- 1 | 2 | Box Requirements Checker 3 | ======================== 4 | 5 | > Using PHP PHP_VERSION 6 | > PHP is using the following php.ini file: 7 | WARNING: No configuration file (php.ini) used by PHP! 8 | 9 | > No requirements found. 10 | 11 | 12 | [OK] Your system is ready to run the application. 13 | 14 | 15 | Success! 16 | -------------------------------------------------------------------------------- /src/Annotation/MalformedTagException.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box\Annotation; 16 | 17 | use UnexpectedValueException; 18 | 19 | /** 20 | * @private 21 | */ 22 | final class MalformedTagException extends UnexpectedValueException 23 | { 24 | } 25 | -------------------------------------------------------------------------------- /tests/bootstrap.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | use function KevinGH\Box\register_aliases; 16 | use Opis\Closure\ClosureStream; 17 | use org\bovigo\vfs\vfsStreamWrapper; 18 | 19 | register_aliases(); 20 | 21 | vfsStreamWrapper::register(); 22 | ClosureStream::register(); 23 | -------------------------------------------------------------------------------- /.docker/build: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euf -o pipefail 4 | 5 | readonly DOCKER=$(which docker) 6 | 7 | # Globals 8 | # PWD 9 | 10 | if [[ "$(docker images -q box_php53 2> /dev/null)" == "" ]]; then 11 | $DOCKER build -t box_php53 -f "$PWD/.docker/php53" . 12 | fi 13 | 14 | if [[ "$(docker images -q box_php73 2> /dev/null)" == "" ]]; then 15 | $DOCKER build -t box_php73 -f "$PWD/.docker/php73" . 16 | fi 17 | 18 | if [[ "$(docker images -q box_php73_xdebug 2> /dev/null)" == "" ]]; then 19 | $DOCKER build -t box_php73_xdebug -f "$PWD/.docker/php73_xdebug" . 20 | fi 21 | -------------------------------------------------------------------------------- /fixtures/build/dir011/src/functions.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace { 16 | function salute(): void 17 | { 18 | echo 'Hello'; 19 | } 20 | } 21 | 22 | namespace Foo { 23 | function back(): void 24 | { 25 | echo '!'; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /bin/generate_default_stub: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | 8 | * Théo Fidry 9 | * 10 | * This source file is subject to the MIT license that is bundled 11 | * with this source code in the file LICENSE. 12 | */ 13 | 14 | declare(strict_types=1); 15 | 16 | $phar = new Phar('tmp.phar'); 17 | $phar->setDefaultStub(); 18 | 19 | file_put_contents( 20 | __DIR__.'/../fixtures/default_stub.php', 21 | $phar->getStub() 22 | ); 23 | 24 | unlink('tmp.phar'); 25 | -------------------------------------------------------------------------------- /fixtures/php-settings-checker/output-pharreadonly-enabled: -------------------------------------------------------------------------------- 1 | [debug] Current memory limit: "-1" 2 | [debug] Checking BOX_ALLOW_XDEBUG 3 | [debug] phar.readonly is enabled 4 | [debug] The xdebug extension is not loaded 5 | [debug] Configured `phar.readonly=0` 6 | [debug] Process restarting (BOX_ALLOW_XDEBUG=internal||1|*|*) 7 | [debug] Running /usr/local/bin/php ./box compile --working-dir=fixtures/php-settings-checker -vvv --no-ansi 8 | [debug] Current memory limit: "-1" 9 | [debug] Checking BOX_ALLOW_XDEBUG 10 | [debug] Restarted (100 ms). The xdebug extension is not loaded 11 | [debug] Restarted process exited 0 12 | -------------------------------------------------------------------------------- /fixtures/php-settings-checker/output-xdebug-enabled.tpl: -------------------------------------------------------------------------------- 1 | [debug] Current memory limit: "-1" 2 | [debug] Checking BOX_ALLOW_XDEBUG 3 | [debug] phar.readonly is disabled 4 | [debug] The xdebug extension is loaded (__XDEBUG_VERSION__) mode=develop 5 | [debug] Process restarting (BOX_ALLOW_XDEBUG=internal|__XDEBUG_VERSION__|1|*|*) 6 | [debug] Running /usr/local/bin/php ./box compile --working-dir=fixtures/php-settings-checker -vvv --no-ansi 7 | [debug] Current memory limit: "-1" 8 | [debug] Checking BOX_ALLOW_XDEBUG 9 | [debug] Restarted (100 ms). The xdebug extension is not loaded 10 | [debug] Restarted process exited 0 11 | -------------------------------------------------------------------------------- /.requirement-checker/bin/check-requirements.php: -------------------------------------------------------------------------------- 1 | 4 | class Box < Formula 5 | desc "📦🚀 Fast, zero config application bundler with PHARs." 6 | homepage "$REPO_WEBITE" 7 | url "$STABLE_ASSET_URL" 8 | sha256 "$STABLE_ASSET_SHA256" 9 | version "$STABLE_VERSION" 10 | 11 | depends_on "php" if MacOS.version <= :el_capitan 12 | 13 | def install 14 | bin.install "box.phar" => "box" 15 | end 16 | 17 | test do 18 | shell_output("#{bin}/box --version").include?(version) 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /fixtures/composer-dump/dir002/vendor/beberlei/assert/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011-2013, Benjamin Eberlei 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | - Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | - Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | -------------------------------------------------------------------------------- /fixtures/configuration/dir001/vendor/beberlei/assert/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011-2013, Benjamin Eberlei 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | - Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | - Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | -------------------------------------------------------------------------------- /fixtures/configuration/dir002/vendor/beberlei/assert/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011-2013, Benjamin Eberlei 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | - Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | - Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | -------------------------------------------------------------------------------- /fixtures/configuration/dir003/vendor/beberlei/assert/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011-2013, Benjamin Eberlei 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | - Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | - Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | -------------------------------------------------------------------------------- /fixtures/configuration/dir004/vendor/beberlei/assert/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011-2013, Benjamin Eberlei 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | - Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | - Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | -------------------------------------------------------------------------------- /fixtures/build/dir012/config/packages/framework.yaml: -------------------------------------------------------------------------------- 1 | # see https://symfony.com/doc/current/reference/configuration/framework.html 2 | framework: 3 | secret: '%env(APP_SECRET)%' 4 | #csrf_protection: true 5 | #http_method_override: true 6 | 7 | # Enables session support. Note that the session will ONLY be started if you read or write from it. 8 | # Remove or comment this section to explicitly disable session support. 9 | session: 10 | handler_id: null 11 | cookie_secure: auto 12 | cookie_samesite: lax 13 | 14 | #esi: true 15 | #fragments: true 16 | php_errors: 17 | log: true 18 | -------------------------------------------------------------------------------- /fixtures/Compactor/DummyCompactor.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box\Compactor; 16 | 17 | class DummyCompactor implements Compactor 18 | { 19 | /** 20 | * {@inheritdoc} 21 | */ 22 | public function compact(string $file, string $contents): string 23 | { 24 | return $contents; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /fixtures/build/dir013/composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", 5 | "This file is @generated automatically" 6 | ], 7 | "content-hash": "d751713988987e9331980363e24189ce", 8 | "packages": [], 9 | "packages-dev": [], 10 | "aliases": [], 11 | "minimum-stability": "stable", 12 | "stability-flags": [], 13 | "prefer-stable": false, 14 | "prefer-lowest": false, 15 | "platform": [], 16 | "platform-dev": [], 17 | "plugin-api-version": "2.0.0" 18 | } 19 | -------------------------------------------------------------------------------- /src/consts.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box; 16 | 17 | // Public constants pointing to environment variable names 18 | const BOX_MEMORY_LIMIT = 'BOX_MEMORY_LIMIT'; 19 | const BOX_ALLOW_XDEBUG = 'BOX_ALLOW_XDEBUG'; 20 | 21 | /** 22 | * @internal 23 | * 24 | * @private 25 | */ 26 | const _NO_PARALLEL_PROCESSING = '_BOX_NO_PARALLEL_PROCESSING'; 27 | -------------------------------------------------------------------------------- /.requirement-checker/src/IsPhpVersionFulfilled.php: -------------------------------------------------------------------------------- 1 | requiredPhpVersion = $requiredPhpVersion; 12 | } 13 | public function __invoke() 14 | { 15 | return \HumbugBox3100\Composer\Semver\Semver::satisfies(\sprintf('%d.%d.%d', \PHP_MAJOR_VERSION, \PHP_MINOR_VERSION, \PHP_RELEASE_VERSION), $this->requiredPhpVersion); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /fixtures/check-requirements/pass-complete/expected-output-53-dist: -------------------------------------------------------------------------------- 1 | 2 | Box Requirements Checker 3 | ======================== 4 | 5 | > Using PHP PHP_VERSION 6 | > PHP is using the following php.ini file: 7 | WARNING: No configuration file (php.ini) used by PHP! 8 | 9 | > Checking Box requirements: 10 | ✔ The application requires the version ">=5.3" or greater. 11 | ✔ The application requires the extension "phar". 12 | 13 | 14 | [OK] Your system is ready to run the application. 15 | 16 | 17 | Success! 18 | -------------------------------------------------------------------------------- /fixtures/check-requirements/pass-complete/expected-output-73-dist: -------------------------------------------------------------------------------- 1 | 2 | Box Requirements Checker 3 | ======================== 4 | 5 | > Using PHP PHP_VERSION 6 | > PHP is using the following php.ini file: 7 | WARNING: No configuration file (php.ini) used by PHP! 8 | 9 | > Checking Box requirements: 10 | ✔ The application requires the version ">=5.3" or greater. 11 | ✔ The application requires the extension "phar". 12 | 13 | 14 | [OK] Your system is ready to run the application. 15 | 16 | 17 | Success! 18 | -------------------------------------------------------------------------------- /fixtures/Console/Command/TestConfigurableCommand.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box\Console\Command; 16 | 17 | use KevinGH\Box\Console\IO\IO; 18 | 19 | class TestConfigurableCommand extends ConfigurableBaseCommand 20 | { 21 | /** 22 | * {@inheritdoc} 23 | */ 24 | protected function executeCommand(IO $io): int 25 | { 26 | return 0; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /fixtures/composer-dump/dir002/vendor/beberlei/assert/lib/Assert/AssertionFailedException.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box\PhpScoper; 16 | 17 | use Humbug\PhpScoper\Scoper; 18 | use Humbug\PhpScoper\Whitelist; 19 | 20 | class DummyScoper implements Scoper 21 | { 22 | public function scope(string $filePath, string $contents, string $prefix, array $patchers, Whitelist $whitelist): string 23 | { 24 | return 'dummy'; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /box.json.dist: -------------------------------------------------------------------------------- 1 | { 2 | "banner": [ 3 | "This file is part of the box project.", 4 | "", 5 | "(c) Kevin Herrera ", 6 | "Théo Fidry ", 7 | "", 8 | "This source file is subject to the MIT license that is bundled", 9 | "with this source code in the file LICENSE." 10 | ], 11 | 12 | "files": [ 13 | "res/schema.json" 14 | ], 15 | "directories-bin": [".requirement-checker"], 16 | 17 | "compression": "GZ", 18 | "compactors": [ 19 | "KevinGH\\Box\\Compactor\\Php", 20 | "KevinGH\\Box\\Compactor\\PhpScoper", 21 | "KevinGH\\Box\\Compactor\\Json" 22 | ], 23 | "datetime": "release-date" 24 | } 25 | -------------------------------------------------------------------------------- /fixtures/Verifier/DummyPublicKey.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box\Verifier; 16 | 17 | class DummyPublicKey extends PublicKey 18 | { 19 | /** 20 | * {@inheritdoc} 21 | */ 22 | public function verify(string $signature): bool 23 | { 24 | return true; 25 | } 26 | 27 | public function getExposedKey(): string 28 | { 29 | return $this->getKey(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /fixtures/Compactor/FakeCompactor.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box\Compactor; 16 | 17 | use function func_get_args; 18 | use KevinGH\Box\NotCallable; 19 | 20 | class FakeCompactor implements Compactor 21 | { 22 | use NotCallable; 23 | 24 | /** 25 | * {@inheritdoc} 26 | */ 27 | public function compact(string $file, string $contents): string 28 | { 29 | $this->__call(__METHOD__, func_get_args()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /fixtures/build/dir012/config/packages/cache.yaml: -------------------------------------------------------------------------------- 1 | framework: 2 | cache: 3 | # Unique name of your app: used to compute stable namespaces for cache keys. 4 | #prefix_seed: your_vendor_name/app_name 5 | 6 | # The "app" cache stores to the filesystem by default. 7 | # The data in this cache should persist between deploys. 8 | # Other options include: 9 | 10 | # Redis 11 | #app: cache.adapter.redis 12 | #default_redis_provider: redis://localhost 13 | 14 | # APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues) 15 | #app: cache.adapter.apcu 16 | 17 | # Namespaced pools use the above "app" backend by default 18 | #pools: 19 | #my.dedicated.cache: null 20 | -------------------------------------------------------------------------------- /requirement-checker/phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | tests/ 15 | 16 | 17 | 18 | 19 | 20 | src/ 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /fixtures/NotCallable.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box; 16 | 17 | use DomainException; 18 | use function sprintf; 19 | 20 | // TODO: move this to throw unsupported method exception instead 21 | trait NotCallable 22 | { 23 | public function __call($method, $arguments): void 24 | { 25 | throw new DomainException( 26 | sprintf( 27 | 'Did not expect "%s" to be called.', 28 | $method 29 | ) 30 | ); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Configuration/NoConfigurationFound.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box\Configuration; 16 | 17 | use RuntimeException; 18 | use Throwable; 19 | 20 | /** 21 | * @private 22 | */ 23 | final class NoConfigurationFound extends RuntimeException 24 | { 25 | /** 26 | * {@inheritdoc} 27 | */ 28 | public function __construct(string $message = 'The configuration file could not be found.', int $code = 0, ?Throwable $previous = null) 29 | { 30 | parent::__construct($message, $code, $previous); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /tests/Console/Command/CommandTester.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box\Console\Command; 16 | 17 | use Symfony\Component\Console\Tester\CommandTester as SymfonyCommandTester; 18 | 19 | class CommandTester extends SymfonyCommandTester 20 | { 21 | /** 22 | * {@inheritdoc} 23 | */ 24 | public function execute(array $input, array $options = []): int 25 | { 26 | if ('compile' === $input['command']) { 27 | $input['--no-parallel'] = null; 28 | } 29 | 30 | return parent::execute($input, $options); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /fixtures/verify/openssl-signed/php-scoper.phar.pubkey: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAxKi/ABhiCMn7hqH9/W0x 3 | v2WKZDtUTDoSFRMl3WMBRL0wEmwvEajOJkzgAZLLomg6DCGrH7dSgZXBaxWyq1yY 4 | efw1qj9HcFlRs82Y8OfzdDRGDbRobERXH+sulukN0Su7jADOJHyILlQgc64Zql2J 5 | +BXQbBXJGIeoVk3I1hKg6GALpoA5kfFMw3l8FztKiRFcBMSRdeFQJlcsB/FCXnfN 6 | LJMnaB2LJnnV6eTj4xD3dXrKky8KxBKMxrryxNFcXqMMfL5gBdaU6CH4VUn5yPDs 7 | R/1KBsCgTmnFY6QmRlp+kI1ogmS5Eqk66xs5WBmuCHeB+phP7CFwvfF4kFGIGITl 8 | 5nKMJ7GJWG9CFEbPlZAcfgK3e12NyHuX+XUoc94IxbfzvcWxC/ZiuFSOAbTG95ut 9 | Ue51KkeIxq0GmW8djFySSJM4PZbPHtr7b2LhkJzjQ66dXWyTJjqxZRskmKQota6o 10 | qe8YWALClKLaG+LYM7ZFC4Q6fb4gs1x05feucbmuiWboeJyfL/CmoafnB6MqYXxX 11 | DXXJhMWYbrTZuawNXUe/WhEQIdiGJsoI61y7DgvKw6ExdnelIakAO9EOfkffY5wE 12 | KVZf+2kuEqm5UPvKmwozp/g/WmMAEEn6OJbHxeqKX7Ds/eLFiE2WlZm1YO3/JNbF 13 | HshwDz0FnMzwQom3CiykuOsCAwEAAQ== 14 | -----END PUBLIC KEY----- 15 | -------------------------------------------------------------------------------- /fixtures/PhpScoper/FakePhpScoper.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box\PhpScoper; 16 | 17 | use function func_get_args; 18 | use Humbug\PhpScoper\Scoper; 19 | use Humbug\PhpScoper\Whitelist; 20 | use KevinGH\Box\NotCallable; 21 | 22 | final class FakePhpScoper implements Scoper 23 | { 24 | use NotCallable; 25 | 26 | /** 27 | * {@inheritdoc} 28 | */ 29 | public function scope(string $filePath, string $contents, string $prefix, array $patchers, Whitelist $whitelist): string 30 | { 31 | $this->__call(__METHOD__, func_get_args()); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /requirement-checker/bin/check-requirements.php: -------------------------------------------------------------------------------- 1 | 7 | * Théo Fidry 8 | * 9 | * This source file is subject to the MIT license that is bundled 10 | * with this source code in the file LICENSE. 11 | */ 12 | 13 | namespace KevinGH\RequirementChecker; 14 | 15 | require __DIR__.'/../vendor/autoload.php'; 16 | 17 | if (false === in_array(PHP_SAPI, array('cli', 'phpdbg', 'embed'), true)) { 18 | echo PHP_EOL.'The application may only be invoked from a command line, got "'.PHP_SAPI.'"'.PHP_EOL; 19 | 20 | exit(1); 21 | } 22 | 23 | if (( 24 | false === isset($_SERVER['BOX_REQUIREMENT_CHECKER']) 25 | || true === (bool) $_SERVER['BOX_REQUIREMENT_CHECKER'] 26 | ) 27 | && false === Checker::checkRequirements() 28 | ) { 29 | exit(1); 30 | } 31 | -------------------------------------------------------------------------------- /src/Test/RequiresPharReadonlyOff.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box\Test; 16 | 17 | use function ini_get; 18 | 19 | /** 20 | * @private 21 | */ 22 | trait RequiresPharReadonlyOff 23 | { 24 | private function markAsSkippedIfPharReadonlyIsOn(): void 25 | { 26 | if (true === (bool) ini_get('phar.readonly')) { 27 | $this->markTestSkipped( 28 | 'Requires phar.readonly to be set to 0. Either update your php.ini file or run this test with ' 29 | .'php -d phar.readonly=0.' 30 | ); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /tests/Console/DisplayNormalizer.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box\Console; 16 | 17 | use function array_map; 18 | use function explode; 19 | use function implode; 20 | 21 | final class DisplayNormalizer 22 | { 23 | public static function removeTrailingSpaces(string $display): string 24 | { 25 | $lines = explode("\n", $display); 26 | 27 | $lines = array_map( 28 | 'rtrim', 29 | $lines 30 | ); 31 | 32 | return implode("\n", $lines); 33 | } 34 | 35 | private function __construct() 36 | { 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /fixtures/verify/openssl-signed-with-corrupted-pubkey/php-scoper.phar.pubkey: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAxKi/ABhiCMn7hqH9/W0x 3 | v2WKZDtUTDoSFRMl3WMBRL0wEmwvEajOJkzgAZLLomg6DCGrH7dSgZXBaxWyq1yY 4 | efw1qj9HcFlRs82Y8OfzdDRGDbRobERXH+sulukN0Su7jADOJHyILlQgc64Zql2J 5 | +BXQbBXJGIeoVk3I1hKg6GALpoA5kfFMw3l8FztKiRFcBMSRdeFQJlcsB/FCXnfN 6 | LJMnaB2LJnnV6eTj4xD3dXrKky8KxBKMxrryxNFcXqMMfL5gBdaU6CH4VUn5yPDs 7 | R/1KBsCgTmnFY6QmRlp+kI1ogmS5Eqk66xs5WBmuCHeB+phP7CFwvfF4kFGIGITl 8 | 5nKMJ7GJWG9CFEbPlZAcfgK3e12NyHuX+XUoc94IxbfzvcWxC/ZiuFSOAbTG95ut 9 | Ue51KkeIxq0GmW8djFySSJM4PZbPHtr7b2LhkJzjQ66dXWyTJjqxZRskmKQota6o 10 | qe8YWALClKLaG+LYM7ZFC4Q6fb4gs1x05feucbmuiWboeJyfL/CmoafnB6MqYXxX 11 | DXXJhMWYbrTZuawNXUe/WhEQIdiGJsoI61y7DgvKw6ExdnelIakAO9EOfkffY5wE 12 | KVZf+2kuEqm5UPvKmwozp/g/WmMAEEn6OJbHxeqKX7Ds/eLFiE2WlZm1YO3/JNbF 13 | HshwDz0FnMzwQom3CiykuOsCAwEAAE== 14 | -----END PUBLIC KEY----- 15 | -------------------------------------------------------------------------------- /requirement-checker/src/IsExtensionFulfilled.php: -------------------------------------------------------------------------------- 1 | 7 | * Théo Fidry 8 | * 9 | * This source file is subject to the MIT license that is bundled 10 | * with this source code in the file LICENSE. 11 | */ 12 | 13 | namespace KevinGH\RequirementChecker; 14 | 15 | /** 16 | * @private 17 | */ 18 | final class IsExtensionFulfilled implements IsFulfilled 19 | { 20 | private $requiredExtension; 21 | 22 | /** 23 | * @param string $requiredExtension 24 | */ 25 | public function __construct($requiredExtension) 26 | { 27 | $this->requiredExtension = $requiredExtension; 28 | } 29 | 30 | /** 31 | * {@inheritdoc} 32 | */ 33 | public function __invoke() 34 | { 35 | return \extension_loaded($this->requiredExtension); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Compactor/Compactor.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box\Compactor; 16 | 17 | /** 18 | * A compactor is a class called to process a file contents before adding it to the PHAR. This make it possible to for 19 | * example strip down the file from useless phpdoc. 20 | * 21 | * @private 22 | */ 23 | interface Compactor 24 | { 25 | /** 26 | * Compacts the file contents. 27 | * 28 | * @param string $file The file name 29 | * @param string $contents The file contents 30 | * 31 | * @return string The compacted contents 32 | */ 33 | public function compact(string $file, string $contents): string; 34 | } 35 | -------------------------------------------------------------------------------- /fixtures/build/dir012/public/index.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | use App\Kernel; 16 | use Symfony\Component\Dotenv\Dotenv; 17 | use Symfony\Component\ErrorHandler\Debug; 18 | use Symfony\Component\HttpFoundation\Request; 19 | 20 | require dirname(__DIR__).'/vendor/autoload.php'; 21 | 22 | (new Dotenv())->bootEnv(dirname(__DIR__).'/.env'); 23 | 24 | if ($_SERVER['APP_DEBUG']) { 25 | umask(0000); 26 | 27 | Debug::enable(); 28 | } 29 | 30 | $kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']); 31 | $request = Request::createFromGlobals(); 32 | $response = $kernel->handle($request); 33 | $response->send(); 34 | $kernel->terminate($request, $response); 35 | -------------------------------------------------------------------------------- /fixtures/check-requirements/fail-complete/composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "packages": [ 3 | { 4 | "name": "package-with-extensions", 5 | "require": { 6 | "php": ">=5.3", 7 | "ext-json": "*", 8 | "ext-ldap": "*", 9 | "ext-random": "*" 10 | } 11 | }, 12 | { 13 | "name": "polyfill", 14 | "require-dev": { 15 | "symfony/polyfill-random": "*" 16 | } 17 | } 18 | ], 19 | "packages-dev": [ 20 | { 21 | "name": "dev-package", 22 | "require": { 23 | "php": "^7.2", 24 | "ext-gettext": "*" 25 | }, 26 | "require-dev": { 27 | "php": "^7.3", 28 | "ext-interbase": "*" 29 | } 30 | } 31 | ], 32 | "platform": { 33 | "php": "^10", 34 | "ext-phar": "*" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /fixtures/check-requirements/pass-complete/composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "packages": [ 3 | { 4 | "name": "package-with-polyfill", 5 | "require": { 6 | "php": ">=5.3", 7 | "ext-random": "*" 8 | }, 9 | "require-dev": { 10 | "ext-json": "*" 11 | } 12 | }, 13 | { 14 | "name": "symfony/polyfill-random", 15 | "require": { 16 | "php": ">=5.2" 17 | } 18 | } 19 | ], 20 | "packages-dev": [ 21 | { 22 | "name": "dev-package", 23 | "require": { 24 | "php": "^7.2", 25 | "ext-gettext": "*" 26 | }, 27 | "require-dev": { 28 | "php": "^7.3", 29 | "ext-interbase": "*" 30 | } 31 | } 32 | ], 33 | "platform": { 34 | "php": ">=5.3", 35 | "ext-phar": "*" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /fixtures/Compactor/DummyFileExtensionCompactor.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box\Compactor; 16 | 17 | use function func_get_args; 18 | use KevinGH\Box\NotCallable; 19 | 20 | class DummyFileExtensionCompactor extends FileExtensionCompactor 21 | { 22 | use NotCallable; 23 | 24 | /** 25 | * {@inheritdoc} 26 | */ 27 | protected function compactContent(string $contents): string 28 | { 29 | $this->__call(__METHOD__, func_get_args()); 30 | } 31 | 32 | /** 33 | * {@inheritdoc} 34 | */ 35 | protected function supports(string $file): bool 36 | { 37 | $this->__call(__METHOD__, func_get_args()); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /fixtures/build/dir012/.env: -------------------------------------------------------------------------------- 1 | # In all environments, the following files are loaded if they exist, 2 | # the latter taking precedence over the former: 3 | # 4 | # * .env contains default values for the environment variables needed by the app 5 | # * .env.local uncommitted file with local overrides 6 | # * .env.$APP_ENV committed environment-specific defaults 7 | # * .env.$APP_ENV.local uncommitted environment-specific overrides 8 | # 9 | # Real environment variables win over .env files. 10 | # 11 | # DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES. 12 | # 13 | # Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2). 14 | # https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration 15 | 16 | ###> symfony/framework-bundle ### 17 | APP_ENV=prod 18 | APP_DEBUG=0 19 | APP_SECRET=91b4670ae7b240ca6b97ed20f81c81f0 20 | ###< symfony/framework-bundle ### 21 | -------------------------------------------------------------------------------- /fixtures/PhpScoper/CallRecorderScoper.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box\PhpScoper; 16 | 17 | use function func_get_args; 18 | use Humbug\PhpScoper\Scoper; 19 | use Humbug\PhpScoper\Whitelist; 20 | 21 | final class CallRecorderScoper implements Scoper 22 | { 23 | private $calls = []; 24 | 25 | /** 26 | * {@inheritdoc} 27 | */ 28 | public function scope(string $filePath, string $contents, string $prefix, array $patchers, Whitelist $whitelist): string 29 | { 30 | $this->calls[] = func_get_args(); 31 | 32 | return $contents; 33 | } 34 | 35 | public function getCalls(): array 36 | { 37 | return $this->calls; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /fixtures/Verifier/DummyBufferedHash.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box\Verifier; 16 | 17 | use function func_get_args; 18 | use KevinGH\Box\NotCallable; 19 | 20 | final class DummyBufferedHash extends BufferedHash 21 | { 22 | use NotCallable; 23 | 24 | /** 25 | * {@inheritdoc} 26 | */ 27 | public function __construct(string $algorithm, string $path) 28 | { 29 | } 30 | 31 | /** 32 | * {@inheritdoc} 33 | */ 34 | public function verify(string $signature): bool 35 | { 36 | $this->__call(__METHOD__, func_get_args()); 37 | } 38 | 39 | public function getPublicBufferedData(): string 40 | { 41 | return $this->getBufferedData(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /fixtures/build/dir000/private.key: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | Proc-Type: 4,ENCRYPTED 3 | DEK-Info: DES-EDE3-CBC,3FF97F75E5A8F534 4 | 5 | TvEPC5L3OXjy4X5t6SRsW6J4Dfdgw0Mfjqwa4OOI88uk5L8SIezs4sHDYHba9GkG 6 | RKVnRhA5F+gEHrabsQiVJdWPdS8xKUgpkvHqoAT8Zl5sAy/3e/EKZ+Bd2pS/t5yQ 7 | aGGqliG4oWecx42QGL8rmyrbs2wnuBZmwQ6iIVIfYabwpiH+lcEmEoxomXjt9A3j 8 | Sh8IhaDzMLnVS8egk1QvvhFjyXyBIW5mLIue6cdEgINbxzRReNQgjlyHS8BJRLp9 9 | EvJcZDKJiNJt+VLncbfm4ZhbdKvSsbZbXC/Pqv06YNMY1+m9QwszHJexqjm7AyzB 10 | MkBFedcxcxqvSb8DaGgQfUkm9rAmbmu+l1Dncd72Cjjf8fIfuodUmKsdfYds3h+n 11 | Ss7K4YiiNp7u9pqJBMvUdtrVoSsNAo6i7uFa7JQTXec9sbFN1nezgq1FZmcfJYUZ 12 | rdpc2J1hbHTfUZWtLZebA72GU63Y9zkZzbP3SjFUSWniEEbzWbPy2sAycHrpagND 13 | itOQNHwZ2Me81MQQB55JOKblKkSha6cNo9nJjd8rpyo/lc/Iay9qlUyba7RO0V/t 14 | wm9ZeUZL+D2/JQH7zGyLxkKqcMC+CFrNYnVh0U4nk3ftZsM+jcyfl7ScVFTKmcRc 15 | ypcpLwfS6gyenTqiTiJx/Zca4xmRNA+Fy1EhkymxP3ku0kTU6qutT2tuYOjtz/rW 16 | k6oIhMcpsXFdB3N9iHT4qqElo3rVW/qLQaNIqxd8+JmE5GkHmF43PhK3HX1PCmRC 17 | TnvzVS0y1l8zCsRToUtv5rCBC+r8Q3gnvGGnT4jrsp98ithGIQCbbQ== 18 | -----END RSA PRIVATE KEY----- -------------------------------------------------------------------------------- /src/PhpScoper/Scoper.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box\PhpScoper; 16 | 17 | use Humbug\PhpScoper\Whitelist; 18 | 19 | interface Scoper 20 | { 21 | /** 22 | * Scope AKA. apply the given prefix to the file in the appropriate way. 23 | * 24 | * @param string $filePath File to scope 25 | * @param string $contents Contents of the file to scope 26 | * 27 | * @return string Contents of the file with the prefix applied 28 | */ 29 | public function scope(string $filePath, string $contents): string; 30 | 31 | public function changeWhitelist(Whitelist $whitelist): void; 32 | 33 | public function getWhitelist(): Whitelist; 34 | 35 | public function getPrefix(): string; 36 | } 37 | -------------------------------------------------------------------------------- /requirement-checker/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "humbug/requirement-checker", 3 | "description": "A tool to check the PHARs dependency requirements.", 4 | "keywords": ["phar"], 5 | "license": "MIT", 6 | "authors": [ 7 | { 8 | "name": "Théo Fidry", 9 | "email": "theo.fidry@gmail.com" 10 | } 11 | ], 12 | 13 | "bin": [ 14 | "bin/check-requirements.php" 15 | ], 16 | "autoload": { 17 | "psr-4": { 18 | "KevinGH\\RequirementChecker\\": "src" 19 | } 20 | }, 21 | "autoload-dev": { 22 | "psr-4": { 23 | "KevinGH\\RequirementChecker\\": "tests" 24 | } 25 | }, 26 | 27 | "require": { 28 | "php": ">=5.3", 29 | "ext-phar": "*", 30 | "composer/semver": "^3.2" 31 | }, 32 | "require-dev": { 33 | "phpunit/phpunit": "^9.0" 34 | }, 35 | 36 | "config": { 37 | "bin-dir": "bin", 38 | "platform-check": false, 39 | "sort-packages": true 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /.requirement-checker/src/Requirement.php: -------------------------------------------------------------------------------- 1 | checkIsFulfilled = $checkIsFulfilled; 14 | $this->testMessage = $testMessage; 15 | $this->helpText = $helpText; 16 | } 17 | public function isFulfilled() 18 | { 19 | if (null === $this->fulfilled) { 20 | $this->fulfilled = $this->checkIsFulfilled->__invoke(); 21 | } 22 | return (bool) $this->fulfilled; 23 | } 24 | public function getIsFullfilledChecker() 25 | { 26 | return $this->checkIsFulfilled; 27 | } 28 | public function getTestMessage() 29 | { 30 | return $this->testMessage; 31 | } 32 | public function getHelpText() 33 | { 34 | return $this->helpText; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Compactor/BaseCompactor.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box\Compactor; 16 | 17 | /** 18 | * Base compactor class providing a slightly simpler API to compact the content only if the file is supported. 19 | * 20 | * @private 21 | */ 22 | abstract class BaseCompactor implements Compactor 23 | { 24 | /** 25 | * {@inheritdoc} 26 | */ 27 | public function compact(string $file, string $contents): string 28 | { 29 | if ($this->supports($file)) { 30 | return $this->compactContent($contents); 31 | } 32 | 33 | return $contents; 34 | } 35 | 36 | abstract protected function compactContent(string $contents): string; 37 | 38 | abstract protected function supports(string $file): bool; 39 | } 40 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/Bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 🐛 Bug Report 3 | about: If something isn't working as expected 🤔. 4 | 5 | --- 6 | 7 | ## Bug report 8 | 9 | | Question | Answer 10 | | ------------| --------------- 11 | | Box version | x.y.z 12 | | PHP version | x.y.z 13 | | Platform with version | e.g. Ubuntu/Windows/MacOS 14 | | Github Repo | - 15 | 16 | 17 | 26 | 27 |
28 | box.json.dist 29 | 30 | ```json 31 | { 32 | 33 | } 34 | ``` 35 |
36 | 37 |
38 | Output 39 | 40 | ```bash 41 | $ command 42 | > output 43 | ``` 44 |
-------------------------------------------------------------------------------- /requirement-checker/src/IsPhpVersionFulfilled.php: -------------------------------------------------------------------------------- 1 | 7 | * Théo Fidry 8 | * 9 | * This source file is subject to the MIT license that is bundled 10 | * with this source code in the file LICENSE. 11 | */ 12 | 13 | namespace KevinGH\RequirementChecker; 14 | 15 | use Composer\Semver\Semver; 16 | 17 | /** 18 | * @private 19 | */ 20 | final class IsPhpVersionFulfilled implements IsFulfilled 21 | { 22 | private $requiredPhpVersion; 23 | 24 | /** 25 | * @param string $requiredPhpVersion 26 | */ 27 | public function __construct($requiredPhpVersion) 28 | { 29 | $this->requiredPhpVersion = $requiredPhpVersion; 30 | } 31 | 32 | /** 33 | * {@inheritdoc} 34 | */ 35 | public function __invoke() 36 | { 37 | return Semver::satisfies( 38 | sprintf('%d.%d.%d', \PHP_MAJOR_VERSION, \PHP_MINOR_VERSION, \PHP_RELEASE_VERSION), 39 | $this->requiredPhpVersion 40 | ); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Kevin Herrera 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished to do 8 | so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /src/Compactor/PhpScoper.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box\Compactor; 16 | 17 | use KevinGH\Box\PhpScoper\Scoper; 18 | use Throwable; 19 | 20 | /** 21 | * @private 22 | */ 23 | final class PhpScoper implements Compactor 24 | { 25 | private $scoper; 26 | 27 | public function __construct(Scoper $scoper) 28 | { 29 | $this->scoper = $scoper; 30 | } 31 | 32 | /** 33 | * {@inheritdoc} 34 | */ 35 | public function compact(string $file, string $contents): string 36 | { 37 | try { 38 | return $this->scoper->scope($file, $contents); 39 | } catch (Throwable $throwable) { 40 | return $contents; 41 | } 42 | } 43 | 44 | public function getScoper(): Scoper 45 | { 46 | return $this->scoper; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/Compactor/Placeholder.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box\Compactor; 16 | 17 | use function array_keys; 18 | use function str_replace; 19 | use Webmozart\Assert\Assert; 20 | 21 | final class Placeholder implements Compactor 22 | { 23 | private $placeholders; 24 | 25 | /** 26 | * @param scalar[] $placeholders 27 | */ 28 | public function __construct(array $placeholders) 29 | { 30 | Assert::allScalar($placeholders); 31 | 32 | $this->placeholders = $placeholders; 33 | } 34 | 35 | /** 36 | * {@inheritdoc} 37 | */ 38 | public function compact(string $file, string $contents): string 39 | { 40 | return str_replace( 41 | array_keys($this->placeholders), 42 | $this->placeholders, 43 | $contents 44 | ); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /.requirement-checker/vendor/composer/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) Nils Adermann, Jordi Boggiano 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is furnished 9 | to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | 22 | -------------------------------------------------------------------------------- /fixtures/configuration/dir001/vendor/composer/autoload_static.php: -------------------------------------------------------------------------------- 1 | __DIR__ . '/..' . '/beberlei/assert/lib/Assert/functions.php', 11 | ); 12 | 13 | public static $prefixLengthsPsr4 = array ( 14 | 'A' => 15 | array ( 16 | 'Assert\\' => 7, 17 | ), 18 | ); 19 | 20 | public static $prefixDirsPsr4 = array ( 21 | 'Assert\\' => 22 | array ( 23 | 0 => __DIR__ . '/..' . '/beberlei/assert/lib/Assert', 24 | ), 25 | ); 26 | 27 | public static function getInitializer(ClassLoader $loader) 28 | { 29 | return \Closure::bind(function () use ($loader) { 30 | $loader->prefixLengthsPsr4 = ComposerStaticInita6ed3ef384c35f1f833cf4888ff06f77::$prefixLengthsPsr4; 31 | $loader->prefixDirsPsr4 = ComposerStaticInita6ed3ef384c35f1f833cf4888ff06f77::$prefixDirsPsr4; 32 | 33 | }, null, ClassLoader::class); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /fixtures/configuration/dir003/vendor/composer/autoload_static.php: -------------------------------------------------------------------------------- 1 | __DIR__ . '/..' . '/beberlei/assert/lib/Assert/functions.php', 11 | ); 12 | 13 | public static $prefixLengthsPsr4 = array ( 14 | 'A' => 15 | array ( 16 | 'Assert\\' => 7, 17 | ), 18 | ); 19 | 20 | public static $prefixDirsPsr4 = array ( 21 | 'Assert\\' => 22 | array ( 23 | 0 => __DIR__ . '/..' . '/beberlei/assert/lib/Assert', 24 | ), 25 | ); 26 | 27 | public static function getInitializer(ClassLoader $loader) 28 | { 29 | return \Closure::bind(function () use ($loader) { 30 | $loader->prefixLengthsPsr4 = ComposerStaticInita6ed3ef384c35f1f833cf4888ff06f77::$prefixLengthsPsr4; 31 | $loader->prefixDirsPsr4 = ComposerStaticInita6ed3ef384c35f1f833cf4888ff06f77::$prefixDirsPsr4; 32 | 33 | }, null, ClassLoader::class); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /fixtures/configuration/dir004/vendor/composer/autoload_static.php: -------------------------------------------------------------------------------- 1 | __DIR__ . '/..' . '/beberlei/assert/lib/Assert/functions.php', 11 | ); 12 | 13 | public static $prefixLengthsPsr4 = array ( 14 | 'A' => 15 | array ( 16 | 'Assert\\' => 7, 17 | ), 18 | ); 19 | 20 | public static $prefixDirsPsr4 = array ( 21 | 'Assert\\' => 22 | array ( 23 | 0 => __DIR__ . '/..' . '/beberlei/assert/lib/Assert', 24 | ), 25 | ); 26 | 27 | public static function getInitializer(ClassLoader $loader) 28 | { 29 | return \Closure::bind(function () use ($loader) { 30 | $loader->prefixLengthsPsr4 = ComposerStaticInita6ed3ef384c35f1f833cf4888ff06f77::$prefixLengthsPsr4; 31 | $loader->prefixDirsPsr4 = ComposerStaticInita6ed3ef384c35f1f833cf4888ff06f77::$prefixDirsPsr4; 32 | 33 | }, null, ClassLoader::class); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Composer/ComposerFile.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box\Composer; 16 | 17 | use Webmozart\Assert\Assert; 18 | 19 | final class ComposerFile 20 | { 21 | private $path; 22 | private $contents; 23 | 24 | public static function createEmpty(): self 25 | { 26 | return new self(null, []); 27 | } 28 | 29 | public function __construct(?string $path, array $contents) 30 | { 31 | Assert::nullOrNotEmpty($path); 32 | 33 | if (null === $path) { 34 | Assert::same([], $contents); 35 | } 36 | 37 | $this->path = $path; 38 | $this->contents = $contents; 39 | } 40 | 41 | public function getPath(): ?string 42 | { 43 | return $this->path; 44 | } 45 | 46 | public function getDecodedContents(): array 47 | { 48 | return $this->contents; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/PhpScoper/NullScoper.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box\PhpScoper; 16 | 17 | use Humbug\PhpScoper\Whitelist; 18 | 19 | /** 20 | * @private 21 | */ 22 | final class NullScoper implements Scoper 23 | { 24 | /** 25 | * {@inheritdoc} 26 | */ 27 | public function scope(string $filePath, string $contents): string 28 | { 29 | return $contents; 30 | } 31 | 32 | /** 33 | * {@inheritdoc} 34 | */ 35 | public function changeWhitelist(Whitelist $whitelist): void 36 | { 37 | } 38 | 39 | /** 40 | * {@inheritdoc} 41 | */ 42 | public function getWhitelist(): Whitelist 43 | { 44 | return Whitelist::create(true, true, true); 45 | } 46 | 47 | /** 48 | * {@inheritdoc} 49 | */ 50 | public function getPrefix(): string 51 | { 52 | return ''; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /fixtures/configuration/dir001/vendor/composer/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) Nils Adermann, Jordi Boggiano 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is furnished 9 | to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | 22 | -------------------------------------------------------------------------------- /fixtures/configuration/dir003/vendor/composer/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) Nils Adermann, Jordi Boggiano 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is furnished 9 | to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | 22 | -------------------------------------------------------------------------------- /fixtures/configuration/dir004/vendor/composer/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) Nils Adermann, Jordi Boggiano 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is furnished 9 | to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | 22 | -------------------------------------------------------------------------------- /fixtures/configuration/dir003/vendor/beberlei/composer/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) Nils Adermann, Jordi Boggiano 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is furnished 9 | to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | 22 | -------------------------------------------------------------------------------- /fixtures/configuration/dir003/vendor/beberlei/composer/autoload_static.php: -------------------------------------------------------------------------------- 1 | __DIR__ . '/..' . '/beberlei/assert/lib/Assert/functions.php', 11 | ); 12 | 13 | public static $prefixLengthsPsr4 = array ( 14 | 'A' => 15 | array ( 16 | 'Assert\\' => 7, 17 | ), 18 | ); 19 | 20 | public static $prefixDirsPsr4 = array ( 21 | 'Assert\\' => 22 | array ( 23 | 0 => __DIR__ . '/..' . '/beberlei/assert/lib/Assert', 24 | ), 25 | ); 26 | 27 | public static function getInitializer(ClassLoader $loader) 28 | { 29 | return \Closure::bind(function () use ($loader) { 30 | $loader->prefixLengthsPsr4 = ComposerStaticInita6ed3ef384c35f1f833cf4888ff06f77::$prefixLengthsPsr4; 31 | $loader->prefixDirsPsr4 = ComposerStaticInita6ed3ef384c35f1f833cf4888ff06f77::$prefixDirsPsr4; 32 | 33 | }, null, ClassLoader::class); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /fixtures/configuration/dir004/vendor/beberlei/composer/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) Nils Adermann, Jordi Boggiano 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is furnished 9 | to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | 22 | -------------------------------------------------------------------------------- /fixtures/configuration/dir004/vendor/beberlei/composer/autoload_static.php: -------------------------------------------------------------------------------- 1 | __DIR__ . '/..' . '/beberlei/assert/lib/Assert/functions.php', 11 | ); 12 | 13 | public static $prefixLengthsPsr4 = array ( 14 | 'A' => 15 | array ( 16 | 'Assert\\' => 7, 17 | ), 18 | ); 19 | 20 | public static $prefixDirsPsr4 = array ( 21 | 'Assert\\' => 22 | array ( 23 | 0 => __DIR__ . '/..' . '/beberlei/assert/lib/Assert', 24 | ), 25 | ); 26 | 27 | public static function getInitializer(ClassLoader $loader) 28 | { 29 | return \Closure::bind(function () use ($loader) { 30 | $loader->prefixLengthsPsr4 = ComposerStaticInita6ed3ef384c35f1f833cf4888ff06f77::$prefixLengthsPsr4; 31 | $loader->prefixDirsPsr4 = ComposerStaticInita6ed3ef384c35f1f833cf4888ff06f77::$prefixDirsPsr4; 32 | 33 | }, null, ClassLoader::class); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Console/OutputFormatterConfigurator.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box\Console; 16 | 17 | use KevinGH\Box\NotInstantiable; 18 | use Symfony\Component\Console\Formatter\OutputFormatterStyle; 19 | use Symfony\Component\Console\Output\OutputInterface; 20 | 21 | /** 22 | * Utility to configure the output formatter styles. 23 | * 24 | * @private 25 | */ 26 | final class OutputFormatterConfigurator 27 | { 28 | use NotInstantiable; 29 | 30 | public static function configure(OutputInterface $output): void 31 | { 32 | $outputFormatter = $output->getFormatter(); 33 | 34 | $outputFormatter->setStyle( 35 | 'recommendation', 36 | new OutputFormatterStyle('black', 'yellow') 37 | ); 38 | $outputFormatter->setStyle( 39 | 'warning', 40 | new OutputFormatterStyle('white', 'red') 41 | ); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/Annotation/CompactedFormatter.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box\Annotation; 16 | 17 | use function array_map; 18 | use function explode; 19 | use function implode; 20 | use phpDocumentor\Reflection\DocBlock\Tag; 21 | use phpDocumentor\Reflection\DocBlock\Tags\Formatter; 22 | use phpDocumentor\Reflection\DocBlock\Tags\Generic; 23 | use function strpos; 24 | 25 | final class CompactedFormatter implements Formatter 26 | { 27 | public function format(Tag $tag): string 28 | { 29 | if (!$tag instanceof Generic) { 30 | return trim('@'.$tag->getName()); 31 | } 32 | 33 | $description = (string) $tag; 34 | 35 | if (0 !== strpos($description, '(')) { 36 | return trim('@'.$tag->getName()); 37 | } 38 | 39 | $description = implode('', array_map('trim', explode("\n", (string) $tag))); 40 | 41 | return trim('@'.$tag->getName().$description); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /tests/PhpUnitAnnotationsTest.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box; 16 | 17 | use function array_filter; 18 | use function chdir; 19 | use function explode; 20 | use const PHP_EOL; 21 | use PHPUnit\Framework\TestCase; 22 | use function shell_exec; 23 | use Symfony\Component\Process\Process; 24 | 25 | /** 26 | * @coversNothing 27 | */ 28 | class PhpUnitAnnotationsTest extends TestCase 29 | { 30 | /** 31 | * @runInSeparateProcess 32 | */ 33 | public function test_there_is_no_commented_phpunit_run_tests_in_separate_processes_annotations_commented(): void 34 | { 35 | chdir(__DIR__.'/..'); 36 | 37 | $output = shell_exec( 38 | Process::fromShellCommandline( 39 | 'grep -rlI "\/\/ \* @runTestsInSeparateProcesses" tests' 40 | )->getCommandLine() 41 | ); 42 | 43 | $files = array_filter(explode(PHP_EOL, (string) $output)); 44 | 45 | $this->assertSame([], $files); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/Compactor/Json.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box\Compactor; 16 | 17 | use function json_decode; 18 | use function json_encode; 19 | use const JSON_ERROR_NONE; 20 | use function json_last_error; 21 | 22 | /** 23 | * Compacts JSON files by re-encoding without pretty print. 24 | * 25 | * @private 26 | */ 27 | final class Json extends FileExtensionCompactor 28 | { 29 | /** 30 | * {@inheritdoc} 31 | */ 32 | public function __construct(array $extensions = ['json', 'lock']) 33 | { 34 | parent::__construct($extensions); 35 | } 36 | 37 | /** 38 | * {@inheritdoc} 39 | */ 40 | protected function compactContent(string $contents): string 41 | { 42 | // TODO: migrate this piece of code once on PHP 7.3 43 | $decodedContents = json_decode($contents, false); 44 | 45 | if (JSON_ERROR_NONE !== json_last_error()) { 46 | return $contents; 47 | } 48 | 49 | return json_encode($decodedContents); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /fixtures/PhpScoper/UnserializableScoper.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box\PhpScoper; 16 | 17 | use DomainException; 18 | use Humbug\PhpScoper\Scoper; 19 | use Humbug\PhpScoper\Whitelist; 20 | use KevinGH\Box\NotCallable; 21 | use Serializable; 22 | 23 | final class UnserializableScoper implements Scoper, Serializable 24 | { 25 | use NotCallable; 26 | 27 | /** 28 | * {@inheritdoc} 29 | */ 30 | public function scope(string $filePath, string $contents, string $prefix, array $patchers, Whitelist $whitelist): string 31 | { 32 | $this->__call(__METHOD__, func_get_args()); 33 | } 34 | 35 | /** 36 | * {@inheritdoc} 37 | */ 38 | public function serialize(): string 39 | { 40 | throw new DomainException('This class is not serializable'); 41 | } 42 | 43 | /** 44 | * {@inheritdoc} 45 | */ 46 | public function unserialize($serialized): void 47 | { 48 | throw new DomainException('This class is not serializable'); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /fixtures/PhpScoper/FakeScoper.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box\PhpScoper; 16 | 17 | use function func_get_args; 18 | use Humbug\PhpScoper\Whitelist; 19 | use KevinGH\Box\NotCallable; 20 | 21 | final class FakeScoper implements Scoper 22 | { 23 | use NotCallable; 24 | 25 | /** 26 | * {@inheritdoc} 27 | */ 28 | public function scope(string $filePath, string $contents): string 29 | { 30 | $this->__call(__METHOD__, func_get_args()); 31 | } 32 | 33 | /** 34 | * {@inheritdoc} 35 | */ 36 | public function changeWhitelist(Whitelist $whitelist): void 37 | { 38 | $this->__call(__METHOD__, func_get_args()); 39 | } 40 | 41 | /** 42 | * {@inheritdoc} 43 | */ 44 | public function getWhitelist(): Whitelist 45 | { 46 | $this->__call(__METHOD__, func_get_args()); 47 | } 48 | 49 | /** 50 | * {@inheritdoc} 51 | */ 52 | public function getPrefix(): string 53 | { 54 | $this->__call(__METHOD__, func_get_args()); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/Console/Command/Build.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box\Console\Command; 16 | 17 | use KevinGH\Box\Console\IO\IO; 18 | use Symfony\Component\Console\Input\InputInterface; 19 | use Symfony\Component\Console\Output\OutputInterface; 20 | 21 | /** 22 | * @deprecated 23 | * 24 | * @private 25 | * 26 | * TODO: make Compile final when Build is removed 27 | */ 28 | final class Build extends Compile 29 | { 30 | /** 31 | * {@inheritdoc} 32 | */ 33 | protected function configure(): void 34 | { 35 | parent::configure(); 36 | 37 | $this->setName('build'); 38 | $this->setDescription('Builds a new PHAR (deprecated, use "compile" instead)'); 39 | } 40 | 41 | /** 42 | * {@inheritdoc} 43 | */ 44 | public function run(InputInterface $input, OutputInterface $output): int 45 | { 46 | $io = new IO($input, $output); 47 | 48 | $io->warning('The command "build" is deprecated. Use "compile" instead.'); 49 | 50 | return parent::run($input, $output); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.box_dump 2 | /box 3 | /*.phar 4 | /*.phar.sig 5 | /box.json 6 | /bin/ 7 | !/bin/box 8 | !/bin/box.bat 9 | !/bin/generate_default_stub 10 | /dist/ 11 | /Dockerfile* 12 | /fixtures/default_stub.php 13 | /fixtures/**/*/vendor/ 14 | /fixtures/build/dir010/*.phar 15 | /fixtures/build/dir011/*.phar 16 | /fixtures/build/dir011/*output 17 | /fixtures/build/dir011/phar-Y.php 18 | /fixtures/build/dir012/bin/console.phar 19 | /fixtures/build/dir012/actual-output 20 | /fixtures/build/dir012/expected-output 21 | /fixtures/check-requirements/*/actual-output 22 | /fixtures/check-requirements/*/expected-output-* 23 | /fixtures/check-requirements/*/*.phar 24 | /fixtures/php-settings-checker/* 25 | !/fixtures/php-settings-checker/index.php 26 | !/fixtures/php-settings-checker/output-* 27 | /fixtures/php-settings-checker/output-xdebug-enabled 28 | !/fixtures/php-settings-checker/create-expected-output 29 | /.phpunit* 30 | /.requirement-checker/ 31 | /requirement-checker/bin/* 32 | !/requirement-checker/bin/check-requirments.php 33 | /requirement-checker/actual_terminal_diff 34 | /requirement-checker/.box/ 35 | /requirement-checker/tests/DisplayNormalizer.php 36 | /requirement-checker/vendor/ 37 | /requirement-checker/.phpunit* 38 | /vendor/ 39 | /vendor-bin/*/composer.lock 40 | /vendor-bin/*/vendor/ 41 | /.php_cs.cache 42 | /.phpcs-cache 43 | /.php-cs-fixer.cache 44 | /phpunit.xml 45 | /phpcs.xml 46 | -------------------------------------------------------------------------------- /fixtures/check-requirements/fail-complete/expected-output-53-dist: -------------------------------------------------------------------------------- 1 | 2 | Box Requirements Checker 3 | ======================== 4 | 5 | > Using PHP PHP_VERSION 6 | > PHP is using the following php.ini file: 7 | WARNING: No configuration file (php.ini) used by PHP! 8 | 9 | > Checking Box requirements: 10 | ✘ The application requires the version "^10" or greater. 11 | ✔ The application requires the extension "phar". 12 | ✔ The package "package-with-extensions" requires the extension "json". 13 | ✘ The package "package-with-extensions" requires the extension "ldap". Enable 14 | it or install a polyfill. 15 | ✘ The package "package-with-extensions" requires the extension "random". 16 | Enable it or install a polyfill. 17 | 18 | 19 | [ERROR] Your system is not ready to run the application. 20 | 21 | 22 | Fix the following mandatory requirements: 23 | ========================================= 24 | 25 | * The application requires the version "^10" or greater. 26 | * The package "package-with-extensions" requires the extension "ldap". Enable 27 | it or install a polyfill. 28 | * The package "package-with-extensions" requires the extension "random". Enable 29 | it or install a polyfill. 30 | 31 | -------------------------------------------------------------------------------- /fixtures/check-requirements/fail-complete/expected-output-73-dist: -------------------------------------------------------------------------------- 1 | 2 | Box Requirements Checker 3 | ======================== 4 | 5 | > Using PHP PHP_VERSION 6 | > PHP is using the following php.ini file: 7 | WARNING: No configuration file (php.ini) used by PHP! 8 | 9 | > Checking Box requirements: 10 | ✘ The application requires the version "^10" or greater. 11 | ✔ The application requires the extension "phar". 12 | ✔ The package "package-with-extensions" requires the extension "json". 13 | ✘ The package "package-with-extensions" requires the extension "ldap". Enable 14 | it or install a polyfill. 15 | ✘ The package "package-with-extensions" requires the extension "random". 16 | Enable it or install a polyfill. 17 | 18 | 19 | [ERROR] Your system is not ready to run the application. 20 | 21 | 22 | Fix the following mandatory requirements: 23 | ========================================= 24 | 25 | * The application requires the version "^10" or greater. 26 | * The package "package-with-extensions" requires the extension "ldap". Enable 27 | it or install a polyfill. 28 | * The package "package-with-extensions" requires the extension "random". Enable 29 | it or install a polyfill. 30 | 31 | -------------------------------------------------------------------------------- /bin/box: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | 10 | * Théo Fidry 11 | * 12 | * This source file is subject to the MIT license that is bundled 13 | * with this source code in the file LICENSE. 14 | */ 15 | 16 | namespace KevinGH\Box; 17 | 18 | use function file_exists; 19 | use function in_array; 20 | use KevinGH\Box\Console\Application; 21 | use const PHP_EOL; 22 | use const PHP_SAPI; 23 | use RuntimeException; 24 | 25 | if (false === in_array(PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) { 26 | echo PHP_EOL.'Box may only be invoked from a command line, got "'.PHP_SAPI.'"'.PHP_EOL; 27 | 28 | exit(1); 29 | } 30 | 31 | (static function (): void { 32 | if (file_exists($autoload = __DIR__.'/../../../autoload.php')) { 33 | // Is installed via Composer 34 | include_once $autoload; 35 | 36 | return; 37 | } 38 | 39 | if (file_exists($autoload = __DIR__.'/../vendor/autoload.php')) { 40 | // Is installed locally 41 | include_once $autoload; 42 | 43 | return; 44 | } 45 | 46 | throw new RuntimeException('Unable to find the Composer autoloader.'); 47 | })(); 48 | 49 | register_aliases(); 50 | register_error_handler(); 51 | 52 | $app = new Application(); 53 | $app->run(); 54 | -------------------------------------------------------------------------------- /src/Compactor/FileExtensionCompactor.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box\Compactor; 16 | 17 | use function in_array; 18 | use function pathinfo; 19 | use const PATHINFO_EXTENSION; 20 | use Webmozart\Assert\Assert; 21 | 22 | /** 23 | * An abstract compactor class that handles matching supported file by their types. 24 | * 25 | * @private 26 | */ 27 | abstract class FileExtensionCompactor extends BaseCompactor 28 | { 29 | private $extensions; 30 | 31 | /** 32 | * @param string[] $extensions the list of supported file extensions 33 | */ 34 | public function __construct(array $extensions) 35 | { 36 | Assert::allString($extensions); 37 | 38 | $this->extensions = $extensions; 39 | } 40 | 41 | /** 42 | * {@inheritdoc} 43 | */ 44 | protected function supports(string $file): bool 45 | { 46 | return in_array( 47 | pathinfo( 48 | $file, 49 | PATHINFO_EXTENSION 50 | ), 51 | $this->extensions, 52 | true 53 | ); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /.requirement-checker/vendor/composer/semver/src/Comparator.php: -------------------------------------------------------------------------------- 1 | ', $version2); 11 | } 12 | public static function greaterThanOrEqualTo($version1, $version2) 13 | { 14 | return self::compare($version1, '>=', $version2); 15 | } 16 | public static function lessThan($version1, $version2) 17 | { 18 | return self::compare($version1, '<', $version2); 19 | } 20 | public static function lessThanOrEqualTo($version1, $version2) 21 | { 22 | return self::compare($version1, '<=', $version2); 23 | } 24 | public static function equalTo($version1, $version2) 25 | { 26 | return self::compare($version1, '==', $version2); 27 | } 28 | public static function notEqualTo($version1, $version2) 29 | { 30 | return self::compare($version1, '!=', $version2); 31 | } 32 | public static function compare($version1, $operator, $version2) 33 | { 34 | $constraint = new \HumbugBox3100\Composer\Semver\Constraint\Constraint($operator, $version2); 35 | return $constraint->matchSpecific(new \HumbugBox3100\Composer\Semver\Constraint\Constraint('==', $version1), \true); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /fixtures/composer-dump/dir002/vendor/beberlei/assert/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "beberlei/assert", 3 | "description": "Thin assertion library for input validation in business models.", 4 | "authors": [ 5 | { 6 | "name": "Benjamin Eberlei", 7 | "email": "kontakt@beberlei.de", 8 | "role": "Lead Developer" 9 | }, 10 | { 11 | "name": "Richard Quadling", 12 | "email": "rquadling@gmail.com", 13 | "role": "Collaborator" 14 | } 15 | ], 16 | "license": "BSD-2-Clause", 17 | "keywords": [ 18 | "assert", 19 | "assertion", 20 | "validation" 21 | ], 22 | "config": { 23 | "sort-packages": true 24 | }, 25 | "require": { 26 | "php": ">=5.3", 27 | "ext-mbstring": "*" 28 | }, 29 | "require-dev": { 30 | "friendsofphp/php-cs-fixer": "^2.1.1", 31 | "phpunit/phpunit": "^4.8.35|^5.7" 32 | }, 33 | "autoload": { 34 | "psr-4": { 35 | "Assert\\": "lib/Assert" 36 | }, 37 | "files": [ 38 | "lib/Assert/functions.php" 39 | ] 40 | }, 41 | "autoload-dev": { 42 | "psr-4": { 43 | "Assert\\Tests\\": "tests/Assert/Tests" 44 | }, 45 | "files": [ 46 | "tests/Assert/Tests/Fixtures/functions.php" 47 | ] 48 | }, 49 | "scripts": { 50 | "assert:generate-docs": "php bin/generate_method_docs.php", 51 | "assert:cs-lint": "php-cs-fixer fix --diff -vvv --dry-run", 52 | "assert:cs-fix": "php-cs-fixer fix . -vvv || true" 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /fixtures/configuration/dir001/vendor/beberlei/assert/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "beberlei/assert", 3 | "description": "Thin assertion library for input validation in business models.", 4 | "authors": [ 5 | { 6 | "name": "Benjamin Eberlei", 7 | "email": "kontakt@beberlei.de", 8 | "role": "Lead Developer" 9 | }, 10 | { 11 | "name": "Richard Quadling", 12 | "email": "rquadling@gmail.com", 13 | "role": "Collaborator" 14 | } 15 | ], 16 | "license": "BSD-2-Clause", 17 | "keywords": [ 18 | "assert", 19 | "assertion", 20 | "validation" 21 | ], 22 | "config": { 23 | "sort-packages": true 24 | }, 25 | "require": { 26 | "php": ">=5.3", 27 | "ext-mbstring": "*" 28 | }, 29 | "require-dev": { 30 | "friendsofphp/php-cs-fixer": "^2.1.1", 31 | "phpunit/phpunit": "^4.8.35|^5.7" 32 | }, 33 | "autoload": { 34 | "psr-4": { 35 | "Assert\\": "lib/Assert" 36 | }, 37 | "files": [ 38 | "lib/Assert/functions.php" 39 | ] 40 | }, 41 | "autoload-dev": { 42 | "psr-4": { 43 | "Assert\\Tests\\": "tests/Assert/Tests" 44 | }, 45 | "files": [ 46 | "tests/Assert/Tests/Fixtures/functions.php" 47 | ] 48 | }, 49 | "scripts": { 50 | "assert:generate-docs": "php bin/generate_method_docs.php", 51 | "assert:cs-lint": "php-cs-fixer fix --diff -vvv --dry-run", 52 | "assert:cs-fix": "php-cs-fixer fix . -vvv || true" 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /fixtures/configuration/dir002/vendor/beberlei/assert/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "beberlei/assert", 3 | "description": "Thin assertion library for input validation in business models.", 4 | "authors": [ 5 | { 6 | "name": "Benjamin Eberlei", 7 | "email": "kontakt@beberlei.de", 8 | "role": "Lead Developer" 9 | }, 10 | { 11 | "name": "Richard Quadling", 12 | "email": "rquadling@gmail.com", 13 | "role": "Collaborator" 14 | } 15 | ], 16 | "license": "BSD-2-Clause", 17 | "keywords": [ 18 | "assert", 19 | "assertion", 20 | "validation" 21 | ], 22 | "config": { 23 | "sort-packages": true 24 | }, 25 | "require": { 26 | "php": ">=5.3", 27 | "ext-mbstring": "*" 28 | }, 29 | "require-dev": { 30 | "friendsofphp/php-cs-fixer": "^2.1.1", 31 | "phpunit/phpunit": "^4.8.35|^5.7" 32 | }, 33 | "autoload": { 34 | "psr-4": { 35 | "Assert\\": "lib/Assert" 36 | }, 37 | "files": [ 38 | "lib/Assert/functions.php" 39 | ] 40 | }, 41 | "autoload-dev": { 42 | "psr-4": { 43 | "Assert\\Tests\\": "tests/Assert/Tests" 44 | }, 45 | "files": [ 46 | "tests/Assert/Tests/Fixtures/functions.php" 47 | ] 48 | }, 49 | "scripts": { 50 | "assert:generate-docs": "php bin/generate_method_docs.php", 51 | "assert:cs-lint": "php-cs-fixer fix --diff -vvv --dry-run", 52 | "assert:cs-fix": "php-cs-fixer fix . -vvv || true" 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /fixtures/configuration/dir003/vendor/beberlei/assert/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "beberlei/assert", 3 | "description": "Thin assertion library for input validation in business models.", 4 | "authors": [ 5 | { 6 | "name": "Benjamin Eberlei", 7 | "email": "kontakt@beberlei.de", 8 | "role": "Lead Developer" 9 | }, 10 | { 11 | "name": "Richard Quadling", 12 | "email": "rquadling@gmail.com", 13 | "role": "Collaborator" 14 | } 15 | ], 16 | "license": "BSD-2-Clause", 17 | "keywords": [ 18 | "assert", 19 | "assertion", 20 | "validation" 21 | ], 22 | "config": { 23 | "sort-packages": true 24 | }, 25 | "require": { 26 | "php": ">=5.3", 27 | "ext-mbstring": "*" 28 | }, 29 | "require-dev": { 30 | "friendsofphp/php-cs-fixer": "^2.1.1", 31 | "phpunit/phpunit": "^4.8.35|^5.7" 32 | }, 33 | "autoload": { 34 | "psr-4": { 35 | "Assert\\": "lib/Assert" 36 | }, 37 | "files": [ 38 | "lib/Assert/functions.php" 39 | ] 40 | }, 41 | "autoload-dev": { 42 | "psr-4": { 43 | "Assert\\Tests\\": "tests/Assert/Tests" 44 | }, 45 | "files": [ 46 | "tests/Assert/Tests/Fixtures/functions.php" 47 | ] 48 | }, 49 | "scripts": { 50 | "assert:generate-docs": "php bin/generate_method_docs.php", 51 | "assert:cs-lint": "php-cs-fixer fix --diff -vvv --dry-run", 52 | "assert:cs-fix": "php-cs-fixer fix . -vvv || true" 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /fixtures/configuration/dir004/vendor/beberlei/assert/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "beberlei/assert", 3 | "description": "Thin assertion library for input validation in business models.", 4 | "authors": [ 5 | { 6 | "name": "Benjamin Eberlei", 7 | "email": "kontakt@beberlei.de", 8 | "role": "Lead Developer" 9 | }, 10 | { 11 | "name": "Richard Quadling", 12 | "email": "rquadling@gmail.com", 13 | "role": "Collaborator" 14 | } 15 | ], 16 | "license": "BSD-2-Clause", 17 | "keywords": [ 18 | "assert", 19 | "assertion", 20 | "validation" 21 | ], 22 | "config": { 23 | "sort-packages": true 24 | }, 25 | "require": { 26 | "php": ">=5.3", 27 | "ext-mbstring": "*" 28 | }, 29 | "require-dev": { 30 | "friendsofphp/php-cs-fixer": "^2.1.1", 31 | "phpunit/phpunit": "^4.8.35|^5.7" 32 | }, 33 | "autoload": { 34 | "psr-4": { 35 | "Assert\\": "lib/Assert" 36 | }, 37 | "files": [ 38 | "lib/Assert/functions.php" 39 | ] 40 | }, 41 | "autoload-dev": { 42 | "psr-4": { 43 | "Assert\\Tests\\": "tests/Assert/Tests" 44 | }, 45 | "files": [ 46 | "tests/Assert/Tests/Fixtures/functions.php" 47 | ] 48 | }, 49 | "scripts": { 50 | "assert:generate-docs": "php bin/generate_method_docs.php", 51 | "assert:cs-lint": "php-cs-fixer fix --diff -vvv --dry-run", 52 | "assert:cs-fix": "php-cs-fixer fix . -vvv || true" 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /.requirement-checker/src/RequirementCollection.php: -------------------------------------------------------------------------------- 1 | requirements); 15 | } 16 | public function count() 17 | { 18 | return \count($this->requirements); 19 | } 20 | public function add(\HumbugBox3100\KevinGH\RequirementChecker\Requirement $requirement) 21 | { 22 | $this->requirements[] = $requirement; 23 | } 24 | public function addRequirement($checkIsFulfilled, $testMessage, $helpText) 25 | { 26 | $this->add(new \HumbugBox3100\KevinGH\RequirementChecker\Requirement($checkIsFulfilled, $testMessage, $helpText)); 27 | } 28 | public function getRequirements() 29 | { 30 | return $this->requirements; 31 | } 32 | public function getPhpIniPath() 33 | { 34 | return \get_cfg_var('cfg_file_path'); 35 | } 36 | public function evaluateRequirements() 37 | { 38 | return \array_reduce($this->requirements, function ($checkPassed, \HumbugBox3100\KevinGH\RequirementChecker\Requirement $requirement) { 39 | return $checkPassed && $requirement->isFulfilled(); 40 | }, \true); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /fixtures/build/dir012/bin/console: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | getParameterOption(['--env', '-e'], null, true)) { 24 | putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env); 25 | } 26 | 27 | if ($input->hasParameterOption('--no-debug', true)) { 28 | putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0'); 29 | } 30 | 31 | (new Dotenv())->bootEnv(dirname(__DIR__).'/.env'); 32 | 33 | if ($_SERVER['APP_DEBUG']) { 34 | umask(0000); 35 | 36 | if (class_exists(Debug::class)) { 37 | Debug::enable(); 38 | } 39 | } 40 | 41 | $kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']); 42 | $application = new Application($kernel); 43 | $application->run($input); 44 | -------------------------------------------------------------------------------- /fixtures/build/dir012/config/services.yaml: -------------------------------------------------------------------------------- 1 | # This file is the entry point to configure your own services. 2 | # Files in the packages/ subdirectory configure your dependencies. 3 | 4 | # Put parameters here that don't need to change on each machine where the app is deployed 5 | # https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration 6 | parameters: 7 | 8 | services: 9 | # default configuration for services in *this* file 10 | _defaults: 11 | autowire: true # Automatically injects dependencies in your services. 12 | autoconfigure: true # Automatically registers your services as commands, event subscribers, etc. 13 | 14 | # makes classes in src/ available to be used as services 15 | # this creates a service per class whose id is the fully-qualified class name 16 | App\: 17 | resource: '../src/' 18 | exclude: 19 | - '../src/DependencyInjection/' 20 | - '../src/Entity/' 21 | - '../src/Kernel.php' 22 | - '../src/Tests/' 23 | 24 | # controllers are imported separately to make sure services can be injected 25 | # as action arguments even if you don't extend any base controller class 26 | App\Controller\: 27 | resource: '../src/Controller/' 28 | tags: ['controller.service_arguments'] 29 | 30 | # add more service definitions when explicit configuration is needed 31 | # please note that last definitions always *replace* previous ones 32 | -------------------------------------------------------------------------------- /psalm.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /fixtures/composer-dump/dir002/vendor/beberlei/assert/lib/Assert/LazyAssertionException.php: -------------------------------------------------------------------------------- 1 | getPropertyPath(), $error->getMessage()); 36 | } 37 | 38 | return new static($message, $errors); 39 | } 40 | 41 | public function __construct($message, array $errors) 42 | { 43 | parent::__construct($message, 0, null, null); 44 | 45 | $this->errors = $errors; 46 | } 47 | 48 | public function getErrorExceptions() 49 | { 50 | return $this->errors; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /fixtures/configuration/dir001/vendor/beberlei/assert/lib/Assert/LazyAssertionException.php: -------------------------------------------------------------------------------- 1 | getPropertyPath(), $error->getMessage()); 36 | } 37 | 38 | return new static($message, $errors); 39 | } 40 | 41 | public function __construct($message, array $errors) 42 | { 43 | parent::__construct($message, 0, null, null); 44 | 45 | $this->errors = $errors; 46 | } 47 | 48 | public function getErrorExceptions() 49 | { 50 | return $this->errors; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /fixtures/configuration/dir002/vendor/beberlei/assert/lib/Assert/LazyAssertionException.php: -------------------------------------------------------------------------------- 1 | getPropertyPath(), $error->getMessage()); 36 | } 37 | 38 | return new static($message, $errors); 39 | } 40 | 41 | public function __construct($message, array $errors) 42 | { 43 | parent::__construct($message, 0, null, null); 44 | 45 | $this->errors = $errors; 46 | } 47 | 48 | public function getErrorExceptions() 49 | { 50 | return $this->errors; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /fixtures/configuration/dir003/vendor/beberlei/assert/lib/Assert/LazyAssertionException.php: -------------------------------------------------------------------------------- 1 | getPropertyPath(), $error->getMessage()); 36 | } 37 | 38 | return new static($message, $errors); 39 | } 40 | 41 | public function __construct($message, array $errors) 42 | { 43 | parent::__construct($message, 0, null, null); 44 | 45 | $this->errors = $errors; 46 | } 47 | 48 | public function getErrorExceptions() 49 | { 50 | return $this->errors; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /fixtures/configuration/dir004/vendor/beberlei/assert/lib/Assert/LazyAssertionException.php: -------------------------------------------------------------------------------- 1 | getPropertyPath(), $error->getMessage()); 36 | } 37 | 38 | return new static($message, $errors); 39 | } 40 | 41 | public function __construct($message, array $errors) 42 | { 43 | parent::__construct($message, 0, null, null); 44 | 45 | $this->errors = $errors; 46 | } 47 | 48 | public function getErrorExceptions() 49 | { 50 | return $this->errors; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /tests/Configuration/NoConfigurationFoundTest.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box\Configuration; 16 | 17 | use Error; 18 | use PHPUnit\Framework\TestCase; 19 | 20 | /** 21 | * @covers \KevinGH\Box\Configuration\NoConfigurationFound 22 | */ 23 | class NoConfigurationFoundTest extends TestCase 24 | { 25 | public function test_it_can_be_created_with_a_default_error_message(): void 26 | { 27 | $exception = new NoConfigurationFound(); 28 | 29 | $this->assertSame( 30 | 'The configuration file could not be found.', 31 | $exception->getMessage() 32 | ); 33 | $this->assertSame(0, $exception->getCode()); 34 | $this->assertNull($exception->getPrevious()); 35 | } 36 | 37 | public function test_it_can_be_created_with_overridden_values(): void 38 | { 39 | $message = 'My message'; 40 | $code = 120; 41 | $error = new Error(); 42 | 43 | $exception = new NoConfigurationFound($message, $code, $error); 44 | 45 | $this->assertSame($message, $exception->getMessage()); 46 | $this->assertSame($code, $exception->getCode()); 47 | $this->assertSame($error, $exception->getPrevious()); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/Console/IO/IO.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box\Console\IO; 16 | 17 | use Symfony\Component\Console\Input\InputInterface; 18 | use Symfony\Component\Console\Input\StringInput; 19 | use Symfony\Component\Console\Output\NullOutput; 20 | use Symfony\Component\Console\Output\OutputInterface; 21 | use Symfony\Component\Console\Style\SymfonyStyle; 22 | 23 | final class IO extends SymfonyStyle 24 | { 25 | private $input; 26 | private $output; 27 | 28 | public static function createNull(): self 29 | { 30 | return new self( 31 | new StringInput(''), 32 | new NullOutput() 33 | ); 34 | } 35 | 36 | public function __construct(InputInterface $input, OutputInterface $output) 37 | { 38 | parent::__construct($input, $output); 39 | 40 | $this->input = $input; 41 | $this->output = $output; 42 | } 43 | 44 | public function getInput(): InputInterface 45 | { 46 | return $this->input; 47 | } 48 | 49 | public function isInteractive(): bool 50 | { 51 | return $this->input->isInteractive(); 52 | } 53 | 54 | public function getOutput(): OutputInterface 55 | { 56 | return $this->output; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/Json/JsonValidationException.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box\Json; 16 | 17 | use Throwable; 18 | use UnexpectedValueException; 19 | use Webmozart\Assert\Assert; 20 | 21 | /** 22 | * @private 23 | */ 24 | final class JsonValidationException extends UnexpectedValueException 25 | { 26 | private $validatedFile; 27 | private $errors; 28 | 29 | /** 30 | * {@inheritdoc} 31 | * 32 | * @param string[] $errors 33 | */ 34 | public function __construct( 35 | string $message, 36 | ?string $file = null, 37 | array $errors = [], 38 | int $code = 0, 39 | ?Throwable $previous = null 40 | ) { 41 | if (null !== $file) { 42 | Assert::file($file); 43 | } 44 | Assert::allString($errors); 45 | 46 | $this->validatedFile = $file; 47 | $this->errors = $errors; 48 | 49 | parent::__construct($message, $code, $previous); 50 | } 51 | 52 | public function getValidatedFile(): ?string 53 | { 54 | return $this->validatedFile; 55 | } 56 | 57 | /** 58 | * @return string[] 59 | */ 60 | public function getErrors(): array 61 | { 62 | return $this->errors; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/Console/Command/BaseCommand.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box\Console\Command; 16 | 17 | use KevinGH\Box\Console\Application; 18 | use KevinGH\Box\Console\ConfigurationHelper; 19 | use KevinGH\Box\Console\IO\IO; 20 | use KevinGH\Box\Console\OutputFormatterConfigurator; 21 | use Symfony\Component\Console\Command\Command as SymfonyCommand; 22 | use Symfony\Component\Console\Input\InputInterface; 23 | use Symfony\Component\Console\Output\OutputInterface; 24 | 25 | /** 26 | * Tiny Symfony Command adapter to allow the command to easily access to the typehinted helpers which are configured 27 | * in the application. 28 | * 29 | * @see Application 30 | */ 31 | abstract class BaseCommand extends SymfonyCommand 32 | { 33 | abstract protected function executeCommand(IO $io): int; 34 | 35 | /** 36 | * {@inheritdoc} 37 | */ 38 | protected function execute(InputInterface $input, OutputInterface $output): int 39 | { 40 | OutputFormatterConfigurator::configure($output); 41 | 42 | return $this->executeCommand(new IO($input, $output)); 43 | } 44 | 45 | final protected function getConfigurationHelper(): ConfigurationHelper 46 | { 47 | return $this->getHelper('config'); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /tests/PhpScoper/NullScoperTest.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box\PhpScoper; 16 | 17 | use Humbug\PhpScoper\Whitelist; 18 | use PHPUnit\Framework\TestCase; 19 | use function serialize; 20 | use function unserialize; 21 | 22 | /** 23 | * @covers \KevinGH\Box\PhpScoper\NullScoper 24 | */ 25 | class NullScoperTest extends TestCase 26 | { 27 | public function test_it_returns_the_content_of_the_file_unchanged(): void 28 | { 29 | $file = 'foo'; 30 | $contents = <<<'JSON' 31 | { 32 | "foo": "bar" 33 | 34 | } 35 | JSON; 36 | 37 | $actual = (new NullScoper())->scope($file, $contents); 38 | 39 | $this->assertSame($contents, $actual); 40 | } 41 | 42 | public function test_it_exposes_some_elements_of_the_scoping_config(): void 43 | { 44 | $scoper = new NullScoper(); 45 | 46 | $this->assertSame('', $scoper->getPrefix()); 47 | $this->assertEquals(Whitelist::create(true, true, true), $scoper->getWhitelist()); 48 | } 49 | 50 | public function test_it_is_serializable(): void 51 | { 52 | $scoper = new NullScoper(); 53 | 54 | $this->assertEquals( 55 | $scoper, 56 | unserialize(serialize($scoper)) 57 | ); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/Configuration/ConfigurationLogger.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box\Configuration; 16 | 17 | use function array_keys; 18 | use function trim; 19 | use Webmozart\Assert\Assert; 20 | 21 | /** 22 | * @private 23 | */ 24 | final class ConfigurationLogger 25 | { 26 | private $recommendations = []; 27 | private $warnings = []; 28 | 29 | public function addRecommendation(string $message): void 30 | { 31 | $message = trim($message); 32 | 33 | Assert::false('' === $message, 'Expected to have a message but a blank string was given instead.'); 34 | 35 | $this->recommendations[$message] = $message; 36 | } 37 | 38 | /** 39 | * @return string[] 40 | */ 41 | public function getRecommendations(): array 42 | { 43 | return array_keys($this->recommendations); 44 | } 45 | 46 | public function addWarning(string $message): void 47 | { 48 | $message = trim($message); 49 | 50 | Assert::false('' === $message, 'Expected to have a message but a blank string was given instead.'); 51 | 52 | $this->warnings[$message] = $message; 53 | } 54 | 55 | /** 56 | * @return string[] 57 | */ 58 | public function getWarnings(): array 59 | { 60 | return array_keys($this->warnings); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /phpcs.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | fixtures 14 | default_stub\.php 15 | src/Box\.php 16 | /vendor/ 17 | /build/ 18 | src 19 | tests 20 | 21 | 22 | 23 | 24 | 25 | src/bootstrap\.php 26 | src/functions\.php 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/PharInfo/Pharaoh.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box\PharInfo; 16 | 17 | use function basename; 18 | use function KevinGH\Box\FileSystem\remove; 19 | use ParagonIE\Pharaoh\Pharaoh as ParagoniePharaoh; 20 | 21 | final class Pharaoh extends ParagoniePharaoh 22 | { 23 | private $fileName; 24 | 25 | /** @var null|PharInfo */ 26 | private $pharInfo; 27 | 28 | /** @var null|string */ 29 | private $path; 30 | 31 | /** 32 | * {@inheritdoc} 33 | */ 34 | public function __construct(string $file, ?string $alias = null) 35 | { 36 | parent::__construct($file, $alias); 37 | 38 | $this->fileName = basename($file); 39 | } 40 | 41 | /** 42 | * {@inheritdoc} 43 | */ 44 | public function __destruct() 45 | { 46 | unset($this->pharInfo); 47 | 48 | parent::__destruct(); 49 | 50 | remove($this->tmp); 51 | } 52 | 53 | public function getFileName(): string 54 | { 55 | return $this->fileName; 56 | } 57 | 58 | public function getPharInfo(): PharInfo 59 | { 60 | if (null === $this->pharInfo || $this->path !== $this->phar->getPath()) { 61 | $this->path = $this->phar->getPath(); 62 | $this->pharInfo = new PharInfo($this->path); 63 | } 64 | 65 | return $this->pharInfo; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /requirement-checker/scoper.inc.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | function get_prefix(): string 16 | { 17 | $lastRelease = shell_exec('git describe --abbrev=0 --tags HEAD'); 18 | 19 | if (!is_string($lastRelease) || '' === $lastRelease) { 20 | throw new RuntimeException('Invalid tag name found.'); 21 | } 22 | 23 | return 'HumbugBox'.str_replace('.', '', $lastRelease); 24 | } 25 | 26 | return [ 27 | 'prefix' => get_prefix(), 28 | 29 | 'whitelist-global-classes' => false, 30 | 'whitelist-global-constants' => false, 31 | 'whitelist-global-functions' => false, 32 | 33 | 'patchers' => [ 34 | // TODO: report back the missing sapi_windows_vt100_support to JetBrains stubs 35 | static function (string $filePath, string $prefix, string $contents): string { 36 | $files = [ 37 | 'vendor/sebastian/environment/src/Console.php', 38 | 'src/IO.php', 39 | ]; 40 | 41 | if (false === in_array($filePath, $files, true)) { 42 | return $contents; 43 | } 44 | 45 | $contents = preg_replace( 46 | '/function_exists\(\''.$prefix.'\\\\(\\\\)?sapi_windows_vt100_support\'\)/', 47 | "function_exists('sapi_windows_vt100_support')", 48 | $contents 49 | ); 50 | 51 | return $contents; 52 | }, 53 | ], 54 | ]; 55 | -------------------------------------------------------------------------------- /src/PhpScoper/WhitelistManipulator.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box\PhpScoper; 16 | 17 | use function array_shift; 18 | use function count; 19 | use Humbug\PhpScoper\Whitelist; 20 | use PhpParser\Node\Name\FullyQualified; 21 | use Webmozart\Assert\Assert; 22 | 23 | /** 24 | * @private 25 | */ 26 | final class WhitelistManipulator 27 | { 28 | public static function mergeWhitelists(Whitelist ...$whitelists): Whitelist 29 | { 30 | Assert::greaterThan(count($whitelists), 0, 'Expected to have at least one whitelist, none given'); 31 | 32 | /** @var Whitelist $whitelist */ 33 | $whitelist = clone array_shift($whitelists); 34 | 35 | foreach ($whitelists as $whitelistToMerge) { 36 | foreach ($whitelistToMerge->getRecordedWhitelistedClasses() as [$original, $alias]) { 37 | $whitelist->recordWhitelistedClass( 38 | new FullyQualified($original), 39 | new FullyQualified($alias) 40 | ); 41 | } 42 | 43 | foreach ($whitelistToMerge->getRecordedWhitelistedFunctions() as [$original, $alias]) { 44 | $whitelist->recordWhitelistedFunction( 45 | new FullyQualified($original), 46 | new FullyQualified($alias) 47 | ); 48 | } 49 | } 50 | 51 | return $whitelist; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /.requirement-checker/vendor/composer/autoload_real.php: -------------------------------------------------------------------------------- 1 | = 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); 30 | if ($useStaticLoader) { 31 | require __DIR__ . '/autoload_static.php'; 32 | 33 | call_user_func(\Composer\Autoload\ComposerStaticInit07b4f39005452b449fc512b8b494da0a::getInitializer($loader)); 34 | } else { 35 | $classMap = require __DIR__ . '/autoload_classmap.php'; 36 | if ($classMap) { 37 | $loader->addClassMap($classMap); 38 | } 39 | } 40 | 41 | $loader->setClassMapAuthoritative(true); 42 | $loader->register(true); 43 | 44 | return $loader; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/MapFile.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box; 16 | 17 | use function KevinGH\Box\FileSystem\make_path_relative; 18 | use function preg_quote; 19 | use function preg_replace; 20 | use function strpos; 21 | 22 | /** 23 | * @internal 24 | * 25 | * @private 26 | */ 27 | final class MapFile 28 | { 29 | private $basePath; 30 | private $map; 31 | 32 | /** 33 | * @param string[][] $map 34 | */ 35 | public function __construct(string $basePath, array $map) 36 | { 37 | $this->basePath = $basePath; 38 | $this->map = $map; 39 | } 40 | 41 | public function __invoke(string $path): ?string 42 | { 43 | $relativePath = make_path_relative($path, $this->basePath); 44 | 45 | foreach ($this->map as $item) { 46 | foreach ($item as $match => $replace) { 47 | if ('' === $match) { 48 | return $replace.'/'.$relativePath; 49 | } 50 | 51 | if (0 === strpos($relativePath, $match)) { 52 | return preg_replace( 53 | '/^'.preg_quote($match, '/').'/', 54 | $replace, 55 | $relativePath 56 | ); 57 | } 58 | } 59 | } 60 | 61 | return $relativePath; 62 | } 63 | 64 | public function getMap(): array 65 | { 66 | return $this->map; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /fixtures/build/dir012/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "project", 3 | "license": "proprietary", 4 | "require": { 5 | "php": "^7.3", 6 | "ext-ctype": "*", 7 | "ext-iconv": "*", 8 | "symfony/console": "5.2.*", 9 | "symfony/dotenv": "5.2.*", 10 | "symfony/flex": "^1.9", 11 | "symfony/framework-bundle": "5.2.*", 12 | "symfony/yaml": "5.2.*" 13 | }, 14 | "config": { 15 | "preferred-install": { 16 | "*": "dist" 17 | }, 18 | "sort-packages": true, 19 | "platform": { 20 | "php": "7.3" 21 | } 22 | }, 23 | "bin": ["bin/console"], 24 | "autoload": { 25 | "psr-4": { 26 | "App\\": "src/" 27 | } 28 | }, 29 | "autoload-dev": { 30 | "psr-4": { 31 | "App\\Tests\\": "tests/" 32 | } 33 | }, 34 | "replace": { 35 | "paragonie/random_compat": "2.*", 36 | "symfony/polyfill-ctype": "*", 37 | "symfony/polyfill-iconv": "*", 38 | "symfony/polyfill-php71": "*", 39 | "symfony/polyfill-php70": "*", 40 | "symfony/polyfill-php56": "*" 41 | }, 42 | "scripts": { 43 | "auto-scripts": { 44 | "cache:clear": "symfony-cmd" 45 | }, 46 | "post-install-cmd": [ 47 | "@auto-scripts" 48 | ], 49 | "post-update-cmd": [ 50 | "@auto-scripts" 51 | ], 52 | "post-autoload-dump": [ 53 | "@auto-scripts" 54 | ] 55 | }, 56 | "conflict": { 57 | "symfony/symfony": "*" 58 | }, 59 | "extra": { 60 | "symfony": { 61 | "allow-contrib": false, 62 | "require": "5.2.*" 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | tests/ 25 | 26 | 27 | 28 | 29 | 30 | src/ 31 | 32 | 33 | src/bootstrap.php 34 | src/consts.php 35 | src/functions.php 36 | src/Console/Command/Build.php 37 | src/Console/Command/ChangeableWorkingDirectory.php 38 | src/PhpSettingsHandler.php 39 | src/Console/Logger 40 | src/FileSystem 41 | src/Test 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/Console/Command/ConfigurationExporter.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box\Console\Command; 16 | 17 | use const DATE_ATOM; 18 | use DateTimeImmutable; 19 | use DateTimeZone; 20 | use function function_exists; 21 | use function get_loaded_extensions; 22 | use function implode; 23 | use KevinGH\Box\Configuration\Configuration; 24 | use function KevinGH\Box\get_box_version; 25 | use KevinGH\Box\NotInstantiable; 26 | use const PHP_OS; 27 | use function php_uname; 28 | use const PHP_VERSION; 29 | 30 | final class ConfigurationExporter 31 | { 32 | use NotInstantiable; 33 | 34 | public static function export(Configuration $config): string 35 | { 36 | $date = (new DateTimeImmutable('now', new DateTimeZone('UTC')))->format(DATE_ATOM); 37 | $file = $config->getConfigurationFile() ?? 'No config file'; 38 | 39 | $phpVersion = PHP_VERSION; 40 | $phpExtensions = implode(',', get_loaded_extensions()); 41 | $os = function_exists('php_uname') ? PHP_OS.' / '.php_uname('r') : 'Unknown OS'; 42 | $command = implode(' ', $GLOBALS['argv']); 43 | $boxVersion = get_box_version(); 44 | 45 | $header = <<export(); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/PhpScoper/SimpleScoper.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box\PhpScoper; 16 | 17 | use Humbug\PhpScoper\Scoper as PhpScoper; 18 | use Humbug\PhpScoper\Whitelist; 19 | 20 | /** 21 | * @private 22 | */ 23 | final class SimpleScoper implements Scoper 24 | { 25 | private $scoper; 26 | private $prefix; 27 | private $whitelist; 28 | private $patchers; 29 | 30 | public function __construct(PhpScoper $scoper, string $prefix, Whitelist $whitelist, array $patchers) 31 | { 32 | $this->scoper = $scoper; 33 | $this->prefix = $prefix; 34 | $this->whitelist = $whitelist; 35 | $this->patchers = $patchers; 36 | } 37 | 38 | /** 39 | * {@inheritdoc} 40 | */ 41 | public function scope(string $filePath, string $contents): string 42 | { 43 | return $this->scoper->scope( 44 | $filePath, 45 | $contents, 46 | $this->prefix, 47 | $this->patchers, 48 | $this->whitelist 49 | ); 50 | } 51 | 52 | /** 53 | * {@inheritdoc} 54 | */ 55 | public function changeWhitelist(Whitelist $whitelist): void 56 | { 57 | $this->whitelist = $whitelist; 58 | } 59 | 60 | /** 61 | * {@inheritdoc} 62 | */ 63 | public function getWhitelist(): Whitelist 64 | { 65 | return $this->whitelist; 66 | } 67 | 68 | /** 69 | * {@inheritdoc} 70 | */ 71 | public function getPrefix(): string 72 | { 73 | return $this->prefix; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /fixtures/composer-dump/dir002/vendor/beberlei/assert/lib/Assert/InvalidArgumentException.php: -------------------------------------------------------------------------------- 1 | propertyPath = $propertyPath; 28 | $this->value = $value; 29 | $this->constraints = $constraints; 30 | } 31 | 32 | /** 33 | * User controlled way to define a sub-property causing 34 | * the failure of a currently asserted objects. 35 | * 36 | * Useful to transport information about the nature of the error 37 | * back to higher layers. 38 | * 39 | * @return string 40 | */ 41 | public function getPropertyPath() 42 | { 43 | return $this->propertyPath; 44 | } 45 | 46 | /** 47 | * Get the value that caused the assertion to fail. 48 | * 49 | * @return mixed 50 | */ 51 | public function getValue() 52 | { 53 | return $this->value; 54 | } 55 | 56 | /** 57 | * Get the constraints that applied to the failed assertion. 58 | * 59 | * @return array 60 | */ 61 | public function getConstraints() 62 | { 63 | return $this->constraints; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /fixtures/configuration/dir001/vendor/beberlei/assert/lib/Assert/InvalidArgumentException.php: -------------------------------------------------------------------------------- 1 | propertyPath = $propertyPath; 28 | $this->value = $value; 29 | $this->constraints = $constraints; 30 | } 31 | 32 | /** 33 | * User controlled way to define a sub-property causing 34 | * the failure of a currently asserted objects. 35 | * 36 | * Useful to transport information about the nature of the error 37 | * back to higher layers. 38 | * 39 | * @return string 40 | */ 41 | public function getPropertyPath() 42 | { 43 | return $this->propertyPath; 44 | } 45 | 46 | /** 47 | * Get the value that caused the assertion to fail. 48 | * 49 | * @return mixed 50 | */ 51 | public function getValue() 52 | { 53 | return $this->value; 54 | } 55 | 56 | /** 57 | * Get the constraints that applied to the failed assertion. 58 | * 59 | * @return array 60 | */ 61 | public function getConstraints() 62 | { 63 | return $this->constraints; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /fixtures/configuration/dir002/vendor/beberlei/assert/lib/Assert/InvalidArgumentException.php: -------------------------------------------------------------------------------- 1 | propertyPath = $propertyPath; 28 | $this->value = $value; 29 | $this->constraints = $constraints; 30 | } 31 | 32 | /** 33 | * User controlled way to define a sub-property causing 34 | * the failure of a currently asserted objects. 35 | * 36 | * Useful to transport information about the nature of the error 37 | * back to higher layers. 38 | * 39 | * @return string 40 | */ 41 | public function getPropertyPath() 42 | { 43 | return $this->propertyPath; 44 | } 45 | 46 | /** 47 | * Get the value that caused the assertion to fail. 48 | * 49 | * @return mixed 50 | */ 51 | public function getValue() 52 | { 53 | return $this->value; 54 | } 55 | 56 | /** 57 | * Get the constraints that applied to the failed assertion. 58 | * 59 | * @return array 60 | */ 61 | public function getConstraints() 62 | { 63 | return $this->constraints; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /fixtures/configuration/dir003/vendor/beberlei/assert/lib/Assert/InvalidArgumentException.php: -------------------------------------------------------------------------------- 1 | propertyPath = $propertyPath; 28 | $this->value = $value; 29 | $this->constraints = $constraints; 30 | } 31 | 32 | /** 33 | * User controlled way to define a sub-property causing 34 | * the failure of a currently asserted objects. 35 | * 36 | * Useful to transport information about the nature of the error 37 | * back to higher layers. 38 | * 39 | * @return string 40 | */ 41 | public function getPropertyPath() 42 | { 43 | return $this->propertyPath; 44 | } 45 | 46 | /** 47 | * Get the value that caused the assertion to fail. 48 | * 49 | * @return mixed 50 | */ 51 | public function getValue() 52 | { 53 | return $this->value; 54 | } 55 | 56 | /** 57 | * Get the constraints that applied to the failed assertion. 58 | * 59 | * @return array 60 | */ 61 | public function getConstraints() 62 | { 63 | return $this->constraints; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /fixtures/configuration/dir004/vendor/beberlei/assert/lib/Assert/InvalidArgumentException.php: -------------------------------------------------------------------------------- 1 | propertyPath = $propertyPath; 28 | $this->value = $value; 29 | $this->constraints = $constraints; 30 | } 31 | 32 | /** 33 | * User controlled way to define a sub-property causing 34 | * the failure of a currently asserted objects. 35 | * 36 | * Useful to transport information about the nature of the error 37 | * back to higher layers. 38 | * 39 | * @return string 40 | */ 41 | public function getPropertyPath() 42 | { 43 | return $this->propertyPath; 44 | } 45 | 46 | /** 47 | * Get the value that caused the assertion to fail. 48 | * 49 | * @return mixed 50 | */ 51 | public function getValue() 52 | { 53 | return $this->value; 54 | } 55 | 56 | /** 57 | * Get the constraints that applied to the failed assertion. 58 | * 59 | * @return array 60 | */ 61 | public function getConstraints() 62 | { 63 | return $this->constraints; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /tests/Annotation/DocblockAnnotationParserTest.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box\Annotation; 16 | 17 | use Generator; 18 | use phpDocumentor\Reflection\DocBlockFactory; 19 | use PHPUnit\Framework\TestCase; 20 | 21 | /** 22 | * @covers \KevinGH\Box\Annotation\DocblockAnnotationParser 23 | */ 24 | class DocblockAnnotationParserTest extends TestCase 25 | { 26 | /** 27 | * @var DocblockAnnotationParser 28 | */ 29 | private $annotationParser; 30 | 31 | /** 32 | * {@inheritdoc} 33 | */ 34 | protected function setUp(): void 35 | { 36 | $this->annotationParser = new DocblockAnnotationParser( 37 | DocBlockFactory::createInstance(), 38 | new CompactedFormatter(), 39 | ['ignored'] 40 | ); 41 | } 42 | 43 | /** 44 | * @dataProvider provideDocblocks 45 | */ 46 | public function test_it_can_parse_php_docblocks(string $docblock, array $expected): void 47 | { 48 | $actual = $this->annotationParser->parse($docblock); 49 | 50 | $this->assertSame($expected, $actual); 51 | } 52 | 53 | public function provideDocblocks(): Generator 54 | { 55 | yield [ 56 | '// @comment', 57 | [], 58 | ]; 59 | 60 | yield [ 61 | <<<'DOCBLOCK' 62 | /** 63 | * @Annotation 64 | */ 65 | DOCBLOCK 66 | , 67 | ['@Annotation'], 68 | ]; 69 | 70 | yield [ 71 | <<<'DOCBLOCK' 72 | /** 73 | * @ignored 74 | * @Kept 75 | */ 76 | DOCBLOCK 77 | , 78 | ['@Kept'], 79 | ]; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/Composer/ComposerFiles.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace KevinGH\Box\Composer; 16 | 17 | use function array_filter; 18 | use function array_map; 19 | 20 | final class ComposerFiles 21 | { 22 | private $composerJson; 23 | private $composerLock; 24 | private $installedJson; 25 | 26 | public static function createEmpty(): self 27 | { 28 | return new self( 29 | ComposerFile::createEmpty(), 30 | ComposerFile::createEmpty(), 31 | ComposerFile::createEmpty() 32 | ); 33 | } 34 | 35 | public function __construct( 36 | ComposerFile $composerJson, 37 | ComposerFile $composerLock, 38 | ComposerFile $installedJson 39 | ) { 40 | $this->composerJson = $composerJson; 41 | $this->composerLock = $composerLock; 42 | $this->installedJson = $installedJson; 43 | } 44 | 45 | public function getComposerJson(): ComposerFile 46 | { 47 | return $this->composerJson; 48 | } 49 | 50 | public function getComposerLock(): ComposerFile 51 | { 52 | return $this->composerLock; 53 | } 54 | 55 | public function getInstalledJson(): ComposerFile 56 | { 57 | return $this->installedJson; 58 | } 59 | 60 | /** 61 | * @return string[] 62 | */ 63 | public function getPaths(): array 64 | { 65 | return array_filter(array_map( 66 | static function (ComposerFile $file): ?string { 67 | return $file->getPath(); 68 | }, 69 | [$this->composerJson, $this->composerLock, $this->installedJson] 70 | )); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /fixtures/build/dir012/src/Kernel.php: -------------------------------------------------------------------------------- 1 | 9 | * Théo Fidry 10 | * 11 | * This source file is subject to the MIT license that is bundled 12 | * with this source code in the file LICENSE. 13 | */ 14 | 15 | namespace App; 16 | 17 | use function dirname; 18 | use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; 19 | use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; 20 | use Symfony\Component\HttpKernel\Kernel as BaseKernel; 21 | use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; 22 | 23 | class Kernel extends BaseKernel 24 | { 25 | use MicroKernelTrait; 26 | 27 | protected function configureContainer(ContainerConfigurator $container): void 28 | { 29 | $container->import('../config/{packages}/*.yaml'); 30 | $container->import('../config/{packages}/'.$this->environment.'/*.yaml'); 31 | 32 | if (is_file(dirname(__DIR__).'/config/services.yaml')) { 33 | $container->import('../config/services.yaml'); 34 | $container->import('../config/{services}_'.$this->environment.'.yaml'); 35 | } elseif (is_file($path = dirname(__DIR__).'/config/services.php')) { 36 | (require $path)($container->withPath($path), $this); 37 | } 38 | } 39 | 40 | protected function configureRoutes(RoutingConfigurator $routes): void 41 | { 42 | $routes->import('../config/{routes}/'.$this->environment.'/*.yaml'); 43 | $routes->import('../config/{routes}/*.yaml'); 44 | 45 | if (is_file(dirname(__DIR__).'/config/routes.yaml')) { 46 | $routes->import('../config/routes.yaml'); 47 | } elseif (is_file($path = dirname(__DIR__).'/config/routes.php')) { 48 | (require $path)($routes->withPath($path), $this); 49 | } 50 | } 51 | } 52 | --------------------------------------------------------------------------------