Skip to content

Commit

Permalink
Fix: Invoke static method statically
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Nov 21, 2024
1 parent 19c997c commit e772604
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 48 deletions.
15 changes: 0 additions & 15 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,6 @@ parameters:
count: 1
path: src/Rules.php

-
message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\TestCase\\:\\:createStub\\(\\)\\.$#"
count: 3
path: test/Unit/FactoryTest.php

-
message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\TestCase\\:\\:createStub\\(\\)\\.$#"
count: 16
path: test/Unit/FixersTest.php

-
message: "#^Parameter \\#1 \\$iterable of static method Ergebnis\\\\PhpCsFixer\\\\Config\\\\Fixers\\:\\:fromIterable\\(\\) expects iterable\\<PhpCsFixer\\\\Fixer\\\\FixerInterface\\>, array\\<int, \\(PhpCsFixer\\\\Fixer\\\\FixerInterface&PHPUnit\\\\Framework\\\\MockObject\\\\Stub\\)\\|stdClass\\> given\\.$#"
count: 1
Expand All @@ -40,8 +30,3 @@ parameters:
count: 1
path: test/Unit/RuleSet/AbstractRuleSetTestCase.php

-
message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\TestCase\\:\\:createStub\\(\\)\\.$#"
count: 14
path: test/Unit/RuleSetTest.php

6 changes: 3 additions & 3 deletions test/Unit/FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ public function testFromRuleSetThrowsRuntimeExceptionWhenCurrentPhpVersionIsLess
public function testFromRuleSetCreatesConfigWhenCurrentPhpVersionIsEqualToOrGreaterThanTargetPhpVersion(PhpVersion $targetPhpVersion): void
{
$customFixers = Fixers::fromFixers(
$this->createStub(Fixer\FixerInterface::class),
$this->createStub(Fixer\FixerInterface::class),
$this->createStub(Fixer\FixerInterface::class),
self::createStub(Fixer\FixerInterface::class),
self::createStub(Fixer\FixerInterface::class),
self::createStub(Fixer\FixerInterface::class),
);

$rules = Rules::fromArray([
Expand Down
32 changes: 16 additions & 16 deletions test/Unit/FixersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public function testEmptyReturnsFixers(): void
public function testFromFixersReturnsFixers(): void
{
$value = [
$this->createStub(Fixer\FixerInterface::class),
$this->createStub(Fixer\FixerInterface::class),
$this->createStub(Fixer\FixerInterface::class),
self::createStub(Fixer\FixerInterface::class),
self::createStub(Fixer\FixerInterface::class),
self::createStub(Fixer\FixerInterface::class),
];

$fixers = Fixers::fromFixers(...$value);
Expand All @@ -43,9 +43,9 @@ public function testFromFixersReturnsFixers(): void
public function testFromIterableRejectsInvalidValue(): void
{
$value = [
$this->createStub(Fixer\FixerInterface::class),
self::createStub(Fixer\FixerInterface::class),
new \stdClass(),
$this->createStub(Fixer\FixerInterface::class),
self::createStub(Fixer\FixerInterface::class),
];

$this->expectException(\InvalidArgumentException::class);
Expand All @@ -63,9 +63,9 @@ public function testFromIterableRejectsInvalidValue(): void
public function testFromIterableReturnsFixersWhenValueIsArray(): void
{
$value = [
$this->createStub(Fixer\FixerInterface::class),
$this->createStub(Fixer\FixerInterface::class),
$this->createStub(Fixer\FixerInterface::class),
self::createStub(Fixer\FixerInterface::class),
self::createStub(Fixer\FixerInterface::class),
self::createStub(Fixer\FixerInterface::class),
];

$fixers = Fixers::fromIterable($value);
Expand All @@ -76,9 +76,9 @@ public function testFromIterableReturnsFixersWhenValueIsArray(): void
public function testFromIterableReturnsFixersWhenValueIsTraversable(): void
{
$value = [
$this->createStub(Fixer\FixerInterface::class),
$this->createStub(Fixer\FixerInterface::class),
$this->createStub(Fixer\FixerInterface::class),
self::createStub(Fixer\FixerInterface::class),
self::createStub(Fixer\FixerInterface::class),
self::createStub(Fixer\FixerInterface::class),
];

$iterable = new \ArrayIterator($value);
Expand All @@ -91,14 +91,14 @@ public function testFromIterableReturnsFixersWhenValueIsTraversable(): void
public function testMergeReturnsFixersMergedWithFixers(): void
{
$one = Fixers::fromFixers(
$this->createStub(Fixer\FixerInterface::class),
$this->createStub(Fixer\FixerInterface::class),
$this->createStub(Fixer\FixerInterface::class),
self::createStub(Fixer\FixerInterface::class),
self::createStub(Fixer\FixerInterface::class),
self::createStub(Fixer\FixerInterface::class),
);

$two = Fixers::fromFixers(
$this->createStub(Fixer\FixerInterface::class),
$this->createStub(Fixer\FixerInterface::class),
self::createStub(Fixer\FixerInterface::class),
self::createStub(Fixer\FixerInterface::class),
);

$mutated = $one->merge($two);
Expand Down
28 changes: 14 additions & 14 deletions test/Unit/RuleSetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public function testCreateReturnsRuleSet(): void
$faker = self::faker();

$customFixers = Fixers::fromFixers(
$this->createStub(Fixer\FixerInterface::class),
$this->createStub(Fixer\FixerInterface::class),
$this->createStub(Fixer\FixerInterface::class),
self::createStub(Fixer\FixerInterface::class),
self::createStub(Fixer\FixerInterface::class),
self::createStub(Fixer\FixerInterface::class),
);
$name = Name::fromString($faker->word());
$phpVersion = PhpVersion::create(
Expand Down Expand Up @@ -71,15 +71,15 @@ public function testWithCustomFixersReturnsRuleSetWithMergedCustomFixers(): void
$faker = self::faker();

$customFixers = Fixers::fromFixers(
$this->createStub(Fixer\FixerInterface::class),
$this->createStub(Fixer\FixerInterface::class),
self::createStub(Fixer\FixerInterface::class),
self::createStub(Fixer\FixerInterface::class),
);

$ruleSet = RuleSet::create(
Fixers::fromFixers(
$this->createStub(Fixer\FixerInterface::class),
$this->createStub(Fixer\FixerInterface::class),
$this->createStub(Fixer\FixerInterface::class),
self::createStub(Fixer\FixerInterface::class),
self::createStub(Fixer\FixerInterface::class),
self::createStub(Fixer\FixerInterface::class),
),
Name::fromString($faker->word()),
PhpVersion::create(
Expand Down Expand Up @@ -116,9 +116,9 @@ public function testWithRulesReturnsRuleSetWithMergedRules(): void

$ruleSet = RuleSet::create(
Fixers::fromFixers(
$this->createStub(Fixer\FixerInterface::class),
$this->createStub(Fixer\FixerInterface::class),
$this->createStub(Fixer\FixerInterface::class),
self::createStub(Fixer\FixerInterface::class),
self::createStub(Fixer\FixerInterface::class),
self::createStub(Fixer\FixerInterface::class),
),
Name::fromString($faker->word()),
PhpVersion::create(
Expand Down Expand Up @@ -152,9 +152,9 @@ public function testWithHeaderReturnsRuleSetWithEnabledHeaderCommentFixer(string

$ruleSet = RuleSet::create(
Fixers::fromFixers(
$this->createStub(Fixer\FixerInterface::class),
$this->createStub(Fixer\FixerInterface::class),
$this->createStub(Fixer\FixerInterface::class),
self::createStub(Fixer\FixerInterface::class),
self::createStub(Fixer\FixerInterface::class),
self::createStub(Fixer\FixerInterface::class),
),
Name::fromString($faker->word()),
PhpVersion::create(
Expand Down

0 comments on commit e772604

Please sign in to comment.