File tree Expand file tree Collapse file tree 3 files changed +34
-1
lines changed Expand file tree Collapse file tree 3 files changed +34
-1
lines changed Original file line number Diff line number Diff line change 9797use PHPStan \Type \MixedType ;
9898use PHPStan \Type \NullType ;
9999use PHPStan \Type \ObjectType ;
100+ use PHPStan \Type \ObjectWithoutClassType ;
100101use PHPStan \Type \StaticType ;
101102use PHPStan \Type \StringType ;
102103use PHPStan \Type \Type ;
@@ -2379,7 +2380,7 @@ private function processAssignVar(
23792380 $ scope = $ result ->getScope ();
23802381
23812382 $ varType = $ scope ->getType ($ var );
2382- if (!(new ObjectType (\ArrayAccess::class ))->isSuperTypeOf ($ varType )->yes ()) {
2383+ if (!(new ObjectWithoutClassType ( ))->isSuperTypeOf ($ varType )->yes ()) {
23832384 // 4. compose types
23842385 if ($ varType instanceof ErrorType) {
23852386 $ varType = new ConstantArrayType ([], []);
Original file line number Diff line number Diff line change @@ -10048,6 +10048,11 @@ public function dataBug2899(): array
1004810048 return $ this ->gatherAssertTypes (__DIR__ . '/data/bug-2899.php ' );
1004910049 }
1005010050
10051+ public function dataBug3782 (): array
10052+ {
10053+ return $ this ->gatherAssertTypes (__DIR__ . '/data/bug-3782.php ' );
10054+ }
10055+
1005110056 /**
1005210057 * @dataProvider dataBug2574
1005310058 * @dataProvider dataBug2577
@@ -10116,6 +10121,7 @@ public function dataBug2899(): array
1011610121 * @dataProvider dataBug3133
1011710122 * @dataProvider dataBug2550
1011810123 * @dataProvider dataBug2899
10124+ * @dataProvider dataBug3782
1011910125 * @param string $assertType
1012010126 * @param string $file
1012110127 * @param mixed ...$args
Original file line number Diff line number Diff line change 1+ <?php declare (strict_types = 1 );
2+
3+ namespace Bug3782 ;
4+
5+ use function PHPStan \Analyser \assertType ;
6+
7+ class HelloWorld
8+ {
9+ /** @param mixed[] $data */
10+ public function sayHello (array $ data ): void
11+ {
12+ foreach ($ data as $ key => $ value ){
13+ $ this [$ key ] = $ value ;
14+ assertType ('$this(Bug3782 \\HelloWorld) ' , $ this );
15+ }
16+ }
17+
18+ public static function sayHello2 (array $ data ): void
19+ {
20+ $ var = new HelloWorld ();
21+ foreach ($ data as $ key => $ value ){
22+ $ var [$ key ] = $ value ;
23+ assertType ('Bug3782 \\HelloWorld ' , $ var );
24+ }
25+ }
26+ }
You can’t perform that action at this time.
0 commit comments