Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7417f3a

Browse files
Configuration class no longer needed, pass arguments directly to services
1 parent c08cd8e commit 7417f3a

15 files changed

+34
-73
lines changed

‎extension.neon

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,24 +101,27 @@ parametersSchema:
101101
])
102102

103103
services:
104-
-
105-
factory: PHPStan\Symfony\Configuration(%symfony%)
106-
107104
# console resolver
108105
-
109106
factory: PHPStan\Symfony\ConsoleApplicationResolver
107+
arguments:
108+
consoleApplicationLoader: %symfony.consoleApplicationLoader%
110109

111110
# service map
112111
symfony.serviceMapFactory:
113112
class: PHPStan\Symfony\ServiceMapFactory
114113
factory: PHPStan\Symfony\XmlServiceMapFactory
114+
arguments:
115+
containerXmlPath: %symfony.containerXmlPath%
115116
-
116117
factory: @symfony.serviceMapFactory::create()
117118

118119
# parameter map
119120
symfony.parameterMapFactory:
120121
class: PHPStan\Symfony\ParameterMapFactory
121122
factory: PHPStan\Symfony\XmlParameterMapFactory
123+
arguments:
124+
containerXmlPath: %symfony.containerXmlPath%
122125
-
123126
factory: @symfony.parameterMapFactory::create()
124127

@@ -131,16 +134,16 @@ services:
131134

132135
# ControllerTrait::get()/has() return type
133136
-
134-
factory: PHPStan\Type\Symfony\ServiceDynamicReturnTypeExtension(Symfony\Component\DependencyInjection\ContainerInterface)
137+
factory: PHPStan\Type\Symfony\ServiceDynamicReturnTypeExtension(Symfony\Component\DependencyInjection\ContainerInterface, %symfony.constantHassers%)
135138
tags: [phpstan.broker.dynamicMethodReturnTypeExtension]
136139
-
137-
factory: PHPStan\Type\Symfony\ServiceDynamicReturnTypeExtension(Psr\Container\ContainerInterface)
140+
factory: PHPStan\Type\Symfony\ServiceDynamicReturnTypeExtension(Psr\Container\ContainerInterface, %symfony.constantHassers%)
138141
tags: [phpstan.broker.dynamicMethodReturnTypeExtension]
139142
-
140-
factory: PHPStan\Type\Symfony\ServiceDynamicReturnTypeExtension(Symfony\Bundle\FrameworkBundle\Controller\Controller)
143+
factory: PHPStan\Type\Symfony\ServiceDynamicReturnTypeExtension(Symfony\Bundle\FrameworkBundle\Controller\Controller, %symfony.constantHassers%)
141144
tags: [phpstan.broker.dynamicMethodReturnTypeExtension]
142145
-
143-
factory: PHPStan\Type\Symfony\ServiceDynamicReturnTypeExtension(Symfony\Bundle\FrameworkBundle\Controller\AbstractController)
146+
factory: PHPStan\Type\Symfony\ServiceDynamicReturnTypeExtension(Symfony\Bundle\FrameworkBundle\Controller\AbstractController, %symfony.constantHassers%)
144147
tags: [phpstan.broker.dynamicMethodReturnTypeExtension]
145148

146149
# ControllerTrait::has() type specification
@@ -296,20 +299,20 @@ services:
296299

297300
# ParameterBagInterface::get()/has() return type
298301
-
299-
factory: PHPStan\Type\Symfony\ParameterDynamicReturnTypeExtension(Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface, 'get', 'has')
302+
factory: PHPStan\Type\Symfony\ParameterDynamicReturnTypeExtension(Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface, 'get', 'has', %symfony.constantHassers%)
300303
tags: [phpstan.broker.dynamicMethodReturnTypeExtension]
301304

302305
# ContainerInterface::getParameter()/hasParameter() return type
303306
-
304-
factory: PHPStan\Type\Symfony\ParameterDynamicReturnTypeExtension(Symfony\Component\DependencyInjection\ContainerInterface, 'getParameter', 'hasParameter')
307+
factory: PHPStan\Type\Symfony\ParameterDynamicReturnTypeExtension(Symfony\Component\DependencyInjection\ContainerInterface, 'getParameter', 'hasParameter', %symfony.constantHassers%)
305308
tags: [phpstan.broker.dynamicMethodReturnTypeExtension]
306309

307310
# (Abstract)Controller::getParameter() return type
308311
-
309-
factory: PHPStan\Type\Symfony\ParameterDynamicReturnTypeExtension(Symfony\Bundle\FrameworkBundle\Controller\AbstractController, 'getParameter', null)
312+
factory: PHPStan\Type\Symfony\ParameterDynamicReturnTypeExtension(Symfony\Bundle\FrameworkBundle\Controller\AbstractController, 'getParameter', null, %symfony.constantHassers%)
310313
tags: [phpstan.broker.dynamicMethodReturnTypeExtension]
311314
-
312-
factory: PHPStan\Type\Symfony\ParameterDynamicReturnTypeExtension(Symfony\Bundle\FrameworkBundle\Controller\Controller, 'getParameter', null)
315+
factory: PHPStan\Type\Symfony\ParameterDynamicReturnTypeExtension(Symfony\Bundle\FrameworkBundle\Controller\Controller, 'getParameter', null, %symfony.constantHassers%)
313316
tags: [phpstan.broker.dynamicMethodReturnTypeExtension]
314317
-
315318
class: PHPStan\Symfony\InputBagStubFilesExtension

‎src/Symfony/Configuration.php

Lines changed: 0 additions & 34 deletions
This file was deleted.

‎src/Symfony/ConsoleApplicationResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ final class ConsoleApplicationResolver
2020

2121
private ?Application $consoleApplication = null;
2222

23-
public function __construct(Configuration$configuration)
23+
public function __construct(?string$consoleApplicationLoader)
2424
{
25-
$this->consoleApplicationLoader = $configuration->getConsoleApplicationLoader();
25+
$this->consoleApplicationLoader = $consoleApplicationLoader;
2626
}
2727

2828
public function hasConsoleApplicationLoader(): bool

‎src/Symfony/XmlParameterMapFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ final class XmlParameterMapFactory implements ParameterMapFactory
1717

1818
private ?string $containerXml = null;
1919

20-
public function __construct(Configuration$configuration)
20+
public function __construct(?string$containerXmlPath)
2121
{
22-
$this->containerXml = $configuration->getContainerXmlPath();
22+
$this->containerXml = $containerXmlPath;
2323
}
2424

2525
public function create(): ParameterMap

‎src/Symfony/XmlServiceMapFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ final class XmlServiceMapFactory implements ServiceMapFactory
1414

1515
private ?string $containerXml = null;
1616

17-
public function __construct(Configuration$configuration)
17+
public function __construct(?string$containerXmlPath)
1818
{
19-
$this->containerXml = $configuration->getContainerXmlPath();
19+
$this->containerXml = $containerXmlPath;
2020
}
2121

2222
public function create(): ServiceMap

‎src/Type/Symfony/ParameterDynamicReturnTypeExtension.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use PHPStan\PhpDoc\TypeStringResolver;
88
use PHPStan\Reflection\MethodReflection;
99
use PHPStan\ShouldNotHappenException;
10-
use PHPStan\Symfony\Configuration;
1110
use PHPStan\Symfony\ParameterMap;
1211
use PHPStan\Type\ArrayType;
1312
use PHPStan\Type\BooleanType;
@@ -62,15 +61,15 @@ public function __construct(
6261
string $className,
6362
?string $methodGet,
6463
?string $methodHas,
65-
Configuration$configuration,
64+
bool$constantHassers,
6665
ParameterMap $symfonyParameterMap,
6766
TypeStringResolver $typeStringResolver
6867
)
6968
{
7069
$this->className = $className;
7170
$this->methodGet = $methodGet;
7271
$this->methodHas = $methodHas;
73-
$this->constantHassers = $configuration->hasConstantHassers();
72+
$this->constantHassers = $constantHassers;
7473
$this->parameterMap = $symfonyParameterMap;
7574
$this->typeStringResolver = $typeStringResolver;
7675
}

‎src/Type/Symfony/ServiceDynamicReturnTypeExtension.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use PHPStan\Analyser\Scope;
77
use PHPStan\Reflection\MethodReflection;
88
use PHPStan\ShouldNotHappenException;
9-
use PHPStan\Symfony\Configuration;
109
use PHPStan\Symfony\ParameterMap;
1110
use PHPStan\Symfony\ServiceDefinition;
1211
use PHPStan\Symfony\ServiceMap;
@@ -38,13 +37,13 @@ final class ServiceDynamicReturnTypeExtension implements DynamicMethodReturnType
3837
*/
3938
public function __construct(
4039
string $className,
41-
Configuration$configuration,
40+
bool$constantHassers,
4241
ServiceMap $symfonyServiceMap,
4342
ParameterMap $symfonyParameterMap
4443
)
4544
{
4645
$this->className = $className;
47-
$this->constantHassers = $configuration->hasConstantHassers();
46+
$this->constantHassers = $constantHassers;
4847
$this->serviceMap = $symfonyServiceMap;
4948
$this->parameterMap = $symfonyParameterMap;
5049
}

‎tests/Rules/Symfony/ContainerInterfacePrivateServiceRuleFakeTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace PHPStan\Rules\Symfony;
44

55
use PHPStan\Rules\Rule;
6-
use PHPStan\Symfony\Configuration;
76
use PHPStan\Symfony\XmlServiceMapFactory;
87
use PHPStan\Testing\RuleTestCase;
98
use function class_exists;
@@ -17,7 +16,7 @@ final class ContainerInterfacePrivateServiceRuleFakeTest extends RuleTestCase
1716

1817
protected function getRule(): Rule
1918
{
20-
return new ContainerInterfacePrivateServiceRule((new XmlServiceMapFactory(newConfiguration([])))->create());
19+
return new ContainerInterfacePrivateServiceRule((new XmlServiceMapFactory(null))->create());
2120
}
2221

2322
public function testGetPrivateService(): void

‎tests/Rules/Symfony/ContainerInterfacePrivateServiceRuleTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace PHPStan\Rules\Symfony;
44

55
use PHPStan\Rules\Rule;
6-
use PHPStan\Symfony\Configuration;
76
use PHPStan\Symfony\XmlServiceMapFactory;
87
use PHPStan\Testing\RuleTestCase;
98
use function class_exists;
@@ -17,7 +16,7 @@ final class ContainerInterfacePrivateServiceRuleTest extends RuleTestCase
1716

1817
protected function getRule(): Rule
1918
{
20-
return new ContainerInterfacePrivateServiceRule((new XmlServiceMapFactory(newConfiguration(['containerXmlPath' => __DIR__ . '/container.xml'])))->create());
19+
return new ContainerInterfacePrivateServiceRule((new XmlServiceMapFactory(__DIR__ . '/container.xml'))->create());
2120
}
2221

2322
public function testGetPrivateService(): void

‎tests/Rules/Symfony/ContainerInterfaceUnknownServiceRuleFakeTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use PHPStan\Node\Printer\Printer;
66
use PHPStan\Rules\Rule;
7-
use PHPStan\Symfony\Configuration;
87
use PHPStan\Symfony\XmlServiceMapFactory;
98
use PHPStan\Testing\RuleTestCase;
109
use PHPStan\Type\MethodTypeSpecifyingExtension;
@@ -20,7 +19,7 @@ final class ContainerInterfaceUnknownServiceRuleFakeTest extends RuleTestCase
2019

2120
protected function getRule(): Rule
2221
{
23-
return new ContainerInterfaceUnknownServiceRule((new XmlServiceMapFactory(newConfiguration([])))->create(), self::getContainer()->getByType(Printer::class));
22+
return new ContainerInterfaceUnknownServiceRule((new XmlServiceMapFactory(null))->create(), self::getContainer()->getByType(Printer::class));
2423
}
2524

2625
/**

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /