Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHPCS: nullable types PHP 8.4 #630

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fixtures/WithArguments.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class WithArguments
{
public function methodWithArgs(\ArrayAccess $arg_1, array $arg_2 = [], \ArrayAccess $arg_3 = null)
public function methodWithArgs(\ArrayAccess $arg_1, array $arg_2 = [], ?\ArrayAccess $arg_3 = null)
{
}

Expand Down
2 changes: 1 addition & 1 deletion fixtures/WithCallableArgument.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class WithCallableArgument
{
public function methodWithArgs(callable $arg_1, callable $arg_2 = null)
public function methodWithArgs(callable $arg_1, ?callable $arg_2 = null)
{
}
}
2 changes: 1 addition & 1 deletion src/Prophecy/Argument/Token/ExactValueToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ExactValueToken implements TokenInterface
*
* @param mixed $value
*/
public function __construct($value, StringUtil $util = null, ComparatorFactory $comparatorFactory = null)
public function __construct($value, ?StringUtil $util = null, ?ComparatorFactory $comparatorFactory = null)
{
$this->value = $value;
$this->util = $util ?: new StringUtil();
Expand Down
2 changes: 1 addition & 1 deletion src/Prophecy/Argument/Token/IdenticalValueToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class IdenticalValueToken implements TokenInterface
*
* @param mixed $value
*/
public function __construct($value, StringUtil $util = null)
public function __construct($value, ?StringUtil $util = null)
{
$this->value = $value;
$this->util = $util ?: new StringUtil();
Expand Down
4 changes: 2 additions & 2 deletions src/Prophecy/Argument/Token/ObjectStateToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class ObjectStateToken implements TokenInterface
public function __construct(
$methodName,
$value,
StringUtil $util = null,
ComparatorFactory $comparatorFactory = null
?StringUtil $util = null,
?ComparatorFactory $comparatorFactory = null
) {
$this->name = $methodName;
$this->value = $value;
Expand Down
2 changes: 1 addition & 1 deletion src/Prophecy/Call/Call.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Call
* @param null|int $line
*/
public function __construct($methodName, array $arguments, $returnValue,
Exception $exception = null, $file, $line)
?Exception $exception, $file, $line)
{
$this->methodName = $methodName;
$this->arguments = $arguments;
Expand Down
2 changes: 1 addition & 1 deletion src/Prophecy/Call/CallCenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class CallCenter
*
* @param StringUtil $util
*/
public function __construct(StringUtil $util = null)
public function __construct(?StringUtil $util = null)
{
$this->util = $util ?: new StringUtil;
$this->unexpectedCalls = new SplObjectStorage();
Expand Down
4 changes: 2 additions & 2 deletions src/Prophecy/Doubler/CachedDoubler.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class CachedDoubler extends Doubler
*/
private static $classes = array();

protected function createDoubleClass(ReflectionClass $class = null, array $interfaces)
protected function createDoubleClass(?ReflectionClass $class, array $interfaces)
{
$classId = $this->generateClassId($class, $interfaces);
if (isset(self::$classes[$classId])) {
Expand All @@ -42,7 +42,7 @@ protected function createDoubleClass(ReflectionClass $class = null, array $inter
*
* @return string
*/
private function generateClassId(ReflectionClass $class = null, array $interfaces)
private function generateClassId(?ReflectionClass $class, array $interfaces)
{
$parts = array();
if (null !== $class) {
Expand Down
2 changes: 1 addition & 1 deletion src/Prophecy/Doubler/ClassPatch/MagicCallPatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class MagicCallPatch implements ClassPatchInterface

private $tagRetriever;

public function __construct(MethodTagRetrieverInterface $tagRetriever = null)
public function __construct(?MethodTagRetrieverInterface $tagRetriever = null)
{
$this->tagRetriever = null === $tagRetriever ? new ClassAndInterfaceTagRetriever() : $tagRetriever;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Prophecy/Doubler/Doubler.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class Doubler
*/
private $instantiator;

public function __construct(ClassMirror $mirror = null, ClassCreator $creator = null,
NameGenerator $namer = null)
public function __construct(?ClassMirror $mirror = null, ?ClassCreator $creator = null,
?NameGenerator $namer = null)
{
$this->mirror = $mirror ?: new ClassMirror;
$this->creator = $creator ?: new ClassCreator;
Expand Down Expand Up @@ -87,7 +87,7 @@ public function registerClassPatch(ClassPatchInterface $patch)
*
* @throws \Prophecy\Exception\InvalidArgumentException
*/
public function double(ReflectionClass $class = null, array $interfaces, array $args = null)
public function double(?ReflectionClass $class, array $interfaces, ?array $args = null)
{
foreach ($interfaces as $interface) {
if (!$interface instanceof ReflectionClass) {
Expand Down Expand Up @@ -127,7 +127,7 @@ public function double(ReflectionClass $class = null, array $interfaces, array $
*
* @return class-string<T&DoubleInterface>
*/
protected function createDoubleClass(ReflectionClass $class = null, array $interfaces)
protected function createDoubleClass(?ReflectionClass $class, array $interfaces)
{
$name = $this->namer->name($class, $interfaces);
$node = $this->mirror->reflect($class, $interfaces);
Expand Down
2 changes: 1 addition & 1 deletion src/Prophecy/Doubler/Generator/ClassCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ClassCreator
{
private $generator;

public function __construct(ClassCodeGenerator $generator = null)
public function __construct(?ClassCodeGenerator $generator = null)
{
$this->generator = $generator ?: new ClassCodeGenerator;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Prophecy/Doubler/LazyDouble.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function addInterface($interface)
*
* @return void
*/
public function setArguments(array $arguments = null)
public function setArguments(?array $arguments = null)
{
$this->arguments = $arguments;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Prophecy/Doubler/NameGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class NameGenerator
*
* @return string
*/
public function name(ReflectionClass $class = null, array $interfaces)
public function name(?ReflectionClass $class, array $interfaces)
{
$parts = array();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ final class ClassAndInterfaceTagRetriever implements MethodTagRetrieverInterface
*/
private $classRetriever;

public function __construct(MethodTagRetrieverInterface $classRetriever = null)
public function __construct(?MethodTagRetrieverInterface $classRetriever = null)
{
if (null !== $classRetriever) {
$this->classRetriever = $classRetriever;
Expand Down
2 changes: 1 addition & 1 deletion src/Prophecy/Prediction/CallPrediction.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class CallPrediction implements PredictionInterface
{
private $util;

public function __construct(StringUtil $util = null)
public function __construct(?StringUtil $util = null)
{
$this->util = $util ?: new StringUtil;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Prophecy/Prediction/CallTimesPrediction.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class CallTimesPrediction implements PredictionInterface
/**
* @param int $times
*/
public function __construct($times, StringUtil $util = null)
public function __construct($times, ?StringUtil $util = null)
{
$this->times = intval($times);
$this->util = $util ?: new StringUtil;
Expand Down
2 changes: 1 addition & 1 deletion src/Prophecy/Prediction/NoCallsPrediction.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class NoCallsPrediction implements PredictionInterface
{
private $util;

public function __construct(StringUtil $util = null)
public function __construct(?StringUtil $util = null)
{
$this->util = $util ?: new StringUtil;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Prophecy/Prophecy/ObjectProphecy.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ class ObjectProphecy implements ProphecyInterface
*/
public function __construct(
LazyDouble $lazyDouble,
CallCenter $callCenter = null,
RevealerInterface $revealer = null,
ComparatorFactory $comparatorFactory = null
?CallCenter $callCenter = null,
?RevealerInterface $revealer = null,
?ComparatorFactory $comparatorFactory = null
) {
$this->lazyDouble = $lazyDouble;
$this->callCenter = $callCenter ?: new CallCenter;
Expand Down Expand Up @@ -103,7 +103,7 @@ public function willImplement($interface)
*
* @return $this
*/
public function willBeConstructedWith(array $arguments = null)
public function willBeConstructedWith(?array $arguments = null)
{
$this->lazyDouble->setArguments($arguments);

Expand Down
6 changes: 3 additions & 3 deletions src/Prophecy/Prophet.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ class Prophet
private $prophecies = array();

public function __construct(
Doubler $doubler = null,
RevealerInterface $revealer = null,
StringUtil $util = null
?Doubler $doubler = null,
?RevealerInterface $revealer = null,
?StringUtil $util = null
) {
if (null === $doubler) {
$doubler = new CachedDoubler();
Expand Down