diff --git a/config/set/php85.php b/config/set/php85.php index 3bd05b90193..a118ca891b9 100644 --- a/config/set/php85.php +++ b/config/set/php85.php @@ -42,7 +42,7 @@ ChrArgModuloRector::class, SleepToSerializeRector::class, OrdSingleByteRector::class, - WakeupToUnserializeRector::class + WakeupToUnserializeRector::class, ] ); diff --git a/rules-tests/TypeDeclarationDocblocks/Rector/ClassMethod/AddReturnDocblockForCommonObjectDenominatorRector/Fixture/skip_deep_array_structure.php.inc b/rules-tests/TypeDeclarationDocblocks/Rector/ClassMethod/AddReturnDocblockForCommonObjectDenominatorRector/Fixture/skip_deep_array_structure.php.inc new file mode 100644 index 00000000000..e2d5356c0d7 --- /dev/null +++ b/rules-tests/TypeDeclarationDocblocks/Rector/ClassMethod/AddReturnDocblockForCommonObjectDenominatorRector/Fixture/skip_deep_array_structure.php.inc @@ -0,0 +1,19 @@ +name = new Identifier('__unserialize'); $classMethod->returnType = new Identifier('void'); - $param = new Param( - var: new Variable('data'), - type: new Identifier('array') - ); + + $param = new Param(var: new Variable('data'), type: new Identifier('array')); $classMethod->params[] = $param; $classMethod->stmts = [$this->assignProperties()]; - + return $node; } - protected function assignProperties(): Foreach_{ + private function assignProperties(): Foreach_ + { $assign = new Assign( new PropertyFetch(new Variable('this'), new Variable('property')), new Variable('value') @@ -109,23 +109,21 @@ protected function assignProperties(): Foreach_{ $if = new If_( new FuncCall(new Name('property_exists'), [ - new Node\Arg(new Variable('this')), - new Node\Arg(new Variable('property')), + new Arg(new Variable('this')), + new Arg(new Variable('property')), ]), [ 'stmts' => [new Expression($assign)], ] ); - $foreach = new Foreach_( + return new Foreach_( new Variable('data'), new Variable('value'), [ 'keyVar' => new Variable('property'), - 'stmts' => [$if], + 'stmts' => [$if], ] ); - - return $foreach; } } diff --git a/rules/TypeDeclarationDocblocks/Rector/ClassMethod/AddReturnDocblockForCommonObjectDenominatorRector.php b/rules/TypeDeclarationDocblocks/Rector/ClassMethod/AddReturnDocblockForCommonObjectDenominatorRector.php index 5e61dccd78e..150d923c587 100644 --- a/rules/TypeDeclarationDocblocks/Rector/ClassMethod/AddReturnDocblockForCommonObjectDenominatorRector.php +++ b/rules/TypeDeclarationDocblocks/Rector/ClassMethod/AddReturnDocblockForCommonObjectDenominatorRector.php @@ -132,6 +132,13 @@ public function refactor(Node $node): ?Node return null; } + /** + * nested structure + */ + if ($valueType->isArray()->yes()) { + return null; + } + $referencedClasses = array_merge($referencedClasses, $valueType->getReferencedClasses()); } diff --git a/src/ValueObject/PhpVersionFeature.php b/src/ValueObject/PhpVersionFeature.php index 182b8b4a3cb..6730eebcb47 100644 --- a/src/ValueObject/PhpVersionFeature.php +++ b/src/ValueObject/PhpVersionFeature.php @@ -822,13 +822,13 @@ final class PhpVersionFeature * @var int */ public const DEPRECATED_METHOD_SLEEP = PhpVersion::PHP_85; - + /** * @see https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_the_sleep_and_wakeup_magic_methods * @var int */ public const DEPRECATED_METHOD_WAKEUP = PhpVersion::PHP_85; - + /** * @see https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_passing_string_which_are_not_one_byte_long_to_ord * @var int