diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index 184d88dc..b2e6bc09 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -333,16 +333,21 @@ abstract class BuilderBase throw new RuntimeException('PHP version file format is malformed, please remove it and download again'); } - public function getPHPVersion(): string + public function getPHPVersion(bool $exception_on_failure = true): string { if (!file_exists(SOURCE_PATH . '/php-src/main/php_version.h')) { + if (!$exception_on_failure) { + return 'unknown'; + } throw new WrongUsageException('PHP source files are not available, you need to download them first'); } $file = file_get_contents(SOURCE_PATH . '/php-src/main/php_version.h'); if (preg_match('/PHP_VERSION "(.*)"/', $file, $match) !== 0) { return $match[1]; } - + if (!$exception_on_failure) { + return 'unknown'; + } throw new RuntimeException('PHP version file format is malformed, please remove it and download again'); } @@ -360,7 +365,7 @@ abstract class BuilderBase } $file = LockFile::getLockFullPath($lock); } - if (preg_match('/php-(\d+\.\d+\.\d+(?:RC\d+)?)\.tar\.(?:gz|bz2|xz)/', $file, $match)) { + if (preg_match('/php-(\d+\.\d+\.\d+(?:RC\d+|alpha\d+|beta\d+)?)\.tar\.(?:gz|bz2|xz)/', $file, $match)) { return $match[1]; } return false; diff --git a/src/SPC/command/BuildPHPCommand.php b/src/SPC/command/BuildPHPCommand.php index 8bfa4aaf..49f6812d 100644 --- a/src/SPC/command/BuildPHPCommand.php +++ b/src/SPC/command/BuildPHPCommand.php @@ -159,7 +159,7 @@ class BuildPHPCommand extends BuildCommand $indent_texts['UPX Pack'] = 'enabled'; } - $ver = $builder->getPHPVersionFromArchive() ?: $builder->getPHPVersion(); + $ver = $builder->getPHPVersionFromArchive() ?: $builder->getPHPVersion(false); $indent_texts['PHP Version'] = $ver; if (!empty($not_included)) { @@ -269,6 +269,7 @@ class BuildPHPCommand extends BuildCommand } catch (WrongUsageException $e) { // WrongUsageException is not an exception, it's a user error, so we just print the error message logger()->critical($e->getMessage()); + logger()->error($e->getTraceAsString()); return static::FAILURE; } catch (\Throwable $e) { if ($this->getOption('debug')) {