Skip to content

Commit

Permalink
Disable php cs fixer on test fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosas committed Jan 11, 2024
1 parent f2dfd73 commit 78053de
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 30 deletions.
6 changes: 1 addition & 5 deletions extension.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<InClassNode>
*/
final class ClassAttributeRule extends CanOnlyDepend implements Rule
final class AllAttributesRule extends CanOnlyDepend implements Rule
{
use ClassAttributeExtractor;
use AllAttributesExtractor;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -15,18 +15,22 @@
use Tests\PHPat\unit\FakeTestParser;

/**
* @extends RuleTestCase<ClassAttributeRule>
* @extends RuleTestCase<AllAttributesRule>
* @internal
* @coversNothing
*/
class ClassAttributeTest extends RuleTestCase
class AllAttributesTest extends RuleTestCase
{
public const RULE_NAME = 'test_FixtureClassCanOnlyDependSimpleAndSpecial';

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],
]);
}

Expand All @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -15,7 +15,7 @@
use Tests\PHPat\unit\FakeTestParser;

/**
* @extends RuleTestCase<ClassAttributeRule>
* @extends RuleTestCase<AllAttributesRule>
* @internal
* @coversNothing
*/
Expand All @@ -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],
]);
}

Expand All @@ -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(),
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/tips/Declaration/MultipleTipTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -15,7 +15,7 @@
use Tests\PHPat\unit\FakeTestParser;

/**
* @extends RuleTestCase<ClassAttributeRule>
* @extends RuleTestCase<AllAttributesRule>
* @internal
* @coversNothing
*/
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/tips/Declaration/NoTipTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -15,7 +15,7 @@
use Tests\PHPat\unit\FakeTestParser;

/**
* @extends RuleTestCase<ClassAttributeRule>
* @extends RuleTestCase<AllAttributesRule>
* @internal
* @coversNothing
*/
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/tips/Declaration/OneTipTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -15,7 +15,7 @@
use Tests\PHPat\unit\FakeTestParser;

/**
* @extends RuleTestCase<ClassAttributeRule>
* @extends RuleTestCase<AllAttributesRule>
* @internal
* @coversNothing
*/
Expand Down
38 changes: 35 additions & 3 deletions tests/unit/tips/Relation/MultipleTipTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -15,7 +15,7 @@
use Tests\PHPat\unit\FakeTestParser;

/**
* @extends RuleTestCase<ClassAttributeRule>
* @extends RuleTestCase<AllAttributesRule>
* @internal
* @coversNothing
*/
Expand All @@ -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,
],
]);
}

Expand All @@ -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(),
Expand Down
10 changes: 7 additions & 3 deletions tests/unit/tips/Relation/NoTipTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -15,7 +15,7 @@
use Tests\PHPat\unit\FakeTestParser;

/**
* @extends RuleTestCase<ClassAttributeRule>
* @extends RuleTestCase<AllAttributesRule>
* @internal
* @coversNothing
*/
Expand All @@ -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'],
]);
}

Expand All @@ -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(),
Expand Down
10 changes: 7 additions & 3 deletions tests/unit/tips/Relation/OneTipTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -15,7 +15,7 @@
use Tests\PHPat\unit\FakeTestParser;

/**
* @extends RuleTestCase<ClassAttributeRule>
* @extends RuleTestCase<AllAttributesRule>
* @internal
* @coversNothing
*/
Expand All @@ -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'],
]);
}

Expand All @@ -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(),
Expand Down

0 comments on commit 78053de

Please sign in to comment.