File tree Expand file tree Collapse file tree
rules-tests/TypeDeclarationDocblocks/Rector/ClassMethod/DocblockReturnArrayFromDirectArrayInstanceRector/Fixture
rules/TypeDeclarationDocblocks/TypeResolver Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ namespace Rector\Tests\TypeDeclarationDocblocks\Rector\ClassMethod\DocblockRetur
3131class ComplexArray
3232{
3333 /**
34- * @return array<string, mixed>
34+ * @return array<string, object| mixed[] >
3535 */
3636 public function run (): array
3737 {
Original file line number Diff line number Diff line change 66
77use PHPStan \PhpDocParser \Ast \Type \GenericTypeNode ;
88use PHPStan \PhpDocParser \Ast \Type \IdentifierTypeNode ;
9+ use PHPStan \Type \ArrayType ;
910use PHPStan \Type \BooleanType ;
1011use PHPStan \Type \Constant \ConstantArrayType ;
1112use PHPStan \Type \FloatType ;
1213use PHPStan \Type \IntegerType ;
1314use PHPStan \Type \IntersectionType ;
1415use PHPStan \Type \MixedType ;
1516use PHPStan \Type \NeverType ;
17+ use PHPStan \Type \ObjectWithoutClassType ;
1618use PHPStan \Type \StringType ;
1719use PHPStan \Type \Type ;
1820use PHPStan \Type \UnionType ;
@@ -98,6 +100,10 @@ private function constantToGenericType(Type $type): Type
98100 return new FloatType ();
99101 }
100102
103+ if ($ type ->isObject ()->yes ()) {
104+ return new ObjectWithoutClassType ();
105+ }
106+
101107 if ($ type instanceof UnionType || $ type instanceof IntersectionType) {
102108 $ genericComplexTypes = [];
103109 foreach ($ type ->getTypes () as $ splitType ) {
@@ -112,6 +118,10 @@ private function constantToGenericType(Type $type): Type
112118 return $ genericComplexTypes [0 ];
113119 }
114120
121+ if ($ type instanceof ConstantArrayType) {
122+ return new ArrayType (new MixedType (), new MixedType ());
123+ }
124+
115125 // unclear
116126 return new MixedType ();
117127 }
You can’t perform that action at this time.
0 commit comments