1 | <?php |
||||||
2 | |||||||
3 | namespace Nip\Container\Traits; |
||||||
4 | |||||||
5 | /** |
||||||
6 | * Class ContainerPersistenceTrait |
||||||
7 | * @package Nip\Container |
||||||
8 | */ |
||||||
9 | trait ContainerArrayAccessTrait |
||||||
10 | { |
||||||
11 | /** |
||||||
12 | * Determine if a given offset exists. |
||||||
13 | * |
||||||
14 | * @param string $key |
||||||
15 | * @return bool |
||||||
16 | */ |
||||||
17 | public function offsetExists($key): bool |
||||||
18 | { |
||||||
19 | return $this->has($key); |
||||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||||
20 | } |
||||||
21 | |||||||
22 | /** |
||||||
23 | * Get the value at a given offset. |
||||||
24 | * |
||||||
25 | * @param string $key |
||||||
26 | * @return mixed |
||||||
27 | */ |
||||||
28 | public function offsetGet($key): mixed |
||||||
29 | { |
||||||
30 | return $this->get($key); |
||||||
0 ignored issues
–
show
It seems like
get() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
31 | } |
||||||
32 | |||||||
33 | /** |
||||||
34 | * Set the value at a given offset. |
||||||
35 | * |
||||||
36 | * @param string $key |
||||||
37 | * @param mixed $value |
||||||
38 | * @return void |
||||||
39 | */ |
||||||
40 | public function offsetSet($key, $value): void |
||||||
41 | { |
||||||
42 | $this->add($key, $value); |
||||||
0 ignored issues
–
show
It seems like
add() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
43 | } |
||||||
44 | |||||||
45 | /** |
||||||
46 | * Unset the value at a given offset. |
||||||
47 | * |
||||||
48 | * @param string $key |
||||||
49 | * @return void |
||||||
50 | */ |
||||||
51 | public function offsetUnset($key): void |
||||||
52 | { |
||||||
53 | $this->remove($key); |
||||||
0 ignored issues
–
show
It seems like
remove() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
54 | } |
||||||
55 | |||||||
56 | /** |
||||||
57 | * Dynamically access container services. |
||||||
58 | * |
||||||
59 | * @param string $key |
||||||
60 | * @return mixed |
||||||
61 | */ |
||||||
62 | public function __get($key) |
||||||
63 | { |
||||||
64 | return $this[$key]; |
||||||
65 | } |
||||||
66 | |||||||
67 | /** |
||||||
68 | * Dynamically set container services. |
||||||
69 | * |
||||||
70 | * @param string $key |
||||||
71 | * @param mixed $value |
||||||
72 | * @return void |
||||||
73 | */ |
||||||
74 | public function __set($key, $value) |
||||||
75 | { |
||||||
76 | $this[$key] = $value; |
||||||
77 | } |
||||||
78 | } |
||||||
79 |