Skip to content

Commit 1ef2845

Browse files
committed
Merge branch '4.4' into 5.1
* 4.4: Use ::class keyword when possible
2 parents 4c2ddc4 + 361f15a commit 1ef2845

File tree

9 files changed

+13
-11
lines changed

9 files changed

+13
-11
lines changed

Tests/Compiler/ResolveClassPassTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function provideInvalidClassId()
5555
{
5656
yield [\stdClass::class];
5757
yield ['bar'];
58-
yield ['\DateTime'];
58+
yield [\DateTime::class];
5959
}
6060

6161
public function testNonFqcnChildDefinition()

Tests/ContainerBuilderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ public function testCreateServiceClass()
420420
$builder = new ContainerBuilder();
421421
$builder->register('foo1', '%class%');
422422
$builder->setParameter('class', 'stdClass');
423-
$this->assertInstanceOf('\stdClass', $builder->get('foo1'), '->createService() replaces parameters in the class provided by the service definition');
423+
$this->assertInstanceOf(\stdClass::class, $builder->get('foo1'), '->createService() replaces parameters in the class provided by the service definition');
424424
}
425425

426426
public function testCreateServiceArguments()
@@ -519,7 +519,7 @@ public function testCreateServiceWithIteratorArgument()
519519
foreach ($lazyContext->lazyValues as $k => $v) {
520520
++$i;
521521
$this->assertEquals('k1', $k);
522-
$this->assertInstanceOf('\stdClass', $v);
522+
$this->assertInstanceOf(\stdClass::class, $v);
523523
}
524524

525525
// The second argument should have been ignored.

Tests/ContainerTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\DependencyInjection\Container;
1616
use Symfony\Component\DependencyInjection\ContainerInterface;
17+
use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException;
1718
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
1819
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
1920
use Symfony\Contracts\Service\ResetInterface;
@@ -116,7 +117,7 @@ public function testGetSetParameter()
116117
$sc->getParameter('baba');
117118
$this->fail('->getParameter() thrown an \InvalidArgumentException if the key does not exist');
118119
} catch (\Exception $e) {
119-
$this->assertInstanceOf('\InvalidArgumentException', $e, '->getParameter() thrown an \InvalidArgumentException if the key does not exist');
120+
$this->assertInstanceOf(\InvalidArgumentException::class, $e, '->getParameter() thrown an \InvalidArgumentException if the key does not exist');
120121
$this->assertEquals('You have requested a non-existent parameter "baba".', $e->getMessage(), '->getParameter() thrown an \InvalidArgumentException if the key does not exist');
121122
}
122123
}
@@ -252,7 +253,7 @@ public function testGetCircularReference()
252253
$sc->get('circular');
253254
$this->fail('->get() throws a ServiceCircularReferenceException if it contains circular reference');
254255
} catch (\Exception $e) {
255-
$this->assertInstanceOf('\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException', $e, '->get() throws a ServiceCircularReferenceException if it contains circular reference');
256+
$this->assertInstanceOf(ServiceCircularReferenceException::class, $e, '->get() throws a ServiceCircularReferenceException if it contains circular reference');
256257
$this->assertStringStartsWith('Circular reference detected for service "circular"', $e->getMessage(), '->get() throws a \LogicException if it contains circular reference');
257258
}
258259
}

Tests/Dumper/PhpDumperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public function testAddService()
217217
$dumper->dump();
218218
$this->fail('->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
219219
} catch (\Exception $e) {
220-
$this->assertInstanceOf('\Symfony\Component\DependencyInjection\Exception\RuntimeException', $e, '->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
220+
$this->assertInstanceOf(RuntimeException::class, $e, '->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
221221
$this->assertEquals('Unable to dump a service container if a parameter is an object or a resource.', $e->getMessage(), '->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
222222
}
223223
}

Tests/Dumper/XmlDumperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function testAddService()
6666
$dumper->dump();
6767
$this->fail('->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
6868
} catch (\Exception $e) {
69-
$this->assertInstanceOf('\RuntimeException', $e, '->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
69+
$this->assertInstanceOf(\RuntimeException::class, $e, '->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
7070
$this->assertEquals('Unable to dump a service container if a parameter is an object or a resource.', $e->getMessage(), '->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
7171
}
7272
}

Tests/Dumper/YamlDumperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function testAddService()
6161
$dumper->dump();
6262
$this->fail('->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
6363
} catch (\Exception $e) {
64-
$this->assertInstanceOf('\RuntimeException', $e, '->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
64+
$this->assertInstanceOf(\RuntimeException::class, $e, '->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
6565
$this->assertEquals('Unable to dump a service container if a parameter is an object or a resource.', $e->getMessage(), '->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
6666
}
6767
}

Tests/Fixtures/containers/container9.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
require_once __DIR__.'/../includes/classes.php';
44
require_once __DIR__.'/../includes/foo.php';
55

6+
use Bar\FooClass;
67
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
78
use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument;
89
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -13,7 +14,7 @@
1314

1415
$container = new ContainerBuilder();
1516
$container
16-
->register('foo', '\Bar\FooClass')
17+
->register('foo', FooClass::class)
1718
->addTag('foo', ['foo' => 'foo'])
1819
->addTag('foo', ['bar' => 'bar', 'baz' => 'baz'])
1920
->addTag('foo', ['name' => 'bar', 'baz' => 'baz'])

Tests/Loader/XmlFileLoaderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ public function testExtensions()
548548
$loader->load('extensions/services4.xml');
549549
$this->fail('->load() throws an InvalidArgumentException if the tag is not valid');
550550
} catch (\Exception $e) {
551-
$this->assertInstanceOf('\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the tag is not valid');
551+
$this->assertInstanceOf(\InvalidArgumentException::class, $e, '->load() throws an InvalidArgumentException if the tag is not valid');
552552
$this->assertStringStartsWith('There is no extension able to load the configuration for "project:bar" (in', $e->getMessage(), '->load() throws an InvalidArgumentException if the tag is not valid');
553553
}
554554
}

Tests/Loader/YamlFileLoaderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ public function testExtensions()
282282
$loader->load('services11.yml');
283283
$this->fail('->load() throws an InvalidArgumentException if the tag is not valid');
284284
} catch (\Exception $e) {
285-
$this->assertInstanceOf('\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the tag is not valid');
285+
$this->assertInstanceOf(\InvalidArgumentException::class, $e, '->load() throws an InvalidArgumentException if the tag is not valid');
286286
$this->assertStringStartsWith('There is no extension able to load the configuration for "foobarfoobar" (in', $e->getMessage(), '->load() throws an InvalidArgumentException if the tag is not valid');
287287
}
288288
}

0 commit comments

Comments
 (0)