Skip to content

Commit e6ccc08

Browse files
Use typed properties in tests as much as possible
1 parent 87bcb72 commit e6ccc08

File tree

4 files changed

+10
-15
lines changed

4 files changed

+10
-15
lines changed

Tests/Iterator/Iterator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
class Iterator implements \Iterator
1515
{
16-
protected $values = [];
16+
protected array $values = [];
1717

1818
public function __construct(array $values = [])
1919
{

Tests/Iterator/MockSplFileInfo.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ class MockSplFileInfo extends \SplFileInfo
1717
public const TYPE_FILE = 2;
1818
public const TYPE_UNKNOWN = 3;
1919

20-
private $contents;
21-
private $mode;
22-
private $type;
23-
private $relativePath;
24-
private $relativePathname;
20+
private ?string $contents = null;
21+
private ?string $mode = null;
22+
private ?int $type = null;
23+
private ?string $relativePath = null;
24+
private ?string $relativePathname = null;
2525

2626
public function __construct($param)
2727
{

Tests/Iterator/RealIteratorTestCase.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
abstract class RealIteratorTestCase extends IteratorTestCase
1818
{
19-
protected static $tmpDir;
20-
protected static $files;
19+
protected static string $tmpDir;
20+
protected static array $files;
2121

2222
public static function setUpBeforeClass(): void
2323
{
@@ -126,9 +126,7 @@ protected static function toAbsolute($files = null)
126126
/*
127127
* Without the call to setUpBeforeClass() property can be null.
128128
*/
129-
if (!self::$tmpDir) {
130-
self::$tmpDir = realpath(sys_get_temp_dir()).\DIRECTORY_SEPARATOR.'symfony_finder';
131-
}
129+
self::$tmpDir ??= realpath(sys_get_temp_dir()).\DIRECTORY_SEPARATOR.'symfony_finder';
132130

133131
if (\is_array($files)) {
134132
$f = [];

Tests/Iterator/VcsIgnoredFilterIteratorTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@
1616

1717
class VcsIgnoredFilterIteratorTest extends IteratorTestCase
1818
{
19-
/**
20-
* @var string
21-
*/
22-
private $tmpDir;
19+
private string $tmpDir;
2320

2421
protected function setUp(): void
2522
{

0 commit comments

Comments
 (0)