classBindParameter
final class BindParameter
implements Scalar
uses Snapshot
Public API: explicitly declared with
@visibility public.A bind parameter: a placeholder for a value supplied when the statement runs.
Rule: SQLITE-PARAMETER-001. The parameter is identified by its prefix and its label: no label for an anonymous ?, digits for ?NNN, a name for the other prefixes. Its type and NULL fact depend on the bound value. Source: https://sqlite.org/lang_expr.html#parameters. Status: Implemented.
$query = (new \SqlSemantics\Platform\Sqlite\Semantics())->analyze('SELECT ?2');
[$query->statement->columns[0]->expression->label, $query->field(0)->type->missing[0]->marker] // => ['2', '?2']new \SqlSemantics\Platform\Sqlite\Statement\Expression\BindParameter(\SqlSemantics\Platform\Sqlite\Statement\Expression\ParameterPrefix::Colon, 'a b') // throws \SqlSemantics\Platform\Sqlite\Model\Diagnostic\InvalidConstructionnew \SqlSemantics\Platform\Sqlite\Statement\Expression\BindParameter(\SqlSemantics\Platform\Sqlite\Statement\Expression\ParameterPrefix::Question, 'ab') // throws \SqlSemantics\Platform\Sqlite\Model\Diagnostic\InvalidConstructionnew \SqlSemantics\Platform\Sqlite\Statement\Expression\BindParameter(\SqlSemantics\Platform\Sqlite\Statement\Expression\ParameterPrefix::Colon, '') // throws \SqlSemantics\Platform\Sqlite\Model\Diagnostic\InvalidConstructionnew \SqlSemantics\Platform\Sqlite\Statement\Expression\BindParameter(\SqlSemantics\Platform\Sqlite\Statement\Expression\ParameterPrefix::Dollar, 'a b') // throws \SqlSemantics\Platform\Sqlite\Model\Diagnostic\InvalidConstructionProperties§
public ParameterPrefix $prefixpublic string $label = ''Methods§
public function __construct(public ParameterPrefix $prefix, public string $label = '')Parameters
$prefix | ParameterPrefix | The prefix character |
$label | string | The text after the prefix: empty or digits after a question mark, a name otherwise |
Calls 3
- class-const ParameterPrefix::Question() line 49
- static-call Check::input() line 50
- function-call
preg_matchline 50
public function marker(): stringAnswers the parameter as written: the prefix and the label.
Returns
stringTest cases 2
Called from 2
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\BindParameter::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/BindParameter.php:66
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\BindParameter::render() packages/sql-semantics-sqlite/src/Statement/Expression/BindParameter.php:74
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives facts that depend on the bound value.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 5
- new ScalarFact line 66
- new Dependent line 66
- new UnboundParameter line 66
- method-call BindParameter::marker() line 66
- class-const Nullability::Dependent() line 66
public function render(Output $out): voidWrites the parameter.
Parameters
$out | Output |
Calls 2
- method-call Output::spelled() line 74
- method-call BindParameter::marker() line 74
Test cases 9§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 3
Other tests reaching this symbol 6
ExpressionRuleTest::testParameterLowersEveryPrefixWithItsLabelcallsProgramOnlyTest::testHoldsFindsANodeOfAClassAnywhereInTheStructurecallsProgramOnlyTest::testInsideProgramReportsABindParameterOncecallsParameterPrefixTest::testFromMatchesThePrefixOfAnAnalyzedParametercallsFrameBoundTest::testReadsTheOffsetOfAnAnalyzedBoundarycallsFrameBoundTest::testRenderWritesANewlyBuiltBoundarycalls
Relations§
Instantiated in 1
Constant reads 2
- class-const SqlSemantics\Platform\Sqlite\Rules\Definition\Query\ValueKinds packages/sql-semantics-sqlite/src/Rules/Definition/Query/ValueKinds.php:78
- class-const SqlSemantics\Platform\Sqlite\Rules\Expression\ProgramOnly::insideProgram() packages/sql-semantics-sqlite/src/Rules/Expression/ProgramOnly.php:47
Type checks 2
- instanceof SqlSemantics\Platform\Sqlite\Rules\Definition\Expression\Limits::classify() packages/sql-semantics-sqlite/src/Rules/Definition/Expression/Limits.php:117
- instanceof SqlSemantics\Platform\Sqlite\Rules\Definition\Expression\Limits::nonConstant() packages/sql-semantics-sqlite/src/Rules/Definition/Expression/Limits.php:165