Skip to content

Commit e3aa440

Browse files
committed
Merge remote-tracking branch 'origin/dev' into dev
# Conflicts: # src/Composite/Dictionary.php
2 parents 4821a8a + eb5780b commit e3aa440

File tree

3 files changed

+65
-14
lines changed

3 files changed

+65
-14
lines changed

Diff for: src/Composite/Struct/Struct.php

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
final class Struct
1010
{
1111
/**
12+
1213
* @var string
1314
*/
1415
public string $name;
@@ -35,6 +36,7 @@ public function __construct(array $fields)
3536
}
3637

3738
/**
39+
3840
* Add a new field to the struct.
3941
*
4042
* Adds a field to the struct with its specified type and initializes it with a null value.
@@ -111,11 +113,13 @@ public function get(string $name): mixed
111113
}
112114

113115
/**
116+
114117
* Get all fields in the struct.
115118
*
116119
* Returns the entire set of fields in the struct along with their types and values.
117120
*
118121
* @return array<string, array{type: string, value: mixed}> The fields with their respective types and values.
122+
119123
*/
120124
public function getFields(): array
121125
{

Diff for: src/Composite/Union/Union.php

+21-3
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,46 @@
66

77
final class Union
88
{
9+
/**
10+
* @var mixed
11+
*/
912
private mixed $value;
13+
14+
/**
15+
* @var array
16+
*/
1017
private array $allowedTypes;
1118

19+
/**
20+
* @param array $allowedTypes
21+
*/
1222
public function __construct(array $allowedTypes)
1323
{
1424
$this->allowedTypes = $allowedTypes;
1525
}
1626

17-
// Set a value of one of the allowed types
27+
/**
28+
* @param mixed $value
29+
* @return void
30+
*/
1831
public function setValue(mixed $value): void
1932
{
2033
$this->validateType($value);
2134
$this->value = $value;
2235
}
2336

24-
// Get the value
37+
/**
38+
* @return mixed
39+
*/
2540
public function getValue(): mixed
2641
{
2742
return $this->value;
2843
}
2944

30-
// Validate that the value matches one of the allowed types
45+
/**
46+
* @param mixed $value
47+
* @return void
48+
*/
3149
private function validateType(mixed $value): void
3250
{
3351
$type = gettype($value);

Diff for: src/helpers.php

+40-11
Original file line numberDiff line numberDiff line change
@@ -21,62 +21,91 @@
2121
use Nejcc\PhpDatatypes\Scalar\Integers\Unsigned\UInt32;
2222
use Nejcc\PhpDatatypes\Scalar\Integers\Unsigned\UInt8;
2323

24+
/**
25+
* @param int $value
26+
* @return Int8
27+
*/
2428
function int8(int $value): Int8
2529
{
2630
return new Int8($value);
2731
}
2832

33+
/**
34+
* @param int $value
35+
* @return Int16
36+
*/
2937
function int16(int $value): Int16
3038
{
3139
return new Int16($value);
3240
}
3341

42+
/**
43+
* @param int $value
44+
* @return Int32
45+
*/
3446
function int32(int $value): Int32
3547
{
3648
return new Int32($value);
3749
}
3850

51+
/**
52+
* @param int $value
53+
* @return Int64
54+
*/
3955
function int64(int $value): Int64
4056
{
4157
return new Int64($value);
4258
}
4359

60+
/**
61+
* @param int $value
62+
* @return Int128
63+
*/
4464
function int128(int $value): Int128
4565
{
4666
return new Int128($value);
4767
}
4868

69+
/**
70+
* @param int $value
71+
* @return UInt8
72+
*/
4973
function uint8(int $value): UInt8
5074
{
5175
return new UInt8($value);
5276
}
5377

78+
/**
79+
* @param int $value
80+
* @return UInt16
81+
*/
5482
function uint16(int $value): UInt16
5583
{
5684
return new UInt16($value);
5785
}
5886

87+
/**
88+
* @param int $value
89+
* @return UInt32
90+
*/
5991
function uint32(int $value): UInt32
6092
{
6193
return new UInt32($value);
6294
}
6395

64-
//
65-
//function uint64(int $value): Int64
66-
//{
67-
// return new UInt64($value);
68-
//}
69-
//
70-
//function uint128(int $value): Int128
71-
//{
72-
// return new UInt128($value);
73-
//}
74-
96+
/**
97+
* @param float $value
98+
* @return Float32
99+
*/
75100
function float32(float $value): Float32
76101
{
77102
return new Float32($value);
78103
}
79104

105+
/**
106+
* @param float $value
107+
* @return Float64
108+
*/
80109
function float64(float $value): Float64
81110
{
82111
return new Float64($value);

0 commit comments

Comments
 (0)