Skip to content

Commit

Permalink
Rewrite in backward compatibility compliant way
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Jun 9, 2021
1 parent 0208ab7 commit 63cec25
Show file tree
Hide file tree
Showing 14 changed files with 14 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@ protected function getRule(): Rule
{
return new BooleanInBooleanAndRule(
new BooleanRuleHelper(
new RuleLevelHelper(
$this->createBroker(),
true,
false,
true
)
self::getContainer()->getByType(RuleLevelHelper::class)
),
true
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@ protected function getRule(): Rule
{
return new BooleanInBooleanNotRule(
new BooleanRuleHelper(
new RuleLevelHelper(
$this->createBroker(),
true,
false,
true
)
self::getContainer()->getByType(RuleLevelHelper::class)
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@ protected function getRule(): Rule
{
return new BooleanInBooleanOrRule(
new BooleanRuleHelper(
new RuleLevelHelper(
$this->createBroker(),
true,
false,
true
)
self::getContainer()->getByType(RuleLevelHelper::class)
),
true
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@ protected function getRule(): Rule
{
return new BooleanInElseIfConditionRule(
new BooleanRuleHelper(
new RuleLevelHelper(
$this->createBroker(),
true,
false,
true
)
self::getContainer()->getByType(RuleLevelHelper::class)
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@ protected function getRule(): Rule
{
return new BooleanInIfConditionRule(
new BooleanRuleHelper(
new RuleLevelHelper(
$this->createBroker(),
true,
false,
true
)
self::getContainer()->getByType(RuleLevelHelper::class)
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@ protected function getRule(): Rule
{
return new BooleanInTernaryOperatorRule(
new BooleanRuleHelper(
new RuleLevelHelper(
$this->createBroker(),
true,
false,
true
)
self::getContainer()->getByType(RuleLevelHelper::class)
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ protected function getRule(): Rule
{
return $this->createRule(
new OperatorRuleHelper(
new RuleLevelHelper($this->createBroker(), true, false, true)
self::getContainer()->getByType(RuleLevelHelper::class)
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ protected function getRule(): Rule
{
return new OperandsInArithmeticAdditionRule(
new OperatorRuleHelper(
new RuleLevelHelper($this->createBroker(), true, false, true)
self::getContainer()->getByType(RuleLevelHelper::class)
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ protected function getRule(): Rule
{
return new OperandsInArithmeticDivisionRule(
new OperatorRuleHelper(
new RuleLevelHelper($this->createBroker(), true, false, true)
self::getContainer()->getByType(RuleLevelHelper::class)
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ protected function getRule(): Rule
{
return new OperandsInArithmeticExponentiationRule(
new OperatorRuleHelper(
new RuleLevelHelper($this->createBroker(), true, false, true)
self::getContainer()->getByType(RuleLevelHelper::class)
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ protected function getRule(): Rule
{
return new OperandsInArithmeticModuloRule(
new OperatorRuleHelper(
new RuleLevelHelper($this->createBroker(), true, false, true)
self::getContainer()->getByType(RuleLevelHelper::class)
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ protected function getRule(): Rule
{
return new OperandsInArithmeticMultiplicationRule(
new OperatorRuleHelper(
new RuleLevelHelper($this->createBroker(), true, false, true)
self::getContainer()->getByType(RuleLevelHelper::class)
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ protected function getRule(): Rule
{
return new OperandsInArithmeticSubtractionRule(
new OperatorRuleHelper(
new RuleLevelHelper($this->createBroker(), true, false, true)
self::getContainer()->getByType(RuleLevelHelper::class)
)
);
}
Expand Down
23 changes: 1 addition & 22 deletions tests/Rules/StrictCalls/DynamicCallOnStaticMethodsRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,13 @@
class DynamicCallOnStaticMethodsRuleTest extends \PHPStan\Testing\RuleTestCase
{

/** @var bool */
private $checkThisOnly;

protected function getRule(): Rule
{
$broker = $this->createBroker();
$ruleLevelHelper = new RuleLevelHelper($broker, true, $this->checkThisOnly, true);
return new DynamicCallOnStaticMethodsRule($ruleLevelHelper);
return new DynamicCallOnStaticMethodsRule(self::getContainer()->getByType(RuleLevelHelper::class));
}

public function testRule(): void
{
$this->checkThisOnly = false;
$this->analyse([__DIR__ . '/data/dynamic-calls-on-static-methods.php'], [
[
'Dynamic call to static method StrictCalls\ClassWithStaticMethod::foo().',
Expand All @@ -41,19 +35,4 @@ public function testRule(): void
]);
}

public function testRuleOnThisOnly(): void
{
$this->checkThisOnly = true;
$this->analyse([__DIR__ . '/data/dynamic-calls-on-static-methods.php'], [
[
'Dynamic call to static method StrictCalls\ClassWithStaticMethod::foo().',
14,
],
[
'Dynamic call to static method StrictCalls\ClassUsingTrait::foo().',
34,
],
]);
}

}

0 comments on commit 63cec25

Please sign in to comment.