Skip to content

Commit c53d8be

Browse files
Merge branch '6.4' into 7.0
* 6.4: Use typed properties in tests as much as possible
2 parents 254ac76 + 886ac3d commit c53d8be

18 files changed

+35
-53
lines changed

Tester/TesterTrait.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public function setInputs(array $inputs): static
130130
*/
131131
private function initOutput(array $options): void
132132
{
133-
$this->captureStreamsIndependently = \array_key_exists('capture_stderr_separately', $options) && $options['capture_stderr_separately'];
133+
$this->captureStreamsIndependently = $options['capture_stderr_separately'] ?? false;
134134
if (!$this->captureStreamsIndependently) {
135135
$this->output = new StreamOutput(fopen('php://memory', 'w', false));
136136
if (isset($options['decorated'])) {

Tests/ApplicationTest.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@
5252

5353
class ApplicationTest extends TestCase
5454
{
55-
protected static $fixturesPath;
55+
protected static string $fixturesPath;
5656

57-
private $colSize;
57+
private string|false $colSize;
5858

5959
protected function setUp(): void
6060
{
@@ -2267,12 +2267,12 @@ public function isEnabled(): bool
22672267
#[AsCommand(name: 'signal')]
22682268
class BaseSignableCommand extends Command
22692269
{
2270-
public $signaled = false;
2271-
public $exitCode = 1;
2272-
public $signalHandlers = [];
2273-
public $loop = 1000;
2274-
private $emitsSignal;
2275-
private $signal;
2270+
public bool $signaled = false;
2271+
public int $exitCode = 1;
2272+
public array $signalHandlers = [];
2273+
public int $loop = 1000;
2274+
private bool $emitsSignal;
2275+
private int $signal;
22762276

22772277
public function __construct(bool $emitsSignal = true, int $signal = \SIGUSR1)
22782278
{
@@ -2383,7 +2383,7 @@ public static function getSubscribedEvents(): array
23832383

23842384
class SignalEventSubscriber implements EventSubscriberInterface
23852385
{
2386-
public $signaled = false;
2386+
public bool $signaled = false;
23872387

23882388
public function onSignal(ConsoleSignalEvent $event): void
23892389
{

Tests/Command/CommandTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
class CommandTest extends TestCase
3030
{
31-
protected static $fixturesPath;
31+
protected static string $fixturesPath;
3232

3333
public static function setUpBeforeClass(): void
3434
{

Tests/Command/CompleteCommandTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424

2525
class CompleteCommandTest extends TestCase
2626
{
27-
private $command;
28-
private $application;
29-
private $tester;
27+
private CompleteCommand $command;
28+
private Application $application;
29+
private CommandTester $tester;
3030

3131
protected function setUp(): void
3232
{

Tests/Command/LockableTraitTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
class LockableTraitTest extends TestCase
2121
{
22-
protected static $fixturesPath;
22+
protected static string $fixturesPath;
2323

2424
public static function setUpBeforeClass(): void
2525
{

Tests/ConsoleEventsTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function testEventAliases()
7373

7474
class EventTraceSubscriber implements EventSubscriberInterface
7575
{
76-
public $observedEvents = [];
76+
public array $observedEvents = [];
7777

7878
public static function getSubscribedEvents(): array
7979
{

Tests/DependencyInjection/AddConsoleCommandPassTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ class EscapedDefaultsFromPhpCommand extends Command
322322
#[AsCommand(name: '|cmdname|cmdalias', description: 'Just testing')]
323323
class DescribedCommand extends Command
324324
{
325-
public static $initCounter = 0;
325+
public static int $initCounter = 0;
326326

327327
public function __construct()
328328
{

Tests/Helper/ProgressBarTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*/
2424
class ProgressBarTest extends TestCase
2525
{
26-
private $colSize;
26+
private string|false $colSize;
2727

2828
protected function setUp(): void
2929
{

Tests/Helper/QuestionHelperTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,7 @@ protected function createInputInterfaceMock($interactive = true)
952952

953953
class AutocompleteValues implements \IteratorAggregate
954954
{
955-
private $values;
955+
private array $values;
956956

957957
public function __construct(array $values)
958958
{

Tests/Input/InputDefinitionTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
class InputDefinitionTest extends TestCase
2020
{
21-
protected static $fixtures;
21+
protected static string $fixtures;
2222

2323
protected $multi;
2424
protected $foo;

Tests/Logger/ConsoleLoggerTest.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@
2626
*/
2727
class ConsoleLoggerTest extends TestCase
2828
{
29-
/**
30-
* @var DummyOutput
31-
*/
32-
protected $output;
29+
protected DummyOutput $output;
3330

3431
public function getLogger(): LoggerInterface
3532
{

Tests/Output/OutputTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public static function verbosityProvider()
175175

176176
class TestOutput extends Output
177177
{
178-
public $output = '';
178+
public string $output = '';
179179

180180
public function clear()
181181
{

Tests/Question/ChoiceQuestionTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public function testSelectWithNonStringChoices()
152152

153153
class StringChoice
154154
{
155-
private $string;
155+
private string $string;
156156

157157
public function __construct(string $string)
158158
{

Tests/Question/QuestionTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
class QuestionTest extends TestCase
1818
{
19-
private $question;
19+
private Question $question;
2020

2121
protected function setUp(): void
2222
{

Tests/Style/SymfonyStyleTest.php

+4-7
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,13 @@
2525
use Symfony\Component\Console\Output\StreamOutput;
2626
use Symfony\Component\Console\Style\SymfonyStyle;
2727
use Symfony\Component\Console\Tester\CommandTester;
28+
use Symfony\Component\Console\Tests\Command\CommandTest;
2829

2930
class SymfonyStyleTest extends TestCase
3031
{
31-
/** @var Command */
32-
protected $command;
33-
/** @var CommandTester */
34-
protected $tester;
35-
private $colSize;
32+
protected Command $command;
33+
protected CommandTester $tester;
34+
private string|false $colSize;
3635

3736
protected function setUp(): void
3837
{
@@ -45,8 +44,6 @@ protected function setUp(): void
4544
protected function tearDown(): void
4645
{
4746
putenv($this->colSize ? 'COLUMNS='.$this->colSize : 'COLUMNS');
48-
$this->command = null;
49-
$this->tester = null;
5047
}
5148

5249
/**

Tests/TerminalTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818
class TerminalTest extends TestCase
1919
{
20-
private $colSize;
21-
private $lineSize;
22-
private $ansiCon;
20+
private string|false $colSize;
21+
private string|false $lineSize;
22+
private string|false $ansiCon;
2323

2424
protected function setUp(): void
2525
{

Tests/Tester/ApplicationTesterTest.php

+2-8
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020

2121
class ApplicationTesterTest extends TestCase
2222
{
23-
protected $application;
24-
protected $tester;
23+
protected Application $application;
24+
protected ApplicationTester $tester;
2525

2626
protected function setUp(): void
2727
{
@@ -38,12 +38,6 @@ protected function setUp(): void
3838
$this->tester->run(['command' => 'foo', 'foo' => 'bar'], ['interactive' => false, 'decorated' => false, 'verbosity' => Output::VERBOSITY_VERBOSE]);
3939
}
4040

41-
protected function tearDown(): void
42-
{
43-
$this->application = null;
44-
$this->tester = null;
45-
}
46-
4741
public function testRun()
4842
{
4943
$this->assertFalse($this->tester->getInput()->isInteractive(), '->execute() takes an interactive option');

Tests/Tester/CommandTesterTest.php

+2-8
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424

2525
class CommandTesterTest extends TestCase
2626
{
27-
protected $command;
28-
protected $tester;
27+
protected Command $command;
28+
protected CommandTester $tester;
2929

3030
protected function setUp(): void
3131
{
@@ -38,12 +38,6 @@ protected function setUp(): void
3838
$this->tester->execute(['foo' => 'bar'], ['interactive' => false, 'decorated' => false, 'verbosity' => Output::VERBOSITY_VERBOSE]);
3939
}
4040

41-
protected function tearDown(): void
42-
{
43-
$this->command = null;
44-
$this->tester = null;
45-
}
46-
4741
public function testExecute()
4842
{
4943
$this->assertFalse($this->tester->getInput()->isInteractive(), '->execute() takes an interactive option');

0 commit comments

Comments
 (0)