Skip to content

Commit 30b9eb8

Browse files
committed
[BCB] Removed Broker
1 parent df278a9 commit 30b9eb8

25 files changed

+45
-288
lines changed

UPGRADING.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,14 @@ Learn more: https://phpstan.org/blog/preprocessing-ast-for-custom-rules
215215

216216
As a replacement you can implement [`PHPStan\Type\ExpressionTypeResolverExtension`](https://apiref.phpstan.org/2.0.x/PHPStan.Type.ExpressionTypeResolverExtension.html) interface instead and register it as a service.
217217

218+
### Removed `PHPStan\Broker\Broker`
219+
220+
Use [`PHPStan\Reflection\ReflectionProvider`](https://apiref.phpstan.org/2.0.x/PHPStan.Reflection.ReflectionProvider.html) instead.
221+
222+
`BrokerAwareExtension` was also removed. Ask for `ReflectionProvider` in the extension constructor instead.
223+
224+
Instead of `PHPStanTestCase::createBroker()`, call `PHPStanTestCase::createReflectionProvider()`.
225+
218226
### Minor backward compatibility breaks
219227

220228
* Classes that were previously `@final` were made `final`

conf/config.neon

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1881,15 +1881,6 @@ services:
18811881
parentDirectory: %currentWorkingDirectory%
18821882
autowired: false
18831883

1884-
broker:
1885-
class: PHPStan\Broker\Broker
1886-
factory: @brokerFactory::create
1887-
autowired:
1888-
- PHPStan\Broker\Broker
1889-
1890-
brokerFactory:
1891-
class: PHPStan\Broker\BrokerFactory
1892-
18931884
cacheStorage:
18941885
class: PHPStan\Cache\FileCacheStorage
18951886
arguments:

phpstan-baseline.neon

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,6 @@ parameters:
189189
count: 1
190190
path: src/PhpDoc/ResolvedPhpDocBlock.php
191191

192-
-
193-
message: """
194-
#^Call to deprecated method getInstance\\(\\) of class PHPStan\\\\Broker\\\\Broker\\:
195-
Use PHPStan\\\\Reflection\\\\ReflectionProviderStaticAccessor instead$#
196-
"""
197-
count: 1
198-
path: src/PhpDoc/StubValidator.php
199-
200192
-
201193
message: "#^Doing instanceof PHPStan\\\\Type\\\\ArrayType is error\\-prone and deprecated\\. Use Type\\:\\:isArray\\(\\) or Type\\:\\:getArrays\\(\\) instead\\.$#"
202194
count: 1
@@ -1161,22 +1153,6 @@ parameters:
11611153
count: 3
11621154
path: src/Type/NullType.php
11631155

1164-
-
1165-
message: """
1166-
#^Call to deprecated method getInstance\\(\\) of class PHPStan\\\\Broker\\\\Broker\\:
1167-
Use PHPStan\\\\Reflection\\\\ReflectionProviderStaticAccessor instead$#
1168-
"""
1169-
count: 2
1170-
path: src/Type/ObjectShapeType.php
1171-
1172-
-
1173-
message: """
1174-
#^Call to deprecated method getUniversalObjectCratesClasses\\(\\) of class PHPStan\\\\Broker\\\\Broker\\:
1175-
Inject %%universalObjectCratesClasses%% parameter instead\\.$#
1176-
"""
1177-
count: 2
1178-
path: src/Type/ObjectShapeType.php
1179-
11801156
-
11811157
message: "#^Doing instanceof PHPStan\\\\Type\\\\IntersectionType is error\\-prone and deprecated\\.$#"
11821158
count: 1
@@ -1192,22 +1168,6 @@ parameters:
11921168
count: 1
11931169
path: src/Type/ObjectShapeType.php
11941170

1195-
-
1196-
message: """
1197-
#^Call to deprecated method getInstance\\(\\) of class PHPStan\\\\Broker\\\\Broker\\:
1198-
Use PHPStan\\\\Reflection\\\\ReflectionProviderStaticAccessor instead$#
1199-
"""
1200-
count: 1
1201-
path: src/Type/ObjectType.php
1202-
1203-
-
1204-
message: """
1205-
#^Call to deprecated method getUniversalObjectCratesClasses\\(\\) of class PHPStan\\\\Broker\\\\Broker\\:
1206-
Inject %%universalObjectCratesClasses%% parameter instead\\.$#
1207-
"""
1208-
count: 1
1209-
path: src/Type/ObjectType.php
1210-
12111171
-
12121172
message: "#^Doing instanceof PHPStan\\\\Type\\\\Enum\\\\EnumCaseObjectType is error\\-prone and deprecated\\. Use Type\\:\\:getEnumCases\\(\\) instead\\.$#"
12131173
count: 1

src/Broker/Broker.php

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

src/Broker/BrokerFactory.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
namespace PHPStan\Broker;
44

5-
use PHPStan\DependencyInjection\Container;
6-
use PHPStan\Reflection\ReflectionProvider;
7-
85
final class BrokerFactory
96
{
107

@@ -17,16 +14,4 @@ final class BrokerFactory
1714
public const OPERATOR_TYPE_SPECIFYING_EXTENSION_TAG = 'phpstan.broker.operatorTypeSpecifyingExtension';
1815
public const EXPRESSION_TYPE_RESOLVER_EXTENSION_TAG = 'phpstan.broker.expressionTypeResolverExtension';
1916

20-
public function __construct(private Container $container)
21-
{
22-
}
23-
24-
public function create(): Broker
25-
{
26-
return new Broker(
27-
$this->container->getByType(ReflectionProvider::class),
28-
$this->container->getParameter('universalObjectCratesClasses'),
29-
);
30-
}
31-
3217
}

src/DependencyInjection/ContainerFactory.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
use PHPStan\BetterReflection\Reflector\Reflector;
2323
use PHPStan\BetterReflection\SourceLocator\SourceStubber\PhpStormStubsSourceStubber;
2424
use PHPStan\BetterReflection\SourceLocator\Type\SourceLocator;
25-
use PHPStan\Broker\Broker;
2625
use PHPStan\Command\CommandHelper;
2726
use PHPStan\File\FileHelper;
2827
use PHPStan\Node\Printer\Printer;
@@ -181,8 +180,6 @@ public static function postInitializeContainer(Container $container): void
181180
$container->getByType(Printer::class),
182181
);
183182

184-
$broker = $container->getByType(Broker::class);
185-
Broker::registerInstance($broker);
186183
ReflectionProviderStaticAccessor::registerInstance($container->getByType(ReflectionProvider::class));
187184
PhpVersionStaticAccessor::registerInstance($container->getByType(PhpVersion::class));
188185
ObjectType::resetCaches();

src/DependencyInjection/Reflection/LazyClassReflectionExtensionRegistryProvider.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace PHPStan\DependencyInjection\Reflection;
44

5-
use PHPStan\Broker\Broker;
65
use PHPStan\Broker\BrokerFactory;
76
use PHPStan\DependencyInjection\Container;
87
use PHPStan\Reflection\Annotations\AnnotationsMethodsClassReflectionExtension;
@@ -35,7 +34,6 @@ public function getRegistry(): ClassReflectionExtensionRegistry
3534
$mixinPropertiesClassReflectionExtension = $this->container->getByType(MixinPropertiesClassReflectionExtension::class);
3635

3736
$this->registry = new ClassReflectionExtensionRegistry(
38-
$this->container->getByType(Broker::class),
3937
array_merge([$phpClassReflectionExtension], $this->container->getServicesByTag(BrokerFactory::PROPERTIES_CLASS_REFLECTION_EXTENSION_TAG), [$annotationsPropertiesClassReflectionExtension, $mixinPropertiesClassReflectionExtension]),
4038
array_merge([$phpClassReflectionExtension], $this->container->getServicesByTag(BrokerFactory::METHODS_CLASS_REFLECTION_EXTENSION_TAG), [$annotationsMethodsClassReflectionExtension, $mixinMethodsClassReflectionExtension]),
4139
$this->container->getServicesByTag(BrokerFactory::ALLOWED_SUB_TYPES_CLASS_REFLECTION_EXTENSION_TAG),

src/DependencyInjection/Type/LazyDynamicReturnTypeExtensionRegistryProvider.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace PHPStan\DependencyInjection\Type;
44

5-
use PHPStan\Broker\Broker;
65
use PHPStan\Broker\BrokerFactory;
76
use PHPStan\DependencyInjection\Container;
87
use PHPStan\Reflection\ReflectionProvider;
@@ -21,7 +20,6 @@ public function getRegistry(): DynamicReturnTypeExtensionRegistry
2120
{
2221
if ($this->registry === null) {
2322
$this->registry = new DynamicReturnTypeExtensionRegistry(
24-
$this->container->getByType(Broker::class),
2523
$this->container->getByType(ReflectionProvider::class),
2624
$this->container->getServicesByTag(BrokerFactory::DYNAMIC_METHOD_RETURN_TYPE_EXTENSION_TAG),
2725
$this->container->getServicesByTag(BrokerFactory::DYNAMIC_STATIC_METHOD_RETURN_TYPE_EXTENSION_TAG),

src/DependencyInjection/Type/LazyOperatorTypeSpecifyingExtensionRegistryProvider.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace PHPStan\DependencyInjection\Type;
44

5-
use PHPStan\Broker\Broker;
65
use PHPStan\Broker\BrokerFactory;
76
use PHPStan\DependencyInjection\Container;
87
use PHPStan\Type\OperatorTypeSpecifyingExtensionRegistry;
@@ -20,7 +19,6 @@ public function getRegistry(): OperatorTypeSpecifyingExtensionRegistry
2019
{
2120
if ($this->registry === null) {
2221
$this->registry = new OperatorTypeSpecifyingExtensionRegistry(
23-
$this->container->getByType(Broker::class),
2422
$this->container->getServicesByTag(BrokerFactory::OPERATOR_TYPE_SPECIFYING_EXTENSION_TAG),
2523
);
2624
}

src/DependencyInjection/ValidateIgnoredErrorsExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function resolveTypeAlias(string $aliasName, NameScope $nameScope): ?Type
103103

104104
public function getRegistry(): OperatorTypeSpecifyingExtensionRegistry
105105
{
106-
return new OperatorTypeSpecifyingExtensionRegistry(null, []);
106+
return new OperatorTypeSpecifyingExtensionRegistry([]);
107107
}
108108

109109
}, new OversizedArrayBuilder(), true),

0 commit comments

Comments
 (0)