only show wrong positioned var tag if it is present
This commit is contained in:
parent
6c1b52389d
commit
4bb9f54ca8
4 changed files with 18 additions and 2 deletions
1
composer.lock
generated
1
composer.lock
generated
|
@ -1725,7 +1725,6 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"abandoned": true,
|
|
||||||
"time": "2020-11-30T07:30:19+00:00"
|
"time": "2020-11-30T07:30:19+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -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');
|
$fix = $phpcsFile->addFixableError('@var should be last property annotation', $varToken, 'VarNotLast');
|
||||||
if ($fix) {
|
if ($fix) {
|
||||||
$this->moveVarTagToEndOfDoctype(
|
$this->moveVarTagToEndOfDoctype(
|
||||||
|
|
|
@ -11,4 +11,10 @@ class VarIsLastTagOnPropertySniffTest extends TestCase
|
||||||
$report = self::checkFile(__DIR__ . '/data/PropertyOrder.php');
|
$report = self::checkFile(__DIR__ . '/data/PropertyOrder.php');
|
||||||
self::assertSame(2, $report->getErrorCount());
|
self::assertSame(2, $report->getErrorCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testIgnoreVarTag(): void
|
||||||
|
{
|
||||||
|
$withoutErrors = self::checkFile(__DIR__ . '/data/Child.php');
|
||||||
|
self::assertSame(0, $withoutErrors->getErrorCount());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
11
tests/DigiComp/Sniffs/Annotations/data/Child.php
Normal file
11
tests/DigiComp/Sniffs/Annotations/data/Child.php
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Inwebs\PhpCodesniffer\Sniffs\Annotations\data;
|
||||||
|
|
||||||
|
class Child extends PropertyOrder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
protected $test;
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue