Skip to content

Commit d94f08c

Browse files
committed
Use ::class keyword when possible
1 parent 743656d commit d94f08c

30 files changed

+97
-97
lines changed

Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1941,7 +1941,7 @@ private function setPhpDefaultLocale(string $locale): void
19411941
// setting the default locale, the intl module is not installed, and
19421942
// the call can be ignored:
19431943
try {
1944-
if (class_exists('Locale', false)) {
1944+
if (class_exists(\Locale::class, false)) {
19451945
\Locale::setDefault($locale);
19461946
}
19471947
} catch (\Exception $e) {

Tests/BinaryFileResponseTest.php

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

4949
public function testSetContent()
5050
{
51-
$this->expectException('LogicException');
51+
$this->expectException(\LogicException::class);
5252
$response = new BinaryFileResponse(__FILE__);
5353
$response->setContent('foo');
5454
}

Tests/CookieTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function namesWithSpecialCharacters()
4343
*/
4444
public function testInstantiationThrowsExceptionIfRawCookieNameContainsSpecialCharacters($name)
4545
{
46-
$this->expectException('InvalidArgumentException');
46+
$this->expectException(\InvalidArgumentException::class);
4747
Cookie::create($name, null, 0, null, null, null, false, true);
4848
}
4949

@@ -57,13 +57,13 @@ public function testInstantiationSucceedNonRawCookieNameContainsSpecialCharacter
5757

5858
public function testInstantiationThrowsExceptionIfCookieNameIsEmpty()
5959
{
60-
$this->expectException('InvalidArgumentException');
60+
$this->expectException(\InvalidArgumentException::class);
6161
Cookie::create('');
6262
}
6363

6464
public function testInvalidExpiration()
6565
{
66-
$this->expectException('InvalidArgumentException');
66+
$this->expectException(\InvalidArgumentException::class);
6767
Cookie::create('MyCookie', 'foo', 'bar');
6868
}
6969

Tests/ExpressionRequestMatcherTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class ExpressionRequestMatcherTest extends TestCase
2020
{
2121
public function testWhenNoExpressionIsSet()
2222
{
23-
$this->expectException('LogicException');
23+
$this->expectException(\LogicException::class);
2424
$expressionRequestMatcher = new ExpressionRequestMatcher();
2525
$expressionRequestMatcher->matches(new Request());
2626
}

Tests/File/FileTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function testGuessExtensionIsBasedOnMimeType()
4141

4242
public function testConstructWhenFileNotExists()
4343
{
44-
$this->expectException('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException');
44+
$this->expectException(\Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException::class);
4545

4646
new File(__DIR__.'/Fixtures/not_here');
4747
}
@@ -57,7 +57,7 @@ public function testMove()
5757

5858
$file = new File($path);
5959
$movedFile = $file->move($targetDir);
60-
$this->assertInstanceOf('Symfony\Component\HttpFoundation\File\File', $movedFile);
60+
$this->assertInstanceOf(File::class, $movedFile);
6161

6262
$this->assertFileExists($targetPath);
6363
$this->assertFileDoesNotExist($path);
@@ -111,7 +111,7 @@ public function testMoveWithNonLatinName($filename, $sanitizedFilename)
111111

112112
$file = new File($path);
113113
$movedFile = $file->move($targetDir, $filename);
114-
$this->assertInstanceOf('Symfony\Component\HttpFoundation\File\File', $movedFile);
114+
$this->assertInstanceOf(File::class, $movedFile);
115115

116116
$this->assertFileExists($targetPath);
117117
$this->assertFileDoesNotExist($path);

Tests/File/MimeType/MimeTypeTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function testGuessImageWithoutExtension()
3939

4040
public function testGuessImageWithDirectory()
4141
{
42-
$this->expectException('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException');
42+
$this->expectException(\Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException::class);
4343

4444
MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/directory');
4545
}
@@ -68,7 +68,7 @@ public function testGuessWithDuplicatedFileType()
6868

6969
public function testGuessWithIncorrectPath()
7070
{
71-
$this->expectException('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException');
71+
$this->expectException(\Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException::class);
7272
MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/not_here');
7373
}
7474

@@ -87,7 +87,7 @@ public function testGuessWithNonReadablePath()
8787
@chmod($path, 0333);
8888

8989
if ('0333' == substr(sprintf('%o', fileperms($path)), -4)) {
90-
$this->expectException('Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException');
90+
$this->expectException(\Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException::class);
9191
MimeTypeGuesser::getInstance()->guess($path);
9292
} else {
9393
$this->markTestSkipped('Can not verify chmod operations, change of file permissions failed');

Tests/File/UploadedFileTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ protected function setUp(): void
3333

3434
public function testConstructWhenFileNotExists()
3535
{
36-
$this->expectException('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException');
36+
$this->expectException(\Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException::class);
3737

3838
new UploadedFile(
3939
__DIR__.'/Fixtures/not_here',
@@ -144,7 +144,7 @@ public function testGetClientOriginalExtension()
144144

145145
public function testMoveLocalFileIsNotAllowed()
146146
{
147-
$this->expectException('Symfony\Component\HttpFoundation\File\Exception\FileException');
147+
$this->expectException(FileException::class);
148148
$file = new UploadedFile(
149149
__DIR__.'/Fixtures/test.gif',
150150
'original.gif',

Tests/FileBagTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class FileBagTest extends TestCase
2525
{
2626
public function testFileMustBeAnArrayOrUploadedFile()
2727
{
28-
$this->expectException('InvalidArgumentException');
28+
$this->expectException(\InvalidArgumentException::class);
2929
new FileBag(['file' => 'foo']);
3030
}
3131

Tests/HeaderBagTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function testGetDate()
4545
{
4646
$bag = new HeaderBag(['foo' => 'Tue, 4 Sep 2012 20:00:00 +0200']);
4747
$headerDate = $bag->getDate('foo');
48-
$this->assertInstanceOf('DateTime', $headerDate);
48+
$this->assertInstanceOf(\DateTime::class, $headerDate);
4949
}
5050

5151
public function testGetDateNull()
@@ -57,7 +57,7 @@ public function testGetDateNull()
5757

5858
public function testGetDateException()
5959
{
60-
$this->expectException('RuntimeException');
60+
$this->expectException(\RuntimeException::class);
6161
$bag = new HeaderBag(['foo' => 'Tue']);
6262
$bag->getDate('foo');
6363
}

Tests/HeaderUtilsTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function testUnquote()
9999

100100
public function testMakeDispositionInvalidDisposition()
101101
{
102-
$this->expectException('InvalidArgumentException');
102+
$this->expectException(\InvalidArgumentException::class);
103103
HeaderUtils::makeDisposition('invalid', 'foo.html');
104104
}
105105

@@ -128,7 +128,7 @@ public function provideMakeDisposition()
128128
*/
129129
public function testMakeDispositionFail($disposition, $filename)
130130
{
131-
$this->expectException('InvalidArgumentException');
131+
$this->expectException(\InvalidArgumentException::class);
132132
HeaderUtils::makeDisposition($disposition, $filename);
133133
}
134134

0 commit comments

Comments
 (0)