From ff8e9b0dc10315e13f3a7951eec6b227e66997e7 Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Sat, 23 Mar 2024 14:07:37 +0100 Subject: [PATCH] Remove unused code and deprecate Runtime::getBinary() as well as Runtime::getRawBinary() --- ChangeLog.md | 12 ++++++++++++ src/Runtime.php | 44 ++++++-------------------------------------- 2 files changed, 18 insertions(+), 38 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index a487544..978a641 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -2,6 +2,17 @@ All notable changes in `sebastianbergmann/environment` are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles. +## [7.2.0] - 2024-MM-DD + +### Changed + +* Removed code left over from a time before PHP 5.4 and when HHVM was still supported + +### Deprecated + +* The `Runtime::getBinary()` method is now deprecated, use `escapeshellarg(PHP_BINARY)` instead +* The `Runtime::getRawBinary()` method is now deprecated, use the `PHP_BINARY` constant instead + ## [7.1.0] - 2024-03-23 ### Added @@ -190,6 +201,7 @@ All notable changes in `sebastianbergmann/environment` are documented in this fi * This component is no longer supported on PHP 5.6 +[7.2.0]: https://github.com/sebastianbergmann/environment/compare/7.1.0...main [7.1.0]: https://github.com/sebastianbergmann/environment/compare/7.0.0...7.1.0 [7.0.0]: https://github.com/sebastianbergmann/environment/compare/6.1...7.0.0 [6.1.0]: https://github.com/sebastianbergmann/environment/compare/6.0.1...6.1.0 diff --git a/src/Runtime.php b/src/Runtime.php index f9ec057..32b092f 100644 --- a/src/Runtime.php +++ b/src/Runtime.php @@ -10,7 +10,6 @@ namespace SebastianBergmann\Environment; use const PHP_BINARY; -use const PHP_BINDIR; use const PHP_MAJOR_VERSION; use const PHP_SAPI; use const PHP_VERSION; @@ -20,7 +19,6 @@ use function explode; use function extension_loaded; use function ini_get; -use function is_readable; use function parse_ini_file; use function php_ini_loaded_file; use function php_ini_scanned_files; @@ -30,9 +28,6 @@ final class Runtime { - private static string $rawBinary; - private static bool $initialized = false; - /** * Returns true when Xdebug or PCOV is available or * the runtime used is PHPDBG. @@ -92,49 +87,22 @@ public function performsJustInTimeCompilation(): bool /** * Returns the raw path to the binary of the current runtime. + * + * @deprecated */ public function getRawBinary(): string { - if (self::$initialized) { - return self::$rawBinary; - } - - if (PHP_BINARY !== '') { - self::$rawBinary = PHP_BINARY; - self::$initialized = true; - - return self::$rawBinary; - } - - // @codeCoverageIgnoreStart - $possibleBinaryLocations = [ - PHP_BINDIR . '/php', - PHP_BINDIR . '/php-cli.exe', - PHP_BINDIR . '/php.exe', - ]; - - foreach ($possibleBinaryLocations as $binary) { - if (is_readable($binary)) { - self::$rawBinary = $binary; - self::$initialized = true; - - return self::$rawBinary; - } - } - - self::$rawBinary = 'php'; - self::$initialized = true; - - return self::$rawBinary; - // @codeCoverageIgnoreEnd + return PHP_BINARY; } /** * Returns the escaped path to the binary of the current runtime. + * + * @deprecated */ public function getBinary(): string { - return escapeshellarg($this->getRawBinary()); + return escapeshellarg(PHP_BINARY); } public function getNameWithVersion(): string