|
| 1 | +<?php // lint >= 8.0 |
| 2 | + |
| 3 | +declare(strict_types = 1); |
| 4 | + |
| 5 | +namespace Bug5207; |
| 6 | + |
| 7 | +use function PHPStan\Testing\assertType; |
| 8 | + |
| 9 | +abstract class HelloWorld { |
| 10 | + abstract public function getChild(): ?HelloWorld; |
| 11 | + |
| 12 | + public function sayHello(): void { |
| 13 | + $foo = null !== $this->getChild(); |
| 14 | + if ($foo) { |
| 15 | + assertType('Bug5207\HelloWorld', $this->getChild()); |
| 16 | + } |
| 17 | + } |
| 18 | + |
| 19 | + public function sayHelloInline(): void { |
| 20 | + if (null !== $this->getChild()) { |
| 21 | + assertType('Bug5207\HelloWorld', $this->getChild()); |
| 22 | + } |
| 23 | + } |
| 24 | +} |
| 25 | + |
| 26 | +abstract class StaticWorld { |
| 27 | + abstract public static function getChild(): ?StaticWorld; |
| 28 | + |
| 29 | + public static function sayHello(): void { |
| 30 | + $foo = null !== static::getChild(); |
| 31 | + if ($foo) { |
| 32 | + assertType('Bug5207\StaticWorld', static::getChild()); |
| 33 | + } |
| 34 | + } |
| 35 | + |
| 36 | + public static function sayHelloInline(): void { |
| 37 | + if (null !== static::getChild()) { |
| 38 | + assertType('Bug5207\StaticWorld', static::getChild()); |
| 39 | + } |
| 40 | + } |
| 41 | +} |
| 42 | + |
| 43 | +abstract class ImpureStaticWorld { |
| 44 | + /** |
| 45 | + * @phpstan-impure |
| 46 | + */ |
| 47 | + abstract public static function getChild(): ?ImpureStaticWorld; |
| 48 | + |
| 49 | + public static function sayHello(): void { |
| 50 | + $foo = null !== static::getChild(); |
| 51 | + if ($foo) { |
| 52 | + assertType('Bug5207\ImpureStaticWorld|null', static::getChild()); |
| 53 | + } |
| 54 | + } |
| 55 | + |
| 56 | + public static function sayHelloInline(): void { |
| 57 | + if (null !== static::getChild()) { |
| 58 | + assertType('Bug5207\ImpureStaticWorld|null', static::getChild()); |
| 59 | + } |
| 60 | + } |
| 61 | +} |
| 62 | + |
| 63 | +abstract class ImpureWorld { |
| 64 | + /** |
| 65 | + * @phpstan-impure |
| 66 | + */ |
| 67 | + abstract public function getChild(): ?ImpureWorld; |
| 68 | + |
| 69 | + public function sayHello(): void { |
| 70 | + $foo = null !== $this->getChild(); |
| 71 | + if ($foo) { |
| 72 | + assertType('Bug5207\ImpureWorld|null', $this->getChild()); |
| 73 | + } |
| 74 | + } |
| 75 | + |
| 76 | + public function sayHelloInline(): void { |
| 77 | + if (null !== $this->getChild()) { |
| 78 | + assertType('Bug5207\ImpureWorld|null', $this->getChild()); |
| 79 | + } |
| 80 | + } |
| 81 | +} |
0 commit comments