|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of Railt package. |
|
4
|
|
|
* |
|
5
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
6
|
|
|
* file that was distributed with this source code. |
|
7
|
|
|
*/ |
|
8
|
|
|
declare(strict_types=1); |
|
9
|
|
|
|
|
10
|
|
|
namespace Railt\SDL\IR\Type\InternalTypes; |
|
11
|
|
|
|
|
12
|
|
|
use Railt\SDL\IR\Type; |
|
13
|
|
|
use Railt\SDL\IR\Type\TypeInterface; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Trait RuntimeTypes |
|
17
|
|
|
*/ |
|
18
|
|
|
trait RuntimeTypes |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* @return array|TypeInterface[] |
|
22
|
|
|
*/ |
|
23
|
|
|
protected static function getRuntimeTypes(): array |
|
24
|
|
|
{ |
|
25
|
|
|
return [ |
|
26
|
|
|
// |
|
27
|
|
|
// NOTE: It is worth noting that the ID, DateTime and others |
|
28
|
|
|
// are not independent types that can be deduced during the |
|
29
|
|
|
// early static binding. |
|
30
|
|
|
// |
|
31
|
|
|
// In particular, the type of the ID can be derived from a |
|
32
|
|
|
// String or any Int or Float. The hierarchy of scalars |
|
33
|
|
|
// determines only the situation when a type can be converted |
|
34
|
|
|
// to a parent without losing a piece of data. |
|
35
|
|
|
// |
|
36
|
|
|
self::STRING => $string = self::createInternalType(self::STRING, Type::scalar()), |
|
37
|
|
|
self::FLOAT => $float = self::createInternalType(self::FLOAT, $string), |
|
38
|
|
|
self::INT => $int = self::createInternalType(self::INT, $float), |
|
39
|
|
|
self::BOOLEAN => $bool = self::createInternalType(self::BOOLEAN, $string), |
|
40
|
|
|
self::NULL => $null = self::createInternalType(self::NULL, Type::scalar()), |
|
41
|
|
|
self::ID => $id = self::createInternalType(self::ID, $string), |
|
42
|
|
|
self::DATE_TIME => $date = self::createInternalType(self::DATE_TIME, $string), |
|
43
|
|
|
]; |
|
44
|
|
|
} |
|
45
|
|
|
} |
|
46
|
|
|
|