Skip to content

Commit

Permalink
Fix final readonly class
Browse files Browse the repository at this point in the history
There is a bug when dealing with readonly class. See squizlabs/PHP_CodeSniffer#3727

This commit will temporary exclude PSR1.Files.SideEffects.FoundWithSymbols
  • Loading branch information
asispts committed Jan 22, 2023
1 parent 3df942e commit 7872598
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
<exclude-pattern>vendor</exclude-pattern>

<rule ref="ptscs/ruleset.xml" />
</ruleset>
</ruleset>
10 changes: 7 additions & 3 deletions ptscs/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<!-- Allow <?php declare(strict_types=1); in the same line -->
<exclude name="PSR12.Files.OpenTag.NotAlone" />
<exclude name="PSR12.Files.FileHeader.SpacingAfterBlock" />
<!-- There is a bug when dealing with readonly class. See squizlabs/PHP_CodeSniffer#3727 -->
<exclude name="PSR1.Files.SideEffects.FoundWithSymbols" />
</rule>

<!--++++++++++++++++++++++++++++++++++++
Expand Down Expand Up @@ -77,7 +79,8 @@
$a = 1;
$b = 2;
These lines should be like this
These lines should be
like this
$a = 1;
$b = 2;
-->
Expand All @@ -87,7 +90,8 @@
<property name="exact" value="true" />
<property name="tabIndent" value="false" />
<!-- <property name="ignoreIndentationTokens" type="array">
<element value="T_CLASS" />
<element
value="T_CLASS" />
</property> -->
</properties>
</rule>
Expand Down Expand Up @@ -190,4 +194,4 @@
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier" />


</ruleset>
</ruleset>
5 changes: 3 additions & 2 deletions tests/Sniffs/Slevomat/RequireAbstractOrFinalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ final class RequireAbstractOrFinalTest extends SniffTestCase
protected function setUp(): void
{
parent::setUp();
$this->setExclude(['Squiz.Classes.ClassFileName.NoMatch']);
$this->setExclude(['Squiz.Classes.ClassFileName.NoMatch', 'PSR1.Classes.ClassDeclaration.MultipleClasses']);
}

public function provideTestData(): Iterator
{
yield[
[
new ErrorData(4, 'SlevomatCodingStandard.Classes.RequireAbstractOrFinal'),
new ErrorData(5, 'SlevomatCodingStandard.Classes.RequireAbstractOrFinal'),
new ErrorData(9, 'SlevomatCodingStandard.Classes.RequireAbstractOrFinal'),
],
];
}
Expand Down
7 changes: 4 additions & 3 deletions tests/Sniffs/Slevomat/_data/RequireAbstractOrFinal.php.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ namespace App;

final class Foobar
{
public function __invoke()
{
}
}

readonly final class ReadonlyClass
{
}
7 changes: 4 additions & 3 deletions tests/Sniffs/Slevomat/_data/RequireAbstractOrFinal.php.inc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ namespace App;

class Foobar
{
public function __invoke()
{
}
}

readonly class ReadonlyClass
{
}

0 comments on commit 7872598

Please sign in to comment.