diff --git a/src/Util/Printer.php b/src/Util/Printer.php index b36d1656c3e..9b52f322ed5 100644 --- a/src/Util/Printer.php +++ b/src/Util/Printer.php @@ -15,7 +15,7 @@ class Printer { /** - * @var resource + * @var closed-resource|resource */ private $stream; @@ -74,6 +74,8 @@ public function __construct($out = null) public function write(string $buffer): void { if ($this->stream) { + \assert(\is_resource($this->stream)); + \fwrite($this->stream, $buffer); } else { if (\PHP_SAPI !== 'cli' && \PHP_SAPI !== 'phpdbg') { @@ -87,6 +89,8 @@ public function write(string $buffer): void public function flush(): void { if ($this->stream && $this->isPhpStream) { + \assert(\is_resource($this->stream)); + \fclose($this->stream); } } diff --git a/src/Util/Test.php b/src/Util/Test.php index 19870acebc5..4bef60cedf2 100644 --- a/src/Util/Test.php +++ b/src/Util/Test.php @@ -162,7 +162,7 @@ public static function getMissingRequirements(string $className, string $methodN if (!\version_compare(\PHP_VERSION, $required['PHP']['version'], $operator->asString())) { $missing[] = \sprintf('PHP %s %s is required.', $operator->asString(), $required['PHP']['version']); - $hint = $hint ?? 'PHP'; + $hint = 'PHP'; } } elseif (!empty($required['PHP_constraint'])) { $version = new \PharIo\Version\Version(self::sanitizeVersionNumber(\PHP_VERSION)); @@ -173,7 +173,7 @@ public static function getMissingRequirements(string $className, string $methodN $required['PHP_constraint']['constraint']->asString() ); - $hint = $hint ?? 'PHP_constraint'; + $hint = 'PHP_constraint'; } }