Skip to content

Commit 8531e28

Browse files
[Tests] New iteration of removing $this occurrences in future static data providers
1 parent 5db17a4 commit 8531e28

10 files changed

+61
-61
lines changed

Tests/Node/AbstractNodeTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function testEvaluate($expected, $node, $variables = [], $functions = [])
2424
$this->assertSame($expected, $node->evaluate($functions, $variables));
2525
}
2626

27-
abstract public function getEvaluateData();
27+
abstract public static function getEvaluateData();
2828

2929
/**
3030
* @dataProvider getCompileData
@@ -36,7 +36,7 @@ public function testCompile($expected, $node, $functions = [])
3636
$this->assertSame($expected, $compiler->getSource());
3737
}
3838

39-
abstract public function getCompileData();
39+
abstract public static function getCompileData();
4040

4141
/**
4242
* @dataProvider getDumpData
@@ -46,5 +46,5 @@ public function testDump($expected, $node)
4646
$this->assertSame($expected, $node->dump());
4747
}
4848

49-
abstract public function getDumpData();
49+
abstract public static function getDumpData();
5050
}

Tests/Node/ArgumentsNodeTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,21 @@
1515

1616
class ArgumentsNodeTest extends ArrayNodeTest
1717
{
18-
public function getCompileData()
18+
public static function getCompileData(): array
1919
{
2020
return [
21-
['"a", "b"', $this->getArrayNode()],
21+
['"a", "b"', static::getArrayNode()],
2222
];
2323
}
2424

25-
public function getDumpData()
25+
public static function getDumpData(): \Generator
2626
{
27-
return [
28-
['"a", "b"', $this->getArrayNode()],
27+
yield from [
28+
['"a", "b"', static::getArrayNode()],
2929
];
3030
}
3131

32-
protected function createArrayNode()
32+
protected static function createArrayNode(): \Symfony\Component\ExpressionLanguage\Node\ArrayNode
3333
{
3434
return new ArgumentsNode();
3535
}

Tests/Node/ArrayNodeTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,45 +28,45 @@ public function testSerialization()
2828
$this->assertNotEquals($this->createArrayNode(), $unserializedNode);
2929
}
3030

31-
public function getEvaluateData()
31+
public static function getEvaluateData(): array
3232
{
3333
return [
34-
[['b' => 'a', 'b'], $this->getArrayNode()],
34+
[['b' => 'a', 'b'], static::getArrayNode()],
3535
];
3636
}
3737

38-
public function getCompileData()
38+
public static function getCompileData(): array
3939
{
4040
return [
41-
['["b" => "a", 0 => "b"]', $this->getArrayNode()],
41+
['["b" => "a", 0 => "b"]', static::getArrayNode()],
4242
];
4343
}
4444

45-
public function getDumpData()
45+
public static function getDumpData(): \Generator
4646
{
47-
yield ['{"b": "a", 0: "b"}', $this->getArrayNode()];
47+
yield ['{"b": "a", 0: "b"}', static::getArrayNode()];
4848

49-
$array = $this->createArrayNode();
49+
$array = static::createArrayNode();
5050
$array->addElement(new ConstantNode('c'), new ConstantNode('a"b'));
5151
$array->addElement(new ConstantNode('d'), new ConstantNode('a\b'));
5252
yield ['{"a\\"b": "c", "a\\\\b": "d"}', $array];
5353

54-
$array = $this->createArrayNode();
54+
$array = static::createArrayNode();
5555
$array->addElement(new ConstantNode('c'));
5656
$array->addElement(new ConstantNode('d'));
5757
yield ['["c", "d"]', $array];
5858
}
5959

60-
protected function getArrayNode()
60+
protected static function getArrayNode(): ArrayNode
6161
{
62-
$array = $this->createArrayNode();
62+
$array = static::createArrayNode();
6363
$array->addElement(new ConstantNode('a'), new ConstantNode('b'));
6464
$array->addElement(new ConstantNode('b'));
6565

6666
return $array;
6767
}
6868

69-
protected function createArrayNode()
69+
protected static function createArrayNode(): ArrayNode
7070
{
7171
return new ArrayNode();
7272
}

Tests/Node/BinaryNodeTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
class BinaryNodeTest extends AbstractNodeTest
2222
{
23-
public function getEvaluateData()
23+
public static function getEvaluateData(): array
2424
{
2525
$array = new ArrayNode();
2626
$array->addElement(new ConstantNode('a'));
@@ -71,7 +71,7 @@ public function getEvaluateData()
7171
];
7272
}
7373

74-
public function getCompileData()
74+
public static function getCompileData(): array
7575
{
7676
$array = new ArrayNode();
7777
$array->addElement(new ConstantNode('a'));
@@ -120,7 +120,7 @@ public function getCompileData()
120120
];
121121
}
122122

123-
public function getDumpData()
123+
public static function getDumpData(): array
124124
{
125125
$array = new ArrayNode();
126126
$array->addElement(new ConstantNode('a'));

Tests/Node/ConditionalNodeTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,23 @@
1616

1717
class ConditionalNodeTest extends AbstractNodeTest
1818
{
19-
public function getEvaluateData()
19+
public static function getEvaluateData(): array
2020
{
2121
return [
2222
[1, new ConditionalNode(new ConstantNode(true), new ConstantNode(1), new ConstantNode(2))],
2323
[2, new ConditionalNode(new ConstantNode(false), new ConstantNode(1), new ConstantNode(2))],
2424
];
2525
}
2626

27-
public function getCompileData()
27+
public static function getCompileData(): array
2828
{
2929
return [
3030
['((true) ? (1) : (2))', new ConditionalNode(new ConstantNode(true), new ConstantNode(1), new ConstantNode(2))],
3131
['((false) ? (1) : (2))', new ConditionalNode(new ConstantNode(false), new ConstantNode(1), new ConstantNode(2))],
3232
];
3333
}
3434

35-
public function getDumpData()
35+
public static function getDumpData(): array
3636
{
3737
return [
3838
['(true ? 1 : 2)', new ConditionalNode(new ConstantNode(true), new ConstantNode(1), new ConstantNode(2))],

Tests/Node/ConstantNodeTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
class ConstantNodeTest extends AbstractNodeTest
1717
{
18-
public function getEvaluateData()
18+
public static function getEvaluateData(): array
1919
{
2020
return [
2121
[false, new ConstantNode(false)],
@@ -28,7 +28,7 @@ public function getEvaluateData()
2828
];
2929
}
3030

31-
public function getCompileData()
31+
public static function getCompileData(): array
3232
{
3333
return [
3434
['false', new ConstantNode(false)],
@@ -41,7 +41,7 @@ public function getCompileData()
4141
];
4242
}
4343

44-
public function getDumpData()
44+
public static function getDumpData(): array
4545
{
4646
return [
4747
['false', new ConstantNode(false)],

Tests/Node/FunctionNodeTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,28 @@
1717

1818
class FunctionNodeTest extends AbstractNodeTest
1919
{
20-
public function getEvaluateData()
20+
public static function getEvaluateData(): array
2121
{
2222
return [
23-
['bar', new FunctionNode('foo', new Node([new ConstantNode('bar')])), [], ['foo' => $this->getCallables()]],
23+
['bar', new FunctionNode('foo', new Node([new ConstantNode('bar')])), [], ['foo' => static::getCallables()]],
2424
];
2525
}
2626

27-
public function getCompileData()
27+
public static function getCompileData(): array
2828
{
2929
return [
30-
['foo("bar")', new FunctionNode('foo', new Node([new ConstantNode('bar')])), ['foo' => $this->getCallables()]],
30+
['foo("bar")', new FunctionNode('foo', new Node([new ConstantNode('bar')])), ['foo' => static::getCallables()]],
3131
];
3232
}
3333

34-
public function getDumpData()
34+
public static function getDumpData(): array
3535
{
3636
return [
37-
['foo("bar")', new FunctionNode('foo', new Node([new ConstantNode('bar')])), ['foo' => $this->getCallables()]],
37+
['foo("bar")', new FunctionNode('foo', new Node([new ConstantNode('bar')])), ['foo' => static::getCallables()]],
3838
];
3939
}
4040

41-
protected function getCallables()
41+
protected static function getCallables(): array
4242
{
4343
return [
4444
'compiler' => function ($arg) {

Tests/Node/GetAttrNodeTest.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,46 +18,46 @@
1818

1919
class GetAttrNodeTest extends AbstractNodeTest
2020
{
21-
public function getEvaluateData()
21+
public static function getEvaluateData(): array
2222
{
2323
return [
24-
['b', new GetAttrNode(new NameNode('foo'), new ConstantNode(0), $this->getArrayNode(), GetAttrNode::ARRAY_CALL), ['foo' => ['b' => 'a', 'b']]],
25-
['a', new GetAttrNode(new NameNode('foo'), new ConstantNode('b'), $this->getArrayNode(), GetAttrNode::ARRAY_CALL), ['foo' => ['b' => 'a', 'b']]],
24+
['b', new GetAttrNode(new NameNode('foo'), new ConstantNode(0), static::getArrayNode(), GetAttrNode::ARRAY_CALL), ['foo' => ['b' => 'a', 'b']]],
25+
['a', new GetAttrNode(new NameNode('foo'), new ConstantNode('b'), static::getArrayNode(), GetAttrNode::ARRAY_CALL), ['foo' => ['b' => 'a', 'b']]],
2626

27-
['bar', new GetAttrNode(new NameNode('foo'), new ConstantNode('foo'), $this->getArrayNode(), GetAttrNode::PROPERTY_CALL), ['foo' => new Obj()]],
27+
['bar', new GetAttrNode(new NameNode('foo'), new ConstantNode('foo'), static::getArrayNode(), GetAttrNode::PROPERTY_CALL), ['foo' => new Obj()]],
2828

29-
['baz', new GetAttrNode(new NameNode('foo'), new ConstantNode('foo'), $this->getArrayNode(), GetAttrNode::METHOD_CALL), ['foo' => new Obj()]],
30-
['a', new GetAttrNode(new NameNode('foo'), new NameNode('index'), $this->getArrayNode(), GetAttrNode::ARRAY_CALL), ['foo' => ['b' => 'a', 'b'], 'index' => 'b']],
29+
['baz', new GetAttrNode(new NameNode('foo'), new ConstantNode('foo'), static::getArrayNode(), GetAttrNode::METHOD_CALL), ['foo' => new Obj()]],
30+
['a', new GetAttrNode(new NameNode('foo'), new NameNode('index'), static::getArrayNode(), GetAttrNode::ARRAY_CALL), ['foo' => ['b' => 'a', 'b'], 'index' => 'b']],
3131
];
3232
}
3333

34-
public function getCompileData()
34+
public static function getCompileData(): array
3535
{
3636
return [
37-
['$foo[0]', new GetAttrNode(new NameNode('foo'), new ConstantNode(0), $this->getArrayNode(), GetAttrNode::ARRAY_CALL)],
38-
['$foo["b"]', new GetAttrNode(new NameNode('foo'), new ConstantNode('b'), $this->getArrayNode(), GetAttrNode::ARRAY_CALL)],
37+
['$foo[0]', new GetAttrNode(new NameNode('foo'), new ConstantNode(0), static::getArrayNode(), GetAttrNode::ARRAY_CALL)],
38+
['$foo["b"]', new GetAttrNode(new NameNode('foo'), new ConstantNode('b'), static::getArrayNode(), GetAttrNode::ARRAY_CALL)],
3939

40-
['$foo->foo', new GetAttrNode(new NameNode('foo'), new ConstantNode('foo'), $this->getArrayNode(), GetAttrNode::PROPERTY_CALL), ['foo' => new Obj()]],
40+
['$foo->foo', new GetAttrNode(new NameNode('foo'), new ConstantNode('foo'), static::getArrayNode(), GetAttrNode::PROPERTY_CALL), ['foo' => new Obj()]],
4141

42-
['$foo->foo(["b" => "a", 0 => "b"])', new GetAttrNode(new NameNode('foo'), new ConstantNode('foo'), $this->getArrayNode(), GetAttrNode::METHOD_CALL), ['foo' => new Obj()]],
43-
['$foo[$index]', new GetAttrNode(new NameNode('foo'), new NameNode('index'), $this->getArrayNode(), GetAttrNode::ARRAY_CALL)],
42+
['$foo->foo(["b" => "a", 0 => "b"])', new GetAttrNode(new NameNode('foo'), new ConstantNode('foo'), static::getArrayNode(), GetAttrNode::METHOD_CALL), ['foo' => new Obj()]],
43+
['$foo[$index]', new GetAttrNode(new NameNode('foo'), new NameNode('index'), static::getArrayNode(), GetAttrNode::ARRAY_CALL)],
4444
];
4545
}
4646

47-
public function getDumpData()
47+
public static function getDumpData(): array
4848
{
4949
return [
50-
['foo[0]', new GetAttrNode(new NameNode('foo'), new ConstantNode(0), $this->getArrayNode(), GetAttrNode::ARRAY_CALL)],
51-
['foo["b"]', new GetAttrNode(new NameNode('foo'), new ConstantNode('b'), $this->getArrayNode(), GetAttrNode::ARRAY_CALL)],
50+
['foo[0]', new GetAttrNode(new NameNode('foo'), new ConstantNode(0), static::getArrayNode(), GetAttrNode::ARRAY_CALL)],
51+
['foo["b"]', new GetAttrNode(new NameNode('foo'), new ConstantNode('b'), static::getArrayNode(), GetAttrNode::ARRAY_CALL)],
5252

53-
['foo.foo', new GetAttrNode(new NameNode('foo'), new NameNode('foo'), $this->getArrayNode(), GetAttrNode::PROPERTY_CALL), ['foo' => new Obj()]],
53+
['foo.foo', new GetAttrNode(new NameNode('foo'), new NameNode('foo'), static::getArrayNode(), GetAttrNode::PROPERTY_CALL), ['foo' => new Obj()]],
5454

55-
['foo.foo({"b": "a", 0: "b"})', new GetAttrNode(new NameNode('foo'), new NameNode('foo'), $this->getArrayNode(), GetAttrNode::METHOD_CALL), ['foo' => new Obj()]],
56-
['foo[index]', new GetAttrNode(new NameNode('foo'), new NameNode('index'), $this->getArrayNode(), GetAttrNode::ARRAY_CALL)],
55+
['foo.foo({"b": "a", 0: "b"})', new GetAttrNode(new NameNode('foo'), new NameNode('foo'), static::getArrayNode(), GetAttrNode::METHOD_CALL), ['foo' => new Obj()]],
56+
['foo[index]', new GetAttrNode(new NameNode('foo'), new NameNode('index'), static::getArrayNode(), GetAttrNode::ARRAY_CALL)],
5757
];
5858
}
5959

60-
protected function getArrayNode()
60+
protected static function getArrayNode(): ArrayNode
6161
{
6262
$array = new ArrayNode();
6363
$array->addElement(new ConstantNode('a'), new ConstantNode('b'));

Tests/Node/NameNodeTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,21 @@
1515

1616
class NameNodeTest extends AbstractNodeTest
1717
{
18-
public function getEvaluateData()
18+
public static function getEvaluateData(): array
1919
{
2020
return [
2121
['bar', new NameNode('foo'), ['foo' => 'bar']],
2222
];
2323
}
2424

25-
public function getCompileData()
25+
public static function getCompileData(): array
2626
{
2727
return [
2828
['$foo', new NameNode('foo')],
2929
];
3030
}
3131

32-
public function getDumpData()
32+
public static function getDumpData(): array
3333
{
3434
return [
3535
['foo', new NameNode('foo')],

Tests/Node/UnaryNodeTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
class UnaryNodeTest extends AbstractNodeTest
1818
{
19-
public function getEvaluateData()
19+
public static function getEvaluateData(): array
2020
{
2121
return [
2222
[-1, new UnaryNode('-', new ConstantNode(1))],
@@ -26,7 +26,7 @@ public function getEvaluateData()
2626
];
2727
}
2828

29-
public function getCompileData()
29+
public static function getCompileData(): array
3030
{
3131
return [
3232
['(-1)', new UnaryNode('-', new ConstantNode(1))],
@@ -36,7 +36,7 @@ public function getCompileData()
3636
];
3737
}
3838

39-
public function getDumpData()
39+
public static function getDumpData(): array
4040
{
4141
return [
4242
['(- 1)', new UnaryNode('-', new ConstantNode(1))],

0 commit comments

Comments
 (0)