|
14 | 14 | use Sabberworm\CSS\Parsing\OutputException; |
15 | 15 | use Sabberworm\CSS\Parsing\SourceException; |
16 | 16 | use Sabberworm\CSS\Parsing\UnexpectedTokenException; |
| 17 | +use Sabberworm\CSS\Position\Positionable; |
17 | 18 | use Sabberworm\CSS\Property\AtRule; |
18 | 19 | use Sabberworm\CSS\Property\Charset; |
19 | 20 | use Sabberworm\CSS\Property\CSSNamespace; |
@@ -975,31 +976,12 @@ public function lineNumbersParsing(): void |
975 | 976 |
|
976 | 977 | $actual = []; |
977 | 978 | foreach ($document->getContents() as $contentItem) { |
978 | | - // PHPStan can see what `assertInstanceOf()` does, |
979 | | - // but does not understand `LogicalOr` with multiple `IsIntanceOf` constraints. |
980 | | - // So a more explicit type check is required. |
981 | | - // TODO: tidy this up when an interface with `getLineNo()` is added. |
982 | | - if ( |
983 | | - !$contentItem instanceof Charset |
984 | | - && !$contentItem instanceof CSSList |
985 | | - && !$contentItem instanceof CSSNamespace |
986 | | - && !$contentItem instanceof Import |
987 | | - && !$contentItem instanceof RuleSet |
988 | | - ) { |
989 | | - self::fail('Content item is not of an expected type. It\'s a `' . \get_class($contentItem) . '`.'); |
990 | | - } |
991 | | - $actual[$contentItem->getLineNo()] = [\get_class($contentItem)]; |
| 979 | + self::assertInstanceOf(Positionable::class, $contentItem); |
| 980 | + $actual[$contentItem->getLineNumber()] = [\get_class($contentItem)]; |
992 | 981 | if ($contentItem instanceof KeyFrame) { |
993 | 982 | foreach ($contentItem->getContents() as $block) { |
994 | | - if ( |
995 | | - !$block instanceof CSSList |
996 | | - && !$block instanceof RuleSet |
997 | | - ) { |
998 | | - self::fail( |
999 | | - 'KeyFrame content item is not of an expected type. It\'s a `' . \get_class($block) . '`.' |
1000 | | - ); |
1001 | | - } |
1002 | | - $actual[$contentItem->getLineNo()][] = $block->getLineNo(); |
| 983 | + self::assertInstanceOf(Positionable::class, $block); |
| 984 | + $actual[$contentItem->getLineNumber()][] = $block->getLineNumber(); |
1003 | 985 | } |
1004 | 986 | } |
1005 | 987 | } |
|
0 commit comments