Skip to content

Commit 63cec25

Browse files
committed
Rewrite in backward compatibility compliant way
1 parent 0208ab7 commit 63cec25

14 files changed

+14
-65
lines changed

tests/Rules/BooleansInConditions/BooleanInBooleanAndRuleTest.php

+1-6
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,7 @@ protected function getRule(): Rule
1515
{
1616
return new BooleanInBooleanAndRule(
1717
new BooleanRuleHelper(
18-
new RuleLevelHelper(
19-
$this->createBroker(),
20-
true,
21-
false,
22-
true
23-
)
18+
self::getContainer()->getByType(RuleLevelHelper::class)
2419
),
2520
true
2621
);

tests/Rules/BooleansInConditions/BooleanInBooleanNotRuleTest.php

+1-6
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,7 @@ protected function getRule(): Rule
1212
{
1313
return new BooleanInBooleanNotRule(
1414
new BooleanRuleHelper(
15-
new RuleLevelHelper(
16-
$this->createBroker(),
17-
true,
18-
false,
19-
true
20-
)
15+
self::getContainer()->getByType(RuleLevelHelper::class)
2116
)
2217
);
2318
}

tests/Rules/BooleansInConditions/BooleanInBooleanOrRuleTest.php

+1-6
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,7 @@ protected function getRule(): Rule
1515
{
1616
return new BooleanInBooleanOrRule(
1717
new BooleanRuleHelper(
18-
new RuleLevelHelper(
19-
$this->createBroker(),
20-
true,
21-
false,
22-
true
23-
)
18+
self::getContainer()->getByType(RuleLevelHelper::class)
2419
),
2520
true
2621
);

tests/Rules/BooleansInConditions/BooleanInElseIfConditionRuleTest.php

+1-6
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,7 @@ protected function getRule(): Rule
1212
{
1313
return new BooleanInElseIfConditionRule(
1414
new BooleanRuleHelper(
15-
new RuleLevelHelper(
16-
$this->createBroker(),
17-
true,
18-
false,
19-
true
20-
)
15+
self::getContainer()->getByType(RuleLevelHelper::class)
2116
)
2217
);
2318
}

tests/Rules/BooleansInConditions/BooleanInIfConditionRuleTest.php

+1-6
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,7 @@ protected function getRule(): Rule
1212
{
1313
return new BooleanInIfConditionRule(
1414
new BooleanRuleHelper(
15-
new RuleLevelHelper(
16-
$this->createBroker(),
17-
true,
18-
false,
19-
true
20-
)
15+
self::getContainer()->getByType(RuleLevelHelper::class)
2116
)
2217
);
2318
}

tests/Rules/BooleansInConditions/BooleanInTernaryOperatorRuleTest.php

+1-6
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,7 @@ protected function getRule(): Rule
1212
{
1313
return new BooleanInTernaryOperatorRule(
1414
new BooleanRuleHelper(
15-
new RuleLevelHelper(
16-
$this->createBroker(),
17-
true,
18-
false,
19-
true
20-
)
15+
self::getContainer()->getByType(RuleLevelHelper::class)
2116
)
2217
);
2318
}

tests/Rules/Operators/OperandInArithmeticIncrementOrDecrementRuleTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ protected function getRule(): Rule
1212
{
1313
return $this->createRule(
1414
new OperatorRuleHelper(
15-
new RuleLevelHelper($this->createBroker(), true, false, true)
15+
self::getContainer()->getByType(RuleLevelHelper::class)
1616
)
1717
);
1818
}

tests/Rules/Operators/OperandsInArithmeticAdditionRuleTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ protected function getRule(): Rule
1313
{
1414
return new OperandsInArithmeticAdditionRule(
1515
new OperatorRuleHelper(
16-
new RuleLevelHelper($this->createBroker(), true, false, true)
16+
self::getContainer()->getByType(RuleLevelHelper::class)
1717
)
1818
);
1919
}

tests/Rules/Operators/OperandsInArithmeticDivisionRuleTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ protected function getRule(): Rule
1212
{
1313
return new OperandsInArithmeticDivisionRule(
1414
new OperatorRuleHelper(
15-
new RuleLevelHelper($this->createBroker(), true, false, true)
15+
self::getContainer()->getByType(RuleLevelHelper::class)
1616
)
1717
);
1818
}

tests/Rules/Operators/OperandsInArithmeticExponentiationRuleTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ protected function getRule(): Rule
1212
{
1313
return new OperandsInArithmeticExponentiationRule(
1414
new OperatorRuleHelper(
15-
new RuleLevelHelper($this->createBroker(), true, false, true)
15+
self::getContainer()->getByType(RuleLevelHelper::class)
1616
)
1717
);
1818
}

tests/Rules/Operators/OperandsInArithmeticModuloRuleTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ protected function getRule(): Rule
1212
{
1313
return new OperandsInArithmeticModuloRule(
1414
new OperatorRuleHelper(
15-
new RuleLevelHelper($this->createBroker(), true, false, true)
15+
self::getContainer()->getByType(RuleLevelHelper::class)
1616
)
1717
);
1818
}

tests/Rules/Operators/OperandsInArithmeticMultiplicationRuleTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ protected function getRule(): Rule
1212
{
1313
return new OperandsInArithmeticMultiplicationRule(
1414
new OperatorRuleHelper(
15-
new RuleLevelHelper($this->createBroker(), true, false, true)
15+
self::getContainer()->getByType(RuleLevelHelper::class)
1616
)
1717
);
1818
}

tests/Rules/Operators/OperandsInArithmeticSubtractionRuleTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ protected function getRule(): Rule
1212
{
1313
return new OperandsInArithmeticSubtractionRule(
1414
new OperatorRuleHelper(
15-
new RuleLevelHelper($this->createBroker(), true, false, true)
15+
self::getContainer()->getByType(RuleLevelHelper::class)
1616
)
1717
);
1818
}

tests/Rules/StrictCalls/DynamicCallOnStaticMethodsRuleTest.php

+1-22
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,13 @@
88
class DynamicCallOnStaticMethodsRuleTest extends \PHPStan\Testing\RuleTestCase
99
{
1010

11-
/** @var bool */
12-
private $checkThisOnly;
13-
1411
protected function getRule(): Rule
1512
{
16-
$broker = $this->createBroker();
17-
$ruleLevelHelper = new RuleLevelHelper($broker, true, $this->checkThisOnly, true);
18-
return new DynamicCallOnStaticMethodsRule($ruleLevelHelper);
13+
return new DynamicCallOnStaticMethodsRule(self::getContainer()->getByType(RuleLevelHelper::class));
1914
}
2015

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

44-
public function testRuleOnThisOnly(): void
45-
{
46-
$this->checkThisOnly = true;
47-
$this->analyse([__DIR__ . '/data/dynamic-calls-on-static-methods.php'], [
48-
[
49-
'Dynamic call to static method StrictCalls\ClassWithStaticMethod::foo().',
50-
14,
51-
],
52-
[
53-
'Dynamic call to static method StrictCalls\ClassUsingTrait::foo().',
54-
34,
55-
],
56-
]);
57-
}
58-
5938
}

0 commit comments

Comments
 (0)