classNumericContext
final class NumericContext
Classifies a value by the arithmetic it takes part in when used as a number.
Rule: MYSQL-NUMERIC-CONTEXT-001. An integer type is a signed or unsigned integer by its attributes; BOOL is a signed integer; SERIAL and BIT are unsigned integers; DECIMAL is exact. A temporal value is converted to a number: an integer when it has no fractional seconds, otherwise a decimal. A hexadecimal or bit literal without introducer is an unsigned integer in a numeric context. FLOAT, DOUBLE, every string, JSON, spatial and vector value, and a bare NULL take part as double precision. Terminates: a grouping is unwrapped in a loop over a finite chain. Source: https://dev.mysql.com/doc/refman/8.4/en/type-conversion.html, https://dev.mysql.com/doc/refman/8.4/en/hexadecimal-literals.html, https://dev.mysql.com/doc/refman/8.4/en/date-and-time-type-conversion.html. Status: Implemented.
Methods§
public function classify(Scalar $expression, ?TypeDescriptor $type): NumericClassAnswers the class of a value of a type, written as an expression; a null type is a bare NULL.
Parameters
$expression | Scalar | |
$type | ?TypeDescriptor |
Returns
Test cases 1
Called from 2
- method-call SqlSemantics\Platform\MySql\Rules\Expression\NumericResult::binary() packages/sql-semantics-mysql/src/Rules/Expression/NumericResult.php:74
- method-call SqlSemantics\Platform\MySql\Rules\Expression\NumericResult::negation() packages/sql-semantics-mysql/src/Rules/Expression/NumericResult.php:139
Calls 6
- class-const NumericClass::Unsigned() line 48
- class-const NumericClass::Signed() line 52
- class-const NumericClass::Decimal() line 53
- method-call NumericContext::temporal() line 54
- method-call NumericContext::elementary() line 55
- class-const NumericClass::Double() line 56
public function temporal(Temporal $type): NumericClassAnswers the class of a temporal value converted to a number.
Parameters
$type | Temporal |
Returns
Test cases 1
Called from 1
Calls 5
- class-const TemporalKind::Date() line 66
- class-const TemporalKind::Year() line 66
- class-const NumericClass::Signed() line 67
- function-call
ltrimline 70 - class-const NumericClass::Decimal() line 70
public function elementary(Elementary $type): NumericClassAnswers the class of BOOL, SERIAL, BIT, JSON and VECTOR values.
Parameters
$type | Elementary |
Returns
Test cases 1
Called from 1
Calls 8
- class-const ElementaryKind::Boolean() line 79
- class-const NumericClass::Signed() line 79
- class-const ElementaryKind::Serial() line 80
- class-const ElementaryKind::Bit() line 80
- class-const NumericClass::Unsigned() line 80
- class-const ElementaryKind::Json() line 81
- class-const ElementaryKind::Vector() line 81
- class-const NumericClass::Double() line 81
Test cases 3§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Relations§
Instantiated in 2
Method calls 2
- method-call SqlSemantics\Platform\MySql\Rules\Expression\NumericResult::binary() packages/sql-semantics-mysql/src/Rules/Expression/NumericResult.php:74
- method-call SqlSemantics\Platform\MySql\Rules\Expression\NumericResult::negation() packages/sql-semantics-mysql/src/Rules/Expression/NumericResult.php:139