Skip to content

Commit

Permalink
[PHP 8.4] Fixes for implicit nullability deprecation (#1398)
Browse files Browse the repository at this point in the history
Signed-off-by: Nathanael Esayeas <nathanael.esayeas@protonmail.com>
  • Loading branch information
ghostwriter committed Mar 18, 2024
2 parents c9cf52d + cbb5798 commit 814cae2
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions library/Mockery.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public static function fetchMock($name)
*
* @return string
*/
public static function formatArgs($method, array $arguments = null)
public static function formatArgs($method, ?array $arguments = null)
{
if ($arguments === null) {
return $method . '()';
Expand All @@ -266,7 +266,7 @@ public static function formatArgs($method, array $arguments = null)
*
* @return string
*/
public static function formatObjects(array $objects = null)
public static function formatObjects(?array $objects = null)
{
static $formatting;

Expand Down
2 changes: 1 addition & 1 deletion library/Mockery/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class Container
*/
protected $instantiator;

public function __construct(Generator $generator = null, LoaderInterface $loader = null, Instantiator $instantiator = null)
public function __construct(?Generator $generator = null, ?LoaderInterface $loader = null, ?Instantiator $instantiator = null)
{
$this->_generator = $generator instanceof Generator ? $generator : Mockery::getDefaultGenerator();
$this->_loader = $loader instanceof LoaderInterface ? $loader : Mockery::getDefaultLoader();
Expand Down
4 changes: 2 additions & 2 deletions library/Mockery/Expectation.php
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ public function andSet($name, ...$values)
*
* @return self
*/
public function andThrow($exception, $message = '', $code = 0, \Exception $previous = null)
public function andThrow($exception, $message = '', $code = 0, ?\Exception $previous = null)
{
$this->_throw = true;

Expand Down Expand Up @@ -391,7 +391,7 @@ public function andThrowExceptions(array $exceptions)
return $this->andReturnValues($exceptions);
}

public function andThrows($exception, $message = '', $code = 0, \Exception $previous = null)
public function andThrows($exception, $message = '', $code = 0, ?\Exception $previous = null)
{
return $this->andThrow($exception, $message, $code, $previous);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function apply($code, MockConfiguration $config)
*
* @return array
*/
public function getMagicMethods(TargetClassInterface $class = null)
public function getMagicMethods(?TargetClassInterface $class = null)
{
if (! $class instanceof TargetClassInterface) {
return [];
Expand Down
4 changes: 2 additions & 2 deletions library/Mockery/LegacyMockInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function mockery_getName();
*
* @return void
*/
public function mockery_init(Container $container = null, $partialObject = null);
public function mockery_init(?Container $container = null, $partialObject = null);

/**
* @return bool
Expand Down Expand Up @@ -220,7 +220,7 @@ public function shouldIgnoreMissing($returnValue = null);
*
* @return mixed
*/
public function shouldNotHaveBeenCalled(array $args = null);
public function shouldNotHaveBeenCalled(?array $args = null);

/**
* @param string $method
Expand Down
4 changes: 2 additions & 2 deletions library/Mockery/Mock.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class Mock implements MockInterface
* @param bool $instanceMock
* @return void
*/
public function mockery_init(Container $container = null, $partialObject = null, $instanceMock = true)
public function mockery_init(?Container $container = null, $partialObject = null, $instanceMock = true)
{
if (is_null($container)) {
$container = new Container();
Expand Down Expand Up @@ -839,7 +839,7 @@ public function shouldNotHaveReceived($method = null, $args = null)
return null;
}

public function shouldNotHaveBeenCalled(array $args = null)
public function shouldNotHaveBeenCalled(?array $args = null)
{
return $this->shouldNotHaveReceived('__invoke', $args);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Mockery/ContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1777,7 +1777,7 @@ public function foo(callable $baz)
$baz();
}

public function bar(callable $callback = null)
public function bar(?callable $callback = null)
{
$callback();
}
Expand Down Expand Up @@ -1864,7 +1864,7 @@ public static function keepMe($b)

class MockeryTest_MethodWithRequiredParamWithDefaultValue
{
public function foo(DateTime $bar = null, $baz)
public function foo(?DateTime $bar = null, $baz)

Check warning on line 1867 in tests/Mockery/ContainerTest.php

View workflow job for this annotation

GitHub Actions / PHPUnit on PHP 8.1 with highest Dependencies

Optional parameter $bar declared before required parameter $baz is implicitly treated as a required parameter

Check warning on line 1867 in tests/Mockery/ContainerTest.php

View workflow job for this annotation

GitHub Actions / PHPUnit on PHP 8.1 with locked Dependencies

Optional parameter $bar declared before required parameter $baz is implicitly treated as a required parameter

Check warning on line 1867 in tests/Mockery/ContainerTest.php

View workflow job for this annotation

GitHub Actions / PHPUnit on PHP 8.2 with highest Dependencies

Optional parameter $bar declared before required parameter $baz is implicitly treated as a required parameter

Check warning on line 1867 in tests/Mockery/ContainerTest.php

View workflow job for this annotation

GitHub Actions / PHPUnit on PHP 8.2 with locked Dependencies

Optional parameter $bar declared before required parameter $baz is implicitly treated as a required parameter

Check warning on line 1867 in tests/Mockery/ContainerTest.php

View workflow job for this annotation

GitHub Actions / PHPUnit on PHP 8.3 with highest Dependencies

Optional parameter $bar declared before required parameter $baz is implicitly treated as a required parameter

Check warning on line 1867 in tests/Mockery/ContainerTest.php

View workflow job for this annotation

GitHub Actions / PHPUnit on PHP 8.3 with locked Dependencies

Optional parameter $bar declared before required parameter $baz is implicitly treated as a required parameter
{
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function foo(?string $bar)
{
}

public function bar(string $bar = null)
public function bar(?string $bar = null)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function foo($bar = null)
{
}

public function bar(string $bar = null)
public function bar(?string $bar = null)
{
}
}

0 comments on commit 814cae2

Please sign in to comment.