@@ -5344,9 +5344,17 @@ private function processAssignVar(
5344
5344
$ originalVar = $ var ;
5345
5345
$ assignedPropertyExpr = $ assignedExpr ;
5346
5346
while ($ var instanceof ArrayDimFetch) {
5347
- $ varForSetOffsetValue = $ var ->var ;
5348
- if ($ varForSetOffsetValue instanceof PropertyFetch || $ varForSetOffsetValue instanceof StaticPropertyFetch) {
5349
- $ varForSetOffsetValue = new OriginalPropertyTypeExpr ($ varForSetOffsetValue );
5347
+ if (
5348
+ $ var ->var instanceof PropertyFetch
5349
+ || $ var ->var instanceof StaticPropertyFetch
5350
+ ) {
5351
+ if (((new ObjectType (ArrayAccess::class))->isSuperTypeOf ($ scope ->getType ($ var ->var ))->yes ())) {
5352
+ $ varForSetOffsetValue = $ var ->var ;
5353
+ } else {
5354
+ $ varForSetOffsetValue = new OriginalPropertyTypeExpr ($ var ->var );
5355
+ }
5356
+ } else {
5357
+ $ varForSetOffsetValue = $ var ->var ;
5350
5358
}
5351
5359
$ assignedPropertyExpr = new SetOffsetValueTypeExpr (
5352
5360
$ varForSetOffsetValue ,
@@ -5682,9 +5690,17 @@ static function (): void {
5682
5690
$ dimFetchStack = [];
5683
5691
$ assignedPropertyExpr = $ assignedExpr ;
5684
5692
while ($ var instanceof ExistingArrayDimFetch) {
5685
- $ varForSetOffsetValue = $ var ->getVar ();
5686
- if ($ varForSetOffsetValue instanceof PropertyFetch || $ varForSetOffsetValue instanceof StaticPropertyFetch) {
5687
- $ varForSetOffsetValue = new OriginalPropertyTypeExpr ($ varForSetOffsetValue );
5693
+ if (
5694
+ $ var ->getVar () instanceof PropertyFetch
5695
+ || $ var ->getVar () instanceof StaticPropertyFetch
5696
+ ) {
5697
+ if (((new ObjectType (ArrayAccess::class))->isSuperTypeOf ($ scope ->getType ($ var ->getVar ()))->yes ())) {
5698
+ $ varForSetOffsetValue = $ var ->getVar ();
5699
+ } else {
5700
+ $ varForSetOffsetValue = new OriginalPropertyTypeExpr ($ var ->getVar ());
5701
+ }
5702
+ } else {
5703
+ $ varForSetOffsetValue = $ var ->getVar ();
5688
5704
}
5689
5705
$ assignedPropertyExpr = new SetExistingOffsetValueTypeExpr (
5690
5706
$ varForSetOffsetValue ,
0 commit comments