Skip to content

Commit d453064

Browse files
committed
[BCB] Removed config option scopeClass
1 parent cad69ee commit d453064

9 files changed

+18
-51
lines changed

UPGRADING.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ parameters:
8383

8484
Appending `(?)` in `ignoreErrors` is not supported.
8585

86+
### Minor backward compatibility breaks
87+
88+
* Removed unused config parameter `cache.nodesByFileCountMax`
89+
* Removed unused config parameter `memoryLimitFile`
90+
91+
8692
## Upgrading guide for extension developers
8793

8894
### PHPStan now uses nikic/php-parser v5
@@ -142,10 +148,12 @@ If you want to change `$overwrite` or `$rootExpr` (previous parameters also used
142148

143149
This method now longer accepts `Expr $rootExpr`. If you want to change it, call `setRootExpr()` on [`SpecifiedTypes`](https://apiref.phpstan.org/2.0.x/PHPStan.Analyser.SpecifiedTypes.html) (object returned by `TypeSpecifier::specifyTypesInCondition()`). `setRootExpr()` method returns a new object (SpecifiedTypes is immutable).
144150

151+
### Removed config parameter `scopeClass`
152+
153+
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.
154+
145155
### Minor backward compatibility breaks
146156

147157
* Parameter `$callableParameters` of [`MutatingScope::enterAnonymousFunction()`](https://apiref.phpstan.org/2.0.x/PHPStan.Analyser.MutatingScope.html#_enterAnonymousFunction) and [`enterArrowFunction()`](https://apiref.phpstan.org/2.0.x/PHPStan.Analyser.MutatingScope.html#_enterArrowFunction) made required
148158
* Parameter `StatementContext $context` of [`NodeScopeResolver::processStmtNodes()`](https://apiref.phpstan.org/2.0.x/PHPStan.Analyser.NodeScopeResolver.html#_processStmtNodes) made required
149159
* ClassPropertiesNode - remove `$extensions` parameter from [`getUninitializedProperties()`](https://apiref.phpstan.org/2.0.x/PHPStan.Node.ClassPropertiesNode.html#_getUninitializedProperties)
150-
* Removed unused config parameter `cache.nodesByFileCountMax`
151-
* Removed unused config parameter `memoryLimitFile`

conf/config.neon

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ parameters:
150150
cache:
151151
nodesByStringCountMax: 256
152152
reportUnmatchedIgnoredErrors: true
153-
scopeClass: PHPStan\Analyser\MutatingScope
154153
typeAliases: []
155154
universalObjectCratesClasses:
156155
- stdClass
@@ -496,8 +495,6 @@ services:
496495

497496
-
498497
class: PHPStan\Analyser\LazyInternalScopeFactory
499-
arguments:
500-
scopeClass: %scopeClass%
501498
autowired:
502499
- PHPStan\Analyser\InternalScopeFactory
503500

conf/parametersSchema.neon

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ parametersSchema:
179179
nodesByStringCountMax: int()
180180
])
181181
reportUnmatchedIgnoredErrors: bool()
182-
scopeClass: string()
183182
typeAliases: arrayOf(string())
184183
universalObjectCratesClasses: listOf(string())
185184
stubFiles: listOf(string())

phpstan-baseline.neon

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,11 @@ parameters:
55
count: 1
66
path: src/Analyser/AnalyserResultFinalizer.php
77

8-
-
9-
message: "#^Function is_a\\(\\) is a runtime reflection concept that might not work in PHPStan because it uses fully static reflection engine\\. Use objects retrieved from ReflectionProvider instead\\.$#"
10-
count: 1
11-
path: src/Analyser/DirectInternalScopeFactory.php
12-
138
-
149
message: "#^Cannot assign offset 'realCount' to array\\|string\\.$#"
1510
count: 1
1611
path: src/Analyser/Ignore/IgnoredErrorHelperResult.php
1712

18-
-
19-
message: "#^Function is_a\\(\\) is a runtime reflection concept that might not work in PHPStan because it uses fully static reflection engine\\. Use objects retrieved from ReflectionProvider instead\\.$#"
20-
count: 1
21-
path: src/Analyser/LazyInternalScopeFactory.php
22-
2313
-
2414
message: """
2515
#^Call to deprecated method getAnyArrays\\(\\) of class PHPStan\\\\Type\\\\TypeUtils\\:

src/Analyser/DirectInternalScopeFactory.php

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,19 @@
77
use PHPStan\Node\Printer\ExprPrinter;
88
use PHPStan\Parser\Parser;
99
use PHPStan\Php\PhpVersion;
10+
use PHPStan\Reflection\ExtendedMethodReflection;
1011
use PHPStan\Reflection\FunctionReflection;
1112
use PHPStan\Reflection\InitializerExprTypeResolver;
1213
use PHPStan\Reflection\MethodReflection;
1314
use PHPStan\Reflection\ParameterReflection;
1415
use PHPStan\Reflection\ParametersAcceptor;
1516
use PHPStan\Reflection\ReflectionProvider;
1617
use PHPStan\Rules\Properties\PropertyReflectionFinder;
17-
use PHPStan\ShouldNotHappenException;
18-
use function is_a;
1918

2019
final class DirectInternalScopeFactory implements InternalScopeFactory
2120
{
2221

23-
/**
24-
* @param class-string $scopeClass
25-
*/
2622
public function __construct(
27-
private string $scopeClass,
2823
private ReflectionProvider $reflectionProvider,
2924
private InitializerExprTypeResolver $initializerExprTypeResolver,
3025
private DynamicReturnTypeExtensionRegistryProvider $dynamicReturnTypeExtensionRegistryProvider,
@@ -51,7 +46,7 @@ public function __construct(
5146
public function create(
5247
ScopeContext $context,
5348
bool $declareStrictTypes = false,
54-
FunctionReflection|MethodReflection|null $function = null,
49+
FunctionReflection|ExtendedMethodReflection|null $function = null,
5550
?string $namespace = null,
5651
array $expressionTypes = [],
5752
array $nativeExpressionTypes = [],
@@ -67,12 +62,7 @@ public function create(
6762
bool $nativeTypesPromoted = false,
6863
): MutatingScope
6964
{
70-
$scopeClass = $this->scopeClass;
71-
if (!is_a($scopeClass, MutatingScope::class, true)) {
72-
throw new ShouldNotHappenException();
73-
}
74-
75-
return new $scopeClass(
65+
return new MutatingScope(
7666
$this,
7767
$this->reflectionProvider,
7868
$this->initializerExprTypeResolver,

src/Analyser/InternalScopeFactory.php

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

33
namespace PHPStan\Analyser;
44

5+
use PHPStan\Reflection\ExtendedMethodReflection;
56
use PHPStan\Reflection\FunctionReflection;
67
use PHPStan\Reflection\MethodReflection;
78
use PHPStan\Reflection\ParameterReflection;
@@ -22,7 +23,7 @@ interface InternalScopeFactory
2223
public function create(
2324
ScopeContext $context,
2425
bool $declareStrictTypes = false,
25-
FunctionReflection|MethodReflection|null $function = null,
26+
FunctionReflection|ExtendedMethodReflection|null $function = null,
2627
?string $namespace = null,
2728
array $expressionTypes = [],
2829
array $nativeExpressionTypes = [],

src/Analyser/LazyInternalScopeFactory.php

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,19 @@
77
use PHPStan\DependencyInjection\Type\ExpressionTypeResolverExtensionRegistryProvider;
88
use PHPStan\Node\Printer\ExprPrinter;
99
use PHPStan\Php\PhpVersion;
10+
use PHPStan\Reflection\ExtendedMethodReflection;
1011
use PHPStan\Reflection\FunctionReflection;
1112
use PHPStan\Reflection\InitializerExprTypeResolver;
1213
use PHPStan\Reflection\MethodReflection;
1314
use PHPStan\Reflection\ParameterReflection;
1415
use PHPStan\Reflection\ParametersAcceptor;
1516
use PHPStan\Reflection\ReflectionProvider;
1617
use PHPStan\Rules\Properties\PropertyReflectionFinder;
17-
use PHPStan\ShouldNotHappenException;
18-
use function is_a;
1918

2019
final class LazyInternalScopeFactory implements InternalScopeFactory
2120
{
2221

23-
/**
24-
* @param class-string $scopeClass
25-
*/
2622
public function __construct(
27-
private string $scopeClass,
2823
private Container $container,
2924
)
3025
{
@@ -41,7 +36,7 @@ public function __construct(
4136
public function create(
4237
ScopeContext $context,
4338
bool $declareStrictTypes = false,
44-
FunctionReflection|MethodReflection|null $function = null,
39+
FunctionReflection|ExtendedMethodReflection|null $function = null,
4540
?string $namespace = null,
4641
array $expressionTypes = [],
4742
array $nativeExpressionTypes = [],
@@ -57,12 +52,7 @@ public function create(
5752
bool $nativeTypesPromoted = false,
5853
): MutatingScope
5954
{
60-
$scopeClass = $this->scopeClass;
61-
if (!is_a($scopeClass, MutatingScope::class, true)) {
62-
throw new ShouldNotHappenException();
63-
}
64-
65-
return new $scopeClass(
55+
return new MutatingScope(
6656
$this,
6757
$this->container->getByType(ReflectionProvider::class),
6858
$this->container->getByType(InitializerExprTypeResolver::class),

src/Command/CommandHelper.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use Nette\Schema\ValidationException;
1313
use Nette\Utils\AssertionException;
1414
use Nette\Utils\Strings;
15-
use PHPStan\Analyser\MutatingScope;
1615
use PHPStan\Command\Symfony\SymfonyOutput;
1716
use PHPStan\Command\Symfony\SymfonyStyle;
1817
use PHPStan\DependencyInjection\Container;
@@ -524,12 +523,6 @@ public static function begin(
524523
throw new InceptionNotSuccessfulException();
525524
}
526525

527-
if ($container->hasParameter('scopeClass') && $container->getParameter('scopeClass') !== MutatingScope::class) {
528-
$errorOutput->writeLineFormatted('⚠️ You\'re using a deprecated config option <fg=cyan>scopeClass</>. ⚠️️');
529-
$errorOutput->writeLineFormatted('');
530-
$errorOutput->writeLineFormatted(sprintf('Please implement PHPStan\Type\ExpressionTypeResolverExtension interface instead and register it as a service.'));
531-
}
532-
533526
$tempResultCachePath = $container->getParameter('tempResultCachePath');
534527
$createDir($tempResultCachePath);
535528

src/Testing/PHPStanTestCase.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ public static function createScopeFactory(ReflectionProvider $reflectionProvider
170170

171171
return new ScopeFactory(
172172
new DirectInternalScopeFactory(
173-
MutatingScope::class,
174173
$reflectionProvider,
175174
new InitializerExprTypeResolver(
176175
$constantResolver,

0 commit comments

Comments
 (0)