classDeclaredGlobals
final class DeclaredGlobals
What the global variables a body declares are known to hold.
global $wpdb; leaves nothing in the statement for the analyzer to read a type from, and the handle an application hands out that way is often the one every statement it issues goes through. Losing it loses the statements with it, so two things are allowed to say what the name stands for: the @global or @var tag documenting the declaration, which is how an application says it in its own source, and an extension, which is how a framework's handle is known without the application having said anything.
Methods§
public function __construct(array<string, string> $declared = [])Parameters
$declared | array<string, string> | Class names, keyed by the variable name written without its `$` |
public function classOf(Global_ $statement, string $name): ?stringThe class a declared global holds, or null when nothing says what it holds.
Parameters
$statement | Global_ | |
$name | string |
Returns
?stringTest cases 2
Called from 1
Calls 1
- method-call DeclaredGlobals::documented() line 43
public function declared(string $name): ?stringThe class an extension declares a global to hold, or null when none does.
Code at the top of a file reads globals without declaring them, so there is no global statement for a tag to be written on; what an extension says is all there is to go on.
Parameters
$name | string |
Returns
?stringTest cases 2
public function documented(Global_ $statement, string $name): ?stringThe class a doc comment around the declaration gives the variable, or null when none does.
Parameters
$statement | Global_ | |
$name | string |
Returns
?stringTest cases 2
Called from 1
Calls 2
- method-call DeclaredGlobals::comments() line 63
- method-call DeclaredGlobals::tagged() line 64
public function comments(Global_ $statement): list<string>The doc comments that can document the declaration, nearest first.
The tag naming the type is written on the declaration the global statement is in far more often than on the statement itself, so the search climbs to the enclosing function and stops there: beyond it the comment documents something else.
Parameters
$statement | Global_ |
Returns
list<string>Called from 1
public function tagged(string $comment, string $name): ?stringThe class an @global or @var tag gives the variable, or null when neither does.
Parameters
$comment | string | |
$name | string |
Returns
?stringTest cases 1
Called from 1
Private surface 1§
Implementation details, listed for orientation only.
private array<string, string> $declaredTest cases 38§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 8
DeclaredGlobalsTest::testClassOfIsSilentWhenNothingSaysWhatTheGlobalHoldscallsDeclaredGlobalsTest::testClassOfNamesAGlobalAnExtensionDeclarescallsDeclaredGlobalsTest::testCommentsClimbToTheDeclarationTheGlobalIsWrittenIncallsDeclaredGlobalsTest::testDeclaredIsSilentForAGlobalNoExtensionDeclarescallsDeclaredGlobalsTest::testDeclaredNamesTheClassAnExtensionGivesAGlobalcallsDeclaredGlobalsTest::testDocumentedIsSilentWhenNoTagNamesTheVariablecallsDeclaredGlobalsTest::testDocumentedReadsTheTagOnTheEnclosingDeclarationcallsDeclaredGlobalsTest::testTaggedReadsTheClassOutOfADocCommentcalls
Other tests reaching this symbol 30
CatalogCommandTestcallsCallEvaluatorTestcallsConstantReaderTestcallsCalleeReturnsTestcallsCallersTestcallsDeriverTestcallsEntryBinderTest::testFileScopeBindsTheGlobalsAnExtensionDeclarescallsEntryBinderTest::testParameterBindingsReadWhatTheTopOfAFileIsDeclaredToHoldcallsCallbackEffectsTestcallsPropertyWritesTestcallsSliceExecutorTest::testApplyBindsADeclarationcallsSliceExecutorTest::testDeclareGlobalTakesTheClassTheNameIsKnownToHoldcallsSliceExecutorTest::testDeclareStaticNeverTakesAClasscallsExpressionEvaluatorTestcallsRegistryTestcallsInterpreterTest::testAnalyzeRecordsNothingAtACallThatOnlyComposesAStatementcallsInterpreterTest::testReceiverOfWorksOutWhatAMethodIsCalledOncallsModelQueriesTestcallsReferenceEvaluatorTestcallsCallContextTestcallsModelContextTest::testKeepsTheModelContractInputscallsQueryModelInterfaceTestcallsBuilderCallsTestcallsBuilderQueriesTestcallsCallbackModelTestcallsCallModelTestcallsLaravelExtensionTest::testModelsRegistersLaravelSemanticsThroughTheOptionalContractcallsAnalyzerTestcallsJsonReporterTestcallsTextReporterTestcalls
Relations§
Instantiated in 4
- new SqlCatalog\Core\Analysis\Derivation\EntryBinder::__construct() packages/sql-catalog/src/Core/Analysis/Derivation/EntryBinder.php:64
- new SqlCatalog\Core\Analysis\Derivation\SliceExecutor::__construct() packages/sql-catalog/src/Core/Analysis/Derivation/SliceExecutor.php:76
- new SqlCatalog\Core\Analysis\Interpreter::__construct() packages/sql-catalog/src/Core/Analysis/Interpreter.php:96
- new SqlCatalog\Facade\Analyzer::entriesOf() packages/sql-catalog/src/Facade/Analyzer.php:163
Method calls 2
Type declarations 6
- type SqlCatalog\Core\Analysis\Derivation\EntryBinder packages/sql-catalog/src/Core/Analysis/Derivation/EntryBinder.php:45
- type SqlCatalog\Core\Analysis\Derivation\EntryBinder packages/sql-catalog/src/Core/Analysis/Derivation/EntryBinder.php:58
- type SqlCatalog\Core\Analysis\Derivation\SliceExecutor packages/sql-catalog/src/Core/Analysis/Derivation/SliceExecutor.php:56
- type SqlCatalog\Core\Analysis\Derivation\SliceExecutor packages/sql-catalog/src/Core/Analysis/Derivation/SliceExecutor.php:70
- type SqlCatalog\Core\Analysis\Interpreter packages/sql-catalog/src/Core/Analysis/Interpreter.php:67
- type SqlCatalog\Core\Analysis\Interpreter packages/sql-catalog/src/Core/Analysis/Interpreter.php:87