Skip to content

Commit 3fddd0b

Browse files
committed
ignore false positive test failure for PHP <8
1 parent b33c62a commit 3fddd0b

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

tests/Sniffs/TypeHints/DNFTypeHintFormatSniffTest.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,14 @@ public function testNullPositionFirstErrors(): void
305305
'nullPosition' => 'first',
306306
], [DNFTypeHintFormatSniff::CODE_NULL_TYPE_HINT_NOT_ON_FIRST_POSITION]);
307307

308-
self::assertSame(3, $report->getErrorCount());
308+
if (PHP_VERSION_ID >= 80000) {
309+
self::assertSame(3, $report->getErrorCount());
310+
311+
self::assertSniffError($report, 6, DNFTypeHintFormatSniff::CODE_NULL_TYPE_HINT_NOT_ON_FIRST_POSITION);
312+
} else {
313+
self::assertSame(2, $report->getErrorCount());
314+
}
309315

310-
self::assertSniffError($report, 6, DNFTypeHintFormatSniff::CODE_NULL_TYPE_HINT_NOT_ON_FIRST_POSITION);
311316
self::assertSniffError(
312317
$report,
313318
8,
@@ -321,7 +326,10 @@ public function testNullPositionFirstErrors(): void
321326
'Null type hint should be on first position in "string|null|\Anything".',
322327
);
323328

324-
self::assertAllFixedInFile($report);
329+
// in PHP < 8 it would be changed to short nullable, which is not tested in this test
330+
if (PHP_VERSION_ID >= 80000) {
331+
self::assertAllFixedInFile($report);
332+
}
325333
}
326334

327335
public function testNullPositionLastNoErrors(): void
@@ -361,7 +369,10 @@ public function testNullPositionLastErrors(): void
361369
'Null type hint should be on last position in "string|null|\Anything".',
362370
);
363371

364-
self::assertAllFixedInFile($report);
372+
// in PHP < 8 it would be changed to short nullable, which is not tested in this test
373+
if (PHP_VERSION_ID >= 80000) {
374+
self::assertAllFixedInFile($report);
375+
}
365376
}
366377

367378
public function testShouldNotReportIfSniffIsDisabled(): void

0 commit comments

Comments
 (0)