classReferenceEvaluator
final class ReferenceEvaluator
Reads the value behind a name: a variable, a property, a constant or an element.
Methods§
public function __construct(ProgramIndex $index, ExternalInput $external, NodeText $text)Wires the reader to the declarations it resolves names against.
Parameters
$index | ProgramIndex | |
$external | ExternalInput | |
$text | NodeText |
Calls 1
public function evaluate(
Expr $node,
Environment $environment,
FunctionScope $scope,
ExpressionEvaluator $expressions,
): ?DomainThe value behind the reference, or null when the expression is not one.
Parameters
$node | Expr | |
$environment | Environment | |
$scope | FunctionScope | |
$expressions | ExpressionEvaluator |
Returns
Test cases 2
Called from 1
Calls 9
- method-call ReferenceEvaluator::readVariable() line 58
- method-call ReferenceEvaluator::readArray() line 61
- method-call ReferenceEvaluator::readElement() line 64
- method-call ConstantReader::readConstant() line 67
- method-call ConstantReader::readClassConstant() line 70
- method-call ReferenceEvaluator::readProperty() line 74
- method-call ReferenceEvaluator::readInstance() line 77
- static-call Domain::of() line 80
- new ObjectTerm line 80
public function readVariable(
Variable $node,
Environment $environment,
FunctionScope $scope,
): DomainThe value bound to a variable, or what is known about it when it is external.
Parameters
$node | Variable | |
$environment | Environment | |
$scope | FunctionScope |
Returns
Test cases 4
ReferenceEvaluatorTest::testReadVariableGivesUpOnAVariableVariablecallsReferenceEvaluatorTest::testReadVariableNamesTheExternalInputItReadscallsReferenceEvaluatorTest::testReadVariablePreservesProvenanceAndDomainFlagsWhileNamingOpaqueValuescallsReferenceEvaluatorTest::testReadVariableResolvesThisToTheEnclosingClasscalls
Called from 1
Calls 9
- function-call
is_stringline 91 - static-call Domain::opaque() line 92
- static-call TypeShape::unknown() line 92
- class-const Origin::Unresolved() line 92
- static-call Domain::of() line 97
- new ObjectTerm line 97
- method-call ExternalInput::isVariable() line 99
- class-const Origin::External() line 100
- method-call Environment::read() line 103
public function readArray(
Array_ $node,
Environment $environment,
FunctionScope $scope,
ExpressionEvaluator $expressions,
): DomainThe array an array literal builds.
Parameters
$node | Array_ | |
$environment | Environment | |
$scope | FunctionScope | |
$expressions | ExpressionEvaluator |
Returns
Test cases 3
Called from 1
Calls 4
- new ArrayEntry line 122
- method-call ExpressionEvaluator::evaluate() line 123
- static-call Domain::of() line 128
- new ArrayTerm line 128
public function readElement(
ArrayDimFetch $node,
Environment $environment,
FunctionScope $scope,
ExpressionEvaluator $expressions,
): DomainThe value of an array element.
A key that resolved reads the element written under it. A key that did not — self::TABLES[$kind] with $kind coming from a request — reads every element the array holds: whatever the key turns out to be, the value is one of them, and an array written out in full lists them all.
Parameters
$node | ArrayDimFetch | |
$environment | Environment | |
$scope | FunctionScope | |
$expressions | ExpressionEvaluator |
Returns
Test cases 1
Called from 1
Calls 5
- method-call ExpressionEvaluator::evaluate() line 145
- method-call NodeText::render() line 148
- static-call Domain::opaque() line 150
- static-call TypeShape::unknown() line 150
- method-call ReferenceEvaluator::originOf() line 150
Where the unresolved parts of a domain come from.
Parameters
$domain | Domain |
Returns
Test cases 2
Called from 2
Calls 2
- class-const Origin::Unresolved() line 158
- class-const Origin::External() line 160
public function readProperty(
PropertyFetch|NullsafePropertyFetch|StaticPropertyFetch $node,
Environment $environment,
FunctionScope $scope,
ExpressionEvaluator $expressions,
): DomainThe value of a property read, resolving a settled default when there is one.
A static property is read the same way: self::$tables declared with a default and assigned nowhere else holds that default for the life of the process, which makes it a constant spelled as a property.
Parameters
$node | PropertyFetch|NullsafePropertyFetch|StaticPropertyFetch | |
$environment | Environment | |
$scope | FunctionScope | |
$expressions | ExpressionEvaluator |
Returns
Test cases 4
ReferenceEvaluatorTest::testReadPropertyIsCalledWithTheExpressionItselfcallsReferenceEvaluatorTest::testReadPropertyPrefersWhatTheBodyAssignedEarliercallsReferenceEvaluatorTest::testReadPropertyQuotesAPropertyItCannotNamecallsReferenceEvaluatorTest::testReadPropertyQuotesAStaticPropertyWhoseClassItCannotNamecalls
Called from 1
Calls 13
- method-call ReferenceEvaluator::trackedName() line 184
- method-call Environment::has() line 185
- method-call Environment::read() line 186
- method-call ConstantReader::resolveClassName() line 191
- method-call ExpressionEvaluator::evaluate() line 193
- static-call Domain::opaque() line 197
- static-call TypeShape::unknown() line 197
- class-const Origin::Property() line 197
- method-call NodeText::render() line 197
- method-call ReferenceEvaluator::readEnumProperty() line 200
- method-call ProgramIndex::lineage() line 205
- new Environment line 208
- method-call ProgramIndex::findPropertyType() line 212
public function readEnumProperty(
Domain $receiver,
string $owner,
string $property,
FunctionScope $scope,
ExpressionEvaluator $expressions,
): ?DomainThe value behind ->value or ->name on an enum.
A value typed as a backed enum can only ever be one of that enum's cases, so reading its backing value resolves to the union of them. That is what turns a parameter typed Status into the handful of strings the column can hold rather than an opaque string.
Parameters
$receiver | Domain | |
$owner | string | |
$property | string | |
$scope | FunctionScope | |
$expressions | ExpressionEvaluator |
Returns
Test cases 3
Called from 1
Calls 5
- method-call ProgramIndex::findClass() line 232
- method-call Domain::soleObject() line 237
- static-call Domain::literal() line 244
- method-call ExpressionEvaluator::evaluate() line 245
- new Environment line 245
public function readInstance(New_ $node, FunctionScope $scope): DomainThe object an instantiation produces.
Parameters
$node | New_ | |
$scope | FunctionScope |
Returns
Test cases 2
Called from 1
Calls 6
- method-call ConstantReader::resolveClassName() line 257
- static-call Domain::opaque() line 260
- static-call TypeShape::of() line 260
- class-const Origin::Unresolved() line 260
- static-call Domain::of() line 261
- new ObjectTerm line 261
public function trackedName(Expr $target): ?stringThe name a target is tracked under in the environment, or null when it is not tracked.
A variable is tracked under its name, and a property of $this under this->property, so that assigning it earlier in a body is seen when it is read later in the same body.
Parameters
$target | Expr |
Returns
?stringTest cases 1
Called from 4
- method-call SqlCatalog\Core\Analysis\ReferenceEvaluator::readProperty() packages/sql-catalog/src/Core/Analysis/ReferenceEvaluator.php:184
- method-call SqlCatalog\Core\Analysis\ReferenceEvaluator::assign() packages/sql-catalog/src/Core/Analysis/ReferenceEvaluator.php:297
- method-call SqlCatalog\Core\Analysis\ReferenceEvaluator::assignElement() packages/sql-catalog/src/Core/Analysis/ReferenceEvaluator.php:366
- method-call SqlCatalog\Core\Analysis\ReferenceEvaluator::loseTrack() packages/sql-catalog/src/Core/Analysis/ReferenceEvaluator.php:395
Calls 1
- function-call
is_stringline 274
public function assign(
Expr $target,
Domain $value,
Environment $environment,
FunctionScope $scope,
ExpressionEvaluator $expressions,
): voidWrites a value to whatever the target expression names.
Parameters
$target | Expr | |
$value | Domain | |
$environment | Environment | |
$scope | FunctionScope | |
$expressions | ExpressionEvaluator |
Test cases 1
Called from 4
- method-call SqlCatalog\Core\Analysis\ExpressionEvaluator::evaluateAssign() packages/sql-catalog/src/Core/Analysis/ExpressionEvaluator.php:373
- method-call SqlCatalog\Core\Analysis\ExpressionEvaluator::evaluateAppend() packages/sql-catalog/src/Core/Analysis/ExpressionEvaluator.php:385
- method-call SqlCatalog\Core\Analysis\ReferenceEvaluator::assignList() packages/sql-catalog/src/Core/Analysis/ReferenceEvaluator.php:342
- method-call SqlCatalog\Core\Analysis\ReferenceEvaluator::assignElement() packages/sql-catalog/src/Core/Analysis/ReferenceEvaluator.php:373
Calls 8
- new WriteEffects line 295
- method-call ReferenceEvaluator::trackedName() line 297
- method-call Environment::write() line 299
- method-call ExpressionEvaluator::evaluate() line 304
- method-call Environment::objects() line 307
- new ObjectTerm line 307
- method-call ReferenceEvaluator::assignElement() line 314
- method-call ReferenceEvaluator::assignList() line 319
public function assignList(
List_|Array_ $target,
Domain $value,
Environment $environment,
FunctionScope $scope,
ExpressionEvaluator $expressions,
): voidWrites the elements of an array into the targets a destructuring assignment lists.
Parameters
$target | List_|Array_ | |
$value | Domain | |
$environment | Environment | |
$scope | FunctionScope | |
$expressions | ExpressionEvaluator |
Test cases 5
ReferenceEvaluatorTest::testAssignListDescendsIntoANestedListcallsReferenceEvaluatorTest::testAssignListLeavesAGapCarryingTheOriginOfAValueThatIsNotAKnownArraycallsReferenceEvaluatorTest::testAssignListLeavesAGapForAnElementTheArrayDoesNotHoldcallsReferenceEvaluatorTest::testAssignListReadsAKeyedTargetByItsKeycallsReferenceEvaluatorTest::testAssignListWritesEachElementIntoTheTargetAtItsPositioncalls
Called from 1
Calls 7
- method-call Domain::soleArray() line 333
- method-call ExpressionEvaluator::evaluate() line 340
- method-call ReferenceEvaluator::assign() line 342
- static-call Domain::opaque() line 344
- static-call TypeShape::unknown() line 344
- method-call ReferenceEvaluator::originOf() line 344
- method-call NodeText::render() line 344
public function assignElement(
ArrayDimFetch $target,
Domain $value,
Environment $environment,
FunctionScope $scope,
ExpressionEvaluator $expressions,
): voidWrites a value into an array held by a tracked name, keeping the key when one is written.
A write one level down, such as $parts['where'][] = …, is not followed element by element: the array it goes into is marked as no longer known in full, so reading it back never claims to have seen all of it.
Parameters
$target | ArrayDimFetch | |
$value | Domain | |
$environment | Environment | |
$scope | FunctionScope | |
$expressions | ExpressionEvaluator |
Test cases 3
Called from 1
Calls 11
- method-call ReferenceEvaluator::trackedName() line 366
- method-call ReferenceEvaluator::assign() line 373
- static-call Domain::unknown() line 373
- method-call ReferenceEvaluator::loseTrack() line 375
- method-call ExpressionEvaluator::evaluate() line 379
- method-call Environment::has() line 380
- method-call Environment::read() line 380
- new ArrayEntry line 382
- method-call Environment::write() line 384
- static-call Domain::of() line 384
- new ArrayTerm line 384
public function loseTrack(Expr $target, Environment $environment): voidMarks the array a nested write goes into as no longer known in full.
Parameters
$target | Expr | |
$environment | Environment |
Test cases 3
Called from 1
Calls 6
- method-call ReferenceEvaluator::trackedName() line 395
- method-call Environment::has() line 396
- method-call Environment::read() line 396
- method-call Environment::write() line 398
- static-call Domain::of() line 398
- new ArrayTerm line 398
Private surface 5§
Implementation details, listed for orientation only.
private ProgramIndex $indexprivate ExternalInput $externalprivate NodeText $textprivate ConstantReader $constantsprivate ?WriteEffects $effects = nullTest cases 57§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 34
ReferenceEvaluatorTest::testAssignElementIgnoresATargetItCannotNamecallsReferenceEvaluatorTest::testAssignElementKeepsWhetherTheArrayIsKnownInFullcallsReferenceEvaluatorTest::testAssignElementMarksTheArrayANestedWriteGoesIntoAsIncompletecallsReferenceEvaluatorTest::testAssignLeavesATargetItDoesNotTrackAlonecallsReferenceEvaluatorTest::testAssignListDescendsIntoANestedListcallsReferenceEvaluatorTest::testAssignListLeavesAGapCarryingTheOriginOfAValueThatIsNotAKnownArraycallsReferenceEvaluatorTest::testAssignListLeavesAGapForAnElementTheArrayDoesNotHoldcallsReferenceEvaluatorTest::testAssignListReadsAKeyedTargetByItsKeycallsReferenceEvaluatorTest::testAssignListWritesEachElementIntoTheTargetAtItsPositioncallsReferenceEvaluatorTest::testEvaluateOnlyAnswersForReferencescallsReferenceEvaluatorTest::testEvaluateReadsAnInstantiationAStaticPropertyAndAClosurecallsReferenceEvaluatorTest::testLoseTrackLeavesAnythingThatIsNotATrackedArrayAlonecallsReferenceEvaluatorTest::testLoseTrackMarksAnArrayHeldByAPropertyOfThisAsIncompletecallsReferenceEvaluatorTest::testLoseTrackMarksTheArrayANestedWriteGoesIntoAsIncompletecallsReferenceEvaluatorTest::testOriginOfIsTheOriginOfTheFirstGapUnlessAnyGapIsExternalInputcallsReferenceEvaluatorTest::testOriginOfReportsExternalInputWhenAnyTermCarriesItcallsReferenceEvaluatorTest::testReadArrayIsCalledWithTheExpressionItselfcallsReferenceEvaluatorTest::testReadArrayKeepsTheElementsWrittenAfterAnUnpackingcallsReferenceEvaluatorTest::testReadArrayKnowsALiteralWithoutUnpackingInFullcallsReferenceEvaluatorTest::testReadElementIsCalledWithTheExpressionItselfcallsReferenceEvaluatorTest::testReadEnumPropertyIgnoresAClassTheSourceDoesNotDeclarecallsReferenceEvaluatorTest::testReadEnumPropertyOnlyAnswersForAnEnumcallsReferenceEvaluatorTest::testReadEnumPropertyReadsTheCaseTheValueIscallsReferenceEvaluatorTest::testReadInstanceGivesUpOnAnExpressionClasscallsReferenceEvaluatorTest::testReadInstanceResolvesStaticToTheEnclosingClasscallsReferenceEvaluatorTest::testReadPropertyIsCalledWithTheExpressionItselfcallsReferenceEvaluatorTest::testReadPropertyPrefersWhatTheBodyAssignedEarliercallsReferenceEvaluatorTest::testReadPropertyQuotesAPropertyItCannotNamecallsReferenceEvaluatorTest::testReadPropertyQuotesAStaticPropertyWhoseClassItCannotNamecallsReferenceEvaluatorTest::testReadVariableGivesUpOnAVariableVariablecallsReferenceEvaluatorTest::testReadVariableNamesTheExternalInputItReadscallsReferenceEvaluatorTest::testReadVariablePreservesProvenanceAndDomainFlagsWhileNamingOpaqueValuescallsReferenceEvaluatorTest::testReadVariableResolvesThisToTheEnclosingClasscallsReferenceEvaluatorTest::testTrackedNameNamesAVariableOrAPropertyOfThiscalls
Other tests reaching this symbol 23
CatalogCommandTestcallsCallEvaluatorTestcallsConstantReaderTestcallsCalleeReturnsTestcallsCallersTestcallsDeriverTestcallsEntryBinderTestcallsCallbackEffectsTestcallsPropertyWritesTestcallsSliceExecutorTestcallsExpressionEvaluatorTestcallsRegistryTestcallsInterpreterTestcallsModelQueriesTestcallsCallContextTestcallsQueryModelInterfaceTestcallsBuilderCallsTestcallsBuilderQueriesTestcallsCallbackModelTestcallsCallModelTestcallsAnalyzerTestcallsJsonReporterTestcallsTextReporterTestcalls
Relations§
Instantiated in 1
Method calls 3
- method-call SqlCatalog\Core\Analysis\ExpressionEvaluator::evaluate() packages/sql-catalog/src/Core/Analysis/ExpressionEvaluator.php:79
- method-call SqlCatalog\Core\Analysis\ExpressionEvaluator::evaluateAssign() packages/sql-catalog/src/Core/Analysis/ExpressionEvaluator.php:373
- method-call SqlCatalog\Core\Analysis\ExpressionEvaluator::evaluateAppend() packages/sql-catalog/src/Core/Analysis/ExpressionEvaluator.php:385
Type declarations 3
- type SqlCatalog\Core\Analysis\ExpressionEvaluator packages/sql-catalog/src/Core/Analysis/ExpressionEvaluator.php:25
- type SqlCatalog\Core\Analysis\ExpressionEvaluator packages/sql-catalog/src/Core/Analysis/ExpressionEvaluator.php:39
- type SqlCatalog\Core\Analysis\ExpressionEvaluator packages/sql-catalog/src/Core/Analysis/ExpressionEvaluator.php:53