Skip to content

Commit 6add490

Browse files
committed
Add DefinitionConfigurator stub for rootNode ArrayNodeDefinition return type
1 parent 51183fe commit 6add490

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

extension.neon

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ parameters:
3232
- stubs/Symfony/Bundle/FrameworkBundle/Test/TestContainer.stub
3333
- stubs/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AuthenticatorFactoryInterface.stub
3434
- stubs/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/FirewallListenerFactoryInterface.stub
35+
- stubs/Symfony/Component/Config/Definition/Configurator/DefinitionConfigurator.stub
3536
- stubs/Symfony/Component/Console/Command.stub
3637
- stubs/Symfony/Component/Console/Exception/ExceptionInterface.stub
3738
- stubs/Symfony/Component/Console/Exception/InvalidArgumentException.stub
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Symfony\Component\Config\Definition\Configurator;
4+
5+
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
6+
7+
class DefinitionConfigurator
8+
{
9+
public function rootNode(): ArrayNodeDefinition;
10+
}

tests/Type/Symfony/ExtensionTest.php

+6
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ public function dataFileAsserts(): iterable
6767
yield from $this->gatherAssertTypes(__DIR__ . '/data/extension/with-configuration-with-constructor/WithConfigurationWithConstructorExtension.php');
6868
yield from $this->gatherAssertTypes(__DIR__ . '/data/extension/with-configuration-with-constructor-optional-params/WithConfigurationWithConstructorOptionalParamsExtension.php');
6969
yield from $this->gatherAssertTypes(__DIR__ . '/data/extension/with-configuration-with-constructor-required-params/WithConfigurationWithConstructorRequiredParamsExtension.php');
70+
71+
if (!class_exists('Symfony\Component\Config\Definition\Configurator\DefinitionConfigurator')) {
72+
return;
73+
}
74+
75+
yield from $this->gatherAssertTypes(__DIR__ . '/data/definition_configurator.php');
7076
}
7177

7278
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php declare(strict_types = 1);
2+
3+
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
4+
use Symfony\Component\Config\Definition\Configurator\DefinitionConfigurator;
5+
use Symfony\Component\Config\Definition\Loader\DefinitionFileLoader;
6+
use function PHPStan\Testing\assertType;
7+
8+
$treeBuilder = new TreeBuilder('my_tree');
9+
$loader = new DefinitionFileLoader($treeBuilder, new \Symfony\Component\Config\FileLocator());
10+
11+
$configurator = new DefinitionConfigurator(
12+
$treeBuilder,
13+
$loader,
14+
'',
15+
''
16+
);
17+
18+
$rootNode = $configurator->rootNode();
19+
assertType('Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition', $rootNode);

0 commit comments

Comments
 (0)