|
21 | 21 | use Nejcc\PhpDatatypes\Scalar\Integers\Unsigned\UInt32;
|
22 | 22 | use Nejcc\PhpDatatypes\Scalar\Integers\Unsigned\UInt8;
|
23 | 23 |
|
24 |
| -/** |
25 |
| - * @param int $value |
26 |
| - * @return Int8 |
27 |
| - */ |
28 |
| -function int8(int $value): Int8 |
29 |
| -{ |
30 |
| - return new Int8($value); |
31 |
| -} |
32 |
| - |
33 |
| -/** |
34 |
| - * @param int $value |
35 |
| - * @return Int16 |
36 |
| - */ |
37 |
| -function int16(int $value): Int16 |
38 |
| -{ |
39 |
| - return new Int16($value); |
40 |
| -} |
41 |
| - |
42 |
| -/** |
43 |
| - * @param int $value |
44 |
| - * @return Int32 |
45 |
| - */ |
46 |
| -function int32(int $value): Int32 |
47 |
| -{ |
48 |
| - return new Int32($value); |
49 |
| -} |
50 |
| - |
51 |
| -/** |
52 |
| - * @param int $value |
53 |
| - * @return Int64 |
54 |
| - */ |
55 |
| -function int64(int $value): Int64 |
56 |
| -{ |
57 |
| - return new Int64($value); |
58 |
| -} |
59 |
| - |
60 |
| -/** |
61 |
| - * @param int $value |
62 |
| - * @return Int128 |
63 |
| - */ |
64 |
| -function int128(int $value): Int128 |
65 |
| -{ |
66 |
| - return new Int128($value); |
67 |
| -} |
68 |
| - |
69 |
| -/** |
70 |
| - * @param int $value |
71 |
| - * @return UInt8 |
72 |
| - */ |
73 |
| -function uint8(int $value): UInt8 |
74 |
| -{ |
75 |
| - return new UInt8($value); |
76 |
| -} |
77 |
| - |
78 |
| -/** |
79 |
| - * @param int $value |
80 |
| - * @return UInt16 |
81 |
| - */ |
82 |
| -function uint16(int $value): UInt16 |
83 |
| -{ |
84 |
| - return new UInt16($value); |
85 |
| -} |
86 |
| - |
87 |
| -/** |
88 |
| - * @param int $value |
89 |
| - * @return UInt32 |
90 |
| - */ |
91 |
| -function uint32(int $value): UInt32 |
92 |
| -{ |
93 |
| - return new UInt32($value); |
94 |
| -} |
95 |
| - |
96 |
| -/** |
97 |
| - * @param float $value |
98 |
| - * @return Float32 |
99 |
| - */ |
100 |
| -function float32(float $value): Float32 |
101 |
| -{ |
102 |
| - return new Float32($value); |
103 |
| -} |
104 |
| - |
105 |
| -/** |
106 |
| - * @param float $value |
107 |
| - * @return Float64 |
108 |
| - */ |
109 |
| -function float64(float $value): Float64 |
110 |
| -{ |
111 |
| - return new Float64($value); |
| 24 | +if (!function_exists('int8')) { |
| 25 | + /** |
| 26 | + * @param int $value |
| 27 | + * @return Int8 |
| 28 | + */ |
| 29 | + function int8(int $value): Int8 |
| 30 | + { |
| 31 | + return new Int8($value); |
| 32 | + } |
| 33 | +} |
| 34 | + |
| 35 | +if (!function_exists('int16')) { |
| 36 | + /** |
| 37 | + * @param int $value |
| 38 | + * @return Int16 |
| 39 | + */ |
| 40 | + function int16(int $value): Int16 |
| 41 | + { |
| 42 | + return new Int16($value); |
| 43 | + } |
| 44 | +} |
| 45 | + |
| 46 | +if (!function_exists('int32')) { |
| 47 | + /** |
| 48 | + * @param int $value |
| 49 | + * @return Int32 |
| 50 | + */ |
| 51 | + function int32(int $value): Int32 |
| 52 | + { |
| 53 | + return new Int32($value); |
| 54 | + } |
| 55 | +} |
| 56 | + |
| 57 | +if (!function_exists('int64')) { |
| 58 | + /** |
| 59 | + * @param int $value |
| 60 | + * @return Int64 |
| 61 | + */ |
| 62 | + function int64(int $value): Int64 |
| 63 | + { |
| 64 | + return new Int64($value); |
| 65 | + } |
| 66 | +} |
| 67 | + |
| 68 | +if (!function_exists('int128')) { |
| 69 | + /** |
| 70 | + * @param int $value |
| 71 | + * @return Int128 |
| 72 | + */ |
| 73 | + function int128(int $value): Int128 |
| 74 | + { |
| 75 | + return new Int128($value); |
| 76 | + } |
| 77 | +} |
| 78 | + |
| 79 | +if (!function_exists('uint8')) { |
| 80 | + /** |
| 81 | + * @param int $value |
| 82 | + * @return UInt8 |
| 83 | + */ |
| 84 | + function uint8(int $value): UInt8 |
| 85 | + { |
| 86 | + return new UInt8($value); |
| 87 | + } |
| 88 | +} |
| 89 | + |
| 90 | +if (!function_exists('uint16')) { |
| 91 | + /** |
| 92 | + * @param int $value |
| 93 | + * @return UInt16 |
| 94 | + */ |
| 95 | + function uint16(int $value): UInt16 |
| 96 | + { |
| 97 | + return new UInt16($value); |
| 98 | + } |
| 99 | +} |
| 100 | + |
| 101 | +if (!function_exists('uint32')) { |
| 102 | + /** |
| 103 | + * @param int $value |
| 104 | + * @return UInt32 |
| 105 | + */ |
| 106 | + function uint32(int $value): UInt32 |
| 107 | + { |
| 108 | + return new UInt32($value); |
| 109 | + } |
| 110 | +} |
| 111 | + |
| 112 | +if (!function_exists('float32')) { |
| 113 | + /** |
| 114 | + * @param float $value |
| 115 | + * @return Float32 |
| 116 | + */ |
| 117 | + function float32(float $value): Float32 |
| 118 | + { |
| 119 | + return new Float32($value); |
| 120 | + } |
| 121 | +} |
| 122 | + |
| 123 | +if (!function_exists('float64')) { |
| 124 | + /** |
| 125 | + * @param float $value |
| 126 | + * @return Float64 |
| 127 | + */ |
| 128 | + function float64(float $value): Float64 |
| 129 | + { |
| 130 | + return new Float64($value); |
| 131 | + } |
| 132 | +} |
| 133 | + |
| 134 | +if (!function_exists('char')) { |
| 135 | + function char(string $value): Char |
| 136 | + { |
| 137 | + return new Char($value); |
| 138 | + } |
| 139 | +} |
| 140 | + |
| 141 | +if (!function_exists('byte')) { |
| 142 | + function byte(string|int $value): Byte |
| 143 | + { |
| 144 | + return new Byte($value); |
| 145 | + } |
| 146 | +} |
| 147 | + |
| 148 | +if (!function_exists('stringArray')) { |
| 149 | + function stringArray(array $value): StringArray |
| 150 | + { |
| 151 | + return new StringArray($value); |
| 152 | + } |
| 153 | +} |
| 154 | + |
| 155 | +if (!function_exists('intArray')) { |
| 156 | + function intArray(array $value): IntArray |
| 157 | + { |
| 158 | + return new IntArray($value); |
| 159 | + } |
| 160 | +} |
| 161 | + |
| 162 | +if (!function_exists('floatArray')) { |
| 163 | + function floatArray(array $value): FloatArray |
| 164 | + { |
| 165 | + return new FloatArray($value); |
| 166 | + } |
| 167 | +} |
| 168 | + |
| 169 | +if (!function_exists('byteSlice')) { |
| 170 | + function byteSlice(array $value): ByteSlice |
| 171 | + { |
| 172 | + return new ByteSlice($value); |
| 173 | + } |
| 174 | +} |
| 175 | + |
| 176 | +if (!function_exists('listData')) { |
| 177 | + function listData(array $value): ListData |
| 178 | + { |
| 179 | + return new ListData($value); |
| 180 | + } |
| 181 | +} |
| 182 | + |
| 183 | +if (!function_exists('dictionary')) { |
| 184 | + function dictionary(array $value): Dictionary |
| 185 | + { |
| 186 | + return new Dictionary($value); |
| 187 | + } |
112 | 188 | }
|
113 | 189 |
|
114 |
| -function char(string $value): Char |
115 |
| -{ |
116 |
| - return new Char($value); |
| 190 | +if (!function_exists('struct')) { |
| 191 | + function struct(array $fields): Struct |
| 192 | + { |
| 193 | + return new Struct($fields); |
| 194 | + } |
117 | 195 | }
|
118 |
| - |
119 |
| -function byte(string|int $value): Byte |
120 |
| -{ |
121 |
| - return new Byte($value); |
122 |
| -} |
123 |
| - |
124 |
| -function stringArray(array $value): StringArray |
125 |
| -{ |
126 |
| - return new StringArray($value); |
127 |
| -} |
128 |
| - |
129 |
| -function intArray(array $value): IntArray |
130 |
| -{ |
131 |
| - return new IntArray($value); |
132 |
| -} |
133 |
| - |
134 |
| -function floatArray(array $value): FloatArray |
135 |
| -{ |
136 |
| - return new FloatArray($value); |
137 |
| -} |
138 |
| - |
139 |
| -function byteSlice(array $value): ByteSlice |
140 |
| -{ |
141 |
| - return new ByteSlice($value); |
142 |
| -} |
143 |
| - |
144 |
| -function listData(array $value): ListData |
145 |
| -{ |
146 |
| - return new ListData($value); |
147 |
| -} |
148 |
| - |
149 |
| -function dictionary(array $value): Dictionary |
150 |
| -{ |
151 |
| - return new Dictionary($value); |
152 |
| -} |
153 |
| - |
154 |
| -function struct(array $fields): Struct |
155 |
| -{ |
156 |
| - return new Struct($fields); |
157 |
| -} |
158 |
| - |
|
0 commit comments