Skip to content

Commit 6a2162a

Browse files
committed
update phpdocs
1 parent cf39f5a commit 6a2162a

File tree

4 files changed

+82
-27
lines changed

4 files changed

+82
-27
lines changed

src/Composite/Dictionary.php

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77

88
class Dictionary
99
{
10-
private array $elements;
10+
/**
11+
* @var array
12+
*/
13+
private array $elements = [];
1114

1215
public function __construct(array $elements = [])
1316
{
@@ -21,13 +24,22 @@ public function __construct(array $elements = [])
2124
$this->elements = $elements;
2225
}
2326

24-
// Add a key-value pair to the dictionary
27+
28+
/**
29+
* @param string $key
30+
* @param $value
31+
* @return void
32+
*/
2533
public function add(string $key, $value): void
2634
{
2735
$this->elements[$key] = $value;
2836
}
2937

30-
// Get the value associated with a key
38+
39+
/**
40+
* @param string $key
41+
* @return mixed
42+
*/
3143
public function get(string $key)
3244
{
3345
if (!isset($this->elements[$key])) {
@@ -37,7 +49,11 @@ public function get(string $key)
3749
return $this->elements[$key];
3850
}
3951

40-
// Remove a key-value pair by the key
52+
53+
/**
54+
* @param string $key
55+
* @return void
56+
*/
4157
public function remove(string $key): void
4258
{
4359
if (!isset($this->elements[$key])) {
@@ -47,31 +63,45 @@ public function remove(string $key): void
4763
unset($this->elements[$key]);
4864
}
4965

50-
// Check if a key exists in the dictionary
66+
/**
67+
* @param string $key
68+
* @return bool
69+
*/
5170
public function containsKey(string $key): bool
5271
{
5372
return array_key_exists($key, $this->elements);
5473
}
5574

56-
// Get all keys in the dictionary
75+
76+
/**
77+
* @return array
78+
*/
5779
public function getKeys(): array
5880
{
5981
return array_keys($this->elements);
6082
}
6183

62-
// Get all values in the dictionary
84+
85+
/**
86+
* @return array
87+
*/
6388
public function getValues(): array
6489
{
6590
return array_values($this->elements);
6691
}
6792

68-
// Get the size of the dictionary
93+
/**
94+
* @return int
95+
*/
6996
public function size(): int
7097
{
7198
return count($this->elements);
7299
}
73100

74-
// Clear the dictionary
101+
102+
/**
103+
* @return void
104+
*/
75105
public function clear(): void
76106
{
77107
$this->elements = [];

src/Composite/Struct/Struct.php

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
final class Struct
88
{
9+
/**
10+
* @var array
11+
*/
912
private array $fields = [];
1013

1114
public function __construct(array $fields)
@@ -15,7 +18,11 @@ public function __construct(array $fields)
1518
}
1619
}
1720

18-
// Add a field with a specific type
21+
/**
22+
* @param string $name
23+
* @param string $type
24+
* @return void
25+
*/
1926
public function addField(string $name, string $type): void
2027
{
2128
$this->fields[$name] = [
@@ -24,7 +31,12 @@ public function addField(string $name, string $type): void
2431
];
2532
}
2633

27-
// Set the value of a field, ensuring it matches the type
34+
35+
/**
36+
* @param string $name
37+
* @param $value
38+
* @return void
39+
*/
2840
public function set(string $name, $value): void
2941
{
3042
if (!isset($this->fields[$name])) {
@@ -42,7 +54,11 @@ public function set(string $name, $value): void
4254
$this->fields[$name]['value'] = $value;
4355
}
4456

45-
// Get the value of a field
57+
58+
/**
59+
* @param string $name
60+
* @return mixed
61+
*/
4662
public function get(string $name)
4763
{
4864
if (!isset($this->fields[$name])) {
@@ -52,7 +68,9 @@ public function get(string $name)
5268
return $this->fields[$name]['value'];
5369
}
5470

55-
// Get all fields
71+
/**
72+
* @return array
73+
*/
5674
public function getFields(): array
5775
{
5876
return $this->fields;

src/Composite/Union/Union.php

Lines changed: 21 additions & 3 deletions
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);

src/helpers.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,6 @@ function uint32(int $value): UInt32
5555
return new UInt32($value);
5656
}
5757

58-
//
59-
//function uint64(int $value): Int64
60-
//{
61-
// return new UInt64($value);
62-
//}
63-
//
64-
//function uint128(int $value): Int128
65-
//{
66-
// return new UInt128($value);
67-
//}
68-
6958
function float32(float $value): Float32
7059
{
7160
return new Float32($value);

0 commit comments

Comments
 (0)