|
| 1 | +<?php declare(strict_types = 1); |
| 2 | + |
| 3 | +namespace PHPStan\Php; |
| 4 | + |
| 5 | +use PHPStan\TrinaryLogic; |
| 6 | +use PHPStan\Type\Constant\ConstantIntegerType; |
| 7 | +use PHPStan\Type\IntegerRangeType; |
| 8 | +use PHPStan\Type\Type; |
| 9 | +use PHPStan\Type\UnionType; |
| 10 | +use PHPUnit\Framework\TestCase; |
| 11 | + |
| 12 | +class PhpVersionsTest extends TestCase |
| 13 | +{ |
| 14 | + |
| 15 | + /** |
| 16 | + * @dataProvider dataProducesWarningForFinalPrivateMethods |
| 17 | + */ |
| 18 | + public function testProducesWarningForFinalPrivateMethods(TrinaryLogic $expected, Type $versionType): void |
| 19 | + { |
| 20 | + $phpVersions = new PhpVersions($versionType); |
| 21 | + $this->assertSame( |
| 22 | + $expected->describe(), |
| 23 | + $phpVersions->producesWarningForFinalPrivateMethods()->describe(), |
| 24 | + ); |
| 25 | + } |
| 26 | + |
| 27 | + public function dataProducesWarningForFinalPrivateMethods(): iterable |
| 28 | + { |
| 29 | + yield [ |
| 30 | + TrinaryLogic::createNo(), |
| 31 | + new ConstantIntegerType(70400), |
| 32 | + ]; |
| 33 | + |
| 34 | + yield [ |
| 35 | + TrinaryLogic::createYes(), |
| 36 | + new ConstantIntegerType(80000), |
| 37 | + ]; |
| 38 | + |
| 39 | + yield [ |
| 40 | + TrinaryLogic::createYes(), |
| 41 | + new ConstantIntegerType(80100), |
| 42 | + ]; |
| 43 | + |
| 44 | + yield [ |
| 45 | + TrinaryLogic::createYes(), |
| 46 | + IntegerRangeType::fromInterval(80000, null), |
| 47 | + ]; |
| 48 | + |
| 49 | + yield [ |
| 50 | + TrinaryLogic::createMaybe(), |
| 51 | + IntegerRangeType::fromInterval(null, 80000), |
| 52 | + ]; |
| 53 | + |
| 54 | + yield [ |
| 55 | + TrinaryLogic::createNo(), |
| 56 | + IntegerRangeType::fromInterval(70200, 70400), |
| 57 | + ]; |
| 58 | + |
| 59 | + yield [ |
| 60 | + TrinaryLogic::createMaybe(), |
| 61 | + new UnionType([ |
| 62 | + IntegerRangeType::fromInterval(70200, 70400), |
| 63 | + IntegerRangeType::fromInterval(80200, 80400), |
| 64 | + ]), |
| 65 | + ]; |
| 66 | + } |
| 67 | + |
| 68 | +} |
0 commit comments