From a6182b481bd14f0d106d7ac10e114dbee55fb752 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Tue, 21 Jun 2022 00:01:44 +0200 Subject: [PATCH] Drop PHP5.3 support (#674) As Composer 2.3 is dropping PHP 5.3 and requires 7.2.5+ as the minimum PHP version, so does Box. In theory it would be possible to keep the 5.3 compatibility, but that would require non trivial efforts as it would require to make the bundle requirement checker work without Composer autoloading _and_ keeping track of Composer Semver too. Since 7.2.5 is now the minimum, the requirement checker has been pimped up a bit. Closes #656 --- .docker/build | 4 +- .docker/php53 | 4 - .docker/php725 | 1 + .gitignore | 1 + .requirement-checker/src/Checker.php | 8 +- .requirement-checker/src/IO.php | 72 ++--- .../src/IsExtensionFulfilled.php | 7 +- .requirement-checker/src/IsFulfilled.php | 2 +- .../src/IsPhpVersionFulfilled.php | 7 +- .requirement-checker/src/Printer.php | 63 +++-- .requirement-checker/src/Requirement.php | 14 +- .../src/RequirementCollection.php | 23 +- .requirement-checker/src/Terminal.php | 77 +++--- .requirement-checker/vendor/autoload.php | 7 +- .../vendor/composer/autoload_classmap.php | 2 +- .../vendor/composer/autoload_namespaces.php | 2 +- .../vendor/composer/autoload_psr4.php | 2 +- .../vendor/composer/autoload_real.php | 21 +- .../vendor/composer/autoload_static.php | 8 +- .../composer/semver/src/VersionParser.php | 16 +- Makefile | 78 +++--- doc/requirement-checker.md | 4 +- .../expected-output-53-dist-skipped | 6 - ...utput-53-dist => expected-output-725-dist} | 2 +- .../expected-output-725-dist-skipped | 6 + ...utput-53-dist => expected-output-725-dist} | 0 ...utput-53-dist => expected-output-725-dist} | 0 requirement-checker/composer.json | 2 +- requirement-checker/composer.lock | 254 ++++++------------ requirement-checker/expected_terminal_diff | 52 ++-- requirement-checker/src/Checker.php | 16 +- requirement-checker/src/IO.php | 86 +++--- .../src/IsExtensionFulfilled.php | 14 +- requirement-checker/src/IsFulfilled.php | 5 +- .../src/IsPhpVersionFulfilled.php | 11 +- requirement-checker/src/Printer.php | 80 ++---- requirement-checker/src/Requirement.php | 35 +-- .../src/RequirementCollection.php | 38 +-- requirement-checker/src/Terminal.php | 71 ++--- requirement-checker/tests/CheckerTest.php | 2 +- .../tests/ConditionIsFulfilled.php | 5 +- .../tests/ConditionIsNotFulfilled.php | 5 +- requirement-checker/tests/IOTest.php | 1 - requirement-checker/tests/RequirementTest.php | 64 +---- 44 files changed, 496 insertions(+), 682 deletions(-) delete mode 100644 .docker/php53 create mode 100644 .docker/php725 delete mode 100644 fixtures/check-requirements/fail-complete/expected-output-53-dist-skipped rename fixtures/check-requirements/fail-complete/{expected-output-53-dist => expected-output-725-dist} (99%) create mode 100644 fixtures/check-requirements/fail-complete/expected-output-725-dist-skipped rename fixtures/check-requirements/pass-complete/{expected-output-53-dist => expected-output-725-dist} (100%) rename fixtures/check-requirements/pass-no-config/{expected-output-53-dist => expected-output-725-dist} (100%) diff --git a/.docker/build b/.docker/build index 2e74837bc..fe10625f4 100755 --- a/.docker/build +++ b/.docker/build @@ -7,8 +7,8 @@ readonly DOCKER=$(which docker) # Globals # PWD -if [[ "$(docker images -q box_php53 2> /dev/null)" == "" ]]; then - $DOCKER build --platform=linux/amd64 --tag=box_php53 --file "$PWD/.docker/php53" . +if [[ "$(docker images -q box_php725 2> /dev/null)" == "" ]]; then + $DOCKER build --platform=linux/amd64 --tag=box_php725 --file "$PWD/.docker/php725" . fi if [[ "$(docker images -q box_php81 2> /dev/null)" == "" ]]; then diff --git a/.docker/php53 b/.docker/php53 deleted file mode 100644 index b2df7ba8e..000000000 --- a/.docker/php53 +++ /dev/null @@ -1,4 +0,0 @@ -FROM helder/php-5.3 - -RUN echo '' | pecl install phar; \ - echo '' | pecl install json diff --git a/.docker/php725 b/.docker/php725 new file mode 100644 index 000000000..2acc08764 --- /dev/null +++ b/.docker/php725 @@ -0,0 +1 @@ +FROM php:7.2.5-alpine diff --git a/.gitignore b/.gitignore index a363977bf..929efe119 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,7 @@ /fixtures/build/dir012/expected-output /fixtures/check-requirements/*/actual-output /fixtures/check-requirements/*/expected-output-* +!/fixtures/check-requirements/*/expected-output-*-dist /fixtures/check-requirements/*/*.phar /fixtures/php-settings-checker/* !/fixtures/php-settings-checker/index.php diff --git a/.requirement-checker/src/Checker.php b/.requirement-checker/src/Checker.php index 215e40bb4..a8ec9b2dd 100644 --- a/.requirement-checker/src/Checker.php +++ b/.requirement-checker/src/Checker.php @@ -5,7 +5,7 @@ final class Checker { private static $requirementsConfig; - public static function checkRequirements() + public static function checkRequirements() : bool { $requirements = self::retrieveRequirements(); $checkPassed = $requirements->evaluateRequirements(); @@ -13,7 +13,7 @@ public static function checkRequirements() self::printCheck($checkPassed, new Printer($io->getVerbosity(), $io->hasColorSupport()), $requirements); return $checkPassed; } - public static function printCheck($checkPassed, Printer $printer, RequirementCollection $requirements) + public static function printCheck($checkPassed, Printer $printer, RequirementCollection $requirements) : void { if (\false === $checkPassed && IO::VERBOSITY_VERY_VERBOSE > $printer->getVerbosity()) { $printer->setVerbosity(IO::VERBOSITY_VERY_VERBOSE); @@ -36,7 +36,7 @@ public static function printCheck($checkPassed, Printer $printer, RequirementCol } else { $printer->printvln('> No requirements found.', $verbosity); } - $errorMessages = array(); + $errorMessages = []; foreach ($requirements->getRequirements() as $requirement) { if ($errorMessage = $printer->getRequirementErrorMessage($requirement)) { if (IO::VERBOSITY_DEBUG === $printer->getVerbosity()) { @@ -70,7 +70,7 @@ public static function printCheck($checkPassed, Printer $printer, RequirementCol } $printer->printvln('', $verbosity); } - private static function retrieveRequirements() + private static function retrieveRequirements() : RequirementCollection { if (null === self::$requirementsConfig) { self::$requirementsConfig = __DIR__ . '/../.requirements.php'; diff --git a/.requirement-checker/src/IO.php b/.requirement-checker/src/IO.php index 79cff267e..d1c0fedc8 100644 --- a/.requirement-checker/src/IO.php +++ b/.requirement-checker/src/IO.php @@ -2,63 +2,75 @@ namespace HumbugBox3160\KevinGH\RequirementChecker; +use function fstat; +use function function_exists; +use function getenv; +use function implode; +use function posix_isatty; +use function preg_match; +use function preg_quote; +use function sapi_windows_vt100_support; +use function sprintf; +use function str_replace; +use function stream_isatty; +use const STDOUT; final class IO { - const VERBOSITY_QUIET = 16; - const VERBOSITY_NORMAL = 32; - const VERBOSITY_VERBOSE = 64; - const VERBOSITY_VERY_VERBOSE = 128; - const VERBOSITY_DEBUG = 256; + public const VERBOSITY_QUIET = 16; + public const VERBOSITY_NORMAL = 32; + public const VERBOSITY_VERBOSE = 64; + public const VERBOSITY_VERY_VERBOSE = 128; + public const VERBOSITY_DEBUG = 256; private $interactive; private $verbosity = self::VERBOSITY_NORMAL; private $colorSupport; private $options; public function __construct() { - $this->options = \implode(' ', $_SERVER['argv']); + $this->options = implode(' ', $_SERVER['argv']); $shellVerbosity = $this->configureVerbosity(); $this->interactive = $this->checkInteractivity($shellVerbosity); $this->colorSupport = $this->checkColorSupport(); } - public function isInteractive() + public function isInteractive() : bool { return $this->interactive; } - public function getVerbosity() + public function getVerbosity() : int { return $this->verbosity; } - public function hasColorSupport() + public function hasColorSupport() : bool { return $this->colorSupport; } - public function hasParameter($values) + public function hasParameter($values) : bool { $values = (array) $values; foreach ($values as $value) { - $regexp = \sprintf('/\\s%s\\b/', \str_replace(' ', '\\s+', \preg_quote($value, '/'))); - if (1 === \preg_match($regexp, $this->options)) { + $regexp = sprintf('/\\s%s\\b/', str_replace(' ', '\\s+', preg_quote($value, '/'))); + if (1 === preg_match($regexp, $this->options)) { return \true; } } return \false; } - private function checkInteractivity($shellVerbosity) + private function checkInteractivity(int $shellVerbosity) : bool { if (-1 === $shellVerbosity) { return \false; } - if (\true === $this->hasParameter(array('--no-interaction', '-n'))) { + if (\true === $this->hasParameter(['--no-interaction', '-n'])) { return \false; } - if (\function_exists('posix_isatty') && !@\posix_isatty(\STDOUT) && \false === \getenv('SHELL_INTERACTIVE')) { + if (function_exists('posix_isatty') && !@posix_isatty(STDOUT) && \false === getenv('SHELL_INTERACTIVE')) { return \false; } return \true; } - private function configureVerbosity() + private function configureVerbosity() : int { - switch ($shellVerbosity = (int) \getenv('SHELL_VERBOSITY')) { + switch ($shellVerbosity = (int) getenv('SHELL_VERBOSITY')) { case -1: $this->verbosity = self::VERBOSITY_QUIET; break; @@ -75,39 +87,39 @@ private function configureVerbosity() $shellVerbosity = 0; break; } - if ($this->hasParameter(array('--quiet', '-q'))) { + if ($this->hasParameter(['--quiet', '-q'])) { $this->verbosity = self::VERBOSITY_QUIET; $shellVerbosity = -1; - } elseif ($this->hasParameter(array('-vvv', '--verbose=3', '--verbose 3'))) { + } elseif ($this->hasParameter(['-vvv', '--verbose=3', '--verbose 3'])) { $this->verbosity = self::VERBOSITY_DEBUG; $shellVerbosity = 3; - } elseif ($this->hasParameter(array('-vv', '--verbose=2', '--verbose 2'))) { + } elseif ($this->hasParameter(['-vv', '--verbose=2', '--verbose 2'])) { $this->verbosity = self::VERBOSITY_VERY_VERBOSE; $shellVerbosity = 2; - } elseif ($this->hasParameter(array('-v', '--verbose=1', '--verbose 1', '--verbose'))) { + } elseif ($this->hasParameter(['-v', '--verbose=1', '--verbose 1', '--verbose'])) { $this->verbosity = self::VERBOSITY_VERBOSE; $shellVerbosity = 1; } return $shellVerbosity; } - private function checkColorSupport() + private function checkColorSupport() : bool { - if ($this->hasParameter(array('--ansi'))) { + if ($this->hasParameter(['--ansi'])) { return \true; } - if ($this->hasParameter(array('--no-ansi'))) { + if ($this->hasParameter(['--no-ansi'])) { return \false; } if (\DIRECTORY_SEPARATOR === '\\') { - return \function_exists('sapi_windows_vt100_support') && \sapi_windows_vt100_support(\STDOUT) || \false !== \getenv('ANSICON') || 'ON' === \getenv('ConEmuANSI') || 'xterm' === \getenv('TERM'); + return function_exists('sapi_windows_vt100_support') && sapi_windows_vt100_support(STDOUT) || \false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI') || 'xterm' === getenv('TERM'); } - if (\function_exists('stream_isatty')) { - return \stream_isatty(\STDOUT); + if (function_exists('stream_isatty')) { + return stream_isatty(STDOUT); } - if (\function_exists('posix_isatty')) { - return \posix_isatty(\STDOUT); + if (function_exists('posix_isatty')) { + return posix_isatty(STDOUT); } - $stat = \fstat(\STDOUT); + $stat = fstat(STDOUT); return $stat ? 020000 === ($stat['mode'] & 0170000) : \false; } } diff --git a/.requirement-checker/src/IsExtensionFulfilled.php b/.requirement-checker/src/IsExtensionFulfilled.php index a02bda83e..87c88e471 100644 --- a/.requirement-checker/src/IsExtensionFulfilled.php +++ b/.requirement-checker/src/IsExtensionFulfilled.php @@ -2,15 +2,16 @@ namespace HumbugBox3160\KevinGH\RequirementChecker; +use function extension_loaded; final class IsExtensionFulfilled implements IsFulfilled { private $requiredExtension; - public function __construct($requiredExtension) + public function __construct(string $requiredExtension) { $this->requiredExtension = $requiredExtension; } - public function __invoke() + public function __invoke() : bool { - return \extension_loaded($this->requiredExtension); + return extension_loaded($this->requiredExtension); } } diff --git a/.requirement-checker/src/IsFulfilled.php b/.requirement-checker/src/IsFulfilled.php index 628bc5590..0046001d5 100644 --- a/.requirement-checker/src/IsFulfilled.php +++ b/.requirement-checker/src/IsFulfilled.php @@ -4,5 +4,5 @@ interface IsFulfilled { - public function __invoke(); + public function __invoke() : bool; } diff --git a/.requirement-checker/src/IsPhpVersionFulfilled.php b/.requirement-checker/src/IsPhpVersionFulfilled.php index 54a1b5717..7e7fea6c9 100644 --- a/.requirement-checker/src/IsPhpVersionFulfilled.php +++ b/.requirement-checker/src/IsPhpVersionFulfilled.php @@ -3,15 +3,16 @@ namespace HumbugBox3160\KevinGH\RequirementChecker; use HumbugBox3160\Composer\Semver\Semver; +use function sprintf; final class IsPhpVersionFulfilled implements IsFulfilled { private $requiredPhpVersion; - public function __construct($requiredPhpVersion) + public function __construct(string $requiredPhpVersion) { $this->requiredPhpVersion = $requiredPhpVersion; } - public function __invoke() + public function __invoke() : bool { - return Semver::satisfies(\sprintf('%d.%d.%d', \PHP_MAJOR_VERSION, \PHP_MINOR_VERSION, \PHP_RELEASE_VERSION), $this->requiredPhpVersion); + return Semver::satisfies(sprintf('%d.%d.%d', \PHP_MAJOR_VERSION, \PHP_MINOR_VERSION, \PHP_RELEASE_VERSION), $this->requiredPhpVersion); } } diff --git a/.requirement-checker/src/Printer.php b/.requirement-checker/src/Printer.php index 718313377..ce858e33d 100644 --- a/.requirement-checker/src/Printer.php +++ b/.requirement-checker/src/Printer.php @@ -2,13 +2,25 @@ namespace HumbugBox3160\KevinGH\RequirementChecker; +use function array_shift; +use function count; +use function explode; +use function ltrim; +use function min; +use function sprintf; +use function str_pad; +use function str_repeat; +use function strlen; +use function trim; +use function wordwrap; +use const PHP_EOL; final class Printer { - private $styles = array('reset' => "\x1b[0m", 'red' => "\x1b[31m", 'green' => "\x1b[32m", 'yellow' => "\x1b[33m", 'title' => "\x1b[33m", 'error' => "\x1b[37;41m", 'success' => "\x1b[30;42m"); + private $styles = ['reset' => "\x1b[0m", 'red' => "\x1b[31m", 'green' => "\x1b[32m", 'yellow' => "\x1b[33m", 'title' => "\x1b[33m", 'error' => "\x1b[37;41m", 'success' => "\x1b[30;42m"]; private $verbosity; private $supportColors; private $width; - public function __construct($verbosity, $supportColors, $width = null) + public function __construct(int $verbosity, bool $supportColors, ?int $width = null) { if (null === $width) { $terminal = new Terminal(); @@ -18,71 +30,70 @@ public function __construct($verbosity, $supportColors, $width = null) $this->supportColors = $supportColors; $this->width = $width ?: 80; } - public function getVerbosity() + public function getVerbosity() : int { return $this->verbosity; } - public function setVerbosity($verbosity) + public function setVerbosity($verbosity) : void { $this->verbosity = $verbosity; } - public function title($title, $verbosity, $style = null) + public function title(string $title, int $verbosity, ?string $style = null) : void { if (null === $style) { $style = 'title'; } $this->printvln('', $verbosity, $style); $this->printvln($title, $verbosity, $style); - $this->printvln(\str_repeat('=', \min(\strlen($title), $this->width)), $verbosity, $style); + $this->printvln(str_repeat('=', min(strlen($title), $this->width)), $verbosity, $style); $this->printvln('', $verbosity, $style); } - public function getRequirementErrorMessage(Requirement $requirement) + public function getRequirementErrorMessage(Requirement $requirement) : ?string { if ($requirement->isFulfilled()) { return null; } - $errorMessage = \wordwrap($requirement->getTestMessage(), $this->width - 3, \PHP_EOL . ' ') . \PHP_EOL; - return $errorMessage; + return wordwrap($requirement->getTestMessage(), $this->width - 3, PHP_EOL . ' ') . PHP_EOL; } - public function block($title, $message, $verbosity, $style = null) + public function block(string $title, string $message, int $verbosity, ?string $style = null) : void { $prefix = ' [' . $title . '] '; - $lineLength = $this->width - \strlen($prefix) - 1; + $lineLength = $this->width - strlen($prefix) - 1; if ($lineLength < 0) { $lineLength = 0; } - $message = $prefix . \trim($message); - $lines = array(); + $message = $prefix . trim($message); + $lines = []; $remainingMessage = $message; - $wrapped = \wordwrap($remainingMessage, $lineLength, '¬'); - $wrapped = \explode('¬', $wrapped); + $wrapped = wordwrap($remainingMessage, $lineLength, '¬'); + $wrapped = explode('¬', $wrapped); do { - $line = \array_shift($wrapped); + $line = array_shift($wrapped); if ($lines && $lineLength > 0) { - $line = \str_repeat(' ', \strlen($prefix)) . \ltrim($line); + $line = str_repeat(' ', strlen($prefix)) . ltrim($line); } - $lines[] = \str_pad($line, $this->width, ' ', \STR_PAD_RIGHT); - } while (\count($wrapped)); + $lines[] = str_pad($line, $this->width, ' ', \STR_PAD_RIGHT); + } while (count($wrapped)); $this->printvln('', $verbosity); - $this->printvln(\str_repeat(' ', $this->width), $verbosity, $style); + $this->printvln(str_repeat(' ', $this->width), $verbosity, $style); foreach ($lines as $line) { $this->printvln($line, $verbosity, $style); } - $this->printv(\str_repeat(' ', $this->width), $verbosity, $style); + $this->printv(str_repeat(' ', $this->width), $verbosity, $style); $this->printvln('', $verbosity); } - public function printvln($message, $verbosity, $style = null) + public function printvln(string $message, int $verbosity, ?string $style = null) : void { $this->printv($message, $verbosity, $style); - $this->printv(\PHP_EOL, $verbosity, null); + $this->printv(PHP_EOL, $verbosity, null); } - public function printv($message, $verbosity, $style = null) + public function printv(string $message, int $verbosity, ?string $style = null) : void { if ($verbosity > $this->verbosity) { return; } - $message = \wordwrap($message, $this->width); - $message = \sprintf('%s%s%s', $this->supportColors && isset($this->styles[$style]) ? $this->styles[$style] : '', $message, $this->supportColors ? $this->styles['reset'] : ''); + $message = wordwrap($message, $this->width); + $message = sprintf('%s%s%s', $this->supportColors && isset($this->styles[$style]) ? $this->styles[$style] : '', $message, $this->supportColors ? $this->styles['reset'] : ''); echo $message; } } diff --git a/.requirement-checker/src/Requirement.php b/.requirement-checker/src/Requirement.php index dd0adab10..0a70a2138 100644 --- a/.requirement-checker/src/Requirement.php +++ b/.requirement-checker/src/Requirement.php @@ -8,28 +8,28 @@ final class Requirement private $fulfilled; private $testMessage; private $helpText; - public function __construct($checkIsFulfilled, $testMessage, $helpText) + public function __construct(IsFulfilled $checkIsFulfilled, string $testMessage, string $helpText) { $this->checkIsFulfilled = $checkIsFulfilled; $this->testMessage = $testMessage; $this->helpText = $helpText; } - public function isFulfilled() + public function isFulfilled() : bool { - if (null === $this->fulfilled) { + if (!isset($this->fulfilled)) { $this->fulfilled = $this->checkIsFulfilled->__invoke(); } - return (bool) $this->fulfilled; + return $this->fulfilled; } - public function getIsFullfilledChecker() + public function getIsFullfilledChecker() : IsFulfilled { return $this->checkIsFulfilled; } - public function getTestMessage() + public function getTestMessage() : string { return $this->testMessage; } - public function getHelpText() + public function getHelpText() : string { return $this->helpText; } diff --git a/.requirement-checker/src/RequirementCollection.php b/.requirement-checker/src/RequirementCollection.php index 82eb089e3..fab369e54 100644 --- a/.requirement-checker/src/RequirementCollection.php +++ b/.requirement-checker/src/RequirementCollection.php @@ -5,40 +5,39 @@ use ArrayIterator; use Countable; use IteratorAggregate; -use ReturnTypeWillChange; use Traversable; +use function count; +use function get_cfg_var; final class RequirementCollection implements IteratorAggregate, Countable { - private $requirements = array(); - #[\ReturnTypeWillChange] - public function getIterator() + private $requirements = []; + public function getIterator() : Traversable { return new ArrayIterator($this->requirements); } - #[\ReturnTypeWillChange] - public function count() + public function count() : int { - return \count($this->requirements); + return count($this->requirements); } - public function add(Requirement $requirement) + public function add(Requirement $requirement) : void { $this->requirements[] = $requirement; } - public function addRequirement($checkIsFulfilled, $testMessage, $helpText) + public function addRequirement(IsFulfilled $checkIsFulfilled, string $testMessage, string $helpText) : void { $this->add(new Requirement($checkIsFulfilled, $testMessage, $helpText)); } - public function getRequirements() + public function getRequirements() : array { return $this->requirements; } public function getPhpIniPath() { - return \get_cfg_var('cfg_file_path'); + return get_cfg_var('cfg_file_path'); } public function evaluateRequirements() { - return \array_reduce($this->requirements, function ($checkPassed, Requirement $requirement) { + return \array_reduce($this->requirements, function (bool $checkPassed, Requirement $requirement) : bool { return $checkPassed && $requirement->isFulfilled(); }, \true); } diff --git a/.requirement-checker/src/Terminal.php b/.requirement-checker/src/Terminal.php index 04d313e33..317133d08 100644 --- a/.requirement-checker/src/Terminal.php +++ b/.requirement-checker/src/Terminal.php @@ -2,48 +2,61 @@ namespace HumbugBox3160\KevinGH\RequirementChecker; +use function exec; +use function fclose; +use function fopen; +use function function_exists; +use function getenv; +use function is_resource; +use function preg_match; +use function proc_close; +use function proc_open; +use function sapi_windows_vt100_support; +use function stream_get_contents; +use function trim; +use const DIRECTORY_SEPARATOR; class Terminal { private static $width; private static $height; private static $stty; - public function getWidth() + public function getWidth() : int { - $width = \getenv('COLUMNS'); + $width = getenv('COLUMNS'); if (\false !== $width) { - return (int) \trim($width); + return (int) trim($width); } - if (null === self::$width) { + if (!isset(self::$width)) { self::initDimensions(); } return self::$width ?: 80; } - public function getHeight() + public function getHeight() : int { - $height = \getenv('LINES'); + $height = getenv('LINES'); if (\false !== $height) { - return (int) \trim($height); + return (int) trim($height); } - if (null === self::$height) { + if (!isset(self::$height)) { self::initDimensions(); } return self::$height ?: 50; } - public static function hasSttyAvailable() + public static function hasSttyAvailable() : bool { - if (null !== self::$stty) { + if (isset(self::$stty)) { return self::$stty; } - if (!\function_exists('exec')) { + if (!function_exists('exec')) { return \false; } - \exec('stty 2>&1', $output, $exitcode); + exec('stty 2>&1', $output, $exitcode); return self::$stty = 0 === $exitcode; } - private static function initDimensions() + private static function initDimensions() : void { - if ('\\' === \DIRECTORY_SEPARATOR) { - if (\preg_match('/^(\\d+)x(\\d+)(?: \\((\\d+)x(\\d+)\\))?$/', \trim(\getenv('ANSICON')), $matches)) { + if ('\\' === DIRECTORY_SEPARATOR) { + if (preg_match('/^(\\d+)x(\\d+)(?: \\((\\d+)x(\\d+)\\))?$/', trim(getenv('ANSICON')), $matches)) { self::$width = (int) $matches[1]; self::$height = isset($matches[4]) ? (int) $matches[4] : (int) $matches[2]; } elseif (!self::hasVt100Support() && self::hasSttyAvailable()) { @@ -56,48 +69,48 @@ private static function initDimensions() self::initDimensionsUsingStty(); } } - private static function hasVt100Support() + private static function hasVt100Support() : bool { - return \function_exists('sapi_windows_vt100_support') && \sapi_windows_vt100_support(\fopen('php://stdout', 'wb')); + return function_exists('sapi_windows_vt100_support') && sapi_windows_vt100_support(fopen('php://stdout', 'wb')); } - private static function initDimensionsUsingStty() + private static function initDimensionsUsingStty() : void { if ($sttyString = self::getSttyColumns()) { - if (\preg_match('/rows.(\\d+);.columns.(\\d+);/i', $sttyString, $matches)) { + if (preg_match('/rows.(\\d+);.columns.(\\d+);/i', $sttyString, $matches)) { self::$width = (int) $matches[2]; self::$height = (int) $matches[1]; - } elseif (\preg_match('/;.(\\d+).rows;.(\\d+).columns/i', $sttyString, $matches)) { + } elseif (preg_match('/;.(\\d+).rows;.(\\d+).columns/i', $sttyString, $matches)) { self::$width = (int) $matches[2]; self::$height = (int) $matches[1]; } } } - private static function getConsoleMode() + private static function getConsoleMode() : ?array { $info = self::readFromProcess('mode CON'); - if (null === $info || !\preg_match('/--------+\\r?\\n.+?(\\d+)\\r?\\n.+?(\\d+)\\r?\\n/', $info, $matches)) { + if (null === $info || !preg_match('/--------+\\r?\\n.+?(\\d+)\\r?\\n.+?(\\d+)\\r?\\n/', $info, $matches)) { return null; } return array((int) $matches[2], (int) $matches[1]); } - private static function getSttyColumns() + private static function getSttyColumns() : ?string { return self::readFromProcess('stty -a | grep columns'); } - private static function readFromProcess($command) + private static function readFromProcess(string $command) : ?string { - if (!\function_exists('proc_open')) { + if (!function_exists('proc_open')) { return null; } - $descriptorspec = array(1 => array('pipe', 'w'), 2 => array('pipe', 'w')); - $process = \proc_open($command, $descriptorspec, $pipes, null, null, array('suppress_errors' => \true)); - if (!\is_resource($process)) { + $descriptorspec = [1 => ['pipe', 'w'], 2 => ['pipe', 'w']]; + $process = proc_open($command, $descriptorspec, $pipes, null, null, ['suppress_errors' => \true]); + if (!is_resource($process)) { return null; } - $info = \stream_get_contents($pipes[1]); - \fclose($pipes[1]); - \fclose($pipes[2]); - \proc_close($process); + $info = stream_get_contents($pipes[1]); + fclose($pipes[1]); + fclose($pipes[2]); + proc_close($process); return $info; } } diff --git a/.requirement-checker/vendor/autoload.php b/.requirement-checker/vendor/autoload.php index 0d3ff9b5f..c2df50a28 100644 --- a/.requirement-checker/vendor/autoload.php +++ b/.requirement-checker/vendor/autoload.php @@ -2,6 +2,11 @@ // autoload.php @generated by Composer +if (PHP_VERSION_ID < 50600) { + echo 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL; + exit(1); +} + require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInit7483a8755c1da229c4754f7d15655976::getLoader(); +return ComposerAutoloaderInitc3988cc2cd530688db10eca392dd6bba::getLoader(); diff --git a/.requirement-checker/vendor/composer/autoload_classmap.php b/.requirement-checker/vendor/composer/autoload_classmap.php index 0991a8b17..223be763b 100644 --- a/.requirement-checker/vendor/composer/autoload_classmap.php +++ b/.requirement-checker/vendor/composer/autoload_classmap.php @@ -2,7 +2,7 @@ // autoload_classmap.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/.requirement-checker/vendor/composer/autoload_namespaces.php b/.requirement-checker/vendor/composer/autoload_namespaces.php index b7fc0125d..15a2ff3ad 100644 --- a/.requirement-checker/vendor/composer/autoload_namespaces.php +++ b/.requirement-checker/vendor/composer/autoload_namespaces.php @@ -2,7 +2,7 @@ // autoload_namespaces.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/.requirement-checker/vendor/composer/autoload_psr4.php b/.requirement-checker/vendor/composer/autoload_psr4.php index eb6c66322..c3b25d6f1 100644 --- a/.requirement-checker/vendor/composer/autoload_psr4.php +++ b/.requirement-checker/vendor/composer/autoload_psr4.php @@ -2,7 +2,7 @@ // autoload_psr4.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/.requirement-checker/vendor/composer/autoload_real.php b/.requirement-checker/vendor/composer/autoload_real.php index 4d607b3c4..68f084908 100644 --- a/.requirement-checker/vendor/composer/autoload_real.php +++ b/.requirement-checker/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit7483a8755c1da229c4754f7d15655976 +class ComposerAutoloaderInitc3988cc2cd530688db10eca392dd6bba { private static $loader; @@ -22,21 +22,12 @@ public static function getLoader() return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit7483a8755c1da229c4754f7d15655976', 'loadClassLoader'), true, true); - self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__))); - spl_autoload_unregister(array('ComposerAutoloaderInit7483a8755c1da229c4754f7d15655976', 'loadClassLoader')); + spl_autoload_register(array('ComposerAutoloaderInitc3988cc2cd530688db10eca392dd6bba', 'loadClassLoader'), true, true); + self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); + spl_autoload_unregister(array('ComposerAutoloaderInitc3988cc2cd530688db10eca392dd6bba', 'loadClassLoader')); - $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); - if ($useStaticLoader) { - require __DIR__ . '/autoload_static.php'; - - call_user_func(\Composer\Autoload\ComposerStaticInit7483a8755c1da229c4754f7d15655976::getInitializer($loader)); - } else { - $classMap = require __DIR__ . '/autoload_classmap.php'; - if ($classMap) { - $loader->addClassMap($classMap); - } - } + require __DIR__ . '/autoload_static.php'; + call_user_func(\Composer\Autoload\ComposerStaticInitc3988cc2cd530688db10eca392dd6bba::getInitializer($loader)); $loader->setClassMapAuthoritative(true); $loader->register(true); diff --git a/.requirement-checker/vendor/composer/autoload_static.php b/.requirement-checker/vendor/composer/autoload_static.php index 79b593377..78c45bb55 100644 --- a/.requirement-checker/vendor/composer/autoload_static.php +++ b/.requirement-checker/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInit7483a8755c1da229c4754f7d15655976 +class ComposerStaticInitc3988cc2cd530688db10eca392dd6bba { public static $prefixLengthsPsr4 = array ( 'H' => @@ -53,9 +53,9 @@ class ComposerStaticInit7483a8755c1da229c4754f7d15655976 public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInit7483a8755c1da229c4754f7d15655976::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInit7483a8755c1da229c4754f7d15655976::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInit7483a8755c1da229c4754f7d15655976::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInitc3988cc2cd530688db10eca392dd6bba::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInitc3988cc2cd530688db10eca392dd6bba::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInitc3988cc2cd530688db10eca392dd6bba::$classMap; }, null, ClassLoader::class); } diff --git a/.requirement-checker/vendor/composer/semver/src/VersionParser.php b/.requirement-checker/vendor/composer/semver/src/VersionParser.php index aac114f92..0d0cd847d 100644 --- a/.requirement-checker/vendor/composer/semver/src/VersionParser.php +++ b/.requirement-checker/vendor/composer/semver/src/VersionParser.php @@ -15,7 +15,7 @@ class VersionParser */ public static function parseStability($version) { - $version = (string) \preg_replace('{#.+$}', '', $version); + $version = (string) \preg_replace('{#.+$}', '', (string) $version); if (\strpos($version, 'dev-') === 0 || '-dev' === \substr($version, -4)) { return 'dev'; } @@ -38,12 +38,12 @@ public static function parseStability($version) } public static function normalizeStability($stability) { - $stability = \strtolower($stability); + $stability = \strtolower((string) $stability); return $stability === 'rc' ? 'RC' : $stability; } public function normalize($version, $fullVersion = null) { - $version = \trim($version); + $version = \trim((string) $version); $origVersion = $version; if (null === $fullVersion) { $fullVersion = $version; @@ -101,14 +101,14 @@ public function normalize($version, $fullVersion = null) } public function parseNumericAliasPrefix($branch) { - if (\preg_match('{^(?P(\\d++\\.)*\\d++)(?:\\.x)?-dev$}i', $branch, $matches)) { + if (\preg_match('{^(?P(\\d++\\.)*\\d++)(?:\\.x)?-dev$}i', (string) $branch, $matches)) { return $matches['version'] . '.'; } return \false; } public function normalizeBranch($name) { - $name = \trim($name); + $name = \trim((string) $name); if (\preg_match('{^v?(\\d++)(\\.(?:\\d++|[xX*]))?(\\.(?:\\d++|[xX*]))?(\\.(?:\\d++|[xX*]))?$}i', $name, $matches)) { $version = ''; for ($i = 1; $i < 5; ++$i) { @@ -123,12 +123,12 @@ public function normalizeDefaultBranch($name) if ($name === 'dev-master' || $name === 'dev-default' || $name === 'dev-trunk') { return '9999999-dev'; } - return $name; + return (string) $name; } public function parseConstraints($constraints) { - $prettyConstraint = $constraints; - $orConstraints = \preg_split('{\\s*\\|\\|?\\s*}', \trim($constraints)); + $prettyConstraint = (string) $constraints; + $orConstraints = \preg_split('{\\s*\\|\\|?\\s*}', \trim((string) $constraints)); if (\false === $orConstraints) { throw new \RuntimeException('Failed to preg_split string: ' . $constraints); } diff --git a/Makefile b/Makefile index c01ab8935..e64e39e36 100644 --- a/Makefile +++ b/Makefile @@ -70,7 +70,7 @@ tu_requirement_checker: ## Runs the unit tests tu_requirement_checker: requirement-checker/bin/phpunit requirement-checker/actual_terminal_diff cd requirement-checker && $(PHPNOGC) bin/phpunit - diff --side-by-side --suppress-common-lines requirement-checker/expected_terminal_diff requirement-checker/actual_terminal_diff + diff --ignore-all-space --side-by-side --suppress-common-lines requirement-checker/expected_terminal_diff requirement-checker/actual_terminal_diff .PHONY: tc tc: ## Runs the unit tests with code coverage @@ -101,13 +101,13 @@ e2e_scoper_expose_symbols: box fixtures/build/dir011/vendor php fixtures/build/dir011/index.phar > fixtures/build/dir011/output cd fixtures/build/dir011 && php -r "file_put_contents('phar-Y.php', file_get_contents((new Phar('index.phar'))['src/Y.php']));" - diff --side-by-side --suppress-common-lines fixtures/build/dir011/expected-output fixtures/build/dir011/output - diff --side-by-side --suppress-common-lines fixtures/build/dir011/phar-Y.php fixtures/build/dir011/src/Y.php + diff --ignore-all-space --side-by-side --suppress-common-lines fixtures/build/dir011/expected-output fixtures/build/dir011/output + diff --ignore-all-space --side-by-side --suppress-common-lines fixtures/build/dir011/phar-Y.php fixtures/build/dir011/src/Y.php .PHONY: e2e_check_requirements DOCKER=docker run -i --platform linux/amd64 --rm -w /opt/box -PHP5_BOX=box_php53 -PHP5_PHAR=$(PHP5_BOX) php index.phar -vvv --no-ansi +PHP_COMPOSER_MIN_BOX=box_php725 +PHP_COMPOSER_MIN_PHAR=$(PHP_COMPOSER_MIN_BOX) php index.phar -vvv --no-ansi MIN_SUPPORTED_PHP_BOX=box_php81 MIN_SUPPORTED_PHP_WITH_XDEBUG_BOX=box_php81_xdebug MIN_SUPPORTED_PHP_PHAR=$(MIN_SUPPORTED_PHP_BOX) php index.phar -vvv --no-ansi @@ -121,14 +121,14 @@ e2e_check_requirements: box .requirement-checker ./box compile --working-dir=fixtures/check-requirements/pass-no-config/ - # 5.3 - sed "s/PHP_VERSION/$$($(DOCKER) $(PHP5_BOX) php -r 'echo PHP_VERSION;')/" \ - fixtures/check-requirements/pass-no-config/expected-output-53-dist \ - > fixtures/check-requirements/pass-no-config/expected-output-53 + # Composer min version + sed "s/PHP_VERSION/$$($(DOCKER) $(PHP_COMPOSER_MIN_BOX) php -r 'echo PHP_VERSION;')/" \ + fixtures/check-requirements/pass-no-config/expected-output-725-dist \ + > fixtures/check-requirements/pass-no-config/expected-output-725 rm fixtures/check-requirements/pass-no-config/actual-output || true - $(DOCKER) -v "$$PWD/fixtures/check-requirements/pass-no-config":/opt/box $(PHP5_PHAR) | tee fixtures/check-requirements/pass-no-config/actual-output - diff --side-by-side --suppress-common-lines fixtures/check-requirements/pass-no-config/expected-output-53 fixtures/check-requirements/pass-no-config/actual-output + $(DOCKER) -v "$$PWD/fixtures/check-requirements/pass-no-config":/opt/box $(PHP_COMPOSER_MIN_PHAR) | tee fixtures/check-requirements/pass-no-config/actual-output + diff --ignore-all-space --side-by-side --suppress-common-lines fixtures/check-requirements/pass-no-config/expected-output-725 fixtures/check-requirements/pass-no-config/actual-output # Current min version sed "s/PHP_VERSION/$$($(DOCKER) $(MIN_SUPPORTED_PHP_BOX) php -r 'echo PHP_VERSION;')/" \ @@ -137,7 +137,7 @@ e2e_check_requirements: box .requirement-checker rm fixtures/check-requirements/pass-no-config/actual-output || true $(DOCKER) -v "$$PWD/fixtures/check-requirements/pass-no-config":/opt/box $(MIN_SUPPORTED_PHP_PHAR) | tee fixtures/check-requirements/pass-no-config/actual-output - diff --side-by-side --suppress-common-lines fixtures/check-requirements/pass-no-config/expected-output-current-min-php fixtures/check-requirements/pass-no-config/actual-output + diff --ignore-all-space --side-by-side --suppress-common-lines fixtures/check-requirements/pass-no-config/expected-output-current-min-php fixtures/check-requirements/pass-no-config/actual-output # # Pass complete @@ -145,14 +145,14 @@ e2e_check_requirements: box .requirement-checker ./box compile --working-dir=fixtures/check-requirements/pass-complete/ - # 5.3 - sed "s/PHP_VERSION/$$($(DOCKER) $(PHP5_BOX) php -r 'echo PHP_VERSION;')/" \ - fixtures/check-requirements/pass-complete/expected-output-53-dist \ - > fixtures/check-requirements/pass-complete/expected-output-53 + # Composer min version + sed "s/PHP_VERSION/$$($(DOCKER) $(PHP_COMPOSER_MIN_BOX) php -r 'echo PHP_VERSION;')/" \ + fixtures/check-requirements/pass-complete/expected-output-725-dist \ + > fixtures/check-requirements/pass-complete/expected-output-725 rm fixtures/check-requirements/pass-complete/actual-output || true - $(DOCKER) -v "$$PWD/fixtures/check-requirements/pass-complete":/opt/box $(PHP5_PHAR) | tee fixtures/check-requirements/pass-complete/actual-output - diff --side-by-side --suppress-common-lines fixtures/check-requirements/pass-complete/expected-output-53 fixtures/check-requirements/pass-complete/actual-output + $(DOCKER) -v "$$PWD/fixtures/check-requirements/pass-complete":/opt/box $(PHP_COMPOSER_MIN_PHAR) | tee fixtures/check-requirements/pass-complete/actual-output + diff --ignore-all-space --side-by-side --suppress-common-lines fixtures/check-requirements/pass-complete/expected-output-725 fixtures/check-requirements/pass-complete/actual-output # Current min version sed "s/PHP_VERSION/$$($(DOCKER) $(MIN_SUPPORTED_PHP_BOX) php -r 'echo PHP_VERSION;')/" \ @@ -161,7 +161,7 @@ e2e_check_requirements: box .requirement-checker rm fixtures/check-requirements/pass-complete/actual-output || true $(DOCKER) -v "$$PWD/fixtures/check-requirements/pass-complete":/opt/box $(MIN_SUPPORTED_PHP_PHAR) | tee fixtures/check-requirements/pass-complete/actual-output - diff --side-by-side --suppress-common-lines fixtures/check-requirements/pass-complete/expected-output-current-min-php fixtures/check-requirements/pass-complete/actual-output + diff --ignore-all-space --side-by-side --suppress-common-lines fixtures/check-requirements/pass-complete/expected-output-current-min-php fixtures/check-requirements/pass-complete/actual-output # # Fail complete @@ -169,14 +169,14 @@ e2e_check_requirements: box .requirement-checker ./box compile --working-dir=fixtures/check-requirements/fail-complete/ - # 5.3 - sed "s/PHP_VERSION/$$($(DOCKER) $(PHP5_BOX) php -r 'echo PHP_VERSION;')/" \ - fixtures/check-requirements/fail-complete/expected-output-53-dist \ - > fixtures/check-requirements/fail-complete/expected-output-53 + # Composer min version + sed "s/PHP_VERSION/$$($(DOCKER) $(PHP_COMPOSER_MIN_BOX) php -r 'echo PHP_VERSION;')/" \ + fixtures/check-requirements/fail-complete/expected-output-725-dist \ + > fixtures/check-requirements/fail-complete/expected-output-725 rm fixtures/check-requirements/fail-complete/actual-output || true - $(DOCKER) -v "$$PWD/fixtures/check-requirements/fail-complete":/opt/box $(PHP5_PHAR) | tee fixtures/check-requirements/fail-complete/actual-output || true - diff --side-by-side --suppress-common-lines fixtures/check-requirements/fail-complete/expected-output-53 fixtures/check-requirements/fail-complete/actual-output + $(DOCKER) -v "$$PWD/fixtures/check-requirements/fail-complete":/opt/box $(PHP_COMPOSER_MIN_PHAR) | tee fixtures/check-requirements/fail-complete/actual-output || true + diff --ignore-all-space --side-by-side --suppress-common-lines fixtures/check-requirements/fail-complete/expected-output-725 fixtures/check-requirements/fail-complete/actual-output # Current min version sed "s/PHP_VERSION/$$($(DOCKER) $(MIN_SUPPORTED_PHP_BOX) php -r 'echo PHP_VERSION;')/" \ @@ -185,7 +185,7 @@ e2e_check_requirements: box .requirement-checker rm fixtures/check-requirements/fail-complete/actual-output || true $(DOCKER) -v "$$PWD/fixtures/check-requirements/fail-complete":/opt/box $(MIN_SUPPORTED_PHP_PHAR) | tee fixtures/check-requirements/fail-complete/actual-output || true - diff --side-by-side --suppress-common-lines fixtures/check-requirements/fail-complete/expected-output-current-min-php fixtures/check-requirements/fail-complete/actual-output + diff --ignore-all-space --side-by-side --suppress-common-lines fixtures/check-requirements/fail-complete/expected-output-current-min-php fixtures/check-requirements/fail-complete/actual-output # # Skip the requirement check @@ -193,13 +193,13 @@ e2e_check_requirements: box .requirement-checker ./box compile --working-dir=fixtures/check-requirements/fail-complete/ - sed "s/PHP_VERSION/$$($(DOCKER) $(PHP5_BOX) php -r 'echo PHP_VERSION;')/" \ - fixtures/check-requirements/fail-complete/expected-output-53-dist-skipped \ - > fixtures/check-requirements/fail-complete/expected-output-53 + sed "s/PHP_VERSION/$$($(DOCKER) $(PHP_COMPOSER_MIN_BOX) php -r 'echo PHP_VERSION;')/" \ + fixtures/check-requirements/fail-complete/expected-output-725-dist-skipped \ + > fixtures/check-requirements/fail-complete/expected-output-725 rm fixtures/check-requirements/fail-complete/actual-output || true - $(DOCKER) -e BOX_REQUIREMENT_CHECKER=0 -v "$$PWD/fixtures/check-requirements/fail-complete":/opt/box $(PHP5_PHAR) | tee fixtures/check-requirements/fail-complete/actual-output || true - diff --side-by-side --suppress-common-lines fixtures/check-requirements/fail-complete/expected-output-53 fixtures/check-requirements/fail-complete/actual-output + $(DOCKER) -e BOX_REQUIREMENT_CHECKER=0 -v "$$PWD/fixtures/check-requirements/fail-complete":/opt/box $(PHP_COMPOSER_MIN_PHAR) | tee fixtures/check-requirements/fail-complete/actual-output || true + diff --ignore-all-space --side-by-side --suppress-common-lines fixtures/check-requirements/fail-complete/expected-output-725 fixtures/check-requirements/fail-complete/actual-output BOX_COMPILE=./box compile --working-dir=fixtures/php-settings-checker -vvv --no-ansi ifeq ($(OS),Darwin) @@ -217,7 +217,7 @@ e2e_php_settings_checker: docker-images fixtures/php-settings-checker/output-xde | grep '\[debug\]' \ | tee fixtures/php-settings-checker/actual-output || true $(SED) "s/Xdebug/xdebug/" fixtures/php-settings-checker/actual-output - diff --side-by-side --suppress-common-lines fixtures/php-settings-checker/output-all-clear fixtures/php-settings-checker/actual-output + diff --ignore-all-space --side-by-side --suppress-common-lines fixtures/php-settings-checker/output-all-clear fixtures/php-settings-checker/actual-output @echo "$(CCYELLOW)Xdebug enabled: restart needed$(CCEND)" $(DOCKER) -v "$$PWD":/opt/box $(MIN_SUPPORTED_PHP_BOX)_xdebug \ @@ -227,7 +227,7 @@ e2e_php_settings_checker: docker-images fixtures/php-settings-checker/output-xde | tee fixtures/php-settings-checker/actual-output || true $(SED) "s/Xdebug/xdebug/" fixtures/php-settings-checker/actual-output $(SED) "s/[0-9]* ms/100 ms/" fixtures/php-settings-checker/actual-output - diff --side-by-side --suppress-common-lines fixtures/php-settings-checker/output-xdebug-enabled fixtures/php-settings-checker/actual-output + diff --ignore-all-space --side-by-side --suppress-common-lines fixtures/php-settings-checker/output-xdebug-enabled fixtures/php-settings-checker/actual-output @echo "$(CCYELLOW)phar.readonly enabled: restart needed$(CCEND)" $(DOCKER) -v "$$PWD":/opt/box $(MIN_SUPPORTED_PHP_BOX) \ @@ -238,7 +238,7 @@ e2e_php_settings_checker: docker-images fixtures/php-settings-checker/output-xde $(SED) "s/Xdebug/xdebug/" fixtures/php-settings-checker/actual-output $(SED) "s/'-c' '.*' '\.\/box'/'-c' '\/tmp-file' 'bin\/box'/" fixtures/php-settings-checker/actual-output $(SED) "s/[0-9]* ms/100 ms/" fixtures/php-settings-checker/actual-output - diff --side-by-side --suppress-common-lines fixtures/php-settings-checker/output-pharreadonly-enabled fixtures/php-settings-checker/actual-output + diff --ignore-all-space --side-by-side --suppress-common-lines fixtures/php-settings-checker/output-pharreadonly-enabled fixtures/php-settings-checker/actual-output @echo "$(CCYELLOW)Bump min memory limit if necessary (limit lower than default)$(CCEND)" $(DOCKER) -v "$$PWD":/opt/box $(MIN_SUPPORTED_PHP_BOX) \ @@ -249,7 +249,7 @@ e2e_php_settings_checker: docker-images fixtures/php-settings-checker/output-xde $(SED) "s/Xdebug/xdebug/" fixtures/php-settings-checker/actual-output $(SED) "s/'-c' '.*' '\.\/box'/'-c' '\/tmp-file' 'bin\/box'/" fixtures/php-settings-checker/actual-output $(SED) "s/[0-9]* ms/100 ms/" fixtures/php-settings-checker/actual-output - diff --side-by-side --suppress-common-lines fixtures/php-settings-checker/output-min-memory-limit fixtures/php-settings-checker/actual-output + diff --ignore-all-space --side-by-side --suppress-common-lines fixtures/php-settings-checker/output-min-memory-limit fixtures/php-settings-checker/actual-output @echo "$(CCYELLOW)Bump min memory limit if necessary (limit higher than default)$(CCEND)" $(DOCKER) -e BOX_MEMORY_LIMIT=64M -v "$$PWD":/opt/box $(MIN_SUPPORTED_PHP_BOX) \ @@ -260,7 +260,7 @@ e2e_php_settings_checker: docker-images fixtures/php-settings-checker/output-xde $(SED) "s/Xdebug/xdebug/" fixtures/php-settings-checker/actual-output $(SED) "s/'-c' '.*' '\.\/box'/'-c' '\/tmp-file' 'bin\/box'/" fixtures/php-settings-checker/actual-output $(SED) "s/[0-9]* ms/100 ms/" fixtures/php-settings-checker/actual-output - diff --side-by-side --suppress-common-lines fixtures/php-settings-checker/output-set-memory-limit fixtures/php-settings-checker/actual-output + diff --ignore-all-space --side-by-side --suppress-common-lines fixtures/php-settings-checker/output-set-memory-limit fixtures/php-settings-checker/actual-output .PHONY: e2e_symfony e2e_symfony: ## Packages a fresh Symfony app @@ -274,7 +274,7 @@ e2e_symfony: fixtures/build/dir012/vendor box php fixtures/build/dir012/bin/console.phar --version > fixtures/build/dir012/actual-output - diff --side-by-side --suppress-common-lines fixtures/build/dir012/expected-output fixtures/build/dir012/actual-output + diff --ignore-all-space --side-by-side --suppress-common-lines fixtures/build/dir012/expected-output fixtures/build/dir012/actual-output .PHONY: e2e_composer_installed_versions e2e_composer_installed_versions: ## Packages an app using Composer\InstalledVersions @@ -283,7 +283,7 @@ e2e_composer_installed_versions: fixtures/build/dir013/vendor box php fixtures/build/dir013/bin/run.phar > fixtures/build/dir013/actual-output - diff --side-by-side --suppress-common-lines fixtures/build/dir013/expected-output fixtures/build/dir013/actual-output + diff --ignore-all-space --side-by-side --suppress-common-lines fixtures/build/dir013/expected-output fixtures/build/dir013/actual-output .PHONY: e2e_phpstorm_stubs e2e_phpstorm_stubs: ## Project using symbols which should be vetted by PhpStormStubs @@ -389,7 +389,7 @@ fixtures/default_stub.php: touch $@ requirement-checker/actual_terminal_diff: requirement-checker/src/Terminal.php vendor/symfony/console/Terminal.php - (diff --side-by-side --suppress-common-lines vendor/symfony/console/Terminal.php requirement-checker/src/Terminal.php || true) > requirement-checker/actual_terminal_diff + (diff --ignore-all-space --side-by-side --suppress-common-lines vendor/symfony/console/Terminal.php requirement-checker/src/Terminal.php || true) > requirement-checker/actual_terminal_diff tests/Console/DisplayNormalizer.php: vendor vendor/symfony/console/Terminal.php: vendor diff --git a/doc/requirement-checker.md b/doc/requirement-checker.md index 265c2361c..e659635ae 100644 --- a/doc/requirement-checker.md +++ b/doc/requirement-checker.md @@ -120,8 +120,8 @@ require the requirement checker script `.box/check_requirements.php` like so: require 'phar://acme.phar/.box/check_requirements.php'; ``` -The requirement checker works down to PHP 5.3+. If however you are including it after your custom code which is not -PHP 5.3+ compatible, it will fail before the requirements are being checked. +The requirement checker works down to PHP 7.2.5+. If however you are including it after your custom code which is not +PHP 7.2.5+ compatible, it will fail before the requirements are being checked. ## Skipping the requirement checker diff --git a/fixtures/check-requirements/fail-complete/expected-output-53-dist-skipped b/fixtures/check-requirements/fail-complete/expected-output-53-dist-skipped deleted file mode 100644 index 2f28dce33..000000000 --- a/fixtures/check-requirements/fail-complete/expected-output-53-dist-skipped +++ /dev/null @@ -1,6 +0,0 @@ - -Fatal error: Uncaught exception 'Exception' with message 'Should not be executed!' in phar:///opt/box/index.phar/index.php:13 -Stack trace: -#0 /opt/box/index.phar(14): require() -#1 {main} - thrown in phar:///opt/box/index.phar/index.php on line 13 diff --git a/fixtures/check-requirements/fail-complete/expected-output-53-dist b/fixtures/check-requirements/fail-complete/expected-output-725-dist similarity index 99% rename from fixtures/check-requirements/fail-complete/expected-output-53-dist rename to fixtures/check-requirements/fail-complete/expected-output-725-dist index c7c03f606..c709ce90a 100644 --- a/fixtures/check-requirements/fail-complete/expected-output-53-dist +++ b/fixtures/check-requirements/fail-complete/expected-output-725-dist @@ -14,7 +14,7 @@ Box Requirements Checker it or install a polyfill. ✘ The package "package-with-extensions" requires the extension "random". Enable it or install a polyfill. - + [ERROR] Your system is not ready to run the application. diff --git a/fixtures/check-requirements/fail-complete/expected-output-725-dist-skipped b/fixtures/check-requirements/fail-complete/expected-output-725-dist-skipped new file mode 100644 index 000000000..3390985ed --- /dev/null +++ b/fixtures/check-requirements/fail-complete/expected-output-725-dist-skipped @@ -0,0 +1,6 @@ + +Fatal error: Uncaught Exception: Should not be executed! in phar:///opt/box/index.phar/index.php:13 +Stack trace: +#0 /opt/box/index.phar(14): require() +#1 {main} + thrown in phar:///opt/box/index.phar/index.php on line 13 diff --git a/fixtures/check-requirements/pass-complete/expected-output-53-dist b/fixtures/check-requirements/pass-complete/expected-output-725-dist similarity index 100% rename from fixtures/check-requirements/pass-complete/expected-output-53-dist rename to fixtures/check-requirements/pass-complete/expected-output-725-dist diff --git a/fixtures/check-requirements/pass-no-config/expected-output-53-dist b/fixtures/check-requirements/pass-no-config/expected-output-725-dist similarity index 100% rename from fixtures/check-requirements/pass-no-config/expected-output-53-dist rename to fixtures/check-requirements/pass-no-config/expected-output-725-dist diff --git a/requirement-checker/composer.json b/requirement-checker/composer.json index fbf313632..7c5d9503e 100644 --- a/requirement-checker/composer.json +++ b/requirement-checker/composer.json @@ -25,7 +25,7 @@ }, "require": { - "php": ">=5.3", + "php": ">=7.2.5", "ext-phar": "*", "composer/semver": "^3.2" }, diff --git a/requirement-checker/composer.lock b/requirement-checker/composer.lock index c18f4e656..a31d8f155 100644 --- a/requirement-checker/composer.lock +++ b/requirement-checker/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "fed43b102774195b129bf15f3aeb7a63", + "content-hash": "95d0fce24d70401c31ee9528248eebcb", "packages": [ { "name": "composer/semver", - "version": "3.2.9", + "version": "3.3.2", "source": { "type": "git", "url": "https://github.com/composer/semver.git", - "reference": "a951f614bd64dcd26137bc9b7b2637ddcfc57649" + "reference": "3953f23262f2bff1919fc82183ad9acb13ff62c9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/semver/zipball/a951f614bd64dcd26137bc9b7b2637ddcfc57649", - "reference": "a951f614bd64dcd26137bc9b7b2637ddcfc57649", + "url": "https://api.github.com/repos/composer/semver/zipball/3953f23262f2bff1919fc82183ad9acb13ff62c9", + "reference": "3953f23262f2bff1919fc82183ad9acb13ff62c9", "shasum": "" }, "require": { @@ -69,7 +69,7 @@ "support": { "irc": "irc://irc.freenode.org/composer", "issues": "https://github.com/composer/semver/issues", - "source": "https://github.com/composer/semver/tree/3.2.9" + "source": "https://github.com/composer/semver/tree/3.3.2" }, "funding": [ { @@ -85,35 +85,36 @@ "type": "tidelift" } ], - "time": "2022-02-04T13:58:43+00:00" + "time": "2022-04-01T19:23:25+00:00" } ], "packages-dev": [ { "name": "doctrine/instantiator", - "version": "1.4.0", + "version": "1.4.1", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b" + "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/d56bf6102915de5702778fe20f2de3b2fe570b5b", - "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/10dcfce151b967d20fde1b34ae6640712c3891bc", + "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc", "shasum": "" }, "require": { "php": "^7.1 || ^8.0" }, "require-dev": { - "doctrine/coding-standard": "^8.0", + "doctrine/coding-standard": "^9", "ext-pdo": "*", "ext-phar": "*", - "phpbench/phpbench": "^0.13 || 1.0.0-alpha2", - "phpstan/phpstan": "^0.12", - "phpstan/phpstan-phpunit": "^0.12", - "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" + "phpbench/phpbench": "^0.16 || ^1", + "phpstan/phpstan": "^1.4", + "phpstan/phpstan-phpunit": "^1", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "vimeo/psalm": "^4.22" }, "type": "library", "autoload": { @@ -140,7 +141,7 @@ ], "support": { "issues": "https://github.com/doctrine/instantiator/issues", - "source": "https://github.com/doctrine/instantiator/tree/1.4.0" + "source": "https://github.com/doctrine/instantiator/tree/1.4.1" }, "funding": [ { @@ -156,29 +157,33 @@ "type": "tidelift" } ], - "time": "2020-11-10T18:47:58+00:00" + "time": "2022-03-03T08:28:38+00:00" }, { "name": "myclabs/deep-copy", - "version": "1.10.2", + "version": "1.11.0", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220" + "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/776f831124e9c62e1a2c601ecc52e776d8bb7220", - "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/14daed4296fae74d9e3201d2c4925d1acb7aa614", + "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614", "shasum": "" }, "require": { "php": "^7.1 || ^8.0" }, + "conflict": { + "doctrine/collections": "<1.6.8", + "doctrine/common": "<2.13.3 || >=3,<3.2.2" + }, "require-dev": { - "doctrine/collections": "^1.0", - "doctrine/common": "^2.6", - "phpunit/phpunit": "^7.1" + "doctrine/collections": "^1.6.8", + "doctrine/common": "^2.13.3 || ^3.2.2", + "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" }, "type": "library", "autoload": { @@ -203,7 +208,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.10.2" + "source": "https://github.com/myclabs/DeepCopy/tree/1.11.0" }, "funding": [ { @@ -211,20 +216,20 @@ "type": "tidelift" } ], - "time": "2020-11-13T09:40:50+00:00" + "time": "2022-03-03T13:19:32+00:00" }, { "name": "nikic/php-parser", - "version": "v4.13.2", + "version": "v4.14.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "210577fe3cf7badcc5814d99455df46564f3c077" + "reference": "34bea19b6e03d8153165d8f30bba4c3be86184c1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/210577fe3cf7badcc5814d99455df46564f3c077", - "reference": "210577fe3cf7badcc5814d99455df46564f3c077", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/34bea19b6e03d8153165d8f30bba4c3be86184c1", + "reference": "34bea19b6e03d8153165d8f30bba4c3be86184c1", "shasum": "" }, "require": { @@ -265,9 +270,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.13.2" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.14.0" }, - "time": "2021-11-30T19:35:32+00:00" + "time": "2022-05-31T20:59:12+00:00" }, { "name": "phar-io/manifest", @@ -331,16 +336,16 @@ }, { "name": "phar-io/version", - "version": "3.1.1", + "version": "3.2.1", "source": { "type": "git", "url": "https://github.com/phar-io/version.git", - "reference": "15a90844ad40f127afd244c0cad228de2a80052a" + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/version/zipball/15a90844ad40f127afd244c0cad228de2a80052a", - "reference": "15a90844ad40f127afd244c0cad228de2a80052a", + "url": "https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74", + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74", "shasum": "" }, "require": { @@ -376,9 +381,9 @@ "description": "Library for handling version information and constraints", "support": { "issues": "https://github.com/phar-io/version/issues", - "source": "https://github.com/phar-io/version/tree/3.1.1" + "source": "https://github.com/phar-io/version/tree/3.2.1" }, - "time": "2022-02-07T21:56:48+00:00" + "time": "2022-02-21T01:04:05+00:00" }, { "name": "phpdocumentor/reflection-common", @@ -492,16 +497,16 @@ }, { "name": "phpdocumentor/type-resolver", - "version": "1.6.0", + "version": "1.6.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "93ebd0014cab80c4ea9f5e297ea48672f1b87706" + "reference": "77a32518733312af16a44300404e945338981de3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/93ebd0014cab80c4ea9f5e297ea48672f1b87706", - "reference": "93ebd0014cab80c4ea9f5e297ea48672f1b87706", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/77a32518733312af16a44300404e945338981de3", + "reference": "77a32518733312af16a44300404e945338981de3", "shasum": "" }, "require": { @@ -536,9 +541,9 @@ "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", "support": { "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.6.0" + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.6.1" }, - "time": "2022-01-04T19:58:01+00:00" + "time": "2022-03-15T21:29:03+00:00" }, { "name": "phpspec/prophecy", @@ -609,16 +614,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "9.2.11", + "version": "9.2.15", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "665a1ac0a763c51afc30d6d130dac0813092b17f" + "reference": "2e9da11878c4202f97915c1cb4bb1ca318a63f5f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/665a1ac0a763c51afc30d6d130dac0813092b17f", - "reference": "665a1ac0a763c51afc30d6d130dac0813092b17f", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/2e9da11878c4202f97915c1cb4bb1ca318a63f5f", + "reference": "2e9da11878c4202f97915c1cb4bb1ca318a63f5f", "shasum": "" }, "require": { @@ -674,7 +679,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.11" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.15" }, "funding": [ { @@ -682,7 +687,7 @@ "type": "github" } ], - "time": "2022-02-18T12:46:09+00:00" + "time": "2022-03-07T09:28:20+00:00" }, { "name": "phpunit/php-file-iterator", @@ -927,16 +932,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.5.14", + "version": "9.5.21", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "1883687169c017d6ae37c58883ca3994cfc34189" + "reference": "0e32b76be457de00e83213528f6bb37e2a38fcb1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/1883687169c017d6ae37c58883ca3994cfc34189", - "reference": "1883687169c017d6ae37c58883ca3994cfc34189", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/0e32b76be457de00e83213528f6bb37e2a38fcb1", + "reference": "0e32b76be457de00e83213528f6bb37e2a38fcb1", "shasum": "" }, "require": { @@ -952,7 +957,7 @@ "phar-io/version": "^3.0.2", "php": ">=7.3", "phpspec/prophecy": "^1.12.1", - "phpunit/php-code-coverage": "^9.2.7", + "phpunit/php-code-coverage": "^9.2.13", "phpunit/php-file-iterator": "^3.0.5", "phpunit/php-invoker": "^3.1.1", "phpunit/php-text-template": "^2.0.3", @@ -966,11 +971,10 @@ "sebastian/global-state": "^5.0.1", "sebastian/object-enumerator": "^4.0.3", "sebastian/resource-operations": "^3.0.3", - "sebastian/type": "^2.3.4", + "sebastian/type": "^3.0", "sebastian/version": "^3.0.2" }, "require-dev": { - "ext-pdo": "*", "phpspec/prophecy-phpunit": "^2.0.1" }, "suggest": { @@ -1014,7 +1018,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.14" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.21" }, "funding": [ { @@ -1026,7 +1030,7 @@ "type": "github" } ], - "time": "2022-02-18T12:54:07+00:00" + "time": "2022-06-19T12:14:25+00:00" }, { "name": "sebastian/cli-parser", @@ -1394,16 +1398,16 @@ }, { "name": "sebastian/environment", - "version": "5.1.3", + "version": "5.1.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "388b6ced16caa751030f6a69e588299fa09200ac" + "reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/388b6ced16caa751030f6a69e588299fa09200ac", - "reference": "388b6ced16caa751030f6a69e588299fa09200ac", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/1b5dff7bb151a4db11d49d90e5408e4e938270f7", + "reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7", "shasum": "" }, "require": { @@ -1445,7 +1449,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/environment/issues", - "source": "https://github.com/sebastianbergmann/environment/tree/5.1.3" + "source": "https://github.com/sebastianbergmann/environment/tree/5.1.4" }, "funding": [ { @@ -1453,7 +1457,7 @@ "type": "github" } ], - "time": "2020-09-28T05:52:38+00:00" + "time": "2022-04-03T09:37:03+00:00" }, { "name": "sebastian/exporter", @@ -1885,28 +1889,28 @@ }, { "name": "sebastian/type", - "version": "2.3.4", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "b8cd8a1c753c90bc1a0f5372170e3e489136f914" + "reference": "b233b84bc4465aff7b57cf1c4bc75c86d00d6dad" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/b8cd8a1c753c90bc1a0f5372170e3e489136f914", - "reference": "b8cd8a1c753c90bc1a0f5372170e3e489136f914", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/b233b84bc4465aff7b57cf1c4bc75c86d00d6dad", + "reference": "b233b84bc4465aff7b57cf1c4bc75c86d00d6dad", "shasum": "" }, "require": { "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^9.5" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.3-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -1929,7 +1933,7 @@ "homepage": "https://github.com/sebastianbergmann/type", "support": { "issues": "https://github.com/sebastianbergmann/type/issues", - "source": "https://github.com/sebastianbergmann/type/tree/2.3.4" + "source": "https://github.com/sebastianbergmann/type/tree/3.0.0" }, "funding": [ { @@ -1937,7 +1941,7 @@ "type": "github" } ], - "time": "2021-06-15T12:49:02+00:00" + "time": "2022-03-15T09:54:48+00:00" }, { "name": "sebastian/version", @@ -1992,88 +1996,6 @@ ], "time": "2020-09-28T06:39:44+00:00" }, - { - "name": "symfony/polyfill-ctype", - "version": "v1.24.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "30885182c981ab175d4d034db0f6f469898070ab" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/30885182c981ab175d4d034db0f6f469898070ab", - "reference": "30885182c981ab175d4d034db0f6f469898070ab", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "provide": { - "ext-ctype": "*" - }, - "suggest": { - "ext-ctype": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.23-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Gert de Pagter", - "email": "BackEndTea@gmail.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for ctype functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "ctype", - "polyfill", - "portable" - ], - "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.24.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-10-20T20:35:02+00:00" - }, { "name": "theseer/tokenizer", "version": "1.2.1", @@ -2126,21 +2048,21 @@ }, { "name": "webmozart/assert", - "version": "1.10.0", + "version": "1.11.0", "source": { "type": "git", "url": "https://github.com/webmozarts/assert.git", - "reference": "6964c76c7804814a842473e0c8fd15bab0f18e25" + "reference": "11cb2199493b2f8a3b53e7f19068fc6aac760991" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozarts/assert/zipball/6964c76c7804814a842473e0c8fd15bab0f18e25", - "reference": "6964c76c7804814a842473e0c8fd15bab0f18e25", + "url": "https://api.github.com/repos/webmozarts/assert/zipball/11cb2199493b2f8a3b53e7f19068fc6aac760991", + "reference": "11cb2199493b2f8a3b53e7f19068fc6aac760991", "shasum": "" }, "require": { - "php": "^7.2 || ^8.0", - "symfony/polyfill-ctype": "^1.8" + "ext-ctype": "*", + "php": "^7.2 || ^8.0" }, "conflict": { "phpstan/phpstan": "<0.12.20", @@ -2178,9 +2100,9 @@ ], "support": { "issues": "https://github.com/webmozarts/assert/issues", - "source": "https://github.com/webmozarts/assert/tree/1.10.0" + "source": "https://github.com/webmozarts/assert/tree/1.11.0" }, - "time": "2021-03-09T10:59:23+00:00" + "time": "2022-06-03T18:03:27+00:00" } ], "aliases": [], @@ -2189,9 +2111,9 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=5.3", + "php": ">=7.2.5", "ext-phar": "*" }, "platform-dev": [], - "plugin-api-version": "2.2.0" + "plugin-api-version": "2.3.0" } diff --git a/requirement-checker/expected_terminal_diff b/requirement-checker/expected_terminal_diff index 23b62141f..5b2a0ecea 100644 --- a/requirement-checker/expected_terminal_diff +++ b/requirement-checker/expected_terminal_diff @@ -4,6 +4,20 @@ * For the full copyright and license information, please vie | * This source file is subject to the MIT license that is bun * file that was distributed with this source code. | * with this source code in the file LICENSE. namespace Symfony\Component\Console; | namespace KevinGH\RequirementChecker; + > use function exec; + > use function fclose; + > use function fopen; + > use function function_exists; + > use function getenv; + > use function is_resource; + > use function preg_match; + > use function proc_close; + > use function proc_open; + > use function sapi_windows_vt100_support; + > use function stream_get_contents; + > use function trim; + > use const DIRECTORY_SEPARATOR; + > > /** > * This file is copy/pasted from the Symfony project to avoid > * class. @@ -13,33 +27,17 @@ namespace Symfony\Component\Console; | namespace KevinGH\RequirementChec private static ?int $width = null; | private static $width; private static ?int $height = null; | private static $height; private static ?bool $stty = null; | private static $stty; - > * - > * @return int - public function getWidth(): int | public function getWidth() - > * - > * @return int - public function getHeight(): int | public function getHeight() - > * - > * @return bool - public static function hasSttyAvailable(): bool | public static function hasSttyAvailable() - private static function hasVt100Support(): bool | private static function hasVt100Support() - return \function_exists('sapi_windows_vt100_support') | return \function_exists('sapi_windows_vt100_support') - /** < + if (null === self::$width) { | if (!isset(self::$width)) { + if (null === self::$height) { | if (!isset(self::$height)) { + if (null !== self::$stty) { | if (isset(self::$stty)) { + if (!\function_exists('exec')) { | if (!function_exists('exec')) { + private static function initDimensions() | private static function initDimensions(): void + if ('\\' === \DIRECTORY_SEPARATOR) { | if ('\\' === DIRECTORY_SEPARATOR) { + return \function_exists('sapi_windows_vt100_support') | return function_exists('sapi_windows_vt100_support') + /** | private static function initDimensionsUsingStty(): void * Initializes dimensions using the output of an stty col < */ < - private static function getConsoleMode(): ?array | private static function getConsoleMode() + private static function initDimensionsUsingStty() < return [(int) $matches[2], (int) $matches[1]]; | return array((int) $matches[2], (int) $matches[1]); - > * - > * @return string|null - private static function getSttyColumns(): ?string | private static function getSttyColumns() - private static function readFromProcess(string $command): | /** - > * @param string $command - > * - > * @return string|null - > */ - > private static function readFromProcess($command) - $descriptorspec = [ | $descriptorspec = array( - 1 => ['pipe', 'w'], | 1 => array('pipe', 'w'), - 2 => ['pipe', 'w'], | 2 => array('pipe', 'w'), - ]; | ); - $process = proc_open($command, $descriptorspec, $pipe | $process = proc_open($command, $descriptorspec, $pipe + if (!\function_exists('proc_open')) { | if (!function_exists('proc_open')) { + if (!\is_resource($process)) { | if (!is_resource($process)) { diff --git a/requirement-checker/src/Checker.php b/requirement-checker/src/Checker.php index b7e88ad7f..639c6fac8 100644 --- a/requirement-checker/src/Checker.php +++ b/requirement-checker/src/Checker.php @@ -24,10 +24,7 @@ final class Checker /** @var null|string */ private static $requirementsConfig; - /** - * @return bool - */ - public static function checkRequirements() + public static function checkRequirements(): bool { $requirements = self::retrieveRequirements(); @@ -47,7 +44,7 @@ public static function checkRequirements() return $checkPassed; } - public static function printCheck($checkPassed, Printer $printer, RequirementCollection $requirements) + public static function printCheck($checkPassed, Printer $printer, RequirementCollection $requirements): void { if (false === $checkPassed && IO::VERBOSITY_VERY_VERBOSE > $printer->getVerbosity()) { // Override the default verbosity to output errors regardless of the verbosity asked by the user @@ -80,7 +77,7 @@ public static function printCheck($checkPassed, Printer $printer, RequirementCol $printer->printvln('> No requirements found.', $verbosity); } - $errorMessages = array(); + $errorMessages = []; foreach ($requirements->getRequirements() as $requirement) { if ($errorMessage = $printer->getRequirementErrorMessage($requirement)) { @@ -123,16 +120,13 @@ public static function printCheck($checkPassed, Printer $printer, RequirementCol $printer->printvln('', $verbosity); } - /** - * @return RequirementCollection - */ - private static function retrieveRequirements() + private static function retrieveRequirements(): RequirementCollection { if (null === self::$requirementsConfig) { self::$requirementsConfig = __DIR__.'/../.requirements.php'; } - /** @var array $config */ + /** @var list $config */ $config = require self::$requirementsConfig; $requirements = new RequirementCollection(); diff --git a/requirement-checker/src/IO.php b/requirement-checker/src/IO.php index 9699e6ef7..f36b5a5e8 100644 --- a/requirement-checker/src/IO.php +++ b/requirement-checker/src/IO.php @@ -12,16 +12,29 @@ namespace KevinGH\RequirementChecker; +use function fstat; +use function function_exists; +use function getenv; +use function implode; +use function posix_isatty; +use function preg_match; +use function preg_quote; +use function sapi_windows_vt100_support; +use function sprintf; +use function str_replace; +use function stream_isatty; +use const STDOUT; + /** * @private */ final class IO { - const VERBOSITY_QUIET = 16; - const VERBOSITY_NORMAL = 32; - const VERBOSITY_VERBOSE = 64; - const VERBOSITY_VERY_VERBOSE = 128; - const VERBOSITY_DEBUG = 256; + public const VERBOSITY_QUIET = 16; + public const VERBOSITY_NORMAL = 32; + public const VERBOSITY_VERBOSE = 64; + public const VERBOSITY_VERY_VERBOSE = 128; + public const VERBOSITY_DEBUG = 256; private $interactive; private $verbosity = self::VERBOSITY_NORMAL; @@ -30,7 +43,7 @@ final class IO public function __construct() { - $this->options = \implode(' ', $_SERVER['argv']); + $this->options = implode(' ', $_SERVER['argv']); $shellVerbosity = $this->configureVerbosity(); @@ -38,37 +51,22 @@ public function __construct() $this->colorSupport = $this->checkColorSupport(); } - /** - * @return bool - */ - public function isInteractive() + public function isInteractive(): bool { return $this->interactive; } - /** - * @return int - */ - public function getVerbosity() + public function getVerbosity(): int { return $this->verbosity; } - /** - * @return bool - */ - public function hasColorSupport() + public function hasColorSupport(): bool { return $this->colorSupport; } - /** - * @param mixed - * @param mixed $values - * - * @return bool - */ - public function hasParameter($values) + public function hasParameter($values): bool { $values = (array) $values; @@ -86,24 +84,19 @@ public function hasParameter($values) return false; } - /** - * @param int $shellVerbosity - * - * @return bool - */ - private function checkInteractivity($shellVerbosity) + private function checkInteractivity(int $shellVerbosity): bool { if (-1 === $shellVerbosity) { return false; } - if (true === $this->hasParameter(array('--no-interaction', '-n'))) { + if (true === $this->hasParameter(['--no-interaction', '-n'])) { return false; } - if (\function_exists('posix_isatty') + if (function_exists('posix_isatty') && !@posix_isatty(STDOUT) - && false === \getenv('SHELL_INTERACTIVE') + && false === getenv('SHELL_INTERACTIVE') ) { return false; } @@ -111,10 +104,7 @@ private function checkInteractivity($shellVerbosity) return true; } - /** - * @return int - */ - private function configureVerbosity() + private function configureVerbosity(): int { switch ($shellVerbosity = (int) getenv('SHELL_VERBOSITY')) { case -1: @@ -134,16 +124,16 @@ private function configureVerbosity() break; } - if ($this->hasParameter(array('--quiet', '-q'))) { + if ($this->hasParameter(['--quiet', '-q'])) { $this->verbosity = self::VERBOSITY_QUIET; $shellVerbosity = -1; - } elseif ($this->hasParameter(array('-vvv', '--verbose=3', '--verbose 3'))) { + } elseif ($this->hasParameter(['-vvv', '--verbose=3', '--verbose 3'])) { $this->verbosity = self::VERBOSITY_DEBUG; $shellVerbosity = 3; - } elseif ($this->hasParameter(array('-vv', '--verbose=2', '--verbose 2'))) { + } elseif ($this->hasParameter(['-vv', '--verbose=2', '--verbose 2'])) { $this->verbosity = self::VERBOSITY_VERY_VERBOSE; $shellVerbosity = 2; - } elseif ($this->hasParameter(array('-v', '--verbose=1', '--verbose 1', '--verbose'))) { + } elseif ($this->hasParameter(['-v', '--verbose=1', '--verbose 1', '--verbose'])) { $this->verbosity = self::VERBOSITY_VERBOSE; $shellVerbosity = 1; } @@ -165,19 +155,19 @@ private function configureVerbosity() * * @license MIT (c) Fabien Potencier */ - private function checkColorSupport() + private function checkColorSupport(): bool { - if ($this->hasParameter(array('--ansi'))) { + if ($this->hasParameter(['--ansi'])) { return true; } - if ($this->hasParameter(array('--no-ansi'))) { + if ($this->hasParameter(['--no-ansi'])) { return false; } if (\DIRECTORY_SEPARATOR === '\\') { return ( - \function_exists('sapi_windows_vt100_support') + function_exists('sapi_windows_vt100_support') && sapi_windows_vt100_support(STDOUT) ) || false !== getenv('ANSICON') @@ -185,11 +175,11 @@ private function checkColorSupport() || 'xterm' === getenv('TERM'); } - if (\function_exists('stream_isatty')) { + if (function_exists('stream_isatty')) { return stream_isatty(STDOUT); } - if (\function_exists('posix_isatty')) { + if (function_exists('posix_isatty')) { return posix_isatty(STDOUT); } diff --git a/requirement-checker/src/IsExtensionFulfilled.php b/requirement-checker/src/IsExtensionFulfilled.php index ef30a9ff4..5090cdfd5 100644 --- a/requirement-checker/src/IsExtensionFulfilled.php +++ b/requirement-checker/src/IsExtensionFulfilled.php @@ -12,6 +12,8 @@ namespace KevinGH\RequirementChecker; +use function extension_loaded; + /** * @private */ @@ -19,19 +21,13 @@ final class IsExtensionFulfilled implements IsFulfilled { private $requiredExtension; - /** - * @param string $requiredExtension - */ - public function __construct($requiredExtension) + public function __construct(string $requiredExtension) { $this->requiredExtension = $requiredExtension; } - /** - * {@inheritdoc} - */ - public function __invoke() + public function __invoke(): bool { - return \extension_loaded($this->requiredExtension); + return extension_loaded($this->requiredExtension); } } diff --git a/requirement-checker/src/IsFulfilled.php b/requirement-checker/src/IsFulfilled.php index 2c5317815..674d276e9 100644 --- a/requirement-checker/src/IsFulfilled.php +++ b/requirement-checker/src/IsFulfilled.php @@ -17,8 +17,5 @@ */ interface IsFulfilled { - /** - * @return bool - */ - public function __invoke(); + public function __invoke(): bool; } diff --git a/requirement-checker/src/IsPhpVersionFulfilled.php b/requirement-checker/src/IsPhpVersionFulfilled.php index a7b80afcf..5fb564589 100644 --- a/requirement-checker/src/IsPhpVersionFulfilled.php +++ b/requirement-checker/src/IsPhpVersionFulfilled.php @@ -13,6 +13,7 @@ namespace KevinGH\RequirementChecker; use Composer\Semver\Semver; +use function sprintf; /** * @private @@ -21,18 +22,12 @@ final class IsPhpVersionFulfilled implements IsFulfilled { private $requiredPhpVersion; - /** - * @param string $requiredPhpVersion - */ - public function __construct($requiredPhpVersion) + public function __construct(string $requiredPhpVersion) { $this->requiredPhpVersion = $requiredPhpVersion; } - /** - * {@inheritdoc} - */ - public function __invoke() + public function __invoke(): bool { return Semver::satisfies( sprintf('%d.%d.%d', \PHP_MAJOR_VERSION, \PHP_MINOR_VERSION, \PHP_RELEASE_VERSION), diff --git a/requirement-checker/src/Printer.php b/requirement-checker/src/Printer.php index b1e2081b8..8a4fb7615 100644 --- a/requirement-checker/src/Printer.php +++ b/requirement-checker/src/Printer.php @@ -12,12 +12,25 @@ namespace KevinGH\RequirementChecker; +use function array_shift; +use function count; +use function explode; +use function ltrim; +use function min; +use function sprintf; +use function str_pad; +use function str_repeat; +use function strlen; +use function trim; +use function wordwrap; +use const PHP_EOL; + /** * @private */ final class Printer { - private $styles = array( + private $styles = [ 'reset' => "\033[0m", 'red' => "\033[31m", 'green' => "\033[32m", @@ -25,17 +38,12 @@ final class Printer 'title' => "\033[33m", 'error' => "\033[37;41m", 'success' => "\033[30;42m", - ); + ]; private $verbosity; private $supportColors; private $width; - /** - * @param int $verbosity - * @param bool $supportColors - * @param null|int $width - */ - public function __construct($verbosity, $supportColors, $width = null) + public function __construct(int $verbosity, bool $supportColors, ?int $width = null) { if (null === $width) { $terminal = new Terminal(); @@ -47,28 +55,17 @@ public function __construct($verbosity, $supportColors, $width = null) $this->width = $width ?: 80; } - /** - * @return int - */ - public function getVerbosity() + public function getVerbosity(): int { return $this->verbosity; } - /** - * @param int $verbosity - */ - public function setVerbosity($verbosity) + public function setVerbosity($verbosity): void { $this->verbosity = $verbosity; } - /** - * @param string $title - * @param int $verbosity - * @param null|string $style - */ - public function title($title, $verbosity, $style = null) + public function title(string $title, int $verbosity, ?string $style = null): void { if (null === $style) { $style = 'title'; @@ -79,7 +76,7 @@ public function title($title, $verbosity, $style = null) $this->printvln( str_repeat( '=', - min(\strlen($title), $this->width) + min(strlen($title), $this->width) ), $verbosity, $style @@ -87,29 +84,16 @@ public function title($title, $verbosity, $style = null) $this->printvln('', $verbosity, $style); } - /** - * @param Requirement $requirement - * - * @return null|string - */ - public function getRequirementErrorMessage(Requirement $requirement) + public function getRequirementErrorMessage(Requirement $requirement): ?string { if ($requirement->isFulfilled()) { return null; } - $errorMessage = wordwrap($requirement->getTestMessage(), $this->width - 3, PHP_EOL.' ').PHP_EOL; - - return $errorMessage; + return wordwrap($requirement->getTestMessage(), $this->width - 3, PHP_EOL.' ').PHP_EOL; } - /** - * @param string $title - * @param string $message - * @param int $verbosity - * @param null|string $style - */ - public function block($title, $message, $verbosity, $style = null) + public function block(string $title, string $message, int $verbosity, ?string $style = null): void { $prefix = ' ['.$title.'] '; $lineLength = $this->width - strlen($prefix) - 1; @@ -118,7 +102,7 @@ public function block($title, $message, $verbosity, $style = null) } $message = $prefix.trim($message); - $lines = array(); + $lines = []; $remainingMessage = $message; @@ -128,7 +112,7 @@ public function block($title, $message, $verbosity, $style = null) do { $line = array_shift($wrapped); if ($lines && $lineLength > 0) { - $line = str_repeat(' ', \strlen($prefix)).ltrim($line); + $line = str_repeat(' ', strlen($prefix)).ltrim($line); } $lines[] = str_pad($line, $this->width, ' ', STR_PAD_RIGHT); } @@ -143,23 +127,13 @@ public function block($title, $message, $verbosity, $style = null) $this->printvln('', $verbosity); } - /** - * @param string $message - * @param int $verbosity - * @param null|string $style - */ - public function printvln($message, $verbosity, $style = null) + public function printvln(string $message, int $verbosity, ?string $style = null): void { $this->printv($message, $verbosity, $style); $this->printv(PHP_EOL, $verbosity, null); } - /** - * @param string $message - * @param int $verbosity - * @param null|string $style - */ - public function printv($message, $verbosity, $style = null) + public function printv(string $message, int $verbosity, ?string $style = null): void { if ($verbosity > $this->verbosity) { return; diff --git a/requirement-checker/src/Requirement.php b/requirement-checker/src/Requirement.php index 453922cf9..8c5d0caa1 100644 --- a/requirement-checker/src/Requirement.php +++ b/requirement-checker/src/Requirement.php @@ -26,53 +26,36 @@ final class Requirement private $testMessage; private $helpText; - /** - * @param IsFulfilled $checkIsFulfilled - * @param string $testMessage - * @param string $helpText - */ public function __construct( - $checkIsFulfilled, - $testMessage, - $helpText + IsFulfilled $checkIsFulfilled, + string $testMessage, + string $helpText ) { $this->checkIsFulfilled = $checkIsFulfilled; $this->testMessage = $testMessage; $this->helpText = $helpText; } - /** - * @return bool - */ - public function isFulfilled() + public function isFulfilled(): bool { - if (null === $this->fulfilled) { + if (!isset($this->fulfilled)) { $this->fulfilled = $this->checkIsFulfilled->__invoke(); } - return (bool) $this->fulfilled; // Cast to boolean, `(bool)` and `boolval()` are not available in PHP 5.3 + return $this->fulfilled; } - /** - * @return IsFulfilled - */ - public function getIsFullfilledChecker() + public function getIsFullfilledChecker(): IsFulfilled { return $this->checkIsFulfilled; } - /** - * @return string - */ - public function getTestMessage() + public function getTestMessage(): string { return $this->testMessage; } - /** - * @return string - */ - public function getHelpText() + public function getHelpText(): string { return $this->helpText; } diff --git a/requirement-checker/src/RequirementCollection.php b/requirement-checker/src/RequirementCollection.php index 0163665bf..4332f1e12 100644 --- a/requirement-checker/src/RequirementCollection.php +++ b/requirement-checker/src/RequirementCollection.php @@ -15,8 +15,9 @@ use ArrayIterator; use Countable; use IteratorAggregate; -use ReturnTypeWillChange; use Traversable; +use function count; +use function get_cfg_var; /** * @private @@ -28,34 +29,27 @@ final class RequirementCollection implements IteratorAggregate, Countable { /** - * @var Requirement[] + * @var list */ - private $requirements = array(); + private $requirements = []; /** - * {@inheritdoc} - * - * @return Requirement[]|Traversable + * @return Traversable */ - #[ReturnTypeWillChange] - public function getIterator() + public function getIterator(): Traversable { return new ArrayIterator($this->requirements); } - /** - * {@inheritdoc} - */ - #[ReturnTypeWillChange] - public function count() + public function count(): int { - return \count($this->requirements); + return count($this->requirements); } /** * @param Requirement $requirement */ - public function add(Requirement $requirement) + public function add(Requirement $requirement): void { $this->requirements[] = $requirement; } @@ -68,7 +62,7 @@ public function add(Requirement $requirement) * @param string $testMessage The message for testing the requirement * @param string $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) */ - public function addRequirement($checkIsFulfilled, $testMessage, $helpText) + public function addRequirement(IsFulfilled $checkIsFulfilled, string $testMessage, string $helpText): void { $this->add(new Requirement($checkIsFulfilled, $testMessage, $helpText)); } @@ -76,9 +70,9 @@ public function addRequirement($checkIsFulfilled, $testMessage, $helpText) /** * Returns all mandatory requirements. * - * @return Requirement[] + * @return list */ - public function getRequirements() + public function getRequirements(): array { return $this->requirements; } @@ -100,13 +94,7 @@ public function evaluateRequirements() { return array_reduce( $this->requirements, - /** - * @param bool $checkPassed - * @param Requirement $requirement - * - * @return bool - */ - function ($checkPassed, Requirement $requirement) { + function (bool $checkPassed, Requirement $requirement): bool { return $checkPassed && $requirement->isFulfilled(); }, true diff --git a/requirement-checker/src/Terminal.php b/requirement-checker/src/Terminal.php index 7335452d1..aa0e695f6 100644 --- a/requirement-checker/src/Terminal.php +++ b/requirement-checker/src/Terminal.php @@ -12,6 +12,20 @@ namespace KevinGH\RequirementChecker; +use function exec; +use function fclose; +use function fopen; +use function function_exists; +use function getenv; +use function is_resource; +use function preg_match; +use function proc_close; +use function proc_open; +use function sapi_windows_vt100_support; +use function stream_get_contents; +use function trim; +use const DIRECTORY_SEPARATOR; + /** * This file is copy/pasted from the Symfony project to avoid a dependency on `symfony/console` which would be too big for just using this * class. @@ -26,17 +40,15 @@ class Terminal /** * Gets the terminal width. - * - * @return int */ - public function getWidth() + public function getWidth(): int { $width = getenv('COLUMNS'); if (false !== $width) { return (int) trim($width); } - if (null === self::$width) { + if (!isset(self::$width)) { self::initDimensions(); } @@ -45,17 +57,15 @@ public function getWidth() /** * Gets the terminal height. - * - * @return int */ - public function getHeight() + public function getHeight(): int { $height = getenv('LINES'); if (false !== $height) { return (int) trim($height); } - if (null === self::$height) { + if (!isset(self::$height)) { self::initDimensions(); } @@ -64,17 +74,15 @@ public function getHeight() /** * @internal - * - * @return bool */ - public static function hasSttyAvailable() + public static function hasSttyAvailable(): bool { - if (null !== self::$stty) { + if (isset(self::$stty)) { return self::$stty; } // skip check if exec function is disabled - if (!\function_exists('exec')) { + if (!function_exists('exec')) { return false; } @@ -83,9 +91,9 @@ public static function hasSttyAvailable() return self::$stty = 0 === $exitcode; } - private static function initDimensions() + private static function initDimensions(): void { - if ('\\' === \DIRECTORY_SEPARATOR) { + if ('\\' === DIRECTORY_SEPARATOR) { if (preg_match('/^(\d+)x(\d+)(?: \((\d+)x(\d+)\))?$/', trim(getenv('ANSICON')), $matches)) { // extract [w, H] from "wxh (WxH)" // or [w, h] from "wxh" @@ -108,12 +116,12 @@ private static function initDimensions() /** * Returns whether STDOUT has vt100 support (some Windows 10+ configurations). */ - private static function hasVt100Support() + private static function hasVt100Support(): bool { - return \function_exists('sapi_windows_vt100_support') && \sapi_windows_vt100_support(\fopen('php://stdout', 'wb')); + return function_exists('sapi_windows_vt100_support') && sapi_windows_vt100_support(fopen('php://stdout', 'wb')); } - private static function initDimensionsUsingStty() + private static function initDimensionsUsingStty(): void { if ($sttyString = self::getSttyColumns()) { if (preg_match('/rows.(\d+);.columns.(\d+);/i', $sttyString, $matches)) { @@ -133,7 +141,7 @@ private static function initDimensionsUsingStty() * * @return int[]|null An array composed of the width and the height or null if it could not be parsed */ - private static function getConsoleMode() + private static function getConsoleMode(): ?array { $info = self::readFromProcess('mode CON'); @@ -146,32 +154,25 @@ private static function getConsoleMode() /** * Runs and parses stty -a if it's available, suppressing any error output. - * - * @return string|null */ - private static function getSttyColumns() + private static function getSttyColumns(): ?string { return self::readFromProcess('stty -a | grep columns'); } - /** - * @param string $command - * - * @return string|null - */ - private static function readFromProcess($command) + private static function readFromProcess(string $command): ?string { - if (!\function_exists('proc_open')) { + if (!function_exists('proc_open')) { return null; } - $descriptorspec = array( - 1 => array('pipe', 'w'), - 2 => array('pipe', 'w'), - ); + $descriptorspec = [ + 1 => ['pipe', 'w'], + 2 => ['pipe', 'w'], + ]; - $process = proc_open($command, $descriptorspec, $pipes, null, null, array('suppress_errors' => true)); - if (!\is_resource($process)) { + $process = proc_open($command, $descriptorspec, $pipes, null, null, ['suppress_errors' => true]); + if (!is_resource($process)) { return null; } diff --git a/requirement-checker/tests/CheckerTest.php b/requirement-checker/tests/CheckerTest.php index 6e96f54c1..cdb3ad5c6 100644 --- a/requirement-checker/tests/CheckerTest.php +++ b/requirement-checker/tests/CheckerTest.php @@ -133,7 +133,7 @@ public function provideRequirements(): Generator ); $requirements->addRequirement( new class implements IsFulfilled { - public function __invoke() + public function __invoke(): bool { return true; } diff --git a/requirement-checker/tests/ConditionIsFulfilled.php b/requirement-checker/tests/ConditionIsFulfilled.php index 0a3fea52d..5668076c6 100644 --- a/requirement-checker/tests/ConditionIsFulfilled.php +++ b/requirement-checker/tests/ConditionIsFulfilled.php @@ -6,11 +6,8 @@ final class ConditionIsFulfilled implements IsFulfilled { - /** - * {@inheritdoc} - */ public function __invoke(): bool { return true; } -} \ No newline at end of file +} diff --git a/requirement-checker/tests/ConditionIsNotFulfilled.php b/requirement-checker/tests/ConditionIsNotFulfilled.php index 8a55a08f4..f304cf9b1 100644 --- a/requirement-checker/tests/ConditionIsNotFulfilled.php +++ b/requirement-checker/tests/ConditionIsNotFulfilled.php @@ -6,11 +6,8 @@ final class ConditionIsNotFulfilled implements IsFulfilled { - /** - * {@inheritdoc} - */ public function __invoke(): bool { return false; } -} \ No newline at end of file +} diff --git a/requirement-checker/tests/IOTest.php b/requirement-checker/tests/IOTest.php index 51c8ca03c..27ff5aef4 100644 --- a/requirement-checker/tests/IOTest.php +++ b/requirement-checker/tests/IOTest.php @@ -17,7 +17,6 @@ use Generator; use function function_exists; use function getenv; -use function in_array; use PHPUnit\Framework\TestCase; use function posix_isatty; use function putenv; diff --git a/requirement-checker/tests/RequirementTest.php b/requirement-checker/tests/RequirementTest.php index c3e14df0d..497a185a2 100644 --- a/requirement-checker/tests/RequirementTest.php +++ b/requirement-checker/tests/RequirementTest.php @@ -41,7 +41,7 @@ public function test_it_evaluates_the_check_lazily(): void { $requirement = new Requirement( $check = new class implements IsFulfilled { - public function __invoke() + public function __invoke(): bool { throw new Error(); } @@ -61,66 +61,18 @@ public function __invoke() } } - public function test_it_casts_the_fulfilled_result_into_a_boolean(): void - { - $requirement = new Requirement( - new class implements IsFulfilled { - public function __invoke() - { - return 1; - } - }, - '', - '' - ); - - $this->assertTrue($requirement->isFulfilled()); - - $requirement = new Requirement( - new class implements IsFulfilled { - public function __invoke() - { - return 0; - } - }, - '', - '' - ); - - $this->assertFalse($requirement->isFulfilled()); - - $requirement = new Requirement( - new class implements IsFulfilled { - public function __invoke() - { - return new stdClass(); - } - }, - '', - '' - ); - - $this->assertTrue($requirement->isFulfilled()); - } - public function test_it_evaluates_the_check_only_once(): void { - $x = -1; - $requirement = new Requirement( - new class($x) implements IsFulfilled { - private $x; - - public function __construct(&$x) - { - $this->x = $x; - } + new class() implements IsFulfilled { + private bool $calledOnce = false; - public function __invoke() + public function __invoke(): bool { - $this->x++; + $result = $this->calledOnce; + $this->calledOnce = true; - return $this->x; + return $result; } }, 'Test message', @@ -128,6 +80,6 @@ public function __invoke() ); $this->assertFalse($requirement->isFulfilled()); - $this->assertFalse($requirement->isFulfilled()); // Would have gave `true` if it was evaluated a second time + $this->assertFalse($requirement->isFulfilled()); // Would have given `true` if it was evaluated a second time } }