| 1 | <?php |
||
| 2 | |||
| 3 | namespace AlibabaCloud\Client\Traits; |
||
| 4 | |||
| 5 | /** |
||
| 6 | * Trait ArrayAccessTrait |
||
| 7 | * |
||
| 8 | * @package AlibabaCloud\Client\Traits |
||
| 9 | */ |
||
| 10 | trait ArrayAccessTrait |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * This method returns a reference to the variable to allow for indirect |
||
| 14 | * array modification (e.g., $foo['bar']['baz'] = 'qux'). |
||
| 15 | * |
||
| 16 | * @param string $offset |
||
| 17 | * |
||
| 18 | * @return mixed|null |
||
| 19 | */ |
||
| 20 | 1 | #[\ReturnTypeWillChange] |
|
| 21 | public function & offsetGet($offset) |
||
| 22 | 1 | { |
|
| 23 | 1 | if (isset($this->data[$offset])) { |
|
| 24 | return $this->data[$offset]; |
||
| 25 | } |
||
| 26 | 1 | ||
| 27 | $value = null; |
||
| 28 | 1 | ||
| 29 | return $value; |
||
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @param string $offset |
||
| 34 | * @param string|mixed $value |
||
| 35 | 1 | */ |
|
| 36 | #[\ReturnTypeWillChange] |
||
| 37 | 1 | public function offsetSet($offset, $value) |
|
| 38 | 1 | { |
|
| 39 | $this->data[$offset] = $value; |
||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @param string $offset |
||
| 44 | * |
||
| 45 | 1 | * @return bool |
|
| 46 | */ |
||
| 47 | 1 | #[\ReturnTypeWillChange] |
|
| 48 | public function offsetExists($offset) |
||
| 49 | { |
||
| 50 | return isset($this->data[$offset]); |
||
| 51 | } |
||
| 52 | |||
| 53 | 1 | /** |
|
| 54 | * @param string $offset |
||
| 55 | 1 | */ |
|
| 56 | 1 | #[\ReturnTypeWillChange] |
|
| 57 | public function offsetUnset($offset) |
||
| 58 | { |
||
| 59 | unset($this->data[$offset]); |
||
| 60 | } |
||
| 61 | } |
||
| 62 |