1 | <?php |
||
7 | class Optional implements ArrayAccess |
||
8 | { |
||
9 | use Traits\Macroable { |
||
10 | __call as macroCall; |
||
11 | } |
||
12 | |||
13 | /** |
||
14 | * The underlying object. |
||
15 | * |
||
16 | * @var mixed |
||
17 | */ |
||
18 | protected $value; |
||
19 | |||
20 | /** |
||
21 | * Create a new optional instance. |
||
22 | * |
||
23 | * @param mixed $value |
||
24 | * @return void |
||
|
|||
25 | */ |
||
26 | public function __construct($value) |
||
30 | |||
31 | /** |
||
32 | * Dynamically access a property on the underlying object. |
||
33 | * |
||
34 | * @param string $key |
||
35 | * @return mixed |
||
36 | */ |
||
37 | public function __get($key) |
||
43 | |||
44 | /** |
||
45 | * Dynamically pass a method to the underlying object. |
||
46 | * |
||
47 | * @param string $method |
||
48 | * @param array $parameters |
||
49 | * @return mixed |
||
50 | */ |
||
51 | public function __call($method, $parameters) |
||
61 | |||
62 | /** |
||
63 | * Determine if an item exists at an offset. |
||
64 | * |
||
65 | * @param mixed $key |
||
66 | * @return bool |
||
67 | */ |
||
68 | public function offsetExists($key) |
||
72 | |||
73 | /** |
||
74 | * Get an item at a given offset. |
||
75 | * |
||
76 | * @param mixed $key |
||
77 | * @return mixed |
||
78 | */ |
||
79 | public function offsetGet($key) |
||
83 | |||
84 | /** |
||
85 | * Set the item at a given offset. |
||
86 | * |
||
87 | * @param mixed $key |
||
88 | * @param mixed $value |
||
89 | * @return void |
||
90 | */ |
||
91 | public function offsetSet($key, $value) |
||
97 | |||
98 | /** |
||
99 | * Unset the item at a given offset. |
||
100 | * |
||
101 | * @param string $key |
||
102 | * @return void |
||
103 | */ |
||
104 | public function offsetUnset($key) |
||
110 | } |
||
111 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.