Skip to content

Commit 6417d2f

Browse files
committed
Use ::class keyword when possible
1 parent 464eddb commit 6417d2f

26 files changed

+73
-73
lines changed

Node/TransNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
use Twig\Node\TextNode;
2121

2222
// BC/FC with namespaced Twig
23-
class_exists('Twig\Node\Expression\ArrayExpression');
23+
class_exists(ArrayExpression::class);
2424

2525
/**
2626
* @author Fabien Potencier <[email protected]>

Tests/AppVariableTest.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function testEnvironment()
5050
*/
5151
public function testGetSession()
5252
{
53-
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
53+
$request = $this->getMockBuilder(Request::class)->getMock();
5454
$request->method('hasSession')->willReturn(true);
5555
$request->method('getSession')->willReturn($session = new Session());
5656

@@ -75,18 +75,18 @@ public function testGetRequest()
7575

7676
public function testGetToken()
7777
{
78-
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
78+
$tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock();
7979
$this->appVariable->setTokenStorage($tokenStorage);
8080

81-
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
81+
$token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock();
8282
$tokenStorage->method('getToken')->willReturn($token);
8383

8484
$this->assertEquals($token, $this->appVariable->getToken());
8585
}
8686

8787
public function testGetUser()
8888
{
89-
$this->setTokenStorage($user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock());
89+
$this->setTokenStorage($user = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock());
9090

9191
$this->assertEquals($user, $this->appVariable->getUser());
9292
}
@@ -100,53 +100,53 @@ public function testGetUserWithUsernameAsTokenUser()
100100

101101
public function testGetTokenWithNoToken()
102102
{
103-
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
103+
$tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock();
104104
$this->appVariable->setTokenStorage($tokenStorage);
105105

106106
$this->assertNull($this->appVariable->getToken());
107107
}
108108

109109
public function testGetUserWithNoToken()
110110
{
111-
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
111+
$tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock();
112112
$this->appVariable->setTokenStorage($tokenStorage);
113113

114114
$this->assertNull($this->appVariable->getUser());
115115
}
116116

117117
public function testEnvironmentNotSet()
118118
{
119-
$this->expectException('RuntimeException');
119+
$this->expectException(\RuntimeException::class);
120120
$this->appVariable->getEnvironment();
121121
}
122122

123123
public function testDebugNotSet()
124124
{
125-
$this->expectException('RuntimeException');
125+
$this->expectException(\RuntimeException::class);
126126
$this->appVariable->getDebug();
127127
}
128128

129129
public function testGetTokenWithTokenStorageNotSet()
130130
{
131-
$this->expectException('RuntimeException');
131+
$this->expectException(\RuntimeException::class);
132132
$this->appVariable->getToken();
133133
}
134134

135135
public function testGetUserWithTokenStorageNotSet()
136136
{
137-
$this->expectException('RuntimeException');
137+
$this->expectException(\RuntimeException::class);
138138
$this->appVariable->getUser();
139139
}
140140

141141
public function testGetRequestWithRequestStackNotSet()
142142
{
143-
$this->expectException('RuntimeException');
143+
$this->expectException(\RuntimeException::class);
144144
$this->appVariable->getRequest();
145145
}
146146

147147
public function testGetSessionWithRequestStackNotSet()
148148
{
149-
$this->expectException('RuntimeException');
149+
$this->expectException(\RuntimeException::class);
150150
$this->appVariable->getSession();
151151
}
152152

@@ -224,18 +224,18 @@ public function testGetFlashes()
224224

225225
protected function setRequestStack($request)
226226
{
227-
$requestStackMock = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock();
227+
$requestStackMock = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class)->getMock();
228228
$requestStackMock->method('getCurrentRequest')->willReturn($request);
229229

230230
$this->appVariable->setRequestStack($requestStackMock);
231231
}
232232

233233
protected function setTokenStorage($user)
234234
{
235-
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
235+
$tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock();
236236
$this->appVariable->setTokenStorage($tokenStorage);
237237

238-
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
238+
$token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock();
239239
$tokenStorage->method('getToken')->willReturn($token);
240240

241241
$token->method('getUser')->willReturn($user);
@@ -251,11 +251,11 @@ private function setFlashMessages($sessionHasStarted = true)
251251
$flashBag = new FlashBag();
252252
$flashBag->initialize($flashMessages);
253253

254-
$session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session')->disableOriginalConstructor()->getMock();
254+
$session = $this->getMockBuilder(Session::class)->disableOriginalConstructor()->getMock();
255255
$session->method('isStarted')->willReturn($sessionHasStarted);
256256
$session->method('getFlashBag')->willReturn($flashBag);
257257

258-
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
258+
$request = $this->getMockBuilder(Request::class)->getMock();
259259
$request->method('hasSession')->willReturn(true);
260260
$request->method('getSession')->willReturn($session);
261261
$this->setRequestStack($request);

Tests/Command/DebugCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function testDeprecationForWrongBundleOverridingInLegacyPath()
9191

9292
public function testMalformedTemplateName()
9393
{
94-
$this->expectException('Symfony\Component\Console\Exception\InvalidArgumentException');
94+
$this->expectException(\Symfony\Component\Console\Exception\InvalidArgumentException::class);
9595
$this->expectExceptionMessage('Malformed namespaced template name "@foo" (expecting "@namespace/template_name").');
9696
$this->createCommandTester()->execute(['name' => '@foo']);
9797
}

Tests/Command/LintCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function testLintIncorrectFile()
4848

4949
public function testLintFileNotReadable()
5050
{
51-
$this->expectException('RuntimeException');
51+
$this->expectException(\RuntimeException::class);
5252
$tester = $this->createCommandTester();
5353
$filename = $this->createFile('');
5454
unlink($filename);

Tests/Extension/DumpExtensionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function getDumpTags()
6767
public function testDump($context, $args, $expectedOutput, $debug = true)
6868
{
6969
$extension = new DumpExtension(new VarCloner());
70-
$twig = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), [
70+
$twig = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock(), [
7171
'debug' => $debug,
7272
'cache' => false,
7373
'optimizations' => 0,
@@ -124,7 +124,7 @@ public function testCustomDumper()
124124
'</pre><script>Sfdump("%s")</script>'
125125
);
126126
$extension = new DumpExtension(new VarCloner(), $dumper);
127-
$twig = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), [
127+
$twig = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock(), [
128128
'debug' => true,
129129
'cache' => false,
130130
'optimizations' => 0,

Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ protected function setUp(): void
5050
'bootstrap_3_horizontal_layout.html.twig',
5151
'custom_widgets.html.twig',
5252
], $environment);
53-
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock());
53+
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock());
5454
$this->registerTwigRuntimeLoader($environment, $this->renderer);
5555
}
5656

Tests/Extension/FormExtensionBootstrap3LayoutTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ protected function setUp(): void
4646
'bootstrap_3_layout.html.twig',
4747
'custom_widgets.html.twig',
4848
], $environment);
49-
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock());
49+
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock());
5050
$this->registerTwigRuntimeLoader($environment, $this->renderer);
5151
}
5252

@@ -88,7 +88,7 @@ public function testMoneyWidgetInIso()
8888
'bootstrap_3_layout.html.twig',
8989
'custom_widgets.html.twig',
9090
], $environment);
91-
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock());
91+
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock());
9292
$this->registerTwigRuntimeLoader($environment, $this->renderer);
9393

9494
$view = $this->factory

Tests/Extension/FormExtensionBootstrap4HorizontalLayoutTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ protected function setUp(): void
5252
'bootstrap_4_horizontal_layout.html.twig',
5353
'custom_widgets.html.twig',
5454
], $environment);
55-
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock());
55+
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock());
5656
$this->registerTwigRuntimeLoader($environment, $this->renderer);
5757
}
5858

Tests/Extension/FormExtensionBootstrap4LayoutTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ protected function setUp(): void
5050
'bootstrap_4_layout.html.twig',
5151
'custom_widgets.html.twig',
5252
], $environment);
53-
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock());
53+
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock());
5454
$this->registerTwigRuntimeLoader($environment, $this->renderer);
5555
}
5656

@@ -92,7 +92,7 @@ public function testMoneyWidgetInIso()
9292
'bootstrap_4_layout.html.twig',
9393
'custom_widgets.html.twig',
9494
], $environment);
95-
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock());
95+
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock());
9696
$this->registerTwigRuntimeLoader($environment, $this->renderer);
9797

9898
$view = $this->factory

Tests/Extension/FormExtensionDivLayoutTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ protected function setUp(): void
5353
'form_div_layout.html.twig',
5454
'custom_widgets.html.twig',
5555
], $environment);
56-
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock());
56+
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock());
5757
$this->registerTwigRuntimeLoader($environment, $this->renderer);
5858
}
5959

@@ -181,7 +181,7 @@ public function testMoneyWidgetInIso()
181181
'form_div_layout.html.twig',
182182
'custom_widgets.html.twig',
183183
], $environment);
184-
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock());
184+
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock());
185185
$this->registerTwigRuntimeLoader($environment, $this->renderer);
186186

187187
$view = $this->factory

0 commit comments

Comments
 (0)