diff --git a/src/Configuration.php b/src/Configuration.php index 9ffccc86b..6520c9a6f 100644 --- a/src/Configuration.php +++ b/src/Configuration.php @@ -65,7 +65,6 @@ final class Configuration private $basePath; private $files; private $binaryFiles; - private $bootstrapFile; private $compactors; private $compressionAlgorithm; private $mainScriptPath; @@ -93,7 +92,6 @@ final class Configuration * @param string $basePath Utility to private the base path used and be able to retrieve a path relative to it (the base path) * @param SplFileInfo[] $files List of files * @param SplFileInfo[] $binaryFiles List of binary files - * @param null|string $bootstrapFile The bootstrap file path * @param Compactor[] $compactors List of file contents compactors * @param null|int $compressionAlgorithm Compression algorithm constant value. See the \Phar class constants * @param null|int $fileMode File mode in octal form @@ -121,7 +119,6 @@ private function __construct( string $basePath, array $files, array $binaryFiles, - ?string $bootstrapFile, array $compactors, ?int $compressionAlgorithm, ?int $fileMode, @@ -156,7 +153,6 @@ private function __construct( $this->basePath = $basePath; $this->files = $files; $this->binaryFiles = $binaryFiles; - $this->bootstrapFile = $bootstrapFile; $this->compactors = $compactors; $this->compressionAlgorithm = $compressionAlgorithm; $this->fileMode = $fileMode; @@ -209,8 +205,6 @@ public static function create(?string $file, stdClass $raw): self $binaryFilesAggregate = array_unique(iterator_to_array(chain($binaryFiles, $binaryDirectories, ...$binaryFilesFromFinders))); } - $bootstrapFile = self::retrieveBootstrapFile($raw, $basePath); - $compactors = self::retrieveCompactors($raw, $basePath); $compressionAlgorithm = self::retrieveCompressionAlgorithm($raw); @@ -254,7 +248,6 @@ public static function create(?string $file, stdClass $raw): self $basePath, $filesAggregate, $binaryFilesAggregate, - $bootstrapFile, $compactors, $compressionAlgorithm, $fileMode, @@ -304,20 +297,6 @@ public function getBinaryFiles(): array return $this->binaryFiles; } - public function getBootstrapFile(): ?string - { - return $this->bootstrapFile; - } - - public function loadBootstrap(): void - { - $file = $this->bootstrapFile; - - if (null !== $file) { - include $file; - } - } - /** * @return Compactor[] the list of compactors */ @@ -728,7 +707,7 @@ function (SplFileInfo $fileInfo) use ($devPackages): bool { ); } - //TODO: add fileExists (as file or directory) to Assert + // TODO: add fileExists (as file or directory) to Assert if (false === is_file($fileOrDirectory)) { Assertion::directory($fileOrDirectory); } else { @@ -854,21 +833,6 @@ private static function normalizePath(string $file, string $basePath): string return make_path_absolute(trim($file), $basePath); } - private static function retrieveBootstrapFile(stdClass $raw, string $basePath): ?string - { - // TODO: deprecate its usage & document this BC break. Compactors will not be configurable - // through that extension point so this is pretty much useless unless proven otherwise. - if (false === isset($raw->bootstrap)) { - return null; - } - - $file = self::normalizePath($raw->bootstrap, $basePath); - - Assertion::file($file, 'The bootstrap path "%s" is not a file or does not exist.'); - - return $file; - } - /** * @return Compactor[] */ diff --git a/src/Console/Command/Compile.php b/src/Console/Command/Compile.php index 7b76d7825..f2c24bbdd 100644 --- a/src/Console/Command/Compile.php +++ b/src/Console/Command/Compile.php @@ -106,7 +106,6 @@ protected function execute(InputInterface $input, OutputInterface $output): void $startTime = microtime(true); - $this->loadBootstrapFile($config, $logger); $this->removeExistingPhar($config, $logger); $logger->logStartBuilding($path); @@ -167,25 +166,6 @@ private function createPhar( } } - private function loadBootstrapFile(Configuration $config, BuildLogger $logger): void - { - $file = $config->getBootstrapFile(); - - if (null === $file) { - return; - } - - $logger->log( - BuildLogger::QUESTION_MARK_PREFIX, - sprintf( - 'Loading the bootstrap file "%s"', - $file - ) - ); - - $config->loadBootstrap(); - } - private function removeExistingPhar(Configuration $config, BuildLogger $logger): void { $path = $config->getOutputPath(); diff --git a/tests/ConfigurationTest.php b/tests/ConfigurationTest.php index 63d85c17b..b624b8df5 100644 --- a/tests/ConfigurationTest.php +++ b/tests/ConfigurationTest.php @@ -1725,27 +1725,6 @@ public function test_the_blacklist_setting_is_applied_to_all_the_files_found_in_ $this->assertCount(0, $this->config->getBinaryFiles()); } - public function test_no_bootstrap_file_is_configured_by_default(): void - { - $this->assertNull($this->config->getBootstrapFile()); - $this->assertNull($this->getNoFileConfig()->getBootstrapFile()); - } - - public function test_configure_the_bootstrap_file(): void - { - touch('test.php'); - - $this->setconfig([ - 'bootstrap' => 'test.php', - 'files' => [self::DEFAULT_FILE], - ]); - - $this->assertSame( - $this->tmp.DIRECTORY_SEPARATOR.'test.php', - $this->config->getBootstrapFile() - ); - } - public function test_no_compactors_is_configured_by_default(): void { $this->assertSame([], $this->config->getCompactors()); @@ -2579,42 +2558,6 @@ public function testIsPrivateKeyPromptSetString(): void $this->assertFalse($this->config->isPrivateKeyPrompt()); } - public function testLoadBootstrap(): void - { - file_put_contents( - 'test.php', - <<<'CODE' -setConfig([ - 'bootstrap' => 'test.php', - 'files' => [self::DEFAULT_FILE], - ]); - - $this->config->loadBootstrap(); - - $this->assertTrue(defined('TEST_BOOTSTRAP_FILE_LOADED')); - } - - public function testLoadBootstrapNotExist(): void - { - try { - $this->setConfig([ - 'bootstrap' => 'test.php', - 'files' => [self::DEFAULT_FILE], - ]); - - $this->fail('Expected exception to be thrown.'); - } catch (InvalidArgumentException $exception) { - $this->assertSame( - 'The bootstrap path "'.$this->tmp.DIRECTORY_SEPARATOR.'test.php" is not a file or does not exist.', - $exception->getMessage() - ); - } - } - public function provideInvalidCompressionAlgorithms(): Generator { yield 'Invalid string key' => [ diff --git a/tests/Console/Command/CompileTest.php b/tests/Console/Command/CompileTest.php index 114107716..6107ee0c7 100644 --- a/tests/Console/Command/CompileTest.php +++ b/tests/Console/Command/CompileTest.php @@ -51,7 +51,6 @@ public function test_it_can_build_a_PHAR_file(): void [ 'alias' => 'alias-test.phar', 'banner' => 'custom banner', - 'bootstrap' => 'bootstrap.php', 'chmod' => '0755', 'compactors' => [Php::class], 'directories' => ['a'], @@ -94,7 +93,6 @@ public function test_it_can_build_a_PHAR_file(): void // Loading the configuration file "/path/to/box.json.dist". -? Loading the bootstrap file "/path/to/tmp/bootstrap.php" ? Removing the existing PHAR "/path/to/tmp/test.phar" Building the PHAR "/path/to/tmp/test.phar" ? Registering compactors @@ -191,7 +189,6 @@ public function test_it_can_build_a_PHAR_from_a_different_directory(): void [ 'alias' => 'alias-test.phar', 'banner' => 'custom banner', - 'bootstrap' => 'bootstrap.php', 'chmod' => '0755', 'compactors' => [Php::class], 'directories' => ['a'], @@ -302,12 +299,12 @@ public function test_it_can_build_a_PHAR_without_any_configuration(): void '/a/deep/test/', '/a/deep/test/directory/', '/a/deep/test/directory/test.php', + '/bootstrap.php', '/one/', '/one/test.php', '/two/', '/two/test.png', '/binary', - '/bootstrap.php', '/private.key', '/test.phar', '/test.phar.pubkey', @@ -329,7 +326,6 @@ public function test_it_can_build_a_PHAR_with_complete_mapping(): void json_encode( [ 'alias' => 'alias-test.phar', - 'bootstrap' => 'bootstrap.php', 'chmod' => '0755', 'compactors' => [Php::class], 'directories' => ['a'], @@ -372,7 +368,6 @@ public function test_it_can_build_a_PHAR_with_complete_mapping(): void // Loading the configuration file "/path/to/box.json.dist". -? Loading the bootstrap file "/path/to/tmp/bootstrap.php" ? Removing the existing PHAR "/path/to/tmp/test.phar" Building the PHAR "/path/to/tmp/test.phar" ? Registering compactors @@ -476,7 +471,6 @@ public function test_it_can_build_a_PHAR_file_in_verbose_mode(): void [ 'alias' => 'test.phar', 'banner' => 'custom banner', - 'bootstrap' => 'bootstrap.php', 'chmod' => '0755', 'compactors' => [Php::class], 'directories' => ['a'], @@ -523,7 +517,6 @@ public function test_it_can_build_a_PHAR_file_in_verbose_mode(): void // Loading the configuration file "/path/to/box.json.dist". -? Loading the bootstrap file "/path/to/tmp/bootstrap.php" ? Removing the existing PHAR "/path/to/tmp/test.phar" * Building the PHAR "/path/to/tmp/test.phar" ? Registering compactors @@ -577,7 +570,6 @@ public function test_it_can_build_a_PHAR_file_in_very_verbose_mode(): void 'multiline', 'custom banner', ], - 'bootstrap' => 'bootstrap.php', 'chmod' => '0755', 'compactors' => [Php::class], 'directories' => ['a'], @@ -624,7 +616,6 @@ public function test_it_can_build_a_PHAR_file_in_very_verbose_mode(): void // Loading the configuration file "/path/to/box.json.dist". -? Loading the bootstrap file "/path/to/tmp/bootstrap.php" ? Removing the existing PHAR "/path/to/tmp/test.phar" * Building the PHAR "/path/to/tmp/test.phar" ? Registering compactors @@ -681,7 +672,6 @@ public function test_it_can_build_a_PHAR_file_in_quiet_mode(): void [ 'alias' => 'test.phar', 'banner' => 'custom banner', - 'bootstrap' => 'bootstrap.php', 'chmod' => '0755', 'compactors' => [Php::class], 'directories' => ['a'], @@ -762,7 +752,6 @@ public function test_it_can_build_a_PHAR_file_using_the_PHAR_default_stub(): voi [ 'alias' => 'alias-test.phar', 'banner' => 'custom banner', - 'bootstrap' => 'bootstrap.php', 'chmod' => '0755', 'compactors' => [Php::class], 'directories' => ['a'], @@ -831,7 +820,6 @@ public function test_it_can_build_a_PHAR_file_using_a_custom_stub(): void [ 'alias' => 'alias-test.phar', 'banner' => 'custom banner', - 'bootstrap' => 'bootstrap.php', 'chmod' => '0755', 'compactors' => [Php::class], 'directories' => ['a'],