diff --git a/composer.lock b/composer.lock index c0b3976..6defba8 100644 --- a/composer.lock +++ b/composer.lock @@ -1725,7 +1725,6 @@ "type": "github" } ], - "abandoned": true, "time": "2020-11-30T07:30:19+00:00" }, { diff --git a/src/DigiComp/Sniffs/Annotations/VarIsLastTagOnPropertySniff.php b/src/DigiComp/Sniffs/Annotations/VarIsLastTagOnPropertySniff.php index 25f651d..aac22cc 100644 --- a/src/DigiComp/Sniffs/Annotations/VarIsLastTagOnPropertySniff.php +++ b/src/DigiComp/Sniffs/Annotations/VarIsLastTagOnPropertySniff.php @@ -71,7 +71,7 @@ class VarIsLastTagOnPropertySniff extends AbstractVariableSniff } } } - if ($otherToken > $varToken) { + if ($varToken !== null && $otherToken > $varToken) { $fix = $phpcsFile->addFixableError('@var should be last property annotation', $varToken, 'VarNotLast'); if ($fix) { $this->moveVarTagToEndOfDoctype( diff --git a/tests/DigiComp/Sniffs/Annotations/VarIsLastTagOnPropertySniffTest.php b/tests/DigiComp/Sniffs/Annotations/VarIsLastTagOnPropertySniffTest.php index 8efdbc6..f45f737 100644 --- a/tests/DigiComp/Sniffs/Annotations/VarIsLastTagOnPropertySniffTest.php +++ b/tests/DigiComp/Sniffs/Annotations/VarIsLastTagOnPropertySniffTest.php @@ -11,4 +11,10 @@ class VarIsLastTagOnPropertySniffTest extends TestCase $report = self::checkFile(__DIR__ . '/data/PropertyOrder.php'); self::assertSame(2, $report->getErrorCount()); } + + public function testIgnoreVarTag(): void + { + $withoutErrors = self::checkFile(__DIR__ . '/data/Child.php'); + self::assertSame(0, $withoutErrors->getErrorCount()); + } } diff --git a/tests/DigiComp/Sniffs/Annotations/data/Child.php b/tests/DigiComp/Sniffs/Annotations/data/Child.php new file mode 100644 index 0000000..6089104 --- /dev/null +++ b/tests/DigiComp/Sniffs/Annotations/data/Child.php @@ -0,0 +1,11 @@ +