1 | <?php |
||
8 | class Optional implements ArrayAccess |
||
9 | { |
||
10 | use Traits\Macroable { |
||
11 | __call as macroCall; |
||
12 | } |
||
13 | |||
14 | /** |
||
15 | * The underlying object. |
||
16 | * |
||
17 | * @var mixed |
||
18 | */ |
||
19 | protected $value; |
||
20 | |||
21 | /** |
||
22 | * Create a new optional instance. |
||
23 | * |
||
24 | * @param mixed $value |
||
25 | * @return void |
||
|
|||
26 | */ |
||
27 | public function __construct($value) |
||
31 | |||
32 | /** |
||
33 | * Dynamically access a property on the underlying object. |
||
34 | * |
||
35 | * @param string $key |
||
36 | * @return mixed |
||
37 | */ |
||
38 | public function __get($key) |
||
44 | |||
45 | /** |
||
46 | * Dynamically check a property exists on the underlying object. |
||
47 | * |
||
48 | * @param $name |
||
49 | * @return bool |
||
50 | */ |
||
51 | public function __isset($name) |
||
63 | |||
64 | /** |
||
65 | * Determine if an item exists at an offset. |
||
66 | * |
||
67 | * @param mixed $key |
||
68 | * @return bool |
||
69 | */ |
||
70 | public function offsetExists($key) |
||
74 | |||
75 | /** |
||
76 | * Get an item at a given offset. |
||
77 | * |
||
78 | * @param mixed $key |
||
79 | * @return mixed |
||
80 | */ |
||
81 | public function offsetGet($key) |
||
85 | |||
86 | /** |
||
87 | * Set the item at a given offset. |
||
88 | * |
||
89 | * @param mixed $key |
||
90 | * @param mixed $value |
||
91 | * @return void |
||
92 | */ |
||
93 | public function offsetSet($key, $value) |
||
99 | |||
100 | /** |
||
101 | * Unset the item at a given offset. |
||
102 | * |
||
103 | * @param string $key |
||
104 | * @return void |
||
105 | */ |
||
106 | public function offsetUnset($key) |
||
112 | |||
113 | /** |
||
114 | * Dynamically pass a method to the underlying object. |
||
115 | * |
||
116 | * @param string $method |
||
117 | * @param array $parameters |
||
118 | * @return mixed |
||
119 | */ |
||
120 | public function __call($method, $parameters) |
||
130 | } |
||
131 |
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.