Skip to content

Commit 003b6e0

Browse files
committed
Use ::class keyword when possible
1 parent 25f2061 commit 003b6e0

File tree

7 files changed

+23
-23
lines changed

7 files changed

+23
-23
lines changed

Client.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public function getMaxRedirects()
117117
*/
118118
public function insulate($insulated = true)
119119
{
120-
if ($insulated && !class_exists('Symfony\\Component\\Process\\Process')) {
120+
if ($insulated && !class_exists(\Symfony\Component\Process\Process::class)) {
121121
throw new \LogicException('Unable to isolate requests as the Symfony Process Component is not installed.');
122122
}
123123

@@ -527,7 +527,7 @@ protected function filterResponse($response)
527527
*/
528528
protected function createCrawlerFromContent($uri, $content, $type)
529529
{
530-
if (!class_exists('Symfony\Component\DomCrawler\Crawler')) {
530+
if (!class_exists(Crawler::class)) {
531531
return null;
532532
}
533533

Tests/AbstractBrowserTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function testGetResponse()
8989
$client->request('GET', 'http://example.com/');
9090

9191
$this->assertSame('foo', $client->getResponse()->getContent(), '->getCrawler() returns the Response of the last request');
92-
$this->assertInstanceOf('Symfony\Component\BrowserKit\Response', $client->getResponse(), '->getCrawler() returns the Response of the last request');
92+
$this->assertInstanceOf(Response::class, $client->getResponse(), '->getCrawler() returns the Response of the last request');
9393
}
9494

9595
/**
@@ -300,7 +300,7 @@ public function testClickLinkNotFound()
300300
$client->clickLink('foo');
301301
$this->fail('->clickLink() throws a \InvalidArgumentException if the link could not be found');
302302
} catch (\Exception $e) {
303-
$this->assertInstanceOf('InvalidArgumentException', $e, '->clickLink() throws a \InvalidArgumentException if the link could not be found');
303+
$this->assertInstanceOf(\InvalidArgumentException::class, $e, '->clickLink() throws a \InvalidArgumentException if the link could not be found');
304304
}
305305
}
306306

@@ -359,7 +359,7 @@ public function testSubmitFormNotFound()
359359
], 'POST');
360360
$this->fail('->submitForm() throws a \InvalidArgumentException if the form could not be found');
361361
} catch (\Exception $e) {
362-
$this->assertInstanceOf('InvalidArgumentException', $e, '->submitForm() throws a \InvalidArgumentException if the form could not be found');
362+
$this->assertInstanceOf(\InvalidArgumentException::class, $e, '->submitForm() throws a \InvalidArgumentException if the form could not be found');
363363
}
364364
}
365365

@@ -410,7 +410,7 @@ public function testFollowRedirect()
410410
$client->followRedirect();
411411
$this->fail('->followRedirect() throws a \LogicException if the request was not redirected');
412412
} catch (\Exception $e) {
413-
$this->assertInstanceOf('LogicException', $e, '->followRedirect() throws a \LogicException if the request was not redirected');
413+
$this->assertInstanceOf(\LogicException::class, $e, '->followRedirect() throws a \LogicException if the request was not redirected');
414414
}
415415

416416
$client->setNextResponse(new Response('', 302, ['Location' => 'http://www.example.com/redirected']));
@@ -440,7 +440,7 @@ public function testFollowRedirect()
440440
$client->followRedirect();
441441
$this->fail('->followRedirect() throws a \LogicException if the request did not respond with 30x HTTP Code');
442442
} catch (\Exception $e) {
443-
$this->assertInstanceOf('LogicException', $e, '->followRedirect() throws a \LogicException if the request did not respond with 30x HTTP Code');
443+
$this->assertInstanceOf(\LogicException::class, $e, '->followRedirect() throws a \LogicException if the request did not respond with 30x HTTP Code');
444444
}
445445
}
446446

@@ -470,7 +470,7 @@ public function testFollowRedirectWithMaxRedirects()
470470
$client->followRedirect();
471471
$this->fail('->followRedirect() throws a \LogicException if the request was redirected and limit of redirections was reached');
472472
} catch (\Exception $e) {
473-
$this->assertInstanceOf('LogicException', $e, '->followRedirect() throws a \LogicException if the request was redirected and limit of redirections was reached');
473+
$this->assertInstanceOf(\LogicException::class, $e, '->followRedirect() throws a \LogicException if the request was redirected and limit of redirections was reached');
474474
}
475475

476476
$client->setNextResponse(new Response('', 302, ['Location' => 'http://www.example.com/redirected']));
@@ -753,7 +753,7 @@ public function testInsulatedRequests()
753753
$client->request('GET', 'http://www.example.com/foo/foobar');
754754
$this->fail('->request() throws a \RuntimeException if the script has an error');
755755
} catch (\Exception $e) {
756-
$this->assertInstanceOf('RuntimeException', $e, '->request() throws a \RuntimeException if the script has an error');
756+
$this->assertInstanceOf(\RuntimeException::class, $e, '->request() throws a \RuntimeException if the script has an error');
757757
}
758758
}
759759

@@ -841,7 +841,7 @@ public function testInternalRequest()
841841
'NEW_SERVER_KEY' => 'new-server-key-value',
842842
]);
843843

844-
$this->assertInstanceOf('Symfony\Component\BrowserKit\Request', $client->getInternalRequest());
844+
$this->assertInstanceOf(\Symfony\Component\BrowserKit\Request::class, $client->getInternalRequest());
845845
}
846846

847847
/**

Tests/CookieJarTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ public function testUpdateFromSetCookie()
7777
$cookieJar->set(new Cookie('bar', 'bar'));
7878
$cookieJar->updateFromSetCookie($setCookies);
7979

80-
$this->assertInstanceOf('Symfony\Component\BrowserKit\Cookie', $cookieJar->get('foo'));
81-
$this->assertInstanceOf('Symfony\Component\BrowserKit\Cookie', $cookieJar->get('bar'));
80+
$this->assertInstanceOf(Cookie::class, $cookieJar->get('foo'));
81+
$this->assertInstanceOf(Cookie::class, $cookieJar->get('bar'));
8282
$this->assertEquals('foo', $cookieJar->get('foo')->getValue(), '->updateFromSetCookie() updates cookies from a Set-Cookie header');
8383
$this->assertEquals('bar', $cookieJar->get('bar')->getValue(), '->updateFromSetCookie() keeps existing cookies');
8484
}
@@ -103,9 +103,9 @@ public function testUpdateFromSetCookieWithMultipleCookies()
103103
$barCookie = $cookieJar->get('bar', '/', '.blog.symfony.com');
104104
$phpCookie = $cookieJar->get('PHPSESSID');
105105

106-
$this->assertInstanceOf('Symfony\Component\BrowserKit\Cookie', $fooCookie);
107-
$this->assertInstanceOf('Symfony\Component\BrowserKit\Cookie', $barCookie);
108-
$this->assertInstanceOf('Symfony\Component\BrowserKit\Cookie', $phpCookie);
106+
$this->assertInstanceOf(Cookie::class, $fooCookie);
107+
$this->assertInstanceOf(Cookie::class, $barCookie);
108+
$this->assertInstanceOf(Cookie::class, $phpCookie);
109109
$this->assertEquals('foo', $fooCookie->getValue());
110110
$this->assertEquals('bar', $barCookie->getValue());
111111
$this->assertEquals('id', $phpCookie->getValue());

Tests/CookieTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function testFromStringWithUrl()
103103

104104
public function testFromStringThrowsAnExceptionIfCookieIsNotValid()
105105
{
106-
$this->expectException('InvalidArgumentException');
106+
$this->expectException(\InvalidArgumentException::class);
107107
Cookie::fromString('foo');
108108
}
109109

@@ -116,7 +116,7 @@ public function testFromStringIgnoresInvalidExpiresDate()
116116

117117
public function testFromStringThrowsAnExceptionIfUrlIsNotValid()
118118
{
119-
$this->expectException('InvalidArgumentException');
119+
$this->expectException(\InvalidArgumentException::class);
120120
Cookie::fromString('foo=bar', 'foobar');
121121
}
122122

@@ -199,7 +199,7 @@ public function testIsExpired()
199199

200200
public function testConstructException()
201201
{
202-
$this->expectException('UnexpectedValueException');
202+
$this->expectException(\UnexpectedValueException::class);
203203
$this->expectExceptionMessage('The cookie expiration time "string" is not valid.');
204204
new Cookie('foo', 'bar', 'string');
205205
}

Tests/HistoryTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function testCurrent()
5555
$history->current();
5656
$this->fail('->current() throws a \LogicException if the history is empty');
5757
} catch (\Exception $e) {
58-
$this->assertInstanceOf('LogicException', $e, '->current() throws a \LogicException if the history is empty');
58+
$this->assertInstanceOf(\LogicException::class, $e, '->current() throws a \LogicException if the history is empty');
5959
}
6060

6161
$history->add(new Request('http://www.example.com/', 'get'));
@@ -72,7 +72,7 @@ public function testBack()
7272
$history->back();
7373
$this->fail('->back() throws a \LogicException if the history is already on the first page');
7474
} catch (\Exception $e) {
75-
$this->assertInstanceOf('LogicException', $e, '->current() throws a \LogicException if the history is already on the first page');
75+
$this->assertInstanceOf(\LogicException::class, $e, '->current() throws a \LogicException if the history is already on the first page');
7676
}
7777

7878
$history->add(new Request('http://www.example1.com/', 'get'));
@@ -91,7 +91,7 @@ public function testForward()
9191
$history->forward();
9292
$this->fail('->forward() throws a \LogicException if the history is already on the last page');
9393
} catch (\Exception $e) {
94-
$this->assertInstanceOf('LogicException', $e, '->forward() throws a \LogicException if the history is already on the last page');
94+
$this->assertInstanceOf(\LogicException::class, $e, '->forward() throws a \LogicException if the history is already on the last page');
9595
}
9696

9797
$history->back();

Tests/TestClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ protected function doRequest($request): Response
4343

4444
protected function getScript($request)
4545
{
46-
$r = new \ReflectionClass('Symfony\Component\BrowserKit\Response');
46+
$r = new \ReflectionClass(Response::class);
4747
$path = $r->getFileName();
4848

4949
return <<<EOF

Tests/TestHttpClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ protected function doRequest($request): Response
6666

6767
protected function getScript($request)
6868
{
69-
$r = new \ReflectionClass('Symfony\Component\BrowserKit\Response');
69+
$r = new \ReflectionClass(Response::class);
7070
$path = $r->getFileName();
7171

7272
return <<<EOF

0 commit comments

Comments
 (0)