|
5 | 5 | use Closure;
|
6 | 6 | use PHPStan\Testing\PHPStanTestCase;
|
7 | 7 | use PHPStan\TrinaryLogic;
|
| 8 | +use PHPStan\Type\Accessory\HasOffsetType; |
| 9 | +use PHPStan\Type\Accessory\HasOffsetValueType; |
8 | 10 | use PHPStan\Type\ArrayType;
|
9 | 11 | use PHPStan\Type\CallableType;
|
10 | 12 | use PHPStan\Type\Generic\GenericClassStringType;
|
11 | 13 | use PHPStan\Type\Generic\TemplateTypeFactory;
|
12 | 14 | use PHPStan\Type\Generic\TemplateTypeScope;
|
13 | 15 | use PHPStan\Type\Generic\TemplateTypeVariance;
|
14 | 16 | use PHPStan\Type\IntegerType;
|
| 17 | +use PHPStan\Type\IntersectionType; |
15 | 18 | use PHPStan\Type\IterableType;
|
16 | 19 | use PHPStan\Type\MixedType;
|
| 20 | +use PHPStan\Type\NeverType; |
17 | 21 | use PHPStan\Type\ObjectType;
|
18 | 22 | use PHPStan\Type\StringType;
|
19 | 23 | use PHPStan\Type\Type;
|
@@ -345,6 +349,63 @@ public function dataAccepts(): iterable
|
345 | 349 | ]),
|
346 | 350 | TrinaryLogic::createNo(),
|
347 | 351 | ];
|
| 352 | + |
| 353 | + yield [ |
| 354 | + new ConstantArrayType([], []), |
| 355 | + new NeverType(), |
| 356 | + TrinaryLogic::createYes(), |
| 357 | + ]; |
| 358 | + |
| 359 | + yield [ |
| 360 | + new ConstantArrayType([new ConstantIntegerType(1)], [new ConstantIntegerType(2)]), |
| 361 | + new NeverType(), |
| 362 | + TrinaryLogic::createYes(), |
| 363 | + ]; |
| 364 | + |
| 365 | + yield [ |
| 366 | + new ConstantArrayType([new ConstantStringType('test')], [new MixedType()]), |
| 367 | + new IntersectionType([ |
| 368 | + new ArrayType(new MixedType(), new MixedType()), |
| 369 | + new HasOffsetType(new ConstantStringType('test')), |
| 370 | + ]), |
| 371 | + TrinaryLogic::createYes(), |
| 372 | + ]; |
| 373 | + |
| 374 | + yield [ |
| 375 | + new ConstantArrayType([new ConstantStringType('test')], [new StringType()]), |
| 376 | + new IntersectionType([ |
| 377 | + new ArrayType(new MixedType(), new MixedType()), |
| 378 | + new HasOffsetValueType(new ConstantStringType('test'), new StringType()), |
| 379 | + ]), |
| 380 | + TrinaryLogic::createYes(), |
| 381 | + ]; |
| 382 | + |
| 383 | + yield [ |
| 384 | + new ConstantArrayType([new ConstantStringType('test')], [new MixedType()]), |
| 385 | + new UnionType([ |
| 386 | + new ArrayType(new MixedType(), new MixedType()), |
| 387 | + new HasOffsetType(new ConstantStringType('test')), |
| 388 | + ]), |
| 389 | + TrinaryLogic::createMaybe(), |
| 390 | + ]; |
| 391 | + |
| 392 | + yield [ |
| 393 | + new ConstantArrayType([new ConstantStringType('test')], [new StringType()]), |
| 394 | + new UnionType([ |
| 395 | + new ArrayType(new MixedType(), new MixedType()), |
| 396 | + new HasOffsetValueType(new ConstantStringType('test'), new StringType()), |
| 397 | + ]), |
| 398 | + TrinaryLogic::createMaybe(), |
| 399 | + ]; |
| 400 | + |
| 401 | + yield [ |
| 402 | + new ConstantArrayType([new ConstantStringType('test')], [new MixedType()]), |
| 403 | + new IntersectionType([ |
| 404 | + new UnionType([new ArrayType(new MixedType(), new MixedType()), new IterableType(new MixedType(), new MixedType())]), |
| 405 | + new HasOffsetType(new ConstantStringType('test')), |
| 406 | + ]), |
| 407 | + TrinaryLogic::createMaybe(), |
| 408 | + ]; |
348 | 409 | }
|
349 | 410 |
|
350 | 411 | /**
|
|
0 commit comments