Skip to content

Commit 0da0af2

Browse files
committed
Use ::class keyword when possible
1 parent 8c5e45d commit 0da0af2

File tree

5 files changed

+28
-28
lines changed

5 files changed

+28
-28
lines changed

Tests/CookieTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function testInstantiationThrowsExceptionIfRawCookieNameContainsSpecialCh
5252
*/
5353
public function testWithRawThrowsExceptionIfCookieNameContainsSpecialCharacters($name)
5454
{
55-
$this->expectException('InvalidArgumentException');
55+
$this->expectException(\InvalidArgumentException::class);
5656
Cookie::create($name)->withRaw();
5757
}
5858

Tests/JsonResponseTest.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function testCreate()
9797
{
9898
$response = JsonResponse::create(['foo' => 'bar'], 204);
9999

100-
$this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response);
100+
$this->assertInstanceOf(JsonResponse::class, $response);
101101
$this->assertEquals('{"foo":"bar"}', $response->getContent());
102102
$this->assertEquals(204, $response->getStatusCode());
103103
}
@@ -108,7 +108,7 @@ public function testCreate()
108108
public function testStaticCreateEmptyJsonObject()
109109
{
110110
$response = JsonResponse::create();
111-
$this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response);
111+
$this->assertInstanceOf(JsonResponse::class, $response);
112112
$this->assertSame('{}', $response->getContent());
113113
}
114114

@@ -118,7 +118,7 @@ public function testStaticCreateEmptyJsonObject()
118118
public function testStaticCreateJsonArray()
119119
{
120120
$response = JsonResponse::create([0, 1, 2, 3]);
121-
$this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response);
121+
$this->assertInstanceOf(JsonResponse::class, $response);
122122
$this->assertSame('[0,1,2,3]', $response->getContent());
123123
}
124124

@@ -128,7 +128,7 @@ public function testStaticCreateJsonArray()
128128
public function testStaticCreateJsonObject()
129129
{
130130
$response = JsonResponse::create(['foo' => 'bar']);
131-
$this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response);
131+
$this->assertInstanceOf(JsonResponse::class, $response);
132132
$this->assertSame('{"foo":"bar"}', $response->getContent());
133133
}
134134

@@ -138,20 +138,20 @@ public function testStaticCreateJsonObject()
138138
public function testStaticCreateWithSimpleTypes()
139139
{
140140
$response = JsonResponse::create('foo');
141-
$this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response);
141+
$this->assertInstanceOf(JsonResponse::class, $response);
142142
$this->assertSame('"foo"', $response->getContent());
143143

144144
$response = JsonResponse::create(0);
145-
$this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response);
145+
$this->assertInstanceOf(JsonResponse::class, $response);
146146
$this->assertSame('0', $response->getContent());
147147

148148
$response = JsonResponse::create(0.1);
149-
$this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response);
149+
$this->assertInstanceOf(JsonResponse::class, $response);
150150
$this->assertEquals(0.1, $response->getContent());
151151
$this->assertIsString($response->getContent());
152152

153153
$response = JsonResponse::create(true);
154-
$this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response);
154+
$this->assertInstanceOf(JsonResponse::class, $response);
155155
$this->assertSame('true', $response->getContent());
156156
}
157157

@@ -236,22 +236,22 @@ public function testItAcceptsJsonAsString()
236236

237237
public function testSetCallbackInvalidIdentifier()
238238
{
239-
$this->expectException('InvalidArgumentException');
239+
$this->expectException(\InvalidArgumentException::class);
240240
$response = new JsonResponse('foo');
241241
$response->setCallback('+invalid');
242242
}
243243

244244
public function testSetContent()
245245
{
246-
$this->expectException('InvalidArgumentException');
246+
$this->expectException(\InvalidArgumentException::class);
247247
new JsonResponse("\xB1\x31");
248248
}
249249

250250
public function testSetContentJsonSerializeError()
251251
{
252-
$this->expectException('Exception');
252+
$this->expectException(\Exception::class);
253253
$this->expectExceptionMessage('This error is expected');
254-
if (!interface_exists('JsonSerializable', false)) {
254+
if (!interface_exists(\JsonSerializable::class, false)) {
255255
$this->markTestSkipped('JsonSerializable is required.');
256256
}
257257

@@ -299,7 +299,7 @@ public function testConstructorWithObjectWithoutToStringMethodThrowsAnException(
299299
}
300300
}
301301

302-
if (interface_exists('JsonSerializable', false)) {
302+
if (interface_exists(\JsonSerializable::class, false)) {
303303
class JsonSerializableObject implements \JsonSerializable
304304
{
305305
public function jsonSerialize()

Tests/RedirectResponseTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ public function testGenerateMetaRedirect()
2525

2626
public function testRedirectResponseConstructorEmptyUrl()
2727
{
28-
$this->expectException('InvalidArgumentException');
28+
$this->expectException(\InvalidArgumentException::class);
2929
$this->expectExceptionMessage('Cannot redirect to an empty URL.');
3030
new RedirectResponse('');
3131
}
3232

3333
public function testRedirectResponseConstructorWrongStatusCode()
3434
{
35-
$this->expectException('InvalidArgumentException');
35+
$this->expectException(\InvalidArgumentException::class);
3636
new RedirectResponse('foo.bar', 404);
3737
}
3838

@@ -66,7 +66,7 @@ public function testCreate()
6666
{
6767
$response = RedirectResponse::create('foo', 301);
6868

69-
$this->assertInstanceOf('Symfony\Component\HttpFoundation\RedirectResponse', $response);
69+
$this->assertInstanceOf(RedirectResponse::class, $response);
7070
$this->assertEquals(301, $response->getStatusCode());
7171
}
7272

Tests/ResponseTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function testCreate()
2727
{
2828
$response = Response::create('foo', 301, ['Foo' => 'bar']);
2929

30-
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response);
30+
$this->assertInstanceOf(Response::class, $response);
3131
$this->assertEquals(301, $response->getStatusCode());
3232
$this->assertEquals('bar', $response->headers->get('foo'));
3333
}
@@ -614,7 +614,7 @@ public function testSetCache()
614614
$response->setCache(['wrong option' => 'value']);
615615
$this->fail('->setCache() throws an InvalidArgumentException if an option is not supported');
616616
} catch (\Exception $e) {
617-
$this->assertInstanceOf('InvalidArgumentException', $e, '->setCache() throws an InvalidArgumentException if an option is not supported');
617+
$this->assertInstanceOf(\InvalidArgumentException::class, $e, '->setCache() throws an InvalidArgumentException if an option is not supported');
618618
$this->assertStringContainsString('"wrong option"', $e->getMessage());
619619
}
620620

Tests/Session/Storage/NativeSessionStorageTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ public function testBag()
7171

7272
public function testRegisterBagException()
7373
{
74-
$this->expectException('InvalidArgumentException');
74+
$this->expectException(\InvalidArgumentException::class);
7575
$storage = $this->getStorage();
7676
$storage->getBag('non_existing');
7777
}
7878

7979
public function testRegisterBagForAStartedSessionThrowsException()
8080
{
81-
$this->expectException('LogicException');
81+
$this->expectException(\LogicException::class);
8282
$storage = $this->getStorage();
8383
$storage->start();
8484
$storage->registerBag(new AttributeBag());
@@ -210,22 +210,22 @@ public function testSetSaveHandler()
210210
$this->iniSet('session.save_handler', 'files');
211211
$storage = $this->getStorage();
212212
$storage->setSaveHandler();
213-
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler());
213+
$this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler());
214214
$storage->setSaveHandler(null);
215-
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler());
215+
$this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler());
216216
$storage->setSaveHandler(new SessionHandlerProxy(new NativeFileSessionHandler()));
217-
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler());
217+
$this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler());
218218
$storage->setSaveHandler(new NativeFileSessionHandler());
219-
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler());
219+
$this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler());
220220
$storage->setSaveHandler(new SessionHandlerProxy(new NullSessionHandler()));
221-
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler());
221+
$this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler());
222222
$storage->setSaveHandler(new NullSessionHandler());
223-
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler());
223+
$this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler());
224224
}
225225

226226
public function testStarted()
227227
{
228-
$this->expectException('RuntimeException');
228+
$this->expectException(\RuntimeException::class);
229229
$storage = $this->getStorage();
230230

231231
$this->assertFalse($storage->getSaveHandler()->isActive());

0 commit comments

Comments
 (0)