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