Skip to content

Commit 22640fb

Browse files
committed
Use ::class keyword when possible
1 parent f1c4a3c commit 22640fb

File tree

5 files changed

+53
-53
lines changed

5 files changed

+53
-53
lines changed

Tests/Command/LintCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function testCustomTagsError()
9292

9393
public function testLintFileNotReadable()
9494
{
95-
$this->expectException('RuntimeException');
95+
$this->expectException(\RuntimeException::class);
9696
$tester = $this->createCommandTester();
9797
$filename = $this->createFile('');
9898
unlink($filename);

Tests/DumperTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public function testObjectSupportDisabledButNoExceptions()
194194

195195
public function testObjectSupportDisabledWithExceptions()
196196
{
197-
$this->expectException('Symfony\Component\Yaml\Exception\DumpException');
197+
$this->expectException(\Symfony\Component\Yaml\Exception\DumpException::class);
198198
$this->dumper->dump(['foo' => new A(), 'bar' => 1], 0, 0, Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE);
199199
}
200200

@@ -619,14 +619,14 @@ public function testDumpTrailingNewlineInMultiLineLiteralBlocks()
619619

620620
public function testZeroIndentationThrowsException()
621621
{
622-
$this->expectException('InvalidArgumentException');
622+
$this->expectException(\InvalidArgumentException::class);
623623
$this->expectExceptionMessage('The indentation must be greater than zero');
624624
new Dumper(0);
625625
}
626626

627627
public function testNegativeIndentationThrowsException()
628628
{
629-
$this->expectException('InvalidArgumentException');
629+
$this->expectException(\InvalidArgumentException::class);
630630
$this->expectExceptionMessage('The indentation must be greater than zero');
631631
new Dumper(-4);
632632
}

Tests/InlineTest.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@ public function getTestsForParsePhpConstants()
6666

6767
public function testParsePhpConstantThrowsExceptionWhenUndefined()
6868
{
69-
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
69+
$this->expectException(ParseException::class);
7070
$this->expectExceptionMessage('The constant "WRONG_CONSTANT" is not defined');
7171
Inline::parse('!php/const WRONG_CONSTANT', Yaml::PARSE_CONSTANT);
7272
}
7373

7474
public function testParsePhpConstantThrowsExceptionOnInvalidType()
7575
{
76-
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
76+
$this->expectException(ParseException::class);
7777
$this->expectExceptionMessageMatches('#The string "!php/const PHP_INT_MAX" could not be parsed as a constant.*#');
7878
Inline::parse('!php/const PHP_INT_MAX', Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE);
7979
}
@@ -117,60 +117,60 @@ public function testHashStringsResemblingExponentialNumericsShouldNotBeChangedTo
117117

118118
public function testParseScalarWithNonEscapedBlackslashShouldThrowException()
119119
{
120-
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
120+
$this->expectException(ParseException::class);
121121
$this->expectExceptionMessage('Found unknown escape character "\V".');
122122
Inline::parse('"Foo\Var"');
123123
}
124124

125125
public function testParseScalarWithNonEscapedBlackslashAtTheEndShouldThrowException()
126126
{
127-
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
127+
$this->expectException(ParseException::class);
128128
Inline::parse('"Foo\\"');
129129
}
130130

131131
public function testParseScalarWithIncorrectlyQuotedStringShouldThrowException()
132132
{
133-
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
133+
$this->expectException(ParseException::class);
134134
$value = "'don't do somthin' like that'";
135135
Inline::parse($value);
136136
}
137137

138138
public function testParseScalarWithIncorrectlyDoubleQuotedStringShouldThrowException()
139139
{
140-
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
140+
$this->expectException(ParseException::class);
141141
$value = '"don"t do somthin" like that"';
142142
Inline::parse($value);
143143
}
144144

145145
public function testParseInvalidMappingKeyShouldThrowException()
146146
{
147-
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
147+
$this->expectException(ParseException::class);
148148
$value = '{ "foo " bar": "bar" }';
149149
Inline::parse($value);
150150
}
151151

152152
public function testParseMappingKeyWithColonNotFollowedBySpace()
153153
{
154-
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
154+
$this->expectException(ParseException::class);
155155
$this->expectExceptionMessage('Colons must be followed by a space or an indication character (i.e. " ", ",", "[", "]", "{", "}")');
156156
Inline::parse('{foo:""}');
157157
}
158158

159159
public function testParseInvalidMappingShouldThrowException()
160160
{
161-
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
161+
$this->expectException(ParseException::class);
162162
Inline::parse('[foo] bar');
163163
}
164164

165165
public function testParseInvalidSequenceShouldThrowException()
166166
{
167-
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
167+
$this->expectException(ParseException::class);
168168
Inline::parse('{ foo: bar } bar');
169169
}
170170

171171
public function testParseInvalidTaggedSequenceShouldThrowException()
172172
{
173-
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
173+
$this->expectException(ParseException::class);
174174
Inline::parse('!foo { bar: baz } qux', Yaml::PARSE_CUSTOM_TAGS);
175175
}
176176

@@ -216,14 +216,14 @@ public function testParseMapReferenceInSequence()
216216

217217
public function testParseUnquotedAsterisk()
218218
{
219-
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
219+
$this->expectException(ParseException::class);
220220
$this->expectExceptionMessage('A reference must contain at least one character at line 1.');
221221
Inline::parse('{ foo: * }');
222222
}
223223

224224
public function testParseUnquotedAsteriskFollowedByAComment()
225225
{
226-
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
226+
$this->expectException(ParseException::class);
227227
$this->expectExceptionMessage('A reference must contain at least one character at line 1.');
228228
Inline::parse('{ foo: * #foo }');
229229
}
@@ -610,7 +610,7 @@ public function getBinaryData()
610610
*/
611611
public function testParseInvalidBinaryData($data, $expectedMessage)
612612
{
613-
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
613+
$this->expectException(ParseException::class);
614614
$this->expectExceptionMessageMatches($expectedMessage);
615615

616616
Inline::parse($data);
@@ -628,7 +628,7 @@ public function getInvalidBinaryData()
628628

629629
public function testNotSupportedMissingValue()
630630
{
631-
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
631+
$this->expectException(ParseException::class);
632632
$this->expectExceptionMessage('Malformed inline YAML string: "{this, is not, supported}" at line 1.');
633633
Inline::parse('{this, is not, supported}');
634634
}
@@ -645,7 +645,7 @@ public function testVeryLongQuotedStrings()
645645

646646
public function testMappingKeysCannotBeOmitted()
647647
{
648-
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
648+
$this->expectException(ParseException::class);
649649
$this->expectExceptionMessage('Missing mapping key');
650650
Inline::parse('{: foo}');
651651
}
@@ -676,7 +676,7 @@ public function testTheEmptyStringIsAValidMappingKey()
676676
*/
677677
public function testImplicitStringCastingOfMappingKeysIsDeprecated($yaml, $expected)
678678
{
679-
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
679+
$this->expectException(ParseException::class);
680680
$this->expectExceptionMessage('Implicit casting of incompatible mapping keys to strings is not supported. Quote your evaluable mapping keys instead');
681681
$this->assertSame($expected, Inline::parse($yaml));
682682
}
@@ -729,7 +729,7 @@ public function testTagWithEmptyValueInMapping()
729729

730730
public function testUnfinishedInlineMap()
731731
{
732-
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
732+
$this->expectException(ParseException::class);
733733
$this->expectExceptionMessage("Unexpected end of line, expected one of \",}\n\" at line 1 (near \"{abc: 'def'\").");
734734
Inline::parse("{abc: 'def'");
735735
}

0 commit comments

Comments
 (0)