Skip to content

Commit e49580b

Browse files
committed
Merge branch '4.4' into 5.1
* 4.4: Use ::class keyword when possible
2 parents db17469 + 22640fb commit e49580b

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
@@ -69,14 +69,14 @@ public function getTestsForParsePhpConstants()
6969

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

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

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

128128
public function testParseScalarWithNonEscapedBlackslashAtTheEndShouldThrowException()
129129
{
130-
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
130+
$this->expectException(ParseException::class);
131131
Inline::parse('"Foo\\"');
132132
}
133133

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

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

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

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

162162
public function testParseInvalidMappingShouldThrowException()
163163
{
164-
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
164+
$this->expectException(ParseException::class);
165165
Inline::parse('[foo] bar');
166166
}
167167

168168
public function testParseInvalidSequenceShouldThrowException()
169169
{
170-
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
170+
$this->expectException(ParseException::class);
171171
Inline::parse('{ foo: bar } bar');
172172
}
173173

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

@@ -219,14 +219,14 @@ public function testParseMapReferenceInSequence()
219219

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

227227
public function testParseUnquotedAsteriskFollowedByAComment()
228228
{
229-
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
229+
$this->expectException(ParseException::class);
230230
$this->expectExceptionMessage('A reference must contain at least one character at line 1.');
231231
Inline::parse('{ foo: * #foo }');
232232
}
@@ -613,7 +613,7 @@ public function getBinaryData()
613613
*/
614614
public function testParseInvalidBinaryData($data, $expectedMessage)
615615
{
616-
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
616+
$this->expectException(ParseException::class);
617617
$this->expectExceptionMessageMatches($expectedMessage);
618618

619619
Inline::parse($data);
@@ -631,7 +631,7 @@ public function getInvalidBinaryData()
631631

632632
public function testNotSupportedMissingValue()
633633
{
634-
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
634+
$this->expectException(ParseException::class);
635635
$this->expectExceptionMessage('Malformed inline YAML string: "{this, is not, supported}" at line 1.');
636636
Inline::parse('{this, is not, supported}');
637637
}
@@ -648,7 +648,7 @@ public function testVeryLongQuotedStrings()
648648

649649
public function testMappingKeysCannotBeOmitted()
650650
{
651-
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
651+
$this->expectException(ParseException::class);
652652
$this->expectExceptionMessage('Missing mapping key');
653653
Inline::parse('{: foo}');
654654
}
@@ -679,7 +679,7 @@ public function testTheEmptyStringIsAValidMappingKey()
679679
*/
680680
public function testImplicitStringCastingOfMappingKeysIsDeprecated($yaml, $expected)
681681
{
682-
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
682+
$this->expectException(ParseException::class);
683683
$this->expectExceptionMessage('Implicit casting of incompatible mapping keys to strings is not supported. Quote your evaluable mapping keys instead');
684684
$this->assertSame($expected, Inline::parse($yaml));
685685
}
@@ -732,7 +732,7 @@ public function testTagWithEmptyValueInMapping()
732732

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

0 commit comments

Comments
 (0)