@@ -431,4 +431,69 @@ public function testGetClassReflectionOfGenericClass(): void
431
431
$ this ->assertSame ('Traversable<mixed,mixed> ' , $ classReflection ->getDisplayName ());
432
432
}
433
433
434
+ public function dataHasOffsetValueType (): array
435
+ {
436
+ return [
437
+ [
438
+ new ObjectType (\stdClass::class),
439
+ new IntegerType (),
440
+ TrinaryLogic::createNo (),
441
+ ],
442
+ [
443
+ new ObjectType (\ArrayAccess::class),
444
+ new IntegerType (),
445
+ TrinaryLogic::createMaybe (),
446
+ ],
447
+ [
448
+ new GenericObjectType (\ArrayAccess::class, [new IntegerType (), new MixedType ()]),
449
+ new IntegerType (),
450
+ TrinaryLogic::createMaybe (),
451
+ ],
452
+ [
453
+ new GenericObjectType (\ArrayAccess::class, [new IntegerType (), new MixedType ()]),
454
+ new MixedType (),
455
+ TrinaryLogic::createMaybe (),
456
+ ],
457
+ [
458
+ new GenericObjectType (\ArrayAccess::class, [new IntegerType (), new MixedType ()]),
459
+ new StringType (),
460
+ TrinaryLogic::createNo (),
461
+ ],
462
+ [
463
+ new GenericObjectType (\ArrayAccess::class, [new ObjectType (\DateTimeInterface::class), new MixedType ()]),
464
+ new ObjectType (\DateTime::class),
465
+ TrinaryLogic::createMaybe (),
466
+ ],
467
+ [
468
+ new GenericObjectType (\ArrayAccess::class, [new ObjectType (\DateTime::class), new MixedType ()]),
469
+ new ObjectType (\DateTimeInterface::class),
470
+ TrinaryLogic::createMaybe (),
471
+ ],
472
+ [
473
+ new GenericObjectType (\ArrayAccess::class, [new ObjectType (\DateTime::class), new MixedType ()]),
474
+ new ObjectType (\stdClass::class),
475
+ TrinaryLogic::createNo (),
476
+ ],
477
+ ];
478
+ }
479
+
480
+ /**
481
+ * @dataProvider dataHasOffsetValueType
482
+ * @param \PHPStan\Type\ObjectType $type
483
+ * @param Type $offsetType
484
+ * @param TrinaryLogic $expectedResult
485
+ */
486
+ public function testHasOffsetValueType (
487
+ ObjectType $ type ,
488
+ Type $ offsetType ,
489
+ TrinaryLogic $ expectedResult
490
+ ): void
491
+ {
492
+ $ this ->assertSame (
493
+ $ expectedResult ->describe (),
494
+ $ type ->hasOffsetValueType ($ offsetType )->describe (),
495
+ sprintf ('%s -> accepts(%s) ' , $ type ->describe (VerbosityLevel::precise ()), $ offsetType ->describe (VerbosityLevel::precise ()))
496
+ );
497
+ }
498
+
434
499
}
0 commit comments