Skip to content

Commit

Permalink
misc: fix PHP 8.4 deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
mpesari authored Dec 19, 2024
1 parent fc4a81e commit b698def
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion qa/Psalm/ValinorPsalmPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class ValinorPsalmPlugin implements PluginEntryPointInterface
{
public function __invoke(RegistrationInterface $api, SimpleXMLElement $config = null): void
public function __invoke(RegistrationInterface $api, ?SimpleXMLElement $config = null): void
{
require_once __DIR__ . '/Plugin/TreeMapperPsalmPlugin.php';
require_once __DIR__ . '/Plugin/ArgumentsMapperPsalmPlugin.php';
Expand Down
2 changes: 1 addition & 1 deletion tests/Fake/Definition/FakeFunctionDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class FakeFunctionDefinition
/**
* @param non-empty-string|null $fileName
*/
public static function new(string $fileName = null): FunctionDefinition
public static function new(?string $fileName = null): FunctionDefinition
{
return new FunctionDefinition(
'foo',
Expand Down
2 changes: 1 addition & 1 deletion tests/Fake/Definition/FakeParameterDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ private function __construct() {}
/**
* @param non-empty-string $name
*/
public static function new(string $name = 'someParameter', Type $type = null): ParameterDefinition
public static function new(string $name = 'someParameter', ?Type $type = null): ParameterDefinition
{
return new ParameterDefinition(
$name,
Expand Down
2 changes: 1 addition & 1 deletion tests/Fake/Mapper/Tree/Builder/FakeNodeBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ final class FakeNodeBuilder implements NodeBuilder
/**
* @param null|callable(Shell): TreeNode $callback
*/
public function __construct(callable $callback = null)
public function __construct(?callable $callback = null)
{
if ($callback) {
$this->callback = $callback;
Expand Down
4 changes: 2 additions & 2 deletions tests/Fake/Mapper/Tree/Builder/FakeTreeNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static function leaf(Type $type, mixed $value): TreeNode
/**
* @param array<array{name?: string, type?: Type, value?: mixed, attributes?: Attributes, message?: Message}> $children
*/
public static function branch(array $children, Type $type = null, mixed $value = null): TreeNode
public static function branch(array $children, ?Type $type = null, mixed $value = null): TreeNode
{
$shell = FakeShell::new($type ?? FakeType::permissive(), $value);
$nodes = [];
Expand Down Expand Up @@ -58,7 +58,7 @@ public static function branch(array $children, Type $type = null, mixed $value =
/**
* @param Throwable&Message $error
*/
public static function error(Throwable $error = null): TreeNode
public static function error(?Throwable $error = null): TreeNode
{
$shell = FakeShell::new(FakeType::permissive(), []);

Expand Down
2 changes: 1 addition & 1 deletion tests/Fake/Type/FakeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class FakeType implements Type

private bool $permissive = false;

public function __construct(string $name = null)
public function __construct(?string $name = null)
{
$this->name = $name ?? 'FakeType' . self::$counter++;
}
Expand Down
6 changes: 3 additions & 3 deletions tests/StaticAnalysis/inferring-types-with-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function mapping_union_of_types_will_infer_correct_type(TreeMapper $mapper): voi

function mapping_function_arguments_will_infer_object_of_same_type(ArgumentsMapper $mapper): void
{
$result = $mapper->mapArguments(fn (string $foo, int $bar = null): string => "$foo / $bar", []);
$result = $mapper->mapArguments(fn (string $foo, ?int $bar = null): string => "$foo / $bar", []);

/** @psalm-check-type $result = array{foo: string, bar?: int|null} */
assertType('array{foo: string, bar?: int|null}', $result);
Expand All @@ -68,12 +68,12 @@ function mapping_method_arguments_will_infer_object_of_same_type(ArgumentsMapper

final class SomeClass
{
public static function someStaticMethod(string $foo, int $bar = null): string
public static function someStaticMethod(string $foo, ?int $bar = null): string
{
return "$foo / $bar";
}

public function someMethod(string $foo, int $bar = null): string
public function someMethod(string $foo, ?int $bar = null): string
{
return "$foo / $bar";
}
Expand Down

0 comments on commit b698def

Please sign in to comment.