Skip to content

Commit

Permalink
Internal classes made final, @api classes made @final
Browse files Browse the repository at this point in the history
`@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.
  • Loading branch information
ondrejmirtes committed Jul 25, 2024
1 parent 67193b6 commit 4010b73
Show file tree
Hide file tree
Showing 994 changed files with 1,313 additions and 1,027 deletions.
2 changes: 1 addition & 1 deletion bin/generate-rule-error-classes.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/**
* @internal Use PHPStan\Rules\RuleErrorBuilder instead.
*/
class RuleError%s implements %s
final class RuleError%s implements %s
{
%s
Expand Down
5 changes: 0 additions & 5 deletions build/enum-adapter-errors.neon
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,3 @@ parameters:
message: "#^Method PHPStan\\\\Reflection\\\\Php\\\\BuiltinMethodReflection\\:\\:getDeclaringClass\\(\\) has invalid return type PHPStan\\\\BetterReflection\\\\Reflection\\\\Adapter\\\\ReflectionEnum\\.$#"
count: 1
path: ../src/Reflection/Php/BuiltinMethodReflection.php

-
message: "#^Method PHPStan\\\\Reflection\\\\Php\\\\NativeBuiltinMethodReflection\\:\\:getDeclaringClass\\(\\) has invalid return type PHPStan\\\\BetterReflection\\\\Reflection\\\\Adapter\\\\ReflectionEnum\\.$#"
count: 1
path: ../src/Reflection/Php/NativeBuiltinMethodReflection.php
25 changes: 0 additions & 25 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -212,31 +212,6 @@ parameters:
count: 1
path: src/PhpDoc/StubValidator.php

-
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\\(\\)$#"
count: 1
path: src/PhpDoc/Tag/ParamOutTag.php

-
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\\(\\)$#"
count: 1
path: src/PhpDoc/Tag/ParamTag.php

-
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\\(\\)$#"
count: 1
path: src/PhpDoc/Tag/ReturnTag.php

-
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\\(\\)$#"
count: 1
path: src/PhpDoc/Tag/SelfOutTypeTag.php

-
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\\(\\)$#"
count: 1
path: src/PhpDoc/Tag/VarTag.php

-
message: "#^Doing instanceof PHPStan\\\\Type\\\\ArrayType is error\\-prone and deprecated\\. Use Type\\:\\:isArray\\(\\) or Type\\:\\:getArrays\\(\\) instead\\.$#"
count: 1
Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/Analyser.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use function count;
use function memory_get_peak_usage;

class Analyser
final class Analyser
{

public function __construct(
Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/AnalyserResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/**
* @phpstan-import-type LinesToIgnore from FileAnalyserResult
*/
class AnalyserResult
final class AnalyserResult
{

/** @var list<Error>|null */
Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/AnalyserResultFinalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use function get_class;
use function sprintf;

class AnalyserResultFinalizer
final class AnalyserResultFinalizer
{

public function __construct(
Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/ConditionalExpressionHolder.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use function implode;
use function sprintf;

class ConditionalExpressionHolder
final class ConditionalExpressionHolder
{

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/ConstantResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
use const NAN;
use const PHP_INT_SIZE;

class ConstantResolver
final class ConstantResolver
{

/** @var array<string, true> */
Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/ConstantResolverFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use PHPStan\DependencyInjection\Container;
use PHPStan\Reflection\ReflectionProvider\ReflectionProviderProvider;

class ConstantResolverFactory
final class ConstantResolverFactory
{

public function __construct(
Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/DirectInternalScopeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use PHPStan\ShouldNotHappenException;
use function is_a;

class DirectInternalScopeFactory implements InternalScopeFactory
final class DirectInternalScopeFactory implements InternalScopeFactory
{

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/EndStatementResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use PhpParser\Node\Stmt;

class EndStatementResult
final class EndStatementResult
{

public function __construct(
Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/EnsuredNonNullabilityResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace PHPStan\Analyser;

class EnsuredNonNullabilityResult
final class EnsuredNonNullabilityResult
{

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/EnsuredNonNullabilityResultExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use PHPStan\TrinaryLogic;
use PHPStan\Type\Type;

class EnsuredNonNullabilityResultExpression
final class EnsuredNonNullabilityResultExpression
{

public function __construct(
Expand Down
5 changes: 4 additions & 1 deletion src/Analyser/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
use function is_bool;
use function sprintf;

/** @api */
/**
* @api
* @final
*/
class Error implements JsonSerializable
{

Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/ExpressionContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use PHPStan\Type\Type;

class ExpressionContext
final class ExpressionContext
{

private function __construct(
Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/ExpressionResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace PHPStan\Analyser;

class ExpressionResult
final class ExpressionResult
{

/** @var (callable(): MutatingScope)|null */
Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/ExpressionTypeHolder.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use PHPStan\Type\Type;
use PHPStan\Type\TypeCombinator;

class ExpressionTypeHolder
final class ExpressionTypeHolder
{

public function __construct(private Expr $expr, private Type $type, private TrinaryLogic $certainty)
Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/FileAnalyser.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
use const E_USER_WARNING;
use const E_WARNING;

class FileAnalyser
final class FileAnalyser
{

/** @var list<Error> */
Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/FileAnalyserResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* @phpstan-type LinesToIgnore = array<string, array<int, non-empty-list<string>|null>>
*/
class FileAnalyserResult
final class FileAnalyserResult
{

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/FinalizerResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace PHPStan\Analyser;

class FinalizerResult
final class FinalizerResult
{

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/Ignore/IgnoreParseException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Exception;

class IgnoreParseException extends Exception
final class IgnoreParseException extends Exception
{

public function __construct(string $message, private int $phpDocLine)
Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/Ignore/IgnoredError.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use function sprintf;
use function str_replace;

class IgnoredError
final class IgnoredError
{

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/Ignore/IgnoredErrorHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use function is_file;
use function sprintf;

class IgnoredErrorHelper
final class IgnoredErrorHelper
{

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/Ignore/IgnoredErrorHelperProcessedResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use PHPStan\Analyser\Error;

class IgnoredErrorHelperProcessedResult
final class IgnoredErrorHelperProcessedResult
{

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/Ignore/IgnoredErrorHelperResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use function is_string;
use function sprintf;

class IgnoredErrorHelperResult
final class IgnoredErrorHelperResult
{

/**
Expand Down
1 change: 1 addition & 0 deletions src/Analyser/ImpurePoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
/**
* @phpstan-type ImpurePointIdentifier = 'echo'|'die'|'exit'|'propertyAssign'|'propertyAssignByRef'|'propertyUnset'|'methodCall'|'new'|'functionCall'|'include'|'require'|'print'|'eval'|'superglobal'|'yield'|'yieldFrom'|'static'|'global'|'betweenPhpTags'
* @api
* @final
*/
class ImpurePoint
{
Expand Down
1 change: 1 addition & 0 deletions src/Analyser/InternalError.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

/**
* @api
* @final
* @phpstan-type Trace = list<array{file: string|null, line: int|null}>
*/
class InternalError implements JsonSerializable
Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/LazyInternalScopeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use PHPStan\ShouldNotHappenException;
use function is_a;

class LazyInternalScopeFactory implements InternalScopeFactory
final class LazyInternalScopeFactory implements InternalScopeFactory
{

private bool $explicitMixedInUnknownGenericNew;
Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/LocalIgnoresProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/**
* @phpstan-import-type LinesToIgnore from FileAnalyserResult
*/
class LocalIgnoresProcessor
final class LocalIgnoresProcessor
{

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/LocalIgnoresProcessorResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* @phpstan-import-type LinesToIgnore from FileAnalyserResult
*/
class LocalIgnoresProcessorResult
final class LocalIgnoresProcessorResult
{

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/MutatingScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
use const PHP_INT_MAX;
use const PHP_INT_MIN;

class MutatingScope implements Scope
final class MutatingScope implements Scope
{

private const BOOLEAN_EXPRESSION_MAX_PROCESS_DEPTH = 4;
Expand Down
5 changes: 4 additions & 1 deletion src/Analyser/NameScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
use function str_starts_with;
use function strtolower;

/** @api */
/**
* @api
* @final
*/
class NameScope
{

Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/NodeScopeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
use const PHP_VERSION_ID;
use const SORT_NUMERIC;

class NodeScopeResolver
final class NodeScopeResolver
{

private const LOOP_SCOPE_ITERATIONS = 3;
Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/NullsafeOperatorHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use PhpParser\Node\Expr;
use PHPStan\Type\TypeCombinator;

class NullsafeOperatorHelper
final class NullsafeOperatorHelper
{

public static function getNullsafeShortcircuitedExprRespectingScope(Scope $scope, Expr $expr): Expr
Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/OutOfClassScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use PHPStan\Reflection\MethodReflection;
use PHPStan\Reflection\PropertyReflection;

class OutOfClassScope implements ClassMemberAccessAnswerer
final class OutOfClassScope implements ClassMemberAccessAnswerer
{

/** @api */
Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/ProcessClosureResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use PHPStan\Node\InvalidateExprNode;

class ProcessClosureResult
final class ProcessClosureResult
{

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/ResultCache/ResultCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/**
* @phpstan-import-type LinesToIgnore from FileAnalyserResult
*/
class ResultCache
final class ResultCache
{

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/ResultCache/ResultCacheClearer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use function is_file;
use function unlink;

class ResultCacheClearer
final class ResultCacheClearer
{

public function __construct(private string $cacheFilePath)
Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/ResultCache/ResultCacheManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
/**
* @phpstan-import-type LinesToIgnore from FileAnalyserResult
*/
class ResultCacheManager
final class ResultCacheManager
{

private const CACHE_VERSION = 'v12-linesToIgnore';
Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/ResultCache/ResultCacheProcessResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use PHPStan\Analyser\AnalyserResult;

class ResultCacheProcessResult
final class ResultCacheProcessResult
{

public function __construct(private AnalyserResult $analyserResult, private bool $saved)
Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/RuleErrorTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use PHPStan\Rules\TipRuleError;
use function is_string;

class RuleErrorTransformer
final class RuleErrorTransformer
{

/**
Expand Down
Loading

0 comments on commit 4010b73

Please sign in to comment.