classConstantReader
final class ConstantReader
Reads constants: global ones, class ones, enum cases and ::class.
A constant is a value the source writes down once and names everywhere else, which is exactly the kind of value that decides a table or a column name, so it is resolved to what the declaration says.
Methods§
public function __construct(ProgramIndex $index, NodeText $text)Wires the reader to the declarations it resolves names against.
Parameters
$index | ProgramIndex | |
$text | NodeText |
public function readConstant(
ConstFetch $node,
FunctionScope $scope,
ExpressionEvaluator $expressions,
): DomainThe value of a global constant.
Parameters
$node | ConstFetch | |
$scope | FunctionScope | |
$expressions | ExpressionEvaluator |
Returns
Test cases 2
Called from 1
Calls 7
- method-call ConstantReader::constantName() line 46
- function-call
strtolowerline 47 - static-call Domain::literal() line 49
- method-call ProgramIndex::findConstant() line 55
- method-call ExpressionEvaluator::evaluate() line 57
- new Environment line 57
- method-call ConstantReader::readRuntimeConstant() line 60
public function constantName(ConstFetch $node): stringThe name a constant reference resolves to.
An unqualified constant is looked for in its own namespace first and in the global one second, which is the order PHP itself resolves it in.
Parameters
$node | ConstFetch |
Returns
stringTest cases 2
Called from 1
Calls 1
- method-call ProgramIndex::findConstant() line 72
public function readRuntimeConstant(string $name): DomainThe value of a constant the running process already defines.
Parameters
$name | string |
Returns
Test cases 2
Called from 1
Calls 10
- function-call
ltrimline 84 - function-call
str_starts_withline 85 - function-call
definedline 85 - static-call Domain::opaque() line 86
- static-call TypeShape::unknown() line 86
- class-const Origin::Unresolved() line 86
- function-call
constantline 88 - function-call
is_scalarline 90 - static-call Domain::literal() line 90
- static-call Domain::unknown() line 90
public function readClassConstant(
ClassConstFetch $node,
FunctionScope $scope,
ExpressionEvaluator $expressions,
): DomainThe value of a class constant, an enum case, or a ::class reference.
Parameters
$node | ClassConstFetch | |
$scope | FunctionScope | |
$expressions | ExpressionEvaluator |
Returns
Test cases 6
ConstantReaderTest::testReadClassConstantGivesUpOnAConstantNothingDeclarescallsConstantReaderTest::testReadClassConstantGivesUpWhenTheClassIsNotWrittencallsConstantReaderTest::testReadClassConstantQuotesWhatItCouldNotReadcallsConstantReaderTest::testReadClassConstantReadsTheClassKeywordWhateverItsCasecallsConstantReaderTest::testReadClassConstantReadsWhatTheClassDeclarescallsConstantReaderTest::testReadClassConstantTellsAnEnumCaseFromAConstantOfTheEnumcalls
Called from 1
Calls 14
- method-call ConstantReader::resolveClassName() line 101
- static-call Domain::opaque() line 104
- static-call TypeShape::unknown() line 104
- class-const Origin::Unresolved() line 104
- method-call NodeText::render() line 104
- function-call
strtolowerline 106 - static-call Domain::literal() line 107
- method-call ProgramIndex::findClass() line 110
- function-call
array_key_existsline 111 - static-call Domain::of() line 112
- new ObjectTerm line 112
- method-call ProgramIndex::findClassConstant() line 115
- method-call ExpressionEvaluator::evaluate() line 119
- new Environment line 119
public function resolveClassName(Name|Expr|Class_ $reference, FunctionScope $scope): ?stringThe class a written class reference names, resolving self and static.
Parameters
$reference | Name|Expr|Class_ | |
$scope | FunctionScope |
Returns
?stringTest cases 2
Called from 3
- method-call SqlCatalog\Core\Analysis\ConstantReader::readClassConstant() packages/sql-catalog/src/Core/Analysis/ConstantReader.php:101
- method-call SqlCatalog\Core\Analysis\ReferenceEvaluator::readProperty() packages/sql-catalog/src/Core/Analysis/ReferenceEvaluator.php:191
- method-call SqlCatalog\Core\Analysis\ReferenceEvaluator::readInstance() packages/sql-catalog/src/Core/Analysis/ReferenceEvaluator.php:257
Calls 1
- function-call
strtolowerline 132
Private surface 2§
Implementation details, listed for orientation only.
private ProgramIndex $indexprivate NodeText $textTest cases 37§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 14
ConstantReaderTest::testConstantNamePrefersTheOneTheNamespaceDeclarescallsConstantReaderTest::testConstantNameReadsTheNamespacedConstantOnlyWhenTheNamespaceDeclaresItcallsConstantReaderTest::testReadClassConstantGivesUpOnAConstantNothingDeclarescallsConstantReaderTest::testReadClassConstantGivesUpWhenTheClassIsNotWrittencallsConstantReaderTest::testReadClassConstantQuotesWhatItCouldNotReadcallsConstantReaderTest::testReadClassConstantReadsTheClassKeywordWhateverItsCasecallsConstantReaderTest::testReadClassConstantReadsWhatTheClassDeclarescallsConstantReaderTest::testReadClassConstantTellsAnEnumCaseFromAConstantOfTheEnumcallsConstantReaderTest::testReadConstantReadsTheKeywordsWhateverTheirCasecallsConstantReaderTest::testReadConstantResolvesTheKeywordsAndTheDeclarationscallsConstantReaderTest::testReadRuntimeConstantOnlyTrustsThePhpConstantscallsConstantReaderTest::testReadRuntimeConstantReadsAFullyQualifiedNamecallsConstantReaderTest::testResolveClassNameResolvesEveryKeywordForTheEnclosingClasscallsConstantReaderTest::testResolveClassNameResolvesTheSelfKeywordscalls
Other tests reaching this symbol 23
CatalogCommandTestcallsCallEvaluatorTestcallsCalleeReturnsTestcallsCallersTestcallsDeriverTestcallsEntryBinderTestcallsCallbackEffectsTestcallsPropertyWritesTestcallsSliceExecutorTestcallsExpressionEvaluatorTestcallsRegistryTestcallsInterpreterTestcallsModelQueriesTestcallsReferenceEvaluatorTestcallsCallContextTestcallsQueryModelInterfaceTestcallsBuilderCallsTestcallsBuilderQueriesTestcallsCallbackModelTestcallsCallModelTestcallsAnalyzerTestcallsJsonReporterTestcallsTextReporterTestcalls
Relations§
Instantiated in 1
Method calls 4
- method-call SqlCatalog\Core\Analysis\ReferenceEvaluator::evaluate() packages/sql-catalog/src/Core/Analysis/ReferenceEvaluator.php:67
- method-call SqlCatalog\Core\Analysis\ReferenceEvaluator::evaluate() packages/sql-catalog/src/Core/Analysis/ReferenceEvaluator.php:70
- method-call SqlCatalog\Core\Analysis\ReferenceEvaluator::readProperty() packages/sql-catalog/src/Core/Analysis/ReferenceEvaluator.php:191
- method-call SqlCatalog\Core\Analysis\ReferenceEvaluator::readInstance() packages/sql-catalog/src/Core/Analysis/ReferenceEvaluator.php:257