From 1ab5e174c9f0b1abb747a7696ca81b0ba901e767 Mon Sep 17 00:00:00 2001 From: Sofiia Kulish Date: Tue, 28 Jan 2025 08:55:37 +0100 Subject: [PATCH] PHP8.4 support --- .../RemoveExtraParametersRector/Source/CollectionImpl.php | 2 +- .../AddParamTypeDeclarationRector/Source/ParserInterface.php | 2 +- .../AddVoidReturnTypeWhereNoReturnRector/Source/vendor/Foo.php | 2 +- .../ParamTypeByMethodCallTypeRector/Source/SomeTypedService.php | 2 +- src/PhpParser/NodeTransformer.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/rules-tests/Php71/Rector/FuncCall/RemoveExtraParametersRector/Source/CollectionImpl.php b/rules-tests/Php71/Rector/FuncCall/RemoveExtraParametersRector/Source/CollectionImpl.php index 954b96932ea..bd02ef9f6cb 100644 --- a/rules-tests/Php71/Rector/FuncCall/RemoveExtraParametersRector/Source/CollectionImpl.php +++ b/rules-tests/Php71/Rector/FuncCall/RemoveExtraParametersRector/Source/CollectionImpl.php @@ -6,7 +6,7 @@ class CollectionImpl implements CollectionInterface { - public function getData(string $var = null) + public function getData(?string $var = null) { echo $var ?? 'fallback'; } diff --git a/rules-tests/TypeDeclaration/Rector/ClassMethod/AddParamTypeDeclarationRector/Source/ParserInterface.php b/rules-tests/TypeDeclaration/Rector/ClassMethod/AddParamTypeDeclarationRector/Source/ParserInterface.php index 2323a6cb1bc..5cc7df6caad 100644 --- a/rules-tests/TypeDeclaration/Rector/ClassMethod/AddParamTypeDeclarationRector/Source/ParserInterface.php +++ b/rules-tests/TypeDeclaration/Rector/ClassMethod/AddParamTypeDeclarationRector/Source/ParserInterface.php @@ -6,5 +6,5 @@ interface ParserInterface { - public function parse($code, \PhpParser\ErrorHandler $errorHandler = null); + public function parse($code, ?\PhpParser\ErrorHandler $errorHandler = null); } diff --git a/rules-tests/TypeDeclaration/Rector/ClassMethod/AddVoidReturnTypeWhereNoReturnRector/Source/vendor/Foo.php b/rules-tests/TypeDeclaration/Rector/ClassMethod/AddVoidReturnTypeWhereNoReturnRector/Source/vendor/Foo.php index 6b34d7b05a4..62dcf23a46b 100644 --- a/rules-tests/TypeDeclaration/Rector/ClassMethod/AddVoidReturnTypeWhereNoReturnRector/Source/vendor/Foo.php +++ b/rules-tests/TypeDeclaration/Rector/ClassMethod/AddVoidReturnTypeWhereNoReturnRector/Source/vendor/Foo.php @@ -4,7 +4,7 @@ trait Foo { - public function load($resource, string $type = null): string + public function load($resource, ?string $type = null): string { } } diff --git a/rules-tests/TypeDeclaration/Rector/ClassMethod/ParamTypeByMethodCallTypeRector/Source/SomeTypedService.php b/rules-tests/TypeDeclaration/Rector/ClassMethod/ParamTypeByMethodCallTypeRector/Source/SomeTypedService.php index 814dd3059bb..07f47312411 100644 --- a/rules-tests/TypeDeclaration/Rector/ClassMethod/ParamTypeByMethodCallTypeRector/Source/SomeTypedService.php +++ b/rules-tests/TypeDeclaration/Rector/ClassMethod/ParamTypeByMethodCallTypeRector/Source/SomeTypedService.php @@ -14,7 +14,7 @@ public static function fun($surname, string $name) { } - public function withDefaultNull(string $name = null) + public function withDefaultNull(?string $name = null) { } diff --git a/src/PhpParser/NodeTransformer.php b/src/PhpParser/NodeTransformer.php index d44591b0921..6f5bb3aac30 100644 --- a/src/PhpParser/NodeTransformer.php +++ b/src/PhpParser/NodeTransformer.php @@ -136,7 +136,7 @@ private function splitMessageAndArgs(FuncCall $sprintfFuncCall): ?SprintfStringA */ private function splitBySpace(string $value): array { - $value = str_getcsv($value, ' '); + $value = str_getcsv($value, ' ', escape: '\\'); return array_filter($value); }