Skip to content

Commit fd4db22

Browse files
committed
minor #39775 [WIP] Use ::class keyword when possible (fabpot)
This PR was merged into the 4.4 branch. Discussion ---------- [WIP] Use ::class keyword when possible | Q | A | ------------- | --- | Branch? | 4.4 <!-- see below --> | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | n/a <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT | Doc PR | n/a Commits ------- 036a36cb14 Use ::class keyword when possible
2 parents f908136 + 19d31cb commit fd4db22

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

Tests/Controller/ControllerNameParserTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function testParse()
5151
$parser->parse('foo:');
5252
$this->fail('->parse() throws an \InvalidArgumentException if the controller is not an a:b:c string');
5353
} catch (\Exception $e) {
54-
$this->assertInstanceOf('\InvalidArgumentException', $e, '->parse() throws an \InvalidArgumentException if the controller is not an a:b:c string');
54+
$this->assertInstanceOf(\InvalidArgumentException::class, $e, '->parse() throws an \InvalidArgumentException if the controller is not an a:b:c string');
5555
}
5656
}
5757

@@ -66,21 +66,21 @@ public function testBuild()
6666
$parser->build('TestBundle\FooBundle\Controller\DefaultController::index');
6767
$this->fail('->parse() throws an \InvalidArgumentException if the controller is not an aController::cAction string');
6868
} catch (\Exception $e) {
69-
$this->assertInstanceOf('\InvalidArgumentException', $e, '->parse() throws an \InvalidArgumentException if the controller is not an aController::cAction string');
69+
$this->assertInstanceOf(\InvalidArgumentException::class, $e, '->parse() throws an \InvalidArgumentException if the controller is not an aController::cAction string');
7070
}
7171

7272
try {
7373
$parser->build('TestBundle\FooBundle\Controller\Default::indexAction');
7474
$this->fail('->parse() throws an \InvalidArgumentException if the controller is not an aController::cAction string');
7575
} catch (\Exception $e) {
76-
$this->assertInstanceOf('\InvalidArgumentException', $e, '->parse() throws an \InvalidArgumentException if the controller is not an aController::cAction string');
76+
$this->assertInstanceOf(\InvalidArgumentException::class, $e, '->parse() throws an \InvalidArgumentException if the controller is not an aController::cAction string');
7777
}
7878

7979
try {
8080
$parser->build('Foo\Controller\DefaultController::indexAction');
8181
$this->fail('->parse() throws an \InvalidArgumentException if the controller is not an aController::cAction string');
8282
} catch (\Exception $e) {
83-
$this->assertInstanceOf('\InvalidArgumentException', $e, '->parse() throws an \InvalidArgumentException if the controller is not an aController::cAction string');
83+
$this->assertInstanceOf(\InvalidArgumentException::class, $e, '->parse() throws an \InvalidArgumentException if the controller is not an aController::cAction string');
8484
}
8585
}
8686

@@ -95,7 +95,7 @@ public function testMissingControllers($name)
9595
$parser->parse($name);
9696
$this->fail('->parse() throws a \InvalidArgumentException if the class is found but does not exist');
9797
} catch (\Exception $e) {
98-
$this->assertInstanceOf('\InvalidArgumentException', $e, '->parse() throws a \InvalidArgumentException if the class is found but does not exist');
98+
$this->assertInstanceOf(\InvalidArgumentException::class, $e, '->parse() throws a \InvalidArgumentException if the class is found but does not exist');
9999
}
100100
}
101101

@@ -125,7 +125,7 @@ public function testInvalidBundleName($bundleName, $suggestedBundleName)
125125
$parser->parse($bundleName);
126126
$this->fail('->parse() throws a \InvalidArgumentException if the bundle does not exist');
127127
} catch (\Exception $e) {
128-
$this->assertInstanceOf('\InvalidArgumentException', $e, '->parse() throws a \InvalidArgumentException if the bundle does not exist');
128+
$this->assertInstanceOf(\InvalidArgumentException::class, $e, '->parse() throws a \InvalidArgumentException if the bundle does not exist');
129129

130130
if (false === $suggestedBundleName) {
131131
// make sure we don't have a suggestion

Tests/Translation/TranslatorTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public function testTransWithCachingWithInvalidLocale()
140140
$this->expectException('InvalidArgumentException');
141141
$this->expectExceptionMessage('Invalid "invalid locale" locale.');
142142
$loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock();
143-
$translator = $this->getTranslator($loader, ['cache_dir' => $this->tmpDir], 'loader', '\Symfony\Bundle\FrameworkBundle\Tests\Translation\TranslatorWithInvalidLocale');
143+
$translator = $this->getTranslator($loader, ['cache_dir' => $this->tmpDir], 'loader', TranslatorWithInvalidLocale::class);
144144

145145
$translator->trans('foo');
146146
}
@@ -346,7 +346,7 @@ protected function getContainer($loader)
346346
return $container;
347347
}
348348

349-
public function getTranslator($loader, $options = [], $loaderFomat = 'loader', $translatorClass = '\Symfony\Bundle\FrameworkBundle\Translation\Translator', $defaultLocale = 'en')
349+
public function getTranslator($loader, $options = [], $loaderFomat = 'loader', $translatorClass = Translator::class, $defaultLocale = 'en')
350350
{
351351
$translator = $this->createTranslator($loader, $options, $translatorClass, $loaderFomat, $defaultLocale);
352352

@@ -403,7 +403,7 @@ public function testLoadingTranslationFilesWithDotsInMessageDomain()
403403
$this->assertEquals('It works!', $translator->trans('message', [], 'domain.with.dots'));
404404
}
405405

406-
private function createTranslator($loader, $options, $translatorClass = '\Symfony\Bundle\FrameworkBundle\Translation\Translator', $loaderFomat = 'loader', $defaultLocale = 'en')
406+
private function createTranslator($loader, $options, $translatorClass = Translator::class, $loaderFomat = 'loader', $defaultLocale = 'en')
407407
{
408408
if (null === $defaultLocale) {
409409
return new $translatorClass(

0 commit comments

Comments
 (0)