From 78053de0af842a5d78f90701de3b999a31b152f9 Mon Sep 17 00:00:00 2001 From: Carlos Alandete Sastre Date: Thu, 11 Jan 2024 22:22:05 +0100 Subject: [PATCH] Disable php cs fixer on test fixtures --- extension.neon | 6 +-- ...ttributeRule.php => AllAttributesRule.php} | 6 +-- ...ttributeTest.php => AllAttributesTest.php} | 12 ++++-- .../ShowRuleNameClassAttributeTest.php | 10 +++-- .../unit/tips/Declaration/MultipleTipTest.php | 4 +- tests/unit/tips/Declaration/NoTipTest.php | 4 +- tests/unit/tips/Declaration/OneTipTest.php | 4 +- tests/unit/tips/Relation/MultipleTipTest.php | 38 +++++++++++++++++-- tests/unit/tips/Relation/NoTipTest.php | 10 +++-- tests/unit/tips/Relation/OneTipTest.php | 10 +++-- 10 files changed, 74 insertions(+), 30 deletions(-) rename src/Rule/Assertion/Relation/CanOnlyDepend/{ClassAttributeRule.php => AllAttributesRule.php} (53%) rename tests/unit/rules/CanOnlyDepend/{ClassAttributeTest.php => AllAttributesTest.php} (68%) diff --git a/extension.neon b/extension.neon index 6ec9568d..ba27bc7b 100644 --- a/extension.neon +++ b/extension.neon @@ -89,10 +89,6 @@ services: class: PHPat\Rule\Assertion\Relation\ShouldNotDepend\ParentClassRule tags: - phpstan.rules.rule - #- - # class: PHPat\Rule\Assertion\Relation\ShouldNotDepend\ClassAttributeRule - # tags: - # - phpstan.rules.rule - class: PHPat\Rule\Assertion\Relation\ShouldNotDepend\AllAttributesRule tags: @@ -160,7 +156,7 @@ services: tags: - phpstan.rules.rule - - class: PHPat\Rule\Assertion\Relation\CanOnlyDepend\ClassAttributeRule + class: PHPat\Rule\Assertion\Relation\CanOnlyDepend\AllAttributesRule tags: - phpstan.rules.rule - diff --git a/src/Rule/Assertion/Relation/CanOnlyDepend/ClassAttributeRule.php b/src/Rule/Assertion/Relation/CanOnlyDepend/AllAttributesRule.php similarity index 53% rename from src/Rule/Assertion/Relation/CanOnlyDepend/ClassAttributeRule.php rename to src/Rule/Assertion/Relation/CanOnlyDepend/AllAttributesRule.php index dbc239fc..34b87998 100644 --- a/src/Rule/Assertion/Relation/CanOnlyDepend/ClassAttributeRule.php +++ b/src/Rule/Assertion/Relation/CanOnlyDepend/AllAttributesRule.php @@ -2,14 +2,14 @@ namespace PHPat\Rule\Assertion\Relation\CanOnlyDepend; -use PHPat\Rule\Extractor\Relation\ClassAttributeExtractor; +use PHPat\Rule\Extractor\Relation\AllAttributesExtractor; use PHPStan\Node\InClassNode; use PHPStan\Rules\Rule; /** * @implements Rule */ -final class ClassAttributeRule extends CanOnlyDepend implements Rule +final class AllAttributesRule extends CanOnlyDepend implements Rule { - use ClassAttributeExtractor; + use AllAttributesExtractor; } diff --git a/tests/unit/rules/CanOnlyDepend/ClassAttributeTest.php b/tests/unit/rules/CanOnlyDepend/AllAttributesTest.php similarity index 68% rename from tests/unit/rules/CanOnlyDepend/ClassAttributeTest.php rename to tests/unit/rules/CanOnlyDepend/AllAttributesTest.php index 0664e9e8..5178d541 100644 --- a/tests/unit/rules/CanOnlyDepend/ClassAttributeTest.php +++ b/tests/unit/rules/CanOnlyDepend/AllAttributesTest.php @@ -4,7 +4,7 @@ use PHPat\Configuration; use PHPat\Rule\Assertion\Relation\CanOnlyDepend\CanOnlyDepend; -use PHPat\Rule\Assertion\Relation\CanOnlyDepend\ClassAttributeRule; +use PHPat\Rule\Assertion\Relation\CanOnlyDepend\AllAttributesRule; use PHPat\Selector\Classname; use PHPat\Statement\Builder\StatementBuilderFactory; use PHPStan\Rules\Rule; @@ -15,11 +15,11 @@ use Tests\PHPat\unit\FakeTestParser; /** - * @extends RuleTestCase + * @extends RuleTestCase * @internal * @coversNothing */ -class ClassAttributeTest extends RuleTestCase +class AllAttributesTest extends RuleTestCase { public const RULE_NAME = 'test_FixtureClassCanOnlyDependSimpleAndSpecial'; @@ -27,6 +27,10 @@ public function testRule(): void { $this->analyse(['tests/fixtures/FixtureClass.php'], [ [sprintf('%s should not depend on %s', FixtureClass::class, SimpleAttribute::class), 29], + [sprintf('%s should not depend on %s', FixtureClass::class, SimpleAttribute::class), 33], + [sprintf('%s should not depend on %s', FixtureClass::class, SimpleAttribute::class), 34], + [sprintf('%s should not depend on %s', FixtureClass::class, SimpleAttribute::class), 94], + [sprintf('%s should not depend on %s', FixtureClass::class, SimpleAttribute::class), 95], ]); } @@ -39,7 +43,7 @@ protected function getRule(): Rule [new Classname(\Attribute::class, false)] ); - return new ClassAttributeRule( + return new AllAttributesRule( new StatementBuilderFactory($testParser), new Configuration(false, true, false), $this->createReflectionProvider(), diff --git a/tests/unit/rules/CanOnlyDepend/ShowRuleNameClassAttributeTest.php b/tests/unit/rules/CanOnlyDepend/ShowRuleNameClassAttributeTest.php index 140abd38..a92a152e 100644 --- a/tests/unit/rules/CanOnlyDepend/ShowRuleNameClassAttributeTest.php +++ b/tests/unit/rules/CanOnlyDepend/ShowRuleNameClassAttributeTest.php @@ -4,7 +4,7 @@ use PHPat\Configuration; use PHPat\Rule\Assertion\Relation\CanOnlyDepend\CanOnlyDepend; -use PHPat\Rule\Assertion\Relation\CanOnlyDepend\ClassAttributeRule; +use PHPat\Rule\Assertion\Relation\CanOnlyDepend\AllAttributesRule; use PHPat\Selector\Classname; use PHPat\Statement\Builder\StatementBuilderFactory; use PHPStan\Rules\Rule; @@ -15,7 +15,7 @@ use Tests\PHPat\unit\FakeTestParser; /** - * @extends RuleTestCase + * @extends RuleTestCase * @internal * @coversNothing */ @@ -27,6 +27,10 @@ public function testRule(): void { $this->analyse(['tests/fixtures/FixtureClass.php'], [ [sprintf('%s: %s should not depend on %s', self::RULE_NAME, FixtureClass::class, SimpleAttribute::class), 29], + [sprintf('%s: %s should not depend on %s', self::RULE_NAME, FixtureClass::class, SimpleAttribute::class), 33], + [sprintf('%s: %s should not depend on %s', self::RULE_NAME, FixtureClass::class, SimpleAttribute::class), 34], + [sprintf('%s: %s should not depend on %s', self::RULE_NAME, FixtureClass::class, SimpleAttribute::class), 94], + [sprintf('%s: %s should not depend on %s', self::RULE_NAME, FixtureClass::class, SimpleAttribute::class), 95], ]); } @@ -39,7 +43,7 @@ protected function getRule(): Rule [new Classname(\Attribute::class, false)] ); - return new ClassAttributeRule( + return new AllAttributesRule( new StatementBuilderFactory($testParser), new Configuration(false, true, true), $this->createReflectionProvider(), diff --git a/tests/unit/tips/Declaration/MultipleTipTest.php b/tests/unit/tips/Declaration/MultipleTipTest.php index 85a20385..5a7a2e71 100644 --- a/tests/unit/tips/Declaration/MultipleTipTest.php +++ b/tests/unit/tips/Declaration/MultipleTipTest.php @@ -5,7 +5,7 @@ use PHPat\Configuration; use PHPat\Rule\Assertion\Declaration\ShouldBeFinal\IsFinalRule; use PHPat\Rule\Assertion\Declaration\ShouldBeFinal\ShouldBeFinal; -use PHPat\Rule\Assertion\Relation\CanOnlyDepend\ClassAttributeRule; +use PHPat\Rule\Assertion\Relation\CanOnlyDepend\AllAttributesRule; use PHPat\Selector\Classname; use PHPat\Statement\Builder\StatementBuilderFactory; use PHPStan\Rules\Rule; @@ -15,7 +15,7 @@ use Tests\PHPat\unit\FakeTestParser; /** - * @extends RuleTestCase + * @extends RuleTestCase * @internal * @coversNothing */ diff --git a/tests/unit/tips/Declaration/NoTipTest.php b/tests/unit/tips/Declaration/NoTipTest.php index 3a5866bd..2aeb074d 100644 --- a/tests/unit/tips/Declaration/NoTipTest.php +++ b/tests/unit/tips/Declaration/NoTipTest.php @@ -5,7 +5,7 @@ use PHPat\Configuration; use PHPat\Rule\Assertion\Declaration\ShouldBeFinal\IsFinalRule; use PHPat\Rule\Assertion\Declaration\ShouldBeFinal\ShouldBeFinal; -use PHPat\Rule\Assertion\Relation\CanOnlyDepend\ClassAttributeRule; +use PHPat\Rule\Assertion\Relation\CanOnlyDepend\AllAttributesRule; use PHPat\Selector\Classname; use PHPat\Statement\Builder\StatementBuilderFactory; use PHPStan\Rules\Rule; @@ -15,7 +15,7 @@ use Tests\PHPat\unit\FakeTestParser; /** - * @extends RuleTestCase + * @extends RuleTestCase * @internal * @coversNothing */ diff --git a/tests/unit/tips/Declaration/OneTipTest.php b/tests/unit/tips/Declaration/OneTipTest.php index 1f90c334..e980781d 100644 --- a/tests/unit/tips/Declaration/OneTipTest.php +++ b/tests/unit/tips/Declaration/OneTipTest.php @@ -5,7 +5,7 @@ use PHPat\Configuration; use PHPat\Rule\Assertion\Declaration\ShouldBeFinal\IsFinalRule; use PHPat\Rule\Assertion\Declaration\ShouldBeFinal\ShouldBeFinal; -use PHPat\Rule\Assertion\Relation\CanOnlyDepend\ClassAttributeRule; +use PHPat\Rule\Assertion\Relation\CanOnlyDepend\AllAttributesRule; use PHPat\Selector\Classname; use PHPat\Statement\Builder\StatementBuilderFactory; use PHPStan\Rules\Rule; @@ -15,7 +15,7 @@ use Tests\PHPat\unit\FakeTestParser; /** - * @extends RuleTestCase + * @extends RuleTestCase * @internal * @coversNothing */ diff --git a/tests/unit/tips/Relation/MultipleTipTest.php b/tests/unit/tips/Relation/MultipleTipTest.php index 600b95ea..e91da511 100644 --- a/tests/unit/tips/Relation/MultipleTipTest.php +++ b/tests/unit/tips/Relation/MultipleTipTest.php @@ -4,7 +4,7 @@ use PHPat\Configuration; use PHPat\Rule\Assertion\Relation\CanOnlyDepend\CanOnlyDepend; -use PHPat\Rule\Assertion\Relation\CanOnlyDepend\ClassAttributeRule; +use PHPat\Rule\Assertion\Relation\CanOnlyDepend\AllAttributesRule; use PHPat\Selector\Classname; use PHPat\Statement\Builder\StatementBuilderFactory; use PHPStan\Rules\Rule; @@ -15,7 +15,7 @@ use Tests\PHPat\unit\FakeTestParser; /** - * @extends RuleTestCase + * @extends RuleTestCase * @internal * @coversNothing */ @@ -34,6 +34,38 @@ public function testRule(): void • tip #2 TIPS, ], + [ + \sprintf('%s should not depend on %s', FixtureClass::class, SimpleAttribute::class), + 33, + <<<'TIPS' + • tip #1 + • tip #2 + TIPS, + ], + [ + \sprintf('%s should not depend on %s', FixtureClass::class, SimpleAttribute::class), + 34, + <<<'TIPS' + • tip #1 + • tip #2 + TIPS, + ], + [ + \sprintf('%s should not depend on %s', FixtureClass::class, SimpleAttribute::class), + 94, + <<<'TIPS' + • tip #1 + • tip #2 + TIPS, + ], + [ + \sprintf('%s should not depend on %s', FixtureClass::class, SimpleAttribute::class), + 95, + <<<'TIPS' + • tip #1 + • tip #2 + TIPS, + ], ]); } @@ -47,7 +79,7 @@ protected function getRule(): Rule ['tip #1', 'tip #2'] ); - return new ClassAttributeRule( + return new AllAttributesRule( new StatementBuilderFactory($testParser), new Configuration(false, true, false), $this->createReflectionProvider(), diff --git a/tests/unit/tips/Relation/NoTipTest.php b/tests/unit/tips/Relation/NoTipTest.php index 0271912b..5646f8cb 100644 --- a/tests/unit/tips/Relation/NoTipTest.php +++ b/tests/unit/tips/Relation/NoTipTest.php @@ -4,7 +4,7 @@ use PHPat\Configuration; use PHPat\Rule\Assertion\Relation\CanOnlyDepend\CanOnlyDepend; -use PHPat\Rule\Assertion\Relation\CanOnlyDepend\ClassAttributeRule; +use PHPat\Rule\Assertion\Relation\CanOnlyDepend\AllAttributesRule; use PHPat\Selector\Classname; use PHPat\Statement\Builder\StatementBuilderFactory; use PHPStan\Rules\Rule; @@ -15,7 +15,7 @@ use Tests\PHPat\unit\FakeTestParser; /** - * @extends RuleTestCase + * @extends RuleTestCase * @internal * @coversNothing */ @@ -27,6 +27,10 @@ public function testRule(): void { $this->analyse(['tests/fixtures/FixtureClass.php'], [ [sprintf('%s should not depend on %s', FixtureClass::class, SimpleAttribute::class), 29, 'tip #1'], + [sprintf('%s should not depend on %s', FixtureClass::class, SimpleAttribute::class), 33, 'tip #1'], + [sprintf('%s should not depend on %s', FixtureClass::class, SimpleAttribute::class), 34, 'tip #1'], + [sprintf('%s should not depend on %s', FixtureClass::class, SimpleAttribute::class), 94, 'tip #1'], + [sprintf('%s should not depend on %s', FixtureClass::class, SimpleAttribute::class), 95, 'tip #1'], ]); } @@ -40,7 +44,7 @@ protected function getRule(): Rule ['tip #1'] ); - return new ClassAttributeRule( + return new AllAttributesRule( new StatementBuilderFactory($testParser), new Configuration(false, true, false), $this->createReflectionProvider(), diff --git a/tests/unit/tips/Relation/OneTipTest.php b/tests/unit/tips/Relation/OneTipTest.php index a5876427..94a6a295 100644 --- a/tests/unit/tips/Relation/OneTipTest.php +++ b/tests/unit/tips/Relation/OneTipTest.php @@ -4,7 +4,7 @@ use PHPat\Configuration; use PHPat\Rule\Assertion\Relation\CanOnlyDepend\CanOnlyDepend; -use PHPat\Rule\Assertion\Relation\CanOnlyDepend\ClassAttributeRule; +use PHPat\Rule\Assertion\Relation\CanOnlyDepend\AllAttributesRule; use PHPat\Selector\Classname; use PHPat\Statement\Builder\StatementBuilderFactory; use PHPStan\Rules\Rule; @@ -15,7 +15,7 @@ use Tests\PHPat\unit\FakeTestParser; /** - * @extends RuleTestCase + * @extends RuleTestCase * @internal * @coversNothing */ @@ -27,6 +27,10 @@ public function testRule(): void { $this->analyse(['tests/fixtures/FixtureClass.php'], [ [sprintf('%s should not depend on %s', FixtureClass::class, SimpleAttribute::class), 29, 'tip #1'], + [sprintf('%s should not depend on %s', FixtureClass::class, SimpleAttribute::class), 33, 'tip #1'], + [sprintf('%s should not depend on %s', FixtureClass::class, SimpleAttribute::class), 34, 'tip #1'], + [sprintf('%s should not depend on %s', FixtureClass::class, SimpleAttribute::class), 94, 'tip #1'], + [sprintf('%s should not depend on %s', FixtureClass::class, SimpleAttribute::class), 95, 'tip #1'], ]); } @@ -40,7 +44,7 @@ protected function getRule(): Rule ['tip #1'] ); - return new ClassAttributeRule( + return new AllAttributesRule( new StatementBuilderFactory($testParser), new Configuration(false, true, false), $this->createReflectionProvider(),