classFunctionParameter
final class FunctionParameter
implements Clause
uses Snapshot
@visibility public.One parameter of a routine definition or signature: mode, name, type and default value.
Mirrors PostgreSQL's FunctionParameter node. The name may be written before or after the mode; both orders declare the same parameter and the order is kept so that the statement is written back as it was. Only input parameters take part in calls; output parameters form the result row. Source: https://www.postgresql.org/docs/17/sql-createfunction.html.
$type = new \SqlSemantics\Platform\PostgreSql\Statement\Type\TypeName(new \SqlSemantics\Platform\PostgreSql\Statement\Type\Designation\NamedDesignation(new \SqlSemantics\Platform\PostgreSql\Statement\Name\DottedName([new \SqlSemantics\Platform\PostgreSql\Model\Statement\Identifier\Name('text')])));
$parameter = new \SqlSemantics\Platform\PostgreSql\Statement\Routine\FunctionParameter($type, new \SqlSemantics\Platform\PostgreSql\Model\Statement\Identifier\Name('label'), \SqlSemantics\Platform\PostgreSql\Statement\Routine\ParameterMode::Out);
[$parameter->name?->value, $parameter->input()] // => ['label', false]Properties§
public TypeName $typepublic Name|null $name = nullpublic ParameterMode|null $mode = nullpublic bool $nameFirst = falsepublic Scalar|null $default = nullpublic DefaultSpelling|null $defaultSpelling = nullMethods§
public function __construct(
public TypeName $type,
public Name|null $name = null,
public ParameterMode|null $mode = null,
public bool $nameFirst = false,
public Scalar|null $default = null,
public DefaultSpelling|null $defaultSpelling = null,
)Parameters
$type | TypeName | The parameter type |
$name | Name|null | The parameter name, if written |
$mode | ParameterMode|null | The written mode; null when no mode is written |
$nameFirst | bool | Whether the name is written before the mode |
$default | Scalar|null | The default value, if written |
$defaultSpelling | DefaultSpelling|null | How the default value is introduced; given exactly with a default value |
Calls 1
- static-call Check::input() line 53
public function input(): boolTells whether the caller passes a value for the parameter.
Returns
boolTest cases 1
Called from 2
- method-call SqlSemantics\Platform\PostgreSql\Rules\Routine\RoutineChecks::parameter() packages/sql-semantics-postgres/src/Rules/Routine/RoutineChecks.php:132
- method-call SqlSemantics\Platform\PostgreSql\Rules\Routine\RoutineChecks::parameter() packages/sql-semantics-postgres/src/Rules/Routine/RoutineChecks.php:134
public function output(): boolTells whether the parameter is part of the result.
Returns
boolTest cases 1
public function deriveClause(Derivation $derivation, Environment $environment): voidDerives the type modifiers and the default value in the given environment.
Parameters
$derivation | Derivation | |
$environment | Environment |
Test cases 1
Calls 2
- method-call TypeName::deriveClause() line 78
- method-call Derivation::scalar() line 80
public function render(Output $out): voidWrites the mode and the name in their written order, the type and the default value.
Parameters
$out | Output |
Test cases 1
Calls 7
- method-call Output::name() line 90
- class-const NameUse::Routine() line 90
- method-call Output::keyword() line 93
- method-call Output::node() line 98
- class-const DefaultSpelling::Keyword() line 101
- class-const DefaultSpelling::EqualsSign() line 102
- method-call Output::symbol() line 102
Test cases 15§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 6
FunctionParameterTest::testDeriveClauseDerivesTheDefaultValuecallsFunctionParameterTest::testInputIsTrueWithoutAModecallsFunctionParameterTest::testOutputFollowsTheModecallsFunctionParameterTest::testRejectsANameFirstWithoutAModecallsFunctionParameterTest::testRejectsASpellingWithoutADefaultcallsFunctionParameterTest::testRenderWritesTheNameBeforeTheModeWhenWrittenSocalls
Other tests reaching this symbol 9
PositionalParameterTest::testDeriveScalarReportsAParameterARoutineDoesNotDeclarecallsRoutineParametersTest::testDeriveRelationHoldsTheInputParameterscallsAggregateArgumentsTest::testDeriveClauseReportsOutputArgumentscallsAggregateArgumentsTest::testRenderWritesTheFourFormscallsAggregateArgumentsTest::testStarIsTheEmptyListWithoutOrderBycallsAggregateSignatureTest::testDeriveClauseDerivesTheArgumentscallsRoutineSignatureTest::testDeriveClauseDerivesTheArgumentscallsRoutineSignatureTest::testRejectsADefaultValuecallsRoutineSignatureTest::testRenderWritesTheArgumentListOnlyWhenWrittencalls
Relations§
Instantiated in 5
- new SqlSemantics\Platform\PostgreSql\Lowering\Routine\SignatureRule::parameter() packages/sql-semantics-postgres/src/Lowering/Routine/SignatureRule.php:133
- new SqlSemantics\Platform\PostgreSql\Lowering\Routine\SignatureRule::parameter() packages/sql-semantics-postgres/src/Lowering/Routine/SignatureRule.php:134
- new SqlSemantics\Platform\PostgreSql\Lowering\Routine\SignatureRule::parameter() packages/sql-semantics-postgres/src/Lowering/Routine/SignatureRule.php:135
- new SqlSemantics\Platform\PostgreSql\Lowering\Routine\SignatureRule::parameter() packages/sql-semantics-postgres/src/Lowering/Routine/SignatureRule.php:136
- new SqlSemantics\Platform\PostgreSql\Lowering\Routine\SignatureRule::parameter() packages/sql-semantics-postgres/src/Lowering/Routine/SignatureRule.php:137
Method calls 3
- method-call SqlSemantics\Platform\PostgreSql\Rules\Routine\RoutineChecks::parameter() packages/sql-semantics-postgres/src/Rules/Routine/RoutineChecks.php:132
- method-call SqlSemantics\Platform\PostgreSql\Rules\Routine\RoutineChecks::parameter() packages/sql-semantics-postgres/src/Rules/Routine/RoutineChecks.php:134
- method-call SqlSemantics\Platform\PostgreSql\Rules\Routine\RoutineChecks::parameter() packages/sql-semantics-postgres/src/Rules/Routine/RoutineChecks.php:136
Constant reads 4
- class-const SqlSemantics\Platform\PostgreSql\Statement\Routine\RoutineParameters::__construct() packages/sql-semantics-postgres/src/Statement/Routine/RoutineParameters.php:46
- class-const SqlSemantics\Platform\PostgreSql\Statement\Routine\Signature\AggregateArguments::__construct() packages/sql-semantics-postgres/src/Statement/Routine/Signature/AggregateArguments.php:50
- class-const SqlSemantics\Platform\PostgreSql\Statement\Routine\Signature\AggregateArguments::__construct() packages/sql-semantics-postgres/src/Statement/Routine/Signature/AggregateArguments.php:51
- class-const SqlSemantics\Platform\PostgreSql\Statement\Routine\Signature\RoutineSignature::__construct() packages/sql-semantics-postgres/src/Statement/Routine/Signature/RoutineSignature.php:51
Type declarations 3
- type SqlSemantics\Platform\PostgreSql\Lowering\Routine\FunctionRule packages/sql-semantics-postgres/src/Lowering/Routine/FunctionRule.php:96
- type SqlSemantics\Platform\PostgreSql\Lowering\Routine\SignatureRule packages/sql-semantics-postgres/src/Lowering/Routine/SignatureRule.php:126
- type SqlSemantics\Platform\PostgreSql\Rules\Routine\RoutineChecks packages/sql-semantics-postgres/src/Rules/Routine/RoutineChecks.php:129