From 7c7f32001ed877c900a05b9c0b3f4fcd8612feae Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Mon, 15 Sep 2025 13:03:07 +0200 Subject: [PATCH] add simple fixture --- .../Fixture/Nesting/simple_nesting.php.inc | 48 +++++++++++++++++++ .../TypeManipulator/TypeNormalizer.php | 3 +- 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 rules-tests/TypeDeclarationDocblocks/Rector/ClassMethod/DocblockReturnArrayFromDirectArrayInstanceRector/Fixture/Nesting/simple_nesting.php.inc diff --git a/rules-tests/TypeDeclarationDocblocks/Rector/ClassMethod/DocblockReturnArrayFromDirectArrayInstanceRector/Fixture/Nesting/simple_nesting.php.inc b/rules-tests/TypeDeclarationDocblocks/Rector/ClassMethod/DocblockReturnArrayFromDirectArrayInstanceRector/Fixture/Nesting/simple_nesting.php.inc new file mode 100644 index 00000000000..0e2f21da8de --- /dev/null +++ b/rules-tests/TypeDeclarationDocblocks/Rector/ClassMethod/DocblockReturnArrayFromDirectArrayInstanceRector/Fixture/Nesting/simple_nesting.php.inc @@ -0,0 +1,48 @@ + 'string-1', + 'key2' => [ + 'key2a' => null, + 'key2b' => [ + 'key2b1' => 'ABC', + ], + ], + 'key3' => 'string-2', + 'key4' => null, + 'key5' => 'string-3', + ]; + } +} +----- +|null>|string|null> + */ + public static function returnArray(): array + { + return [ + 'key1' => 'string-1', + 'key2' => [ + 'key2a' => null, + 'key2b' => [ + 'key2b1' => 'ABC', + ], + ], + 'key3' => 'string-2', + 'key4' => null, + 'key5' => 'string-3', + ]; + } +} diff --git a/rules/Privatization/TypeManipulator/TypeNormalizer.php b/rules/Privatization/TypeManipulator/TypeNormalizer.php index 90664309bdd..ab33a99bf4e 100644 --- a/rules/Privatization/TypeManipulator/TypeNormalizer.php +++ b/rules/Privatization/TypeManipulator/TypeNormalizer.php @@ -27,7 +27,7 @@ /** * @var int */ - private const MAX_PRINTED_UNION_DOC_LENGHT = 50; + private const MAX_PRINTED_UNION_DOC_LENGHT = 60; public function __construct( private TypeFactory $typeFactory, @@ -78,6 +78,7 @@ public function generalizeConstantTypes(Type $type): Type // should be string[] $itemType = $traverseCallback($type->getItemType(), $traverseCallback); + if ($itemType instanceof ConstantStringType) { $itemType = new StringType(); }