Skip to content

Commit 74815c3

Browse files
Merge branch '3.4' into 4.3
* 3.4: Use `::class` constants instead of `__NAMESPACE__` when possible
2 parents 247a597 + 812a3a4 commit 74815c3

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

Definition/Builder/NodeBuilder.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ class NodeBuilder implements NodeParentInterface
2424
public function __construct()
2525
{
2626
$this->nodeMapping = [
27-
'variable' => __NAMESPACE__.'\\VariableNodeDefinition',
28-
'scalar' => __NAMESPACE__.'\\ScalarNodeDefinition',
29-
'boolean' => __NAMESPACE__.'\\BooleanNodeDefinition',
30-
'integer' => __NAMESPACE__.'\\IntegerNodeDefinition',
31-
'float' => __NAMESPACE__.'\\FloatNodeDefinition',
32-
'array' => __NAMESPACE__.'\\ArrayNodeDefinition',
33-
'enum' => __NAMESPACE__.'\\EnumNodeDefinition',
27+
'variable' => VariableNodeDefinition::class,
28+
'scalar' => ScalarNodeDefinition::class,
29+
'boolean' => BooleanNodeDefinition::class,
30+
'integer' => IntegerNodeDefinition::class,
31+
'float' => FloatNodeDefinition::class,
32+
'array' => ArrayNodeDefinition::class,
33+
'enum' => EnumNodeDefinition::class,
3434
];
3535
}
3636

Tests/Definition/Builder/NodeBuilderTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function testThrowsAnExceptionWhenTheNodeClassIsNotFound()
3535

3636
public function testAddingANewNodeType()
3737
{
38-
$class = __NAMESPACE__.'\\SomeNodeDefinition';
38+
$class = SomeNodeDefinition::class;
3939

4040
$builder = new BaseNodeBuilder();
4141
$node = $builder
@@ -47,7 +47,7 @@ public function testAddingANewNodeType()
4747

4848
public function testOverridingAnExistingNodeType()
4949
{
50-
$class = __NAMESPACE__.'\\SomeNodeDefinition';
50+
$class = SomeNodeDefinition::class;
5151

5252
$builder = new BaseNodeBuilder();
5353
$node = $builder
@@ -66,7 +66,7 @@ public function testNodeTypesAreNotCaseSensitive()
6666

6767
$this->assertInstanceOf(\get_class($node1), $node2);
6868

69-
$builder->setNodeClass('CuStOm', __NAMESPACE__.'\\SomeNodeDefinition');
69+
$builder->setNodeClass('CuStOm', SomeNodeDefinition::class);
7070

7171
$node1 = $builder->node('', 'CUSTOM');
7272
$node2 = $builder->node('', 'custom');

Tests/Util/XmlUtilsTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function testLoadFile()
4848
$this->assertStringContainsString('XSD file or callable', $e->getMessage());
4949
}
5050

51-
$mock = $this->getMockBuilder(__NAMESPACE__.'\Validator')->getMock();
51+
$mock = $this->getMockBuilder(Validator::class)->getMock();
5252
$mock->expects($this->exactly(2))->method('validate')->will($this->onConsecutiveCalls(false, true));
5353

5454
try {
@@ -68,7 +68,7 @@ public function testParseWithInvalidValidatorCallable()
6868
$this->expectExceptionMessage('The XML is not valid');
6969
$fixtures = __DIR__.'/../Fixtures/Util/';
7070

71-
$mock = $this->getMockBuilder(__NAMESPACE__.'\Validator')->getMock();
71+
$mock = $this->getMockBuilder(Validator::class)->getMock();
7272
$mock->expects($this->once())->method('validate')->willReturn(false);
7373

7474
XmlUtils::parse(file_get_contents($fixtures.'valid.xml'), [$mock, 'validate']);

0 commit comments

Comments
 (0)