-
Notifications
You must be signed in to change notification settings - Fork 577
Single-pass expression analysis groundwork - answer type questions from ExpressionResults #5857
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ondrejmirtes
wants to merge
113
commits into
2.2.x
Choose a base branch
from
resolve-type-rewrite-2
base: 2.2.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
113 commits
Select commit
Hold shift + click to select a range
f9d803e
Introduce ExpressionResultFactory
ondrejmirtes f273819
ExpressionResult - add beforeScope
ondrejmirtes 59996fe
ExpressionResult - add Expr
ondrejmirtes 21bf8e9
Store ExpressionResult instead of before-Scope
ondrejmirtes 8ae0839
Fill the missing gaps in expr processing
ondrejmirtes 83535c9
Divide ExprHandler into TypeResolvingExprHandler
ondrejmirtes 30424b4
ScalarHandler stops implementing TypeResolvingExprHandler
ondrejmirtes 5c4ea04
ExpressionResultStorageStack - answer type questions from ExpressionR…
ondrejmirtes 55f3c7b
Migrate ArrayHandler - per-item types from ExpressionResults
ondrejmirtes 5664d64
Throw on unbalanced ExpressionResultStorageStack pop
ondrejmirtes 538dd88
Fix PHP 7.4 compat
ondrejmirtes 9f40fe1
Migrate VariableHandler and InstanceofHandler - narrowing from Expres…
ondrejmirtes 9179b49
Add regression tests for evaluation-point array item types
ondrejmirtes 2515d8b
Add regression test for certainty of undefined variables in loops
ondrejmirtes 43b6fa5
Store expressions even without FNSR
ondrejmirtes 12ca8df
Only sureNot specifications skip certainly-undefined variables
ondrejmirtes 9d8fefa
This is better
ondrejmirtes e7621fa
ExpressionResult::createTypesCallback - the inside-out TypeSpecifier:…
ondrejmirtes cbd9441
Coalesce, Ternary, BooleanAnd, BooleanOr stop implementing TypeResolv…
ondrejmirtes b3197c9
Add regression test for conditional holders narrowing coalesce of pro…
ondrejmirtes 7ebb050
Never process expressions on a FiberScope
ondrejmirtes b48a9c5
Convert rule-facing FiberScope at the new-world hook boundary
ondrejmirtes 5fdb451
Guard that only synthetic nodes reach the pending-fiber on-demand path
ondrejmirtes eb81e63
Fix immediately-invoked-closure fiber flush; make the new-world guard…
ondrejmirtes eaeba8f
Flush pending fibers only at scope boundaries; process dropped call args
ondrejmirtes 92cc156
Add PHPSTAN_GUARD_NW guard: no getType on a real node before processE…
ondrejmirtes 8759198
BitwiseNotHandler is no longer TypeResolvingExprHandler
ondrejmirtes 5b01972
One more should-not
ondrejmirtes 3bfef7c
UnaryMinusHandler is no longer TypeResolvingExprHandler
ondrejmirtes a9fc38f
UnaryPlusHandler is no longer TypeResolvingExprHandler
ondrejmirtes e2843b6
ConstFetchHandler is no longer TypeResolvingExprHandler
ondrejmirtes 7838476
PrintHandler is no longer TypeResolvingExprHandler
ondrejmirtes 23e7cdd
ThrowHandler is no longer TypeResolvingExprHandler
ondrejmirtes 65b57ce
ExitHandler is no longer TypeResolvingExprHandler
ondrejmirtes 21ebb5e
EvalHandler is no longer TypeResolvingExprHandler
ondrejmirtes 4f90ae7
IncludeHandler is no longer TypeResolvingExprHandler
ondrejmirtes 90e32ad
YieldFromHandler is no longer TypeResolvingExprHandler
ondrejmirtes 1a9a69a
ClassConstFetchHandler is no longer TypeResolvingExprHandler
ondrejmirtes c2e0806
InterpolatedStringHandler is no longer TypeResolvingExprHandler
ondrejmirtes f28c52f
CloneHandler is no longer TypeResolvingExprHandler
ondrejmirtes af23a79
YieldHandler is no longer TypeResolvingExprHandler
ondrejmirtes 0c78464
AlwaysRememberedExprHandler is no longer TypeResolvingExprHandler
ondrejmirtes 225cc29
NativeTypeExprHandler is no longer TypeResolvingExprHandler
ondrejmirtes 0e4cb92
FunctionCallableNodeHandler is no longer TypeResolvingExprHandler
ondrejmirtes 97f60ed
MethodCallableNodeHandler is no longer TypeResolvingExprHandler
ondrejmirtes acf2185
StaticMethodCallableNodeHandler is no longer TypeResolvingExprHandler
ondrejmirtes 9bb2c01
InstantiationCallableNodeHandler is no longer TypeResolvingExprHandler
ondrejmirtes 140482b
TypeExprHandler is no longer TypeResolvingExprHandler
ondrejmirtes 431f847
Fix failure of forwarding ExpressionResult
ondrejmirtes 09065ca
ErrorSuppressHandler is no longer TypeResolvingExprHandler
ondrejmirtes ee55581
CastHandler is no longer TypeResolvingExprHandler
ondrejmirtes d40d377
CastStringHandler is no longer TypeResolvingExprHandler
ondrejmirtes f77c8de
PostIncHandler is no longer TypeResolvingExprHandler
ondrejmirtes 1fad852
PostDecHandler is no longer TypeResolvingExprHandler
ondrejmirtes f92af63
PipeHandler is no longer TypeResolvingExprHandler
ondrejmirtes bf43d04
PreIncHandler is no longer TypeResolvingExprHandler
ondrejmirtes a9950bf
PreDecHandler is no longer TypeResolvingExprHandler
ondrejmirtes 873cd34
AssignOpHandler is no longer TypeResolvingExprHandler
ondrejmirtes bfaea31
AssignHandler is no longer TypeResolvingExprHandler
ondrejmirtes 8bbf880
Track containsNullsafe on ExpressionResult and propagate it through f…
ondrejmirtes c017942
PropertyFetchHandler is no longer TypeResolvingExprHandler
ondrejmirtes 9a89588
StaticPropertyFetchHandler is no longer TypeResolvingExprHandler
ondrejmirtes 3e4e367
Store ArrayDimFetch assign-target results with a typeCallback
ondrejmirtes d4fdf57
ArrayDimFetchHandler is no longer TypeResolvingExprHandler
ondrejmirtes 3ea7cdd
Introduce IssetabilityDescriptor and fold it in MutatingScope::issetC…
ondrejmirtes a8cf306
Move issetCheck onto ExpressionResult with isset()/empty() convenience
ondrejmirtes 38995a2
CoalesceHandler reads issetCheck from the left result instead of the …
ondrejmirtes 4c46aa4
EmptyHandler is no longer TypeResolvingExprHandler
ondrejmirtes 7b09a80
Match issetCheckUndefined ordering in IssetabilityDescriptor::checkUn…
ondrejmirtes ba726dd
Re-evaluate getCurrentTypesOfSpecifiedExpr on the asking scope
ondrejmirtes 2bad7b0
Rules\IssetCheck folds IssetabilityDescriptor instead of re-walking t…
ondrejmirtes d339180
MatchHandler is no longer TypeResolvingExprHandler
ondrejmirtes 4c784db
NullsafePropertyFetchHandler and NullsafeMethodCallHandler are no lon…
ondrejmirtes 31888e7
Move first-class callable type resolution into the *CallableNode hand…
ondrejmirtes f3371dc
Price synthetic narrowing expressions on demand in getCurrentTypesOfS…
ondrejmirtes fad3c7b
BinaryOpHandler and BooleanNotHandler are no longer TypeResolvingExpr…
ondrejmirtes 7ac47a9
Fix getIssetabilityDescriptor shadowed by descriptor-less assignment-…
ondrejmirtes 00ca7a5
Eliminate the OriginalPropertyTypeExpr virtual node
ondrejmirtes d82266b
Eliminate the GetOffsetValueTypeExpr virtual node
ondrejmirtes 4b95a42
Eliminate the GetIterableKeyTypeExpr virtual node
ondrejmirtes 254d9ff
Eliminate the GetIterableValueTypeExpr virtual node
ondrejmirtes 0e0c238
ExistingArrayDimFetchHandler is no longer TypeResolvingExprHandler
ondrejmirtes a877de7
UnsetOffsetExprHandler is no longer TypeResolvingExprHandler
ondrejmirtes d869c72
SetOffsetValueTypeExprHandler is no longer TypeResolvingExprHandler
ondrejmirtes 9a6fadc
SetExistingOffsetValueTypeExprHandler is no longer TypeResolvingExprH…
ondrejmirtes 6e617eb
Read operand types from ExpressionResults in Throw/BooleanAnd/Coalesc…
ondrejmirtes 2f80158
Read operand types from ExpressionResults in Ternary/ArrayDimFetch/Pr…
ondrejmirtes 6963841
Read sub-expression types from ExpressionResults in offset Virtual ha…
ondrejmirtes 11c97c0
Read child/narrowed types from results instead of Scope::getType in l…
ondrejmirtes d2e2cde
Process synthetic offsetGet/callable nodes in processExpr, read resul…
ondrejmirtes b043f84
Add readStoredOrPriceOnDemand/priceSyntheticOnDemand and use them ins…
ondrejmirtes 414974e
Price synthetic unary-minus operand on demand instead of Scope::getType
ondrejmirtes 66c8df2
Read child/synthetic types via result or helpers in Match/BinaryOp/Eq…
ondrejmirtes d422c46
Thread NodeScopeResolver into narrowing/throw-point helpers to avoid …
ondrejmirtes 214869a
Read child/synthetic types via results or helpers in AssignHandler's …
ondrejmirtes 46a53f8
Read expr types via results or helpers in NodeScopeResolver instead o…
ondrejmirtes bcd0e02
Correct the explanation of the two load-bearing Scope::getType() exce…
ondrejmirtes 53e4fa3
Read Identical operand types from results in RicherScopeGetTypeHelper…
ondrejmirtes 259d4c1
Read expr types from results in SpecifiedTypes::normalize when called…
ondrejmirtes 3dd027b
Read assign-target sub-expression types from their results instead of…
ondrejmirtes 9f0a479
Read while-loop condition type from its result instead of the on-dema…
ondrejmirtes 376ea07
Pass already-computed results into ImplicitToStringCallHelper and rea…
ondrejmirtes 5a1230a
NSRT test for precise Scope
ondrejmirtes 0b14737
Extract intrinsic argument parameter overrides from selectFromArgs in…
ondrejmirtes bc198cf
Resolve argument types on an arg-to-arg evolving scope and select the…
ondrejmirtes d064584
FuncCallHandler is no longer TypeResolvingExprHandler
ondrejmirtes 7f2b9fc
MethodCallHandler is no longer TypeResolvingExprHandler
ondrejmirtes 5e03760
NewHandler is no longer TypeResolvingExprHandler
ondrejmirtes b1f5af5
StaticCallHandler is no longer TypeResolvingExprHandler
ondrejmirtes 7257b5b
Extract combineVariantsForNormalization into a shared ParametersAccep…
ondrejmirtes 4c1ffb2
Add regression test for #13253
ondrejmirtes 0d85dce
Add regression test for #14396
ondrejmirtes 125cf22
Call handleDefaultTruthyOrFalseyContext on $this->typeSpecifier in mi…
ondrejmirtes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| <?php declare(strict_types = 1); | ||
|
|
||
| namespace PHPStan\Analyser; | ||
|
|
||
| use PHPStan\Reflection\ParametersAcceptor; | ||
|
|
||
| /** | ||
| * Result of NodeScopeResolver::processArgs(): the scope/throw/impure state after | ||
| * processing all arguments (wrapped ExpressionResult) plus the ParametersAcceptor | ||
| * resolved from the arg types gathered on the arg-to-arg evolving scope. The | ||
| * resolved acceptor is type-driven (selectFromTypes) so its generics are resolved | ||
| * against the actual argument types - callers wire it into the call expression's | ||
| * stored return type. Null when the call had no variants (dynamic callee). | ||
| */ | ||
| final class ArgsResult | ||
| { | ||
|
|
||
| public function __construct( | ||
| private ExpressionResult $expressionResult, | ||
| private ?ParametersAcceptor $resolvedParametersAcceptor, | ||
| ) | ||
| { | ||
| } | ||
|
|
||
| public function getScope(): MutatingScope | ||
| { | ||
| return $this->expressionResult->getScope(); | ||
| } | ||
|
|
||
| public function hasYield(): bool | ||
| { | ||
| return $this->expressionResult->hasYield(); | ||
| } | ||
|
|
||
| public function isAlwaysTerminating(): bool | ||
| { | ||
| return $this->expressionResult->isAlwaysTerminating(); | ||
| } | ||
|
|
||
| /** | ||
| * @return InternalThrowPoint[] | ||
| */ | ||
| public function getThrowPoints(): array | ||
| { | ||
| return $this->expressionResult->getThrowPoints(); | ||
| } | ||
|
|
||
| /** | ||
| * @return ImpurePoint[] | ||
| */ | ||
| public function getImpurePoints(): array | ||
| { | ||
| return $this->expressionResult->getImpurePoints(); | ||
| } | ||
|
|
||
| public function getResolvedParametersAcceptor(): ?ParametersAcceptor | ||
| { | ||
| return $this->resolvedParametersAcceptor; | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this read
withFiber?