Skip to content

Commit

Permalink
Fix CS/WS issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Mar 1, 2024
1 parent 8414139 commit 90f86fc
Show file tree
Hide file tree
Showing 18 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/Framework/Constraint/Constraint.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ protected function matches($other): bool
*
* @psalm-return never-return
*/
protected function fail($other, $description, ComparisonFailure $comparisonFailure = null): void
protected function fail($other, $description, ?ComparisonFailure $comparisonFailure = null): void
{
$failureDescription = sprintf(
'Failed asserting that %s.',
Expand Down
2 changes: 1 addition & 1 deletion src/Framework/Constraint/JsonMatches.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ protected function matches($other): bool
*
* @psalm-return never-return
*/
protected function fail($other, $description, ComparisonFailure $comparisonFailure = null): void
protected function fail($other, $description, ?ComparisonFailure $comparisonFailure = null): void
{
if ($comparisonFailure === null) {
[$error, $recodedOther] = Json::canonicalize($other);
Expand Down
2 changes: 1 addition & 1 deletion src/Framework/Error/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class Error extends Exception
{
public function __construct(string $message, int $code, string $file, int $line, \Exception $previous = null)
public function __construct(string $message, int $code, string $file, int $line, ?\Exception $previous = null)
{
parent::__construct($message, $code, $previous);

Expand Down
2 changes: 1 addition & 1 deletion src/Framework/Exception/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Exception extends RuntimeException implements \PHPUnit\Exception
*/
protected $serializableTrace;

public function __construct($message = '', $code = 0, Throwable $previous = null)
public function __construct($message = '', $code = 0, ?Throwable $previous = null)
{
parent::__construct($message, $code, $previous);

Expand Down
2 changes: 1 addition & 1 deletion src/Framework/Exception/ExpectationFailedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ final class ExpectationFailedException extends AssertionFailedError
*/
protected $comparisonFailure;

public function __construct(string $message, ComparisonFailure $comparisonFailure = null, Exception $previous = null)
public function __construct(string $message, ?ComparisonFailure $comparisonFailure = null, ?Exception $previous = null)
{
$this->comparisonFailure = $comparisonFailure;

Expand Down
2 changes: 1 addition & 1 deletion src/Framework/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static function create(int $argument, string $type): self
);
}

private function __construct(string $message = '', int $code = 0, \Exception $previous = null)
private function __construct(string $message = '', int $code = 0, ?\Exception $previous = null)
{
parent::__construct($message, $code, $previous);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Framework/ExceptionWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function getOriginalException(): ?Throwable
* which can be quite big, from being garbage-collected, thus blocking memory until shutdown.
* Approach works both for var_dump() and var_export() and print_r().
*/
private function originalException(Throwable $exceptionToStore = null): ?Throwable
private function originalException(?Throwable $exceptionToStore = null): ?Throwable
{
static $originalExceptions;

Expand Down
10 changes: 5 additions & 5 deletions src/Framework/MockObject/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function __clone()
*
* @throws RuntimeException
*/
public function getMock($type, $methods = [], array $arguments = [], string $mockClassName = '', bool $callOriginalConstructor = true, bool $callOriginalClone = true, bool $callAutoload = true, bool $cloneArguments = true, bool $callOriginalMethods = false, object $proxyTarget = null, bool $allowMockingUnknownTypes = true, bool $returnValueGeneration = true): MockObject
public function getMock($type, $methods = [], array $arguments = [], string $mockClassName = '', bool $callOriginalConstructor = true, bool $callOriginalClone = true, bool $callAutoload = true, bool $cloneArguments = true, bool $callOriginalMethods = false, ?object $proxyTarget = null, bool $allowMockingUnknownTypes = true, bool $returnValueGeneration = true): MockObject
{
if (!is_array($type) && !is_string($type)) {
throw InvalidArgumentException::create(1, 'array or string');
Expand Down Expand Up @@ -288,7 +288,7 @@ static function ($type)
*
* @throws RuntimeException
*/
public function getMockForAbstractClass(string $originalClassName, array $arguments = [], string $mockClassName = '', bool $callOriginalConstructor = true, bool $callOriginalClone = true, bool $callAutoload = true, array $mockedMethods = null, bool $cloneArguments = true): MockObject
public function getMockForAbstractClass(string $originalClassName, array $arguments = [], string $mockClassName = '', bool $callOriginalConstructor = true, bool $callOriginalClone = true, bool $callAutoload = true, ?array $mockedMethods = null, bool $cloneArguments = true): MockObject
{
if (class_exists($originalClassName, $callAutoload) ||
interface_exists($originalClassName, $callAutoload)) {
Expand Down Expand Up @@ -340,7 +340,7 @@ interface_exists($originalClassName, $callAutoload)) {
*
* @throws RuntimeException
*/
public function getMockForTrait(string $traitName, array $arguments = [], string $mockClassName = '', bool $callOriginalConstructor = true, bool $callOriginalClone = true, bool $callAutoload = true, array $mockedMethods = null, bool $cloneArguments = true): MockObject
public function getMockForTrait(string $traitName, array $arguments = [], string $mockClassName = '', bool $callOriginalConstructor = true, bool $callOriginalClone = true, bool $callAutoload = true, ?array $mockedMethods = null, bool $cloneArguments = true): MockObject
{
if (!trait_exists($traitName, $callAutoload)) {
throw new RuntimeException(
Expand Down Expand Up @@ -417,7 +417,7 @@ public function getObjectForTrait(string $traitName, string $traitClassName = ''
);
}

public function generate($type, array $methods = null, string $mockClassName = '', bool $callOriginalClone = true, bool $callAutoload = true, bool $cloneArguments = true, bool $callOriginalMethods = false): MockClass
public function generate($type, ?array $methods = null, string $mockClassName = '', bool $callOriginalClone = true, bool $callAutoload = true, bool $cloneArguments = true, bool $callOriginalMethods = false): MockClass
{
if (is_array($type)) {
sort($type);
Expand Down Expand Up @@ -672,7 +672,7 @@ private function userDefinedInterfaceMethods(string $interfaceName): array
return $methods;
}

private function getObject(MockType $mockClass, $type = '', bool $callOriginalConstructor = false, bool $callAutoload = false, array $arguments = [], bool $callOriginalMethods = false, object $proxyTarget = null, bool $returnValueGeneration = true)
private function getObject(MockType $mockClass, $type = '', bool $callOriginalConstructor = false, bool $callAutoload = false, array $arguments = [], bool $callOriginalMethods = false, ?object $proxyTarget = null, bool $returnValueGeneration = true)
{
$className = $mockClass->generate();

Expand Down
2 changes: 1 addition & 1 deletion src/Framework/Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ interface Test extends Countable
/**
* Runs a test and collects its result in a TestResult instance.
*/
public function run(TestResult $result = null): TestResult;
public function run(?TestResult $result = null): TestResult;
}
2 changes: 1 addition & 1 deletion src/Framework/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ public function hasFailed(): bool
* @throws CodeCoverageException
* @throws UtilException
*/
public function run(TestResult $result = null): TestResult
public function run(?TestResult $result = null): TestResult
{
if ($result === null) {
$result = $this->createResult();
Expand Down
2 changes: 1 addition & 1 deletion src/Framework/TestSuite.php
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ public function setGroupDetails(array $groups): void
* @throws CodeCoverageException
* @throws Warning
*/
public function run(TestResult $result = null): TestResult
public function run(?TestResult $result = null): TestResult
{
if ($result === null) {
$result = $this->createResult();
Expand Down
4 changes: 2 additions & 2 deletions src/Runner/PhptTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ final class PhptTestCase implements SelfDescribing, Test
*
* @throws Exception
*/
public function __construct(string $filename, AbstractPhpProcess $phpUtil = null)
public function __construct(string $filename, ?AbstractPhpProcess $phpUtil = null)
{
if (!is_file($filename)) {
throw new Exception(
Expand Down Expand Up @@ -117,7 +117,7 @@ public function count(): int
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws Exception
*/
public function run(TestResult $result = null): TestResult
public function run(?TestResult $result = null): TestResult
{
if ($result === null) {
$result = new TestResult;
Expand Down
2 changes: 1 addition & 1 deletion src/TextUI/TestRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ final class TestRunner extends BaseTestRunner
*/
private $extensions = [];

public function __construct(TestSuiteLoader $loader = null, CodeCoverageFilter $filter = null)
public function __construct(?TestSuiteLoader $loader = null, ?CodeCoverageFilter $filter = null)
{
if ($filter === null) {
$filter = new CodeCoverageFilter;
Expand Down
2 changes: 1 addition & 1 deletion src/Util/Getopt.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ final class Getopt
/**
* @throws Exception
*/
public static function parse(array $args, string $short_options, array $long_options = null): array
public static function parse(array $args, string $short_options, ?array $long_options = null): array
{
if (empty($args)) {
return [[], []];
Expand Down
2 changes: 1 addition & 1 deletion src/Util/PHP/AbstractPhpProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public function runTestJob(string $job, Test $test, TestResult $result, string $
/**
* Returns the command based into the configurations.
*/
public function getCommand(array $settings, string $file = null): string
public function getCommand(array $settings, ?string $file = null): string
{
$command = $this->runtime->getBinary();

Expand Down
2 changes: 1 addition & 1 deletion src/Util/PHP/WindowsPhpProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
final class WindowsPhpProcess extends DefaultPhpProcess
{
public function getCommand(array $settings, string $file = null): string
public function getCommand(array $settings, ?string $file = null): string
{
if (PHP_MAJOR_VERSION < 8) {
return '"' . parent::getCommand($settings, $file) . '"';
Expand Down
2 changes: 1 addition & 1 deletion tests/_files/DoubleTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function count(): int
return 2;
}

public function run(TestResult $result = null): TestResult
public function run(?TestResult $result = null): TestResult
{
$result->startTest($this);

Expand Down
2 changes: 1 addition & 1 deletion tests/_files/NotSelfDescribingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function count(): int
return 0;
}

public function run(TestResult $result = null): TestResult
public function run(?TestResult $result = null): TestResult
{
return new TestResult;
}
Expand Down

0 comments on commit 90f86fc

Please sign in to comment.