diff --git a/src/CodeCoverage/Generators/AbstractGenerator.php b/src/CodeCoverage/Generators/AbstractGenerator.php index 8eaf34c6..671af88e 100644 --- a/src/CodeCoverage/Generators/AbstractGenerator.php +++ b/src/CodeCoverage/Generators/AbstractGenerator.php @@ -72,7 +72,7 @@ public function __construct(string $file, array $sources = []) } - public function render(string $file = null): void + public function render(?string $file = null): void { $handle = $file ? @fopen($file, 'w') : STDOUT; // @ is escalated to exception if (!$handle) { diff --git a/src/CodeCoverage/Generators/CloverXMLGenerator.php b/src/CodeCoverage/Generators/CloverXMLGenerator.php index b088a1d0..1e04d35b 100644 --- a/src/CodeCoverage/Generators/CloverXMLGenerator.php +++ b/src/CodeCoverage/Generators/CloverXMLGenerator.php @@ -151,7 +151,7 @@ protected function renderSelf(): void } - private function calculateClassMetrics(\stdClass $info, array $coverageData = null): \stdClass + private function calculateClassMetrics(\stdClass $info, ?array $coverageData = null): \stdClass { $stats = (object) [ 'methodCount' => count($info->methods), @@ -182,7 +182,7 @@ private function calculateClassMetrics(\stdClass $info, array $coverageData = nu } - private static function analyzeMethod(\stdClass $info, array $coverageData = null): array + private static function analyzeMethod(\stdClass $info, ?array $coverageData = null): array { $count = 0; $coveredCount = 0; diff --git a/src/CodeCoverage/Generators/HtmlGenerator.php b/src/CodeCoverage/Generators/HtmlGenerator.php index ad02199e..2bf0412d 100644 --- a/src/CodeCoverage/Generators/HtmlGenerator.php +++ b/src/CodeCoverage/Generators/HtmlGenerator.php @@ -34,7 +34,7 @@ class HtmlGenerator extends AbstractGenerator * @param string $file path to coverage.dat file * @param array $sources files/directories */ - public function __construct(string $file, array $sources = [], string $title = null) + public function __construct(string $file, array $sources = [], ?string $title = null) { parent::__construct($file, $sources); $this->title = $title; diff --git a/src/Framework/Assert.php b/src/Framework/Assert.php index f6adc733..3ed4dc96 100644 --- a/src/Framework/Assert.php +++ b/src/Framework/Assert.php @@ -53,7 +53,7 @@ class Assert /** * Asserts that two values are equal and have the same type and identity of objects. */ - public static function same($expected, $actual, string $description = null): void + public static function same($expected, $actual, ?string $description = null): void { self::$counter++; if ($actual !== $expected) { @@ -65,7 +65,7 @@ public static function same($expected, $actual, string $description = null): voi /** * Asserts that two values are not equal or do not have the same type and identity of objects. */ - public static function notSame($expected, $actual, string $description = null): void + public static function notSame($expected, $actual, ?string $description = null): void { self::$counter++; if ($actual === $expected) { @@ -78,7 +78,7 @@ public static function notSame($expected, $actual, string $description = null): * Asserts that two values are equal and checks expectations. The identity of objects, * the order of keys in the arrays and marginally different floats are ignored. */ - public static function equal($expected, $actual, string $description = null): void + public static function equal($expected, $actual, ?string $description = null): void { self::$counter++; if (!self::isEqual($expected, $actual)) { @@ -91,7 +91,7 @@ public static function equal($expected, $actual, string $description = null): vo * Asserts that two values are not equal and checks expectations. The identity of objects, * the order of keys in the arrays and marginally different floats are ignored. */ - public static function notEqual($expected, $actual, string $description = null): void + public static function notEqual($expected, $actual, ?string $description = null): void { self::$counter++; try { @@ -110,7 +110,7 @@ public static function notEqual($expected, $actual, string $description = null): * @param mixed $needle * @param array|string $actual */ - public static function contains($needle, $actual, string $description = null): void + public static function contains($needle, $actual, ?string $description = null): void { self::$counter++; if (is_array($actual)) { @@ -135,7 +135,7 @@ public static function contains($needle, $actual, string $description = null): v * @param mixed $needle * @param array|string $actual */ - public static function notContains($needle, $actual, string $description = null): void + public static function notContains($needle, $actual, ?string $description = null): void { self::$counter++; if (is_array($actual)) { @@ -159,7 +159,7 @@ public static function notContains($needle, $actual, string $description = null) * Asserts that a haystack has an expected key. * @param string|int $key */ - public static function hasKey($key, array $actual, string $description = null): void + public static function hasKey($key, array $actual, ?string $description = null): void { self::$counter++; if (!is_int($key) && !is_string($key)) { @@ -175,7 +175,7 @@ public static function hasKey($key, array $actual, string $description = null): * Asserts that a haystack doesn't have an expected key. * @param string|int $key */ - public static function hasNotKey($key, array $actual, string $description = null): void + public static function hasNotKey($key, array $actual, ?string $description = null): void { self::$counter++; if (!is_int($key) && !is_string($key)) { @@ -191,7 +191,7 @@ public static function hasNotKey($key, array $actual, string $description = null * Asserts that a value is true. * @param mixed $actual */ - public static function true($actual, string $description = null): void + public static function true($actual, ?string $description = null): void { self::$counter++; if ($actual !== true) { @@ -204,7 +204,7 @@ public static function true($actual, string $description = null): void * Asserts that a value is false. * @param mixed $actual */ - public static function false($actual, string $description = null): void + public static function false($actual, ?string $description = null): void { self::$counter++; if ($actual !== false) { @@ -217,7 +217,7 @@ public static function false($actual, string $description = null): void * Asserts that a value is null. * @param mixed $actual */ - public static function null($actual, string $description = null): void + public static function null($actual, ?string $description = null): void { self::$counter++; if ($actual !== null) { @@ -230,7 +230,7 @@ public static function null($actual, string $description = null): void * Asserts that a value is not null. * @param mixed $actual */ - public static function notNull($actual, string $description = null): void + public static function notNull($actual, ?string $description = null): void { self::$counter++; if ($actual === null) { @@ -243,7 +243,7 @@ public static function notNull($actual, string $description = null): void * Asserts that a value is Not a Number. * @param mixed $actual */ - public static function nan($actual, string $description = null): void + public static function nan($actual, ?string $description = null): void { self::$counter++; if (!is_float($actual) || !is_nan($actual)) { @@ -256,7 +256,7 @@ public static function nan($actual, string $description = null): void * Asserts that a value is truthy. * @param mixed $actual */ - public static function truthy($actual, string $description = null): void + public static function truthy($actual, ?string $description = null): void { self::$counter++; if (!$actual) { @@ -269,7 +269,7 @@ public static function truthy($actual, string $description = null): void * Asserts that a value is falsey. * @param mixed $actual */ - public static function falsey($actual, string $description = null): void + public static function falsey($actual, ?string $description = null): void { self::$counter++; if ($actual) { @@ -282,7 +282,7 @@ public static function falsey($actual, string $description = null): void * Asserts the number of items in an array or Countable. * @param array|\Countable $value */ - public static function count(int $count, $value, string $description = null): void + public static function count(int $count, $value, ?string $description = null): void { self::$counter++; if (!$value instanceof \Countable && !is_array($value)) { @@ -299,7 +299,7 @@ public static function count(int $count, $value, string $description = null): vo * @param string|object $type * @param mixed $value */ - public static function type($type, $value, string $description = null): void + public static function type($type, $value, ?string $description = null): void { self::$counter++; if (!is_object($type) && !is_string($type)) { @@ -329,7 +329,7 @@ public static function type($type, $value, string $description = null): void public static function exception( callable $function, string $class, - string $message = null, + ?string $message = null, $code = null ): ?\Throwable { self::$counter++; @@ -359,7 +359,7 @@ public static function exception( /** * Asserts that a function throws exception of given type and its message matches given pattern. Alias for exception(). */ - public static function throws(callable $function, string $class, string $message = null, $code = null): ?\Throwable + public static function throws(callable $function, string $class, ?string $message = null, $code = null): ?\Throwable { return self::exception($function, $class, $message, $code); } @@ -372,7 +372,7 @@ public static function throws(callable $function, string $class, string $message * @throws \Exception * @throws \Exception */ - public static function error(callable $function, $expectedType, string $expectedMessage = null): ?\Throwable + public static function error(callable $function, $expectedType, ?string $expectedMessage = null): ?\Throwable { if (is_string($expectedType) && !preg_match('#^E_[A-Z_]+$#D', $expectedType)) { return static::exception($function, $expectedType, $expectedMessage); @@ -458,7 +458,7 @@ public static function noError(callable $function): void * %h% one or more HEX digits * @param string $pattern mask|regexp; only delimiters ~ and # are supported for regexp */ - public static function match(string $pattern, $actual, string $description = null): void + public static function match(string $pattern, $actual, ?string $description = null): void { self::$counter++; if (!is_scalar($actual)) { @@ -477,7 +477,7 @@ public static function match(string $pattern, $actual, string $description = nul /** * Asserts that a string matches a given pattern stored in file. */ - public static function matchFile(string $file, $actual, string $description = null): void + public static function matchFile(string $file, $actual, ?string $description = null): void { self::$counter++; $pattern = @file_get_contents($file); // @ is escalated to exception @@ -504,8 +504,8 @@ public static function fail( string $message, $actual = null, $expected = null, - \Throwable $previous = null, - string $outputName = null + ?\Throwable $previous = null, + ?string $outputName = null ): void { $e = new AssertException($message, $expected, $actual, $previous); $e->outputName = $outputName; @@ -517,7 +517,7 @@ public static function fail( } - private static function describe(string $reason, string $description = null): string + private static function describe(string $reason, ?string $description = null): string { return ($description ? $description . ': ' : '') . $reason; } diff --git a/src/Framework/AssertException.php b/src/Framework/AssertException.php index 4c8c9a5d..2a41829d 100644 --- a/src/Framework/AssertException.php +++ b/src/Framework/AssertException.php @@ -24,7 +24,7 @@ class AssertException extends \Exception public $outputName; - public function __construct(string $message, $expected, $actual, \Throwable $previous = null) + public function __construct(string $message, $expected, $actual, ?\Throwable $previous = null) { parent::__construct('', 0, $previous); $this->expected = $expected; diff --git a/src/Framework/Dumper.php b/src/Framework/Dumper.php index 658c78b6..02d764aa 100644 --- a/src/Framework/Dumper.php +++ b/src/Framework/Dumper.php @@ -418,7 +418,7 @@ public static function saveOutput(string $testFile, $content, string $suffix = ' /** * Applies color to string. */ - public static function color(string $color = '', string $s = null): string + public static function color(string $color = '', ?string $s = null): string { static $colors = [ 'black' => '0;30', 'gray' => '1;30', 'silver' => '0;37', 'white' => '1;37', diff --git a/src/Framework/FileMock.php b/src/Framework/FileMock.php index b8f827eb..fcf3bbdf 100644 --- a/src/Framework/FileMock.php +++ b/src/Framework/FileMock.php @@ -42,7 +42,7 @@ class FileMock /** * @return string file name */ - public static function create(string $content = '', string $extension = null): string + public static function create(string $content = '', ?string $extension = null): string { self::register(); diff --git a/src/Framework/TestCase.php b/src/Framework/TestCase.php index a65d7cca..a1e2671b 100644 --- a/src/Framework/TestCase.php +++ b/src/Framework/TestCase.php @@ -68,7 +68,7 @@ public function run(): void * Runs the test method. * @param array $args test method parameters (dataprovider bypass) */ - public function runTest(string $method, array $args = null): void + public function runTest(string $method, ?array $args = null): void { if (!method_exists($this, $method)) { throw new TestCaseException("Method '$method' does not exist."); diff --git a/src/Runner/CommandLine.php b/src/Runner/CommandLine.php index 9574dc60..226e9137 100644 --- a/src/Runner/CommandLine.php +++ b/src/Runner/CommandLine.php @@ -71,7 +71,7 @@ public function __construct(string $help, array $defaults = []) } - public function parse(array $args = null): array + public function parse(?array $args = null): array { if ($args === null) { $args = isset($_SERVER['argv']) ? array_slice($_SERVER['argv'], 1) : []; diff --git a/src/Runner/Job.php b/src/Runner/Job.php index 62fdc7c5..9384633f 100644 --- a/src/Runner/Job.php +++ b/src/Runner/Job.php @@ -59,7 +59,7 @@ class Job private $duration; - public function __construct(Test $test, PhpInterpreter $interpreter, array $envVars = null) + public function __construct(Test $test, PhpInterpreter $interpreter, ?array $envVars = null) { if ($test->getResult() !== Test::PREPARED) { throw new \LogicException("Test '{$test->getSignature()}' already has result '{$test->getResult()}'."); diff --git a/src/Runner/Output/ConsolePrinter.php b/src/Runner/Output/ConsolePrinter.php index f10c943b..686ded10 100644 --- a/src/Runner/Output/ConsolePrinter.php +++ b/src/Runner/Output/ConsolePrinter.php @@ -51,7 +51,7 @@ class ConsolePrinter implements Tester\Runner\OutputHandler public function __construct( Runner $runner, bool $displaySkipped = false, - string $file = null, + ?string $file = null, bool $ciderMode = false ) { $this->runner = $runner; diff --git a/src/Runner/Output/JUnitPrinter.php b/src/Runner/Output/JUnitPrinter.php index 453a5a03..94b1d035 100644 --- a/src/Runner/Output/JUnitPrinter.php +++ b/src/Runner/Output/JUnitPrinter.php @@ -31,7 +31,7 @@ class JUnitPrinter implements Tester\Runner\OutputHandler private $results; - public function __construct(string $file = null) + public function __construct(?string $file = null) { $this->file = fopen($file ?: 'php://output', 'w'); } diff --git a/src/Runner/Output/Logger.php b/src/Runner/Output/Logger.php index a7c29226..516826c9 100644 --- a/src/Runner/Output/Logger.php +++ b/src/Runner/Output/Logger.php @@ -32,7 +32,7 @@ class Logger implements Tester\Runner\OutputHandler private $results; - public function __construct(Runner $runner, string $file = null) + public function __construct(Runner $runner, ?string $file = null) { $this->runner = $runner; $this->file = fopen($file ?: 'php://output', 'w'); diff --git a/src/Runner/Output/TapPrinter.php b/src/Runner/Output/TapPrinter.php index b03e1105..956ef3fb 100644 --- a/src/Runner/Output/TapPrinter.php +++ b/src/Runner/Output/TapPrinter.php @@ -25,7 +25,7 @@ class TapPrinter implements Tester\Runner\OutputHandler private $results; - public function __construct(string $file = null) + public function __construct(?string $file = null) { $this->file = fopen($file ?: 'php://output', 'w'); } diff --git a/src/Runner/PhpInterpreter.php b/src/Runner/PhpInterpreter.php index ac160a77..c98e694d 100644 --- a/src/Runner/PhpInterpreter.php +++ b/src/Runner/PhpInterpreter.php @@ -89,7 +89,7 @@ public function __construct(string $path, array $args = []) /** * @return static */ - public function withPhpIniOption(string $name, string $value = null): self + public function withPhpIniOption(string $name, ?string $value = null): self { $me = clone $this; $me->commandLine .= ' -d ' . Helpers::escapeArg($name . ($value === null ? '' : "=$value")); diff --git a/src/Runner/Runner.php b/src/Runner/Runner.php index eefe238c..96aac9f3 100644 --- a/src/Runner/Runner.php +++ b/src/Runner/Runner.php @@ -76,7 +76,7 @@ public function getEnvironmentVariables(): array } - public function addPhpIniOption(string $name, string $value = null): void + public function addPhpIniOption(string $name, ?string $value = null): void { $this->interpreter = $this->interpreter->withPhpIniOption($name, $value); } diff --git a/src/Runner/Test.php b/src/Runner/Test.php index 7825d0e1..85237aaa 100644 --- a/src/Runner/Test.php +++ b/src/Runner/Test.php @@ -46,7 +46,7 @@ class Test private $args = []; - public function __construct(string $file, string $title = null) + public function __construct(string $file, ?string $title = null) { $this->file = $file; $this->title = $title; @@ -124,7 +124,7 @@ public function withArguments(array $args): self /** * @return static */ - public function withResult(int $result, ?string $message, float $duration = null): self + public function withResult(int $result, ?string $message, ?float $duration = null): self { if ($this->hasResult()) { throw new \LogicException("Result of test is already set to $this->result with message '$this->message'.");