Skip to content
Merged
50 changes: 50 additions & 0 deletions build/PHPStan/Build/TurboAttributeCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,30 @@
use Nette\Utils\RegexpException;
use Nette\Utils\Strings;
use PhpParser\Node;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\Array_;
use PhpParser\Node\Expr\ArrayDimFetch;
use PhpParser\Node\Expr\ArrowFunction;
use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\CallLike;
use PhpParser\Node\Expr\ClassConstFetch;
use PhpParser\Node\Expr\Closure;
use PhpParser\Node\Expr\ConstFetch;
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Expr\List_;
use PhpParser\Node\Expr\Match_;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\New_;
use PhpParser\Node\Expr\NullsafeMethodCall;
use PhpParser\Node\Expr\NullsafePropertyFetch;
use PhpParser\Node\Expr\PostDec;
use PhpParser\Node\Expr\PostInc;
use PhpParser\Node\Expr\PreDec;
use PhpParser\Node\Expr\PreInc;
use PhpParser\Node\Expr\PropertyFetch;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Expr\StaticPropertyFetch;
use PhpParser\Node\Expr\UnaryMinus;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Expr\Yield_;
Expand All @@ -27,14 +39,26 @@
use PhpParser\Node\Identifier;
use PhpParser\Node\Name;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Param;
use PhpParser\Node\Scalar;
use PhpParser\Node\Scalar\Float_;
use PhpParser\Node\Scalar\Int_;
use PhpParser\Node\Scalar\String_;
use PhpParser\Node\Stmt;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Declare_;
use PhpParser\Node\Stmt\Expression;
use PhpParser\Node\Stmt\HaltCompiler;
use PhpParser\Node\Stmt\Namespace_;
use PhpParser\Node\VariadicPlaceholder;
use PhpParser\Node\VarLikeIdentifier;
use PhpParser\NodeTraverser;
use PhpParser\NodeVisitorAbstract;
use PHPStan\BetterReflection\Reflection\Adapter\ReflectionEnum;
use PHPStan\BetterReflection\Reflection\Adapter\ReflectionEnumBackedCase;
use PHPStan\BetterReflection\Reflection\Adapter\ReflectionIntersectionType;
use PHPStan\BetterReflection\Reflection\Adapter\ReflectionMethod;
use PHPStan\BetterReflection\Reflection\Adapter\ReflectionNamedType;
use PHPStan\BetterReflection\Reflection\Adapter\ReflectionUnionType;
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprFloatNode;
Expand Down Expand Up @@ -164,6 +188,32 @@ final class TurboAttributeCollector
'conditionalTypeNode' => ConditionalTypeNode::class,
'conditionalTypeForParameterNode' => ConditionalTypeForParameterNode::class,
'reflectionEnum' => ReflectionEnum::class,
'constFetch' => ConstFetch::class,
'haltCompiler' => HaltCompiler::class,
'match' => Match_::class,
'nullsafeMethodCall' => NullsafeMethodCall::class,
'staticPropertyFetch' => StaticPropertyFetch::class,
'classConstFetch' => ClassConstFetch::class,
'scalarString' => String_::class,
'scalarInt' => Int_::class,
'scalarFloat' => Float_::class,
'varLikeIdentifier' => VarLikeIdentifier::class,
'listExpr' => List_::class,
'reflectionEnumBackedCase' => ReflectionEnumBackedCase::class,
'arg' => Arg::class,
'param' => Param::class,
'preInc' => PreInc::class,
'preDec' => PreDec::class,
'postInc' => PostInc::class,
'postDec' => PostDec::class,
'adapterReflectionMethod' => ReflectionMethod::class,
'expressionStmt' => Expression::class,
'assignExpr' => Assign::class,
'namespaceStmt' => Namespace_::class,
'declareStmt' => Declare_::class,
'classMethodStmt' => ClassMethod::class,
'adapterReflectionClass' => \PHPStan\BetterReflection\Reflection\Adapter\ReflectionClass::class,
'betterReflectionClass' => \PHPStan\BetterReflection\Reflection\ReflectionClass::class,
];

private string $realRoot;
Expand Down
2 changes: 2 additions & 0 deletions src/Analyser/ArgumentsNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use PHPStan\Reflection\ParametersAcceptorSelector;
use PHPStan\ShouldNotHappenException;
use PHPStan\TrinaryLogic;
use PHPStan\Turbo\ReferencedByTurboExtension;
use PHPStan\Type\Constant\ConstantArrayType;
use function array_is_list;
use function array_key_exists;
Expand All @@ -33,6 +34,7 @@
/**
* @api
*/
#[ReferencedByTurboExtension(key: 'argumentsNormalizer')]
final class ArgumentsNormalizer
{

Expand Down
2 changes: 2 additions & 0 deletions src/Analyser/ExprHandlerRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use PhpParser\Node\Expr;
use PHPStan\DependencyInjection\Container;
use PHPStan\Turbo\ReferencedByTurboExtension;
use function get_class;
use function spl_object_id;

Expand All @@ -12,6 +13,7 @@
* Expr class so dispatch does not re-scan every tagged handler (a linear
* supports() sweep) on each call.
*/
#[ReferencedByTurboExtension(key: 'exprHandlerRegistry')]
final class ExprHandlerRegistry
{

Expand Down
2 changes: 2 additions & 0 deletions src/Analyser/ExpressionResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use PHPStan\DependencyInjection\ExtensionsCollection;
use PHPStan\DependencyInjection\GenerateFactory;
use PHPStan\ShouldNotHappenException;
use PHPStan\Turbo\ShadowedByTurboExtension;
use PHPStan\Type\Constant\ConstantBooleanType;
use PHPStan\Type\ExpressionTypeResolverExtension;
use PHPStan\Type\Type;
Expand All @@ -22,6 +23,7 @@
use function spl_object_id;

#[GenerateFactory(interface: ExpressionResultFactory::class)]
#[ShadowedByTurboExtension(implementation: __DIR__ . '/../../turbo-ext/src/ExpressionResult.cpp')]
final class ExpressionResult
{

Expand Down
2 changes: 2 additions & 0 deletions src/Analyser/ExpressionResultStorageStack.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace PHPStan\Analyser;

use PHPStan\ShouldNotHappenException;
use PHPStan\Turbo\ShadowedByTurboExtension;
use function array_pop;
use function count;

Expand All @@ -24,6 +25,7 @@
* A scope used outside any running analysis simply misses here and resolves
* on demand with a throwaway storage.
*/
#[ShadowedByTurboExtension(implementation: __DIR__ . '/../../turbo-ext/src/ExpressionResultStorageStack.cpp')]
final class ExpressionResultStorageStack
{

Expand Down
2 changes: 2 additions & 0 deletions src/Analyser/Generics/TemplateArgumentFrame.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use PHPStan\Analyser\MutatingScope;
use PHPStan\Reflection\ParametersAcceptor;
use PHPStan\Reflection\ResolvedFunctionVariant;
use PHPStan\Turbo\ReferencedByTurboExtension;
use PHPStan\Type\Generic\TemplateType;
use PHPStan\Type\Type;
use PHPStan\Type\TypeTraverser;
Expand All @@ -17,6 +18,7 @@
* Immutable template inference context carried by a scope. The observation walk
* and the resolved walk use distinct instances, including in saved callbacks.
*/
#[ReferencedByTurboExtension(key: 'templateArgumentFrame')]
final class TemplateArgumentFrame
{

Expand Down
2 changes: 2 additions & 0 deletions src/Analyser/IssetabilityLinkInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use PHPStan\Rules\Properties\FoundPropertyReflection;
use PHPStan\ShouldNotHappenException;
use PHPStan\TrinaryLogic;
use PHPStan\Turbo\ReferencedByTurboExtension;
use PHPStan\Type\Type;

/**
Expand All @@ -15,6 +16,7 @@
* (IssetabilityResolution::isSet) and the rule (PHPStan\Rules\IssetCheck) read the
* facts instead of re-walking and re-resolving.
*/
#[ReferencedByTurboExtension(key: 'issetabilityLinkInfo')]
final class IssetabilityLinkInfo
{

Expand Down
2 changes: 2 additions & 0 deletions src/Analyser/IssetabilityResolution.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace PHPStan\Analyser;

use PHPStan\Turbo\ReferencedByTurboExtension;
use PHPStan\Type\Type;

/**
Expand All @@ -11,6 +12,7 @@
* the fold via isSet() and the rule (PHPStan\Rules\IssetCheck) renders messages
* from the same links - neither re-walks the AST nor re-resolves types.
*/
#[ReferencedByTurboExtension(key: 'issetabilityResolution')]
final class IssetabilityResolution
{

Expand Down
2 changes: 2 additions & 0 deletions src/Analyser/LazyInternalScopeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
use PHPStan\Reflection\Php\PhpFunctionFromParserNodeReflection;
use PHPStan\Reflection\ReflectionProvider;
use PHPStan\Rules\Properties\PropertyReflectionFinder;
use PHPStan\Turbo\ReferencedByTurboExtension;
use PHPStan\Type\ClosureType;
use PHPStan\Type\ExpressionTypeResolverExtension;
use WeakReference;

#[GenerateFactory(interface: InternalScopeFactoryFactory::class, resultType: LazyInternalScopeFactory::class)]
#[ReferencedByTurboExtension(key: 'lazyInternalScopeFactory')]
final class LazyInternalScopeFactory implements InternalScopeFactory
{

Expand Down
4 changes: 2 additions & 2 deletions src/Analyser/MutatingScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
use PHPStan\Rules\Properties\PropertyReflectionFinder;
use PHPStan\ShouldNotHappenException;
use PHPStan\TrinaryLogic;
use PHPStan\Turbo\ReferencedByTurboExtension;
use PHPStan\Turbo\ShadowedByTurboExtension;
use PHPStan\Type\Accessory\AccessoryArrayListType;
use PHPStan\Type\Accessory\HasOffsetValueType;
use PHPStan\Type\Accessory\NonEmptyArrayType;
Expand Down Expand Up @@ -147,7 +147,7 @@
use const PHP_INT_MAX;
use const PHP_INT_MIN;

#[ReferencedByTurboExtension(key: 'mutatingScope')]
#[ShadowedByTurboExtension(implementation: __DIR__ . '/../../turbo-ext/src/MutatingScope.cpp')]
class MutatingScope implements Scope, NodeCallbackInvoker, CollectedDataEmitter
{

Expand Down
2 changes: 2 additions & 0 deletions src/Analyser/NodeCallbackScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
use PHPStan\Reflection\FunctionReflection;
use PHPStan\Reflection\MethodReflection;
use PHPStan\Reflection\ParameterReflection;
use PHPStan\Turbo\ReferencedByTurboExtension;
use PHPStan\Type\Type;
use WeakReference;
use function array_pop;
use function count;
use function spl_object_id;

#[ReferencedByTurboExtension(key: 'nodeCallbackScope')]
final class NodeCallbackScope extends MutatingScope
{

Expand Down
2 changes: 2 additions & 0 deletions src/Analyser/NodeScopeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
use PHPStan\Reflection\Php\PhpMethodReflection;
use PHPStan\Reflection\Php\PhpPropertyReflection;
use PHPStan\ShouldNotHappenException;
use PHPStan\Turbo\ReferencedByTurboExtension;
use PHPStan\Type\ErrorType;
use PHPStan\Type\MixedType;
use PHPStan\Type\Type;
Expand All @@ -59,6 +60,7 @@
use function sprintf;

#[AutowiredService]
#[ReferencedByTurboExtension(key: 'nodeScopeResolver')]
class NodeScopeResolver
{

Expand Down
2 changes: 2 additions & 0 deletions src/Analyser/Traverser/TransformStaticTypeTraverser.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
namespace PHPStan\Analyser\Traverser;

use PHPStan\Analyser\Scope;
use PHPStan\Turbo\ReferencedByTurboExtension;
use PHPStan\Type\StaticType;
use PHPStan\Type\ThisType;
use PHPStan\Type\Type;
use PHPStan\Type\TypeTraverserCallable;

#[ReferencedByTurboExtension(key: 'transformStaticTypeTraverser')]
final class TransformStaticTypeTraverser implements TypeTraverserCallable
{

Expand Down
2 changes: 2 additions & 0 deletions src/Analyser/Traverser/VoidToNullTraverser.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

namespace PHPStan\Analyser\Traverser;

use PHPStan\Turbo\ReferencedByTurboExtension;
use PHPStan\Type\NullType;
use PHPStan\Type\Type;
use PHPStan\Type\TypeTraverserCallable;
use PHPStan\Type\UnionType;

#[ReferencedByTurboExtension(key: 'voidToNullTraverser')]
final class VoidToNullTraverser implements TypeTraverserCallable
{

Expand Down
2 changes: 2 additions & 0 deletions src/Analyser/TypeSpecifierContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
namespace PHPStan\Analyser;

use PHPStan\ShouldNotHappenException;
use PHPStan\Turbo\ReferencedByTurboExtension;

/**
* @api
*/
#[ReferencedByTurboExtension(key: 'typeSpecifierContext')]
final class TypeSpecifierContext
{

Expand Down
2 changes: 2 additions & 0 deletions src/Analyser/UndefinedVariableException.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace PHPStan\Analyser;

use PHPStan\AnalysedCodeException;
use PHPStan\Turbo\ReferencedByTurboExtension;
use function sprintf;

/**
Expand All @@ -11,6 +12,7 @@
* Unchecked exception thrown from `PHPStan\Analyser\Scope::getVariableType()`
* in case the user doesn't check `hasVariableType()` is not `no()`.
*/
#[ReferencedByTurboExtension(key: 'undefinedVariableException')]
final class UndefinedVariableException extends AnalysedCodeException
{

Expand Down
2 changes: 2 additions & 0 deletions src/Analyser/VariableAccessFlow.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
namespace PHPStan\Analyser;

use PHPStan\Node\Variable\VariableWrite;
use PHPStan\Turbo\ReferencedByTurboExtension;
use PHPStan\Type\Type;

#[ReferencedByTurboExtension(key: 'variableAccessFlow')]
final class VariableAccessFlow extends VariableFlow
{

Expand Down
2 changes: 2 additions & 0 deletions src/Analyser/VariableControlFlow.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
use PhpParser\Node\Stmt\For_;
use PhpParser\Node\Stmt\Foreach_;
use PHPStan\Node\Variable\VariableWrite;
use PHPStan\Turbo\ReferencedByTurboExtension;
use PHPStan\Type\Type;

#[ReferencedByTurboExtension(key: 'variableControlFlow')]
final class VariableControlFlow extends VariableFlow
{

Expand Down
2 changes: 2 additions & 0 deletions src/Analyser/VariableFlow.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use PhpParser\Node\Stmt\For_;
use PhpParser\Node\Stmt\Foreach_;
use PHPStan\Node\Variable\VariableWrite;
use PHPStan\Turbo\ShadowedByTurboExtension;
use PHPStan\Type\Type;
use function count;
use function in_array;
Expand All @@ -14,6 +15,7 @@
* Immutable source execution fragment, composed with expression and statement
* results. Liveness is resolved at the body boundary, independently of types.
*/
#[ShadowedByTurboExtension(implementation: __DIR__ . '/../../turbo-ext/src/VariableFlow.cpp')]
abstract class VariableFlow
{

Expand Down
2 changes: 2 additions & 0 deletions src/Analyser/VariableFlowBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
use PhpParser\Node;
use PhpParser\Node\Expr;
use PHPStan\Node\Variable\VariableWrite;
use PHPStan\Turbo\ShadowedByTurboExtension;
use PHPStan\Type\Type;
use function in_array;
use function is_string;
use function spl_object_id;

/** Compose variable flow for assignment targets and arguments. */
#[ShadowedByTurboExtension(implementation: __DIR__ . '/../../turbo-ext/src/VariableFlowBuilder.cpp')]
final class VariableFlowBuilder
{

Expand Down
3 changes: 3 additions & 0 deletions src/Analyser/VariableInputFlow.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace PHPStan\Analyser;

use PHPStan\Turbo\ReferencedByTurboExtension;

#[ReferencedByTurboExtension(key: 'variableInputFlow')]
final class VariableInputFlow extends VariableFlow
{

Expand Down
Loading
Loading