Skip to content

Commit 76558e5

Browse files
Use typed properties in tests as much as possible
1 parent aa9201d commit 76558e5

22 files changed

+38
-53
lines changed

Tests/Compiler/AbstractRecursivePassTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function testGetConstructorResolvesFactoryChildDefinitionsClass()
3636
->setFactory([new Reference('child'), 'createFactory']);
3737

3838
$pass = new class() extends AbstractRecursivePass {
39-
public $actual;
39+
public \ReflectionMethod $actual;
4040

4141
protected function processValue($value, $isRoot = false): mixed
4242
{
@@ -62,7 +62,7 @@ public function testGetConstructorResolvesChildDefinitionsClass()
6262
$container->setDefinition('foo', new ChildDefinition('parent'));
6363

6464
$pass = new class() extends AbstractRecursivePass {
65-
public $actual;
65+
public \ReflectionMethod $actual;
6666

6767
protected function processValue($value, $isRoot = false): mixed
6868
{
@@ -88,7 +88,7 @@ public function testGetReflectionMethodResolvesChildDefinitionsClass()
8888
$container->setDefinition('foo', new ChildDefinition('parent'));
8989

9090
$pass = new class() extends AbstractRecursivePass {
91-
public $actual;
91+
public \ReflectionMethod $actual;
9292

9393
protected function processValue($value, $isRoot = false): mixed
9494
{

Tests/Compiler/ExtensionCompilerPassTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
*/
2323
class ExtensionCompilerPassTest extends TestCase
2424
{
25-
private $container;
26-
private $pass;
25+
private ContainerBuilder $container;
26+
private ExtensionCompilerPass $pass;
2727

2828
protected function setUp(): void
2929
{

Tests/Compiler/IntegrationTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,7 @@ public function testTaggedIteratorAndLocatorWithExclude()
10891089

10901090
class ServiceSubscriberStub implements ServiceSubscriberInterface
10911091
{
1092-
public $container;
1092+
public ContainerInterface $container;
10931093

10941094
public function __construct(ContainerInterface $container)
10951095
{
@@ -1109,10 +1109,7 @@ class DecoratedServiceSubscriber
11091109

11101110
class DecoratedServiceLocator implements ServiceProviderInterface
11111111
{
1112-
/**
1113-
* @var ServiceLocator
1114-
*/
1115-
private $locator;
1112+
private ServiceLocator $locator;
11161113

11171114
public function __construct(ServiceLocator $locator)
11181115
{
@@ -1153,7 +1150,7 @@ public function setSunshine($type)
11531150

11541151
final class TagCollector implements CompilerPassInterface
11551152
{
1156-
public $collectedTags;
1153+
public array $collectedTags;
11571154

11581155
public function process(ContainerBuilder $container): void
11591156
{

Tests/Compiler/ResolveParameterPlaceHoldersPassTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\DependencyInjection\Compiler\ResolveParameterPlaceHoldersPass;
1616
use Symfony\Component\DependencyInjection\ContainerBuilder;
17+
use Symfony\Component\DependencyInjection\Definition;
1718
use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
1819

1920
class ResolveParameterPlaceHoldersPassTest extends TestCase
2021
{
21-
private $compilerPass;
22-
private $container;
23-
private $fooDefinition;
22+
private ResolveParameterPlaceHoldersPass $compilerPass;
23+
private ContainerBuilder $container;
24+
private Definition $fooDefinition;
2425

2526
protected function setUp(): void
2627
{

Tests/Compiler/ServiceLocatorTagPassTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,7 @@ public function testBindingsAreProcessed()
230230

231231
class Locator
232232
{
233-
/**
234-
* @var ServiceLocator
235-
*/
236-
public $locator;
233+
public ServiceLocator $locator;
237234

238235
public function __construct(ServiceLocator $locator)
239236
{

Tests/Compiler/ValidateEnvPlaceholdersPassTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,8 @@ public function getConfigTreeBuilder(): TreeBuilder
371371

372372
class EnvExtension extends Extension
373373
{
374-
private $configuration;
375-
private $config;
374+
private ConfigurationInterface $configuration;
375+
private array $config;
376376

377377
public function __construct(ConfigurationInterface $configuration = null)
378378
{

Tests/Config/ContainerParametersResourceCheckerTest.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,15 @@
1313

1414
use PHPUnit\Framework\MockObject\MockObject;
1515
use PHPUnit\Framework\TestCase;
16-
use Symfony\Component\Config\ResourceCheckerInterface;
1716
use Symfony\Component\DependencyInjection\Config\ContainerParametersResource;
1817
use Symfony\Component\DependencyInjection\Config\ContainerParametersResourceChecker;
1918
use Symfony\Component\DependencyInjection\ContainerInterface;
2019

2120
class ContainerParametersResourceCheckerTest extends TestCase
2221
{
23-
/** @var ContainerParametersResource */
24-
private $resource;
25-
26-
/** @var ResourceCheckerInterface */
27-
private $resourceChecker;
28-
29-
/** @var ContainerInterface */
30-
private $container;
22+
private ContainerParametersResource $resource;
23+
private ContainerParametersResourceChecker $resourceChecker;
24+
private MockObject&ContainerInterface $container;
3125

3226
protected function setUp(): void
3327
{

Tests/Config/ContainerParametersResourceTest.php

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

1717
class ContainerParametersResourceTest extends TestCase
1818
{
19-
/** @var ContainerParametersResource */
20-
private $resource;
19+
private ContainerParametersResource $resource;
2120

2221
protected function setUp(): void
2322
{

Tests/ContainerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ public function testReset()
315315
{
316316
$c = new Container();
317317
$c->set('bar', $bar = new class() implements ResetInterface {
318-
public $resetCounter = 0;
318+
public int $resetCounter = 0;
319319

320320
public function reset(): void
321321
{

Tests/CrossCheckTest.php

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

1818
class CrossCheckTest extends TestCase
1919
{
20-
protected static $fixturesPath;
20+
protected static string $fixturesPath;
2121

2222
public static function setUpBeforeClass(): void
2323
{

0 commit comments

Comments
 (0)