Skip to content

Commit 4010b73

Browse files
committed
Internal classes made final, @api classes made @final
`@api` classes will become `final` in PHPStan 2.0 PHPStan\Type\Type interface implementations are excluded from these changes If these changes impact your project, please open a GitHub Discussion so we can have a conversation about your use case and solve it properly.
1 parent 67193b6 commit 4010b73

File tree

994 files changed

+1313
-1027
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

994 files changed

+1313
-1027
lines changed

Diff for: bin/generate-rule-error-classes.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
/**
1515
* @internal Use PHPStan\Rules\RuleErrorBuilder instead.
1616
*/
17-
class RuleError%s implements %s
17+
final class RuleError%s implements %s
1818
{
1919
2020
%s

Diff for: build/enum-adapter-errors.neon

-5
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,3 @@ parameters:
144144
message: "#^Method PHPStan\\\\Reflection\\\\Php\\\\BuiltinMethodReflection\\:\\:getDeclaringClass\\(\\) has invalid return type PHPStan\\\\BetterReflection\\\\Reflection\\\\Adapter\\\\ReflectionEnum\\.$#"
145145
count: 1
146146
path: ../src/Reflection/Php/BuiltinMethodReflection.php
147-
148-
-
149-
message: "#^Method PHPStan\\\\Reflection\\\\Php\\\\NativeBuiltinMethodReflection\\:\\:getDeclaringClass\\(\\) has invalid return type PHPStan\\\\BetterReflection\\\\Reflection\\\\Adapter\\\\ReflectionEnum\\.$#"
150-
count: 1
151-
path: ../src/Reflection/Php/NativeBuiltinMethodReflection.php

Diff for: phpstan-baseline.neon

-25
Original file line numberDiff line numberDiff line change
@@ -212,31 +212,6 @@ parameters:
212212
count: 1
213213
path: src/PhpDoc/StubValidator.php
214214

215-
-
216-
message: "#^Return type \\(PHPStan\\\\PhpDoc\\\\Tag\\\\ParamOutTag\\) of method PHPStan\\\\PhpDoc\\\\Tag\\\\ParamOutTag\\:\\:withType\\(\\) should be covariant with return type \\(static\\(PHPStan\\\\PhpDoc\\\\Tag\\\\TypedTag\\)\\) of method PHPStan\\\\PhpDoc\\\\Tag\\\\TypedTag\\:\\:withType\\(\\)$#"
217-
count: 1
218-
path: src/PhpDoc/Tag/ParamOutTag.php
219-
220-
-
221-
message: "#^Return type \\(PHPStan\\\\PhpDoc\\\\Tag\\\\ParamTag\\) of method PHPStan\\\\PhpDoc\\\\Tag\\\\ParamTag\\:\\:withType\\(\\) should be covariant with return type \\(static\\(PHPStan\\\\PhpDoc\\\\Tag\\\\TypedTag\\)\\) of method PHPStan\\\\PhpDoc\\\\Tag\\\\TypedTag\\:\\:withType\\(\\)$#"
222-
count: 1
223-
path: src/PhpDoc/Tag/ParamTag.php
224-
225-
-
226-
message: "#^Return type \\(PHPStan\\\\PhpDoc\\\\Tag\\\\ReturnTag\\) of method PHPStan\\\\PhpDoc\\\\Tag\\\\ReturnTag\\:\\:withType\\(\\) should be covariant with return type \\(static\\(PHPStan\\\\PhpDoc\\\\Tag\\\\TypedTag\\)\\) of method PHPStan\\\\PhpDoc\\\\Tag\\\\TypedTag\\:\\:withType\\(\\)$#"
227-
count: 1
228-
path: src/PhpDoc/Tag/ReturnTag.php
229-
230-
-
231-
message: "#^Return type \\(PHPStan\\\\PhpDoc\\\\Tag\\\\SelfOutTypeTag\\) of method PHPStan\\\\PhpDoc\\\\Tag\\\\SelfOutTypeTag\\:\\:withType\\(\\) should be covariant with return type \\(static\\(PHPStan\\\\PhpDoc\\\\Tag\\\\TypedTag\\)\\) of method PHPStan\\\\PhpDoc\\\\Tag\\\\TypedTag\\:\\:withType\\(\\)$#"
232-
count: 1
233-
path: src/PhpDoc/Tag/SelfOutTypeTag.php
234-
235-
-
236-
message: "#^Return type \\(PHPStan\\\\PhpDoc\\\\Tag\\\\VarTag\\) of method PHPStan\\\\PhpDoc\\\\Tag\\\\VarTag\\:\\:withType\\(\\) should be covariant with return type \\(static\\(PHPStan\\\\PhpDoc\\\\Tag\\\\TypedTag\\)\\) of method PHPStan\\\\PhpDoc\\\\Tag\\\\TypedTag\\:\\:withType\\(\\)$#"
237-
count: 1
238-
path: src/PhpDoc/Tag/VarTag.php
239-
240215
-
241216
message: "#^Doing instanceof PHPStan\\\\Type\\\\ArrayType is error\\-prone and deprecated\\. Use Type\\:\\:isArray\\(\\) or Type\\:\\:getArrays\\(\\) instead\\.$#"
242217
count: 1

Diff for: src/Analyser/Analyser.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use function count;
1313
use function memory_get_peak_usage;
1414

15-
class Analyser
15+
final class Analyser
1616
{
1717

1818
public function __construct(

Diff for: src/Analyser/AnalyserResult.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/**
1010
* @phpstan-import-type LinesToIgnore from FileAnalyserResult
1111
*/
12-
class AnalyserResult
12+
final class AnalyserResult
1313
{
1414

1515
/** @var list<Error>|null */

Diff for: src/Analyser/AnalyserResultFinalizer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use function get_class;
1515
use function sprintf;
1616

17-
class AnalyserResultFinalizer
17+
final class AnalyserResultFinalizer
1818
{
1919

2020
public function __construct(

Diff for: src/Analyser/ConditionalExpressionHolder.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use function implode;
99
use function sprintf;
1010

11-
class ConditionalExpressionHolder
11+
final class ConditionalExpressionHolder
1212
{
1313

1414
/**

Diff for: src/Analyser/ConstantResolver.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
use const NAN;
2626
use const PHP_INT_SIZE;
2727

28-
class ConstantResolver
28+
final class ConstantResolver
2929
{
3030

3131
/** @var array<string, true> */

Diff for: src/Analyser/ConstantResolverFactory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use PHPStan\DependencyInjection\Container;
66
use PHPStan\Reflection\ReflectionProvider\ReflectionProviderProvider;
77

8-
class ConstantResolverFactory
8+
final class ConstantResolverFactory
99
{
1010

1111
public function __construct(

Diff for: src/Analyser/DirectInternalScopeFactory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use PHPStan\ShouldNotHappenException;
1818
use function is_a;
1919

20-
class DirectInternalScopeFactory implements InternalScopeFactory
20+
final class DirectInternalScopeFactory implements InternalScopeFactory
2121
{
2222

2323
/**

Diff for: src/Analyser/EndStatementResult.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use PhpParser\Node\Stmt;
66

7-
class EndStatementResult
7+
final class EndStatementResult
88
{
99

1010
public function __construct(

Diff for: src/Analyser/EnsuredNonNullabilityResult.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace PHPStan\Analyser;
44

5-
class EnsuredNonNullabilityResult
5+
final class EnsuredNonNullabilityResult
66
{
77

88
/**

Diff for: src/Analyser/EnsuredNonNullabilityResultExpression.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use PHPStan\TrinaryLogic;
77
use PHPStan\Type\Type;
88

9-
class EnsuredNonNullabilityResultExpression
9+
final class EnsuredNonNullabilityResultExpression
1010
{
1111

1212
public function __construct(

Diff for: src/Analyser/Error.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
use function is_bool;
1313
use function sprintf;
1414

15-
/** @api */
15+
/**
16+
* @api
17+
* @final
18+
*/
1619
class Error implements JsonSerializable
1720
{
1821

Diff for: src/Analyser/ExpressionContext.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use PHPStan\Type\Type;
66

7-
class ExpressionContext
7+
final class ExpressionContext
88
{
99

1010
private function __construct(

Diff for: src/Analyser/ExpressionResult.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace PHPStan\Analyser;
44

5-
class ExpressionResult
5+
final class ExpressionResult
66
{
77

88
/** @var (callable(): MutatingScope)|null */

Diff for: src/Analyser/ExpressionTypeHolder.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use PHPStan\Type\Type;
88
use PHPStan\Type\TypeCombinator;
99

10-
class ExpressionTypeHolder
10+
final class ExpressionTypeHolder
1111
{
1212

1313
public function __construct(private Expr $expr, private Type $type, private TrinaryLogic $certainty)

Diff for: src/Analyser/FileAnalyser.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
use const E_USER_WARNING;
3737
use const E_WARNING;
3838

39-
class FileAnalyser
39+
final class FileAnalyser
4040
{
4141

4242
/** @var list<Error> */

Diff for: src/Analyser/FileAnalyserResult.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/**
99
* @phpstan-type LinesToIgnore = array<string, array<int, non-empty-list<string>|null>>
1010
*/
11-
class FileAnalyserResult
11+
final class FileAnalyserResult
1212
{
1313

1414
/**

Diff for: src/Analyser/FinalizerResult.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace PHPStan\Analyser;
44

5-
class FinalizerResult
5+
final class FinalizerResult
66
{
77

88
/**

Diff for: src/Analyser/Ignore/IgnoreParseException.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Exception;
66

7-
class IgnoreParseException extends Exception
7+
final class IgnoreParseException extends Exception
88
{
99

1010
public function __construct(string $message, private int $phpDocLine)

Diff for: src/Analyser/Ignore/IgnoredError.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use function sprintf;
1515
use function str_replace;
1616

17-
class IgnoredError
17+
final class IgnoredError
1818
{
1919

2020
/**

Diff for: src/Analyser/Ignore/IgnoredErrorHelper.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use function is_file;
1313
use function sprintf;
1414

15-
class IgnoredErrorHelper
15+
final class IgnoredErrorHelper
1616
{
1717

1818
/**

Diff for: src/Analyser/Ignore/IgnoredErrorHelperProcessedResult.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use PHPStan\Analyser\Error;
66

7-
class IgnoredErrorHelperProcessedResult
7+
final class IgnoredErrorHelperProcessedResult
88
{
99

1010
/**

Diff for: src/Analyser/Ignore/IgnoredErrorHelperResult.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use function is_string;
1414
use function sprintf;
1515

16-
class IgnoredErrorHelperResult
16+
final class IgnoredErrorHelperResult
1717
{
1818

1919
/**

Diff for: src/Analyser/ImpurePoint.php

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
/**
99
* @phpstan-type ImpurePointIdentifier = 'echo'|'die'|'exit'|'propertyAssign'|'propertyAssignByRef'|'propertyUnset'|'methodCall'|'new'|'functionCall'|'include'|'require'|'print'|'eval'|'superglobal'|'yield'|'yieldFrom'|'static'|'global'|'betweenPhpTags'
1010
* @api
11+
* @final
1112
*/
1213
class ImpurePoint
1314
{

Diff for: src/Analyser/InternalError.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
/**
1212
* @api
13+
* @final
1314
* @phpstan-type Trace = list<array{file: string|null, line: int|null}>
1415
*/
1516
class InternalError implements JsonSerializable

Diff for: src/Analyser/LazyInternalScopeFactory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use PHPStan\ShouldNotHappenException;
1818
use function is_a;
1919

20-
class LazyInternalScopeFactory implements InternalScopeFactory
20+
final class LazyInternalScopeFactory implements InternalScopeFactory
2121
{
2222

2323
private bool $explicitMixedInUnknownGenericNew;

Diff for: src/Analyser/LocalIgnoresProcessor.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
/**
1111
* @phpstan-import-type LinesToIgnore from FileAnalyserResult
1212
*/
13-
class LocalIgnoresProcessor
13+
final class LocalIgnoresProcessor
1414
{
1515

1616
/**

Diff for: src/Analyser/LocalIgnoresProcessorResult.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/**
66
* @phpstan-import-type LinesToIgnore from FileAnalyserResult
77
*/
8-
class LocalIgnoresProcessorResult
8+
final class LocalIgnoresProcessorResult
99
{
1010

1111
/**

Diff for: src/Analyser/MutatingScope.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@
158158
use const PHP_INT_MAX;
159159
use const PHP_INT_MIN;
160160

161-
class MutatingScope implements Scope
161+
final class MutatingScope implements Scope
162162
{
163163

164164
private const BOOLEAN_EXPRESSION_MAX_PROCESS_DEPTH = 4;

Diff for: src/Analyser/NameScope.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
use function str_starts_with;
1717
use function strtolower;
1818

19-
/** @api */
19+
/**
20+
* @api
21+
* @final
22+
*/
2023
class NameScope
2124
{
2225

Diff for: src/Analyser/NodeScopeResolver.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@
211211
use const PHP_VERSION_ID;
212212
use const SORT_NUMERIC;
213213

214-
class NodeScopeResolver
214+
final class NodeScopeResolver
215215
{
216216

217217
private const LOOP_SCOPE_ITERATIONS = 3;

Diff for: src/Analyser/NullsafeOperatorHelper.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use PhpParser\Node\Expr;
66
use PHPStan\Type\TypeCombinator;
77

8-
class NullsafeOperatorHelper
8+
final class NullsafeOperatorHelper
99
{
1010

1111
public static function getNullsafeShortcircuitedExprRespectingScope(Scope $scope, Expr $expr): Expr

Diff for: src/Analyser/OutOfClassScope.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use PHPStan\Reflection\MethodReflection;
99
use PHPStan\Reflection\PropertyReflection;
1010

11-
class OutOfClassScope implements ClassMemberAccessAnswerer
11+
final class OutOfClassScope implements ClassMemberAccessAnswerer
1212
{
1313

1414
/** @api */

Diff for: src/Analyser/ProcessClosureResult.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use PHPStan\Node\InvalidateExprNode;
66

7-
class ProcessClosureResult
7+
final class ProcessClosureResult
88
{
99

1010
/**

Diff for: src/Analyser/ResultCache/ResultCache.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
/**
1111
* @phpstan-import-type LinesToIgnore from FileAnalyserResult
1212
*/
13-
class ResultCache
13+
final class ResultCache
1414
{
1515

1616
/**

Diff for: src/Analyser/ResultCache/ResultCacheClearer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use function is_file;
77
use function unlink;
88

9-
class ResultCacheClearer
9+
final class ResultCacheClearer
1010
{
1111

1212
public function __construct(private string $cacheFilePath)

Diff for: src/Analyser/ResultCache/ResultCacheManager.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
/**
4848
* @phpstan-import-type LinesToIgnore from FileAnalyserResult
4949
*/
50-
class ResultCacheManager
50+
final class ResultCacheManager
5151
{
5252

5353
private const CACHE_VERSION = 'v12-linesToIgnore';

Diff for: src/Analyser/ResultCache/ResultCacheProcessResult.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use PHPStan\Analyser\AnalyserResult;
66

7-
class ResultCacheProcessResult
7+
final class ResultCacheProcessResult
88
{
99

1010
public function __construct(private AnalyserResult $analyserResult, private bool $saved)

Diff for: src/Analyser/RuleErrorTransformer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use PHPStan\Rules\TipRuleError;
1313
use function is_string;
1414

15-
class RuleErrorTransformer
15+
final class RuleErrorTransformer
1616
{
1717

1818
/**

0 commit comments

Comments
 (0)