classCallTyping
final class CallTyping
Types the result of a call from its name and the facts of its arguments.
Rule: PG-CALL-RESULT-001. A context declares no routine, so a call has a known result only when it certainly resolves to a function of pg_catalog (PG-ROUTINE-MATCH-001 over PG-CALL-SIGNATURES-001): its name is qualified with pg_catalog, or unqualified while pg_catalog is the first schema searched for functions (pg_temp is never searched for them). Arguments passed by name or with VARIADIC are matched by the routine's declaration and are left to it. An invalid argument makes the call invalid; dependent arguments make it depend on the same inputs. A resolved call has the row's result type and NULL rule; a clause its kind does not accept is a diagnostic and leaves the call without a type (PG-CALL-CHECKS-001). Any other call depends on the undeclared routine; a name with a catalog qualifier also depends on the name of the current database; a name of more than three parts is improper. Source: https://www.postgresql.org/docs/17/typeconv-func.html, https://www.postgresql.org/docs/17/ddl-schemas.html#DDL-SCHEMAS-PATH. Termination: constant work per argument. Status: Implemented.
Methods§
public function call(
Derivation $derivation,
FunctionCall $call,
list<ScalarFact> $arguments,
): ScalarFactAnswers the facts of a call written with a function name.
Parameters
$derivation | Derivation | |
$call | FunctionCall | |
$arguments | list<ScalarFact> | The facts of the arguments in order |
Returns
Test cases 5
CallTypingTest::testCallDependsOnTheCurrentDatabaseForACatalogQualifiercallsCallTypingTest::testCallDependsWhenAnotherSchemaIsSearchedFirstcallsCallTypingTest::testCallLeavesNamedArgumentsToTheRoutinecallsCallTypingTest::testCallReportsAnImproperNamecallsCallTypingTest::testCallTypesAnExactCatalogMatchcalls
Called from 1
Calls 16
- new CallChecks line 53
- method-call CallChecks::arguments() line 54
- new ImproperName line 59
- method-call Derivation::report() line 60
- new ScalarFact line 62
- new Invalid line 62
- class-const Nullability::Dependent() line 62
- function-call
countline 68 - method-call CallTyping::catalogFirst() line 69
- new SessionState line 71
- method-call CallTyping::inputs() line 73
- new Dependent line 73
- new UndeclaredRoutine line 73
- method-call CallTyping::row() line 76
- method-call CallChecks::misuse() line 80
- method-call CallTyping::result() line 82
public function catalog(
AnalysisContext $context,
string $name,
list<ScalarFact> $arguments,
bool $catalogOnly = true,
): ScalarFactAnswers the facts of a call of a pg_catalog function by a fixed name, as the SQL-syntax forms make.
Parameters
$context | AnalysisContext | |
$name | string | |
$arguments | list<ScalarFact> | The facts of the arguments in order |
$catalogOnly | bool | Whether only `pg_catalog` is searched, as for the SQL-syntax forms; otherwise the name is unqualified |
Returns
Test cases 2
Called from 11
- method-call SqlSemantics\Platform\PostgreSql\Statement\Invocation\Syntax\CollationFor::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Syntax/CollationFor.php:53
- method-call SqlSemantics\Platform\PostgreSql\Statement\Invocation\Syntax\KeywordCall::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Syntax/KeywordCall.php:86
- method-call SqlSemantics\Platform\PostgreSql\Statement\Invocation\Syntax\Normalize::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Syntax/Normalize.php:65
- method-call SqlSemantics\Platform\PostgreSql\Statement\Invocation\Syntax\Treat::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Syntax/Treat.php:64
- method-call SqlSemantics\Platform\PostgreSql\Statement\Invocation\Text\Extract::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Text/Extract.php:79
- method-call SqlSemantics\Platform\PostgreSql\Statement\Invocation\Text\Overlay::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Text/Overlay.php:64
- method-call SqlSemantics\Platform\PostgreSql\Statement\Invocation\Text\Position::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Text/Position.php:64
- method-call SqlSemantics\Platform\PostgreSql\Statement\Invocation\Text\SimilarSubstring::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Text/SimilarSubstring.php:66
- method-call SqlSemantics\Platform\PostgreSql\Statement\Invocation\Text\Substring::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Text/Substring.php:77
- method-call SqlSemantics\Platform\PostgreSql\Statement\Invocation\Text\Trim::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Text/Trim.php:74
- method-call SqlSemantics\Platform\PostgreSql\Statement\Invocation\Xml\XmlExists::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Xml/XmlExists.php:62
Calls 10
- new QualifiedName line 93
- new Name line 93
- method-call CallTyping::inputs() line 94
- method-call CallTyping::catalogFirst() line 98
- method-call CallTyping::row() line 98
- new ScalarFact line 100
- new Dependent line 100
- new UndeclaredRoutine line 100
- class-const Nullability::Dependent() line 100
- method-call CallTyping::result() line 100
public function row(
string $name,
list<ScalarFact> $arguments,
bool $catalogOnly,
): array{string, string, string, list<string>}|nullAnswers the row a call resolves to, from the argument types.
Parameters
$name | string | |
$arguments | list<ScalarFact> | |
$catalogOnly | bool |
Returns
array{string, string, string, list<string>}|nullTest cases 1
Called from 2
- method-call SqlSemantics\Platform\PostgreSql\Rules\Invocation\CallTyping::call() packages/sql-semantics-postgres/src/Rules/Invocation/CallTyping.php:76
- method-call SqlSemantics\Platform\PostgreSql\Rules\Invocation\CallTyping::catalog() packages/sql-semantics-postgres/src/Rules/Invocation/CallTyping.php:98
Calls 4
- new Coercions line 112
- method-call Coercions::key() line 115
- method-call RoutineMatch::find() line 122
- new RoutineMatch line 122
public function result(
array{string, string, string, list<string>} $row,
list<ScalarFact> $arguments,
): ScalarFactAnswers the facts of a resolved call: the row's result type and NULL rule.
Parameters
$row | array{string, string, string, list<string>} | |
$arguments | list<ScalarFact> |
Returns
Test cases 1
Called from 2
- method-call SqlSemantics\Platform\PostgreSql\Rules\Invocation\CallTyping::call() packages/sql-semantics-postgres/src/Rules/Invocation/CallTyping.php:82
- method-call SqlSemantics\Platform\PostgreSql\Rules\Invocation\CallTyping::catalog() packages/sql-semantics-postgres/src/Rules/Invocation/CallTyping.php:100
Calls 7
- class-const Nullability::NotNull() line 134
- method-call CallTyping::strict() line 135
- class-const Nullability::Nullable() line 136
- new ScalarFact line 139
- new Known line 139
- method-call Coercions::type() line 139
- new Coercions line 139
public function strict(list<ScalarFact> $arguments): NullabilityAnswers the NULL fact of a strict function: NULL exactly when an argument is.
Parameters
$arguments | list<ScalarFact> |
Returns
Test cases 1
Called from 1
Calls 2
- class-const Nullability::NotNull() line 149
- class-const Nullability::Nullable() line 151
public function inputs(list<ScalarFact> $arguments): ?ScalarFactAnswers the facts a call takes from its arguments before its own rule: the first invalid argument, or the inputs dependent arguments miss; null when every argument is decided.
Parameters
$arguments | list<ScalarFact> |
Returns
Test cases 1
Called from 3
- method-call SqlSemantics\Platform\PostgreSql\Rules\Invocation\CallTyping::call() packages/sql-semantics-postgres/src/Rules/Invocation/CallTyping.php:73
- method-call SqlSemantics\Platform\PostgreSql\Rules\Invocation\CallTyping::call() packages/sql-semantics-postgres/src/Rules/Invocation/CallTyping.php:75
- method-call SqlSemantics\Platform\PostgreSql\Rules\Invocation\CallTyping::catalog() packages/sql-semantics-postgres/src/Rules/Invocation/CallTyping.php:94
Calls 3
- new ScalarFact line 167
- class-const Nullability::Dependent() line 167
- new Dependent line 174
public function catalogFirst(AnalysisContext $context): boolTells whether pg_catalog is the first schema searched for functions.
Parameters
$context | AnalysisContext |
Returns
boolTest cases 1
Called from 2
- method-call SqlSemantics\Platform\PostgreSql\Rules\Invocation\CallTyping::call() packages/sql-semantics-postgres/src/Rules/Invocation/CallTyping.php:69
- method-call SqlSemantics\Platform\PostgreSql\Rules\Invocation\CallTyping::catalog() packages/sql-semantics-postgres/src/Rules/Invocation/CallTyping.php:98
Test cases 12§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 12
CallTypingTest::testCallDependsOnTheCurrentDatabaseForACatalogQualifiercallsCallTypingTest::testCallDependsWhenAnotherSchemaIsSearchedFirstcallsCallTypingTest::testCallLeavesNamedArgumentsToTheRoutinecallsCallTypingTest::testCallReportsAnImproperNamecallsCallTypingTest::testCallTypesAnExactCatalogMatchcallsCallTypingTest::testCatalogFirstReadsTheSearchPathcallsCallTypingTest::testCatalogMatchesThroughImplicitCastscallsCallTypingTest::testCatalogPassesAnInvalidArgumentOncallsCallTypingTest::testInputsMergesTheMissingInputsOfDependentArgumentscallsCallTypingTest::testResultAppliesTheNullRulecallsCallTypingTest::testRowAnswersNullForATypeOutsideTheTablecallsCallTypingTest::testStrictIsNullableWhenAnArgumentIscalls
Relations§
Instantiated in 12
- new SqlSemantics\Platform\PostgreSql\Statement\Invocation\FunctionCall::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/FunctionCall.php:127
- new SqlSemantics\Platform\PostgreSql\Statement\Invocation\Syntax\CollationFor::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Syntax/CollationFor.php:53
- new SqlSemantics\Platform\PostgreSql\Statement\Invocation\Syntax\KeywordCall::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Syntax/KeywordCall.php:86
- new SqlSemantics\Platform\PostgreSql\Statement\Invocation\Syntax\Normalize::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Syntax/Normalize.php:65
- new SqlSemantics\Platform\PostgreSql\Statement\Invocation\Syntax\Treat::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Syntax/Treat.php:64
- new SqlSemantics\Platform\PostgreSql\Statement\Invocation\Text\Extract::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Text/Extract.php:79
- new SqlSemantics\Platform\PostgreSql\Statement\Invocation\Text\Overlay::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Text/Overlay.php:64
- new SqlSemantics\Platform\PostgreSql\Statement\Invocation\Text\Position::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Text/Position.php:64
- new SqlSemantics\Platform\PostgreSql\Statement\Invocation\Text\SimilarSubstring::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Text/SimilarSubstring.php:66
- new SqlSemantics\Platform\PostgreSql\Statement\Invocation\Text\Substring::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Text/Substring.php:77
- new SqlSemantics\Platform\PostgreSql\Statement\Invocation\Text\Trim::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Text/Trim.php:74
- new SqlSemantics\Platform\PostgreSql\Statement\Invocation\Xml\XmlExists::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Xml/XmlExists.php:62
Method calls 12
- method-call SqlSemantics\Platform\PostgreSql\Statement\Invocation\FunctionCall::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/FunctionCall.php:127
- method-call SqlSemantics\Platform\PostgreSql\Statement\Invocation\Syntax\CollationFor::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Syntax/CollationFor.php:53
- method-call SqlSemantics\Platform\PostgreSql\Statement\Invocation\Syntax\KeywordCall::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Syntax/KeywordCall.php:86
- method-call SqlSemantics\Platform\PostgreSql\Statement\Invocation\Syntax\Normalize::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Syntax/Normalize.php:65
- method-call SqlSemantics\Platform\PostgreSql\Statement\Invocation\Syntax\Treat::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Syntax/Treat.php:64
- method-call SqlSemantics\Platform\PostgreSql\Statement\Invocation\Text\Extract::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Text/Extract.php:79
- method-call SqlSemantics\Platform\PostgreSql\Statement\Invocation\Text\Overlay::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Text/Overlay.php:64
- method-call SqlSemantics\Platform\PostgreSql\Statement\Invocation\Text\Position::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Text/Position.php:64
- method-call SqlSemantics\Platform\PostgreSql\Statement\Invocation\Text\SimilarSubstring::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Text/SimilarSubstring.php:66
- method-call SqlSemantics\Platform\PostgreSql\Statement\Invocation\Text\Substring::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Text/Substring.php:77
- method-call SqlSemantics\Platform\PostgreSql\Statement\Invocation\Text\Trim::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Text/Trim.php:74
- method-call SqlSemantics\Platform\PostgreSql\Statement\Invocation\Xml\XmlExists::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Xml/XmlExists.php:62