Skip to content

Commit 7c54862

Browse files
committed
Use ::class keyword when possible
1 parent 0a748fe commit 7c54862

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

Tests/ApplicationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ public function testSetCatchExceptions()
777777
$tester->run(['command' => 'foo'], ['decorated' => false]);
778778
$this->fail('->setCatchExceptions() sets the catch exception flag');
779779
} catch (\Exception $e) {
780-
$this->assertInstanceOf('\Exception', $e, '->setCatchExceptions() sets the catch exception flag');
780+
$this->assertInstanceOf(\Exception::class, $e, '->setCatchExceptions() sets the catch exception flag');
781781
$this->assertEquals('Command "foo" is not defined.', $e->getMessage(), '->setCatchExceptions() sets the catch exception flag');
782782
}
783783
}

Tests/Formatter/OutputFormatterStyleTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,15 @@ public function testOptions()
8585
$style->setOption('foo');
8686
$this->fail('->setOption() throws an \InvalidArgumentException when the option does not exist in the available options');
8787
} catch (\Exception $e) {
88-
$this->assertInstanceOf('\InvalidArgumentException', $e, '->setOption() throws an \InvalidArgumentException when the option does not exist in the available options');
88+
$this->assertInstanceOf(\InvalidArgumentException::class, $e, '->setOption() throws an \InvalidArgumentException when the option does not exist in the available options');
8989
$this->assertStringContainsString('Invalid option specified: "foo"', $e->getMessage(), '->setOption() throws an \InvalidArgumentException when the option does not exist in the available options');
9090
}
9191

9292
try {
9393
$style->unsetOption('foo');
9494
$this->fail('->unsetOption() throws an \InvalidArgumentException when the option does not exist in the available options');
9595
} catch (\Exception $e) {
96-
$this->assertInstanceOf('\InvalidArgumentException', $e, '->unsetOption() throws an \InvalidArgumentException when the option does not exist in the available options');
96+
$this->assertInstanceOf(\InvalidArgumentException::class, $e, '->unsetOption() throws an \InvalidArgumentException when the option does not exist in the available options');
9797
$this->assertStringContainsString('Invalid option specified: "foo"', $e->getMessage(), '->unsetOption() throws an \InvalidArgumentException when the option does not exist in the available options');
9898
}
9999
}

Tests/Helper/HelperSetTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Console\Command\Command;
16+
use Symfony\Component\Console\Helper\HelperInterface;
1617
use Symfony\Component\Console\Helper\HelperSet;
1718

1819
class HelperSetTest extends TestCase
@@ -66,7 +67,7 @@ public function testGet()
6667
$helperset->get('foo');
6768
$this->fail('->get() throws InvalidArgumentException when helper not found');
6869
} catch (\Exception $e) {
69-
$this->assertInstanceOf('\InvalidArgumentException', $e, '->get() throws InvalidArgumentException when helper not found');
70+
$this->assertInstanceOf(\InvalidArgumentException::class, $e, '->get() throws InvalidArgumentException when helper not found');
7071
$this->assertInstanceOf('Symfony\Component\Console\Exception\ExceptionInterface', $e, '->get() throws domain specific exception when helper not found');
7172
$this->assertStringContainsString('The helper "foo" is not defined.', $e->getMessage(), '->get() throws InvalidArgumentException when helper not found');
7273
}
@@ -111,7 +112,7 @@ public function testIteration()
111112

112113
private function getGenericMockHelper($name, HelperSet $helperset = null)
113114
{
114-
$mock_helper = $this->getMockBuilder('\Symfony\Component\Console\Helper\HelperInterface')->getMock();
115+
$mock_helper = $this->getMockBuilder(HelperInterface::class)->getMock();
115116
$mock_helper->expects($this->any())
116117
->method('getName')
117118
->willReturn($name);

Tests/Helper/QuestionHelperTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Symfony\Component\Console\Helper\FormatterHelper;
1818
use Symfony\Component\Console\Helper\HelperSet;
1919
use Symfony\Component\Console\Helper\QuestionHelper;
20+
use Symfony\Component\Console\Output\OutputInterface;
2021
use Symfony\Component\Console\Output\StreamOutput;
2122
use Symfony\Component\Console\Question\ChoiceQuestion;
2223
use Symfony\Component\Console\Question\ConfirmationQuestion;
@@ -684,7 +685,7 @@ public function testChoiceOutputFormattingQuestionForUtf8Keys()
684685
' [<info>żółw </info>] bar',
685686
' [<info>łabądź</info>] baz',
686687
];
687-
$output = $this->getMockBuilder('\Symfony\Component\Console\Output\OutputInterface')->getMock();
688+
$output = $this->getMockBuilder(OutputInterface::class)->getMock();
688689
$output->method('getFormatter')->willReturn(new OutputFormatter());
689690

690691
$dialog = new QuestionHelper();

0 commit comments

Comments
 (0)