classAlternatives
final class Alternatives
Lifts a type rule over the alternatives of its operand types.
Rule: MYSQL-TYPE-ALTERNATIVES-001. An operand whose request is invalid makes the result invalid with the same cause; otherwise an operand that depends on missing inputs makes the result depend on all of them. A known type is one alternative, a choice is each of its alternatives, and the type of a bare NULL is the alternative null. The results of a rule over the alternatives are one known type when they agree and a choice otherwise. Terminates: no recursion. Source: https://dev.mysql.com/doc/refman/8.4/en/type-conversion.html. Status: Implemented.
Methods§
Answers the type fact that decides the result without a rule: the first invalid operand, or the dependence on every missing input.
Parameters
$types | list<TypeFact> |
Returns
Called from 5
- method-call SqlSemantics\Platform\MySql\Rules\Expression\NumericResult::binary() packages/sql-semantics-mysql/src/Rules/Expression/NumericResult.php:61
- method-call SqlSemantics\Platform\MySql\Rules\Expression\NumericResult::negation() packages/sql-semantics-mysql/src/Rules/Expression/NumericResult.php:133
- method-call SqlSemantics\Platform\MySql\Rules\Expression\StringResult::concatenation() packages/sql-semantics-mysql/src/Rules/Expression/StringResult.php:37
- method-call SqlSemantics\Platform\MySql\Rules\Expression\TemporalResult::interval() packages/sql-semantics-mysql/src/Rules/Expression/TemporalResult.php:57
- method-call SqlSemantics\Platform\MySql\Rules\Expression\TypeAggregation::aggregate() packages/sql-semantics-mysql/src/Rules/Expression/TypeAggregation.php:67
public function of(TypeFact $type): list<TypeDescriptor|null>Answers the alternatives of a type that does not block: its descriptors, or null for a bare NULL.
Parameters
$type | TypeFact |
Returns
list<TypeDescriptor|null>Test cases 1
Called from 6
- method-call SqlSemantics\Platform\MySql\Rules\Expression\NumericResult::binary() packages/sql-semantics-mysql/src/Rules/Expression/NumericResult.php:72
- method-call SqlSemantics\Platform\MySql\Rules\Expression\NumericResult::binary() packages/sql-semantics-mysql/src/Rules/Expression/NumericResult.php:73
- method-call SqlSemantics\Platform\MySql\Rules\Expression\NumericResult::negation() packages/sql-semantics-mysql/src/Rules/Expression/NumericResult.php:138
- method-call SqlSemantics\Platform\MySql\Rules\Expression\StringResult::concatenation() packages/sql-semantics-mysql/src/Rules/Expression/StringResult.php:45
- method-call SqlSemantics\Platform\MySql\Rules\Expression\TemporalResult::interval() packages/sql-semantics-mysql/src/Rules/Expression/TemporalResult.php:62
- method-call SqlSemantics\Platform\MySql\Rules\Expression\TypeAggregation::aggregate() packages/sql-semantics-mysql/src/Rules/Expression/TypeAggregation.php:73
public function known(list<TypeDescriptor> $types): TypeFactAnswers the type fact of a list of possible result types.
Parameters
$types | list<TypeDescriptor> | At least one |
Returns
Test cases 1
Called from 6
- method-call SqlSemantics\Platform\MySql\Rules\Expression\NumericResult::binary() packages/sql-semantics-mysql/src/Rules/Expression/NumericResult.php:79
- method-call SqlSemantics\Platform\MySql\Rules\Expression\NumericResult::negation() packages/sql-semantics-mysql/src/Rules/Expression/NumericResult.php:146
- method-call SqlSemantics\Platform\MySql\Rules\Expression\StringResult::concatenation() packages/sql-semantics-mysql/src/Rules/Expression/StringResult.php:53
- method-call SqlSemantics\Platform\MySql\Rules\Expression\StringResult::concatenation() packages/sql-semantics-mysql/src/Rules/Expression/StringResult.php:56
- method-call SqlSemantics\Platform\MySql\Rules\Expression\TemporalResult::interval() packages/sql-semantics-mysql/src/Rules/Expression/TemporalResult.php:66
- method-call SqlSemantics\Platform\MySql\Rules\Expression\TypeAggregation::aggregate() packages/sql-semantics-mysql/src/Rules/Expression/TypeAggregation.php:86
public function key(TypeDescriptor $type): stringAnswers the key two result types share when they are the same type.
Parameters
$type | TypeDescriptor |
Returns
stringTest cases 1
Called from 3
- method-call SqlSemantics\Platform\MySql\Rules\Expression\Alternatives::known() packages/sql-semantics-mysql/src/Rules/Expression/Alternatives.php:76
- method-call SqlSemantics\Platform\MySql\Rules\Expression\TypeAggregation::distinct() packages/sql-semantics-mysql/src/Rules/Expression/TypeAggregation.php:100
- method-call SqlSemantics\Platform\MySql\Rules\Expression\TypeAggregation::merge() packages/sql-semantics-mysql/src/Rules/Expression/TypeAggregation.php:111
Calls 2
- method-call TypeDescriptor::name() line 91
- method-call TypeDescriptor::unsigned() line 91
Test cases 4§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Relations§
Instantiated in 7
- new SqlSemantics\Platform\MySql\Rules\Expression\NumericResult::binary() packages/sql-semantics-mysql/src/Rules/Expression/NumericResult.php:60
- new SqlSemantics\Platform\MySql\Rules\Expression\NumericResult::negation() packages/sql-semantics-mysql/src/Rules/Expression/NumericResult.php:132
- new SqlSemantics\Platform\MySql\Rules\Expression\StringResult::concatenation() packages/sql-semantics-mysql/src/Rules/Expression/StringResult.php:36
- new SqlSemantics\Platform\MySql\Rules\Expression\TemporalResult::interval() packages/sql-semantics-mysql/src/Rules/Expression/TemporalResult.php:56
- new SqlSemantics\Platform\MySql\Rules\Expression\TypeAggregation::aggregate() packages/sql-semantics-mysql/src/Rules/Expression/TypeAggregation.php:66
- new SqlSemantics\Platform\MySql\Rules\Expression\TypeAggregation::distinct() packages/sql-semantics-mysql/src/Rules/Expression/TypeAggregation.php:97
- new SqlSemantics\Platform\MySql\Rules\Expression\TypeAggregation::merge() packages/sql-semantics-mysql/src/Rules/Expression/TypeAggregation.php:111
Method calls 19
- method-call SqlSemantics\Platform\MySql\Rules\Expression\NumericResult::binary() packages/sql-semantics-mysql/src/Rules/Expression/NumericResult.php:61
- method-call SqlSemantics\Platform\MySql\Rules\Expression\NumericResult::binary() packages/sql-semantics-mysql/src/Rules/Expression/NumericResult.php:72
- method-call SqlSemantics\Platform\MySql\Rules\Expression\NumericResult::binary() packages/sql-semantics-mysql/src/Rules/Expression/NumericResult.php:73
- method-call SqlSemantics\Platform\MySql\Rules\Expression\NumericResult::binary() packages/sql-semantics-mysql/src/Rules/Expression/NumericResult.php:79
- method-call SqlSemantics\Platform\MySql\Rules\Expression\NumericResult::negation() packages/sql-semantics-mysql/src/Rules/Expression/NumericResult.php:133
- method-call SqlSemantics\Platform\MySql\Rules\Expression\NumericResult::negation() packages/sql-semantics-mysql/src/Rules/Expression/NumericResult.php:138
- method-call SqlSemantics\Platform\MySql\Rules\Expression\NumericResult::negation() packages/sql-semantics-mysql/src/Rules/Expression/NumericResult.php:146
- method-call SqlSemantics\Platform\MySql\Rules\Expression\StringResult::concatenation() packages/sql-semantics-mysql/src/Rules/Expression/StringResult.php:37
- method-call SqlSemantics\Platform\MySql\Rules\Expression\StringResult::concatenation() packages/sql-semantics-mysql/src/Rules/Expression/StringResult.php:45
- method-call SqlSemantics\Platform\MySql\Rules\Expression\StringResult::concatenation() packages/sql-semantics-mysql/src/Rules/Expression/StringResult.php:53
- method-call SqlSemantics\Platform\MySql\Rules\Expression\StringResult::concatenation() packages/sql-semantics-mysql/src/Rules/Expression/StringResult.php:56
- method-call SqlSemantics\Platform\MySql\Rules\Expression\TemporalResult::interval() packages/sql-semantics-mysql/src/Rules/Expression/TemporalResult.php:57
- method-call SqlSemantics\Platform\MySql\Rules\Expression\TemporalResult::interval() packages/sql-semantics-mysql/src/Rules/Expression/TemporalResult.php:62
- method-call SqlSemantics\Platform\MySql\Rules\Expression\TemporalResult::interval() packages/sql-semantics-mysql/src/Rules/Expression/TemporalResult.php:66
- method-call SqlSemantics\Platform\MySql\Rules\Expression\TypeAggregation::aggregate() packages/sql-semantics-mysql/src/Rules/Expression/TypeAggregation.php:67
- method-call SqlSemantics\Platform\MySql\Rules\Expression\TypeAggregation::aggregate() packages/sql-semantics-mysql/src/Rules/Expression/TypeAggregation.php:73
- method-call SqlSemantics\Platform\MySql\Rules\Expression\TypeAggregation::aggregate() packages/sql-semantics-mysql/src/Rules/Expression/TypeAggregation.php:86
- method-call SqlSemantics\Platform\MySql\Rules\Expression\TypeAggregation::distinct() packages/sql-semantics-mysql/src/Rules/Expression/TypeAggregation.php:100
- method-call SqlSemantics\Platform\MySql\Rules\Expression\TypeAggregation::merge() packages/sql-semantics-mysql/src/Rules/Expression/TypeAggregation.php:111