1 | <?php |
||
12 | class Container |
||
13 | { |
||
14 | /** |
||
15 | * @var array<string> パラメータMap |
||
16 | */ |
||
17 | protected $values = []; |
||
18 | |||
19 | /** |
||
20 | * @var bool strict container flag |
||
21 | */ |
||
22 | private $isStrict; |
||
23 | |||
24 | /** |
||
25 | * {@inheritdoc} |
||
26 | */ |
||
27 | 15 | public function __construct($isStrict = true) |
|
31 | |||
32 | /** |
||
33 | * magic method of set |
||
34 | * @param string $key キー |
||
35 | * @param mixed $value 値 |
||
36 | * @return void |
||
37 | */ |
||
38 | 6 | public function __set($key, $value) |
|
46 | |||
47 | /** |
||
48 | * magic method of get |
||
49 | * @param string $key キー |
||
50 | * @return mixed 値 |
||
51 | */ |
||
52 | 14 | public function __get($key) |
|
56 | |||
57 | /** |
||
58 | * 未定義のメソッドを処理 |
||
59 | * @param string $name メソッド名 |
||
60 | * @param array $arguments 引数リスト |
||
61 | * @return void |
||
62 | */ |
||
63 | public function __call($name, $arguments) |
||
72 | |||
73 | /** |
||
74 | * キーの値を設定する |
||
75 | * @param string $name メソッド名 |
||
|
|||
76 | * @param array $arguments 引数リスト |
||
77 | * @return void |
||
78 | */ |
||
79 | 9 | public function set($key, $value) |
|
83 | |||
84 | /** |
||
85 | * 格納した値を取得 |
||
86 | * @param string $key キー |
||
87 | * @throws InvalidArgumentException 引数例外 |
||
88 | * @return mixed 格納値 |
||
89 | */ |
||
90 | 14 | public function get($key) |
|
91 | { |
||
92 | 14 | if (!isset($this->values[$key])) { |
|
93 | 2 | if ($this->isStrict) { |
|
94 | 1 | throw new InvalidArgumentException("The value of the specified key does not exist: $key"); |
|
95 | } else { |
||
96 | 1 | return null; |
|
97 | } |
||
98 | } |
||
99 | 12 | if ($this->values[$key] instanceof ValueProxy) { |
|
100 | 4 | return $this->values[$key]->fetch(); |
|
101 | } else { |
||
102 | 9 | return $this->values[$key]; |
|
103 | } |
||
104 | } |
||
105 | |||
106 | /** |
||
107 | * 要素の格納数を返却するを設定する |
||
108 | * @return integer 格納数 |
||
109 | */ |
||
110 | 1 | public function length() |
|
111 | { |
||
112 | 1 | return count($this->values); |
|
113 | } |
||
114 | |||
115 | /** |
||
116 | * 格納された値を削除する |
||
117 | * @param string $key キー |
||
118 | * @return void |
||
119 | */ |
||
120 | 1 | public function remove($key) |
|
121 | { |
||
122 | 1 | unset($this->values[$key]); |
|
123 | 1 | } |
|
124 | |||
125 | /** |
||
126 | * 値を登録する |
||
127 | * @param string $key キー |
||
128 | * @param string $value 値 |
||
129 | * @return void |
||
130 | */ |
||
131 | 4 | public function register($key, $value) |
|
132 | { |
||
133 | 4 | $this->set($key, $value); |
|
134 | 4 | } |
|
135 | |||
136 | /** |
||
137 | * 即時実行した値を登録する |
||
138 | * @param string $key キー |
||
139 | * @param callable $callback クロージャ |
||
140 | * @param array $context クロージャの引数リスト |
||
141 | * @return void |
||
142 | */ |
||
143 | 2 | public function registerAsDynamic($key, $callback, $context = []) |
|
144 | { |
||
145 | 2 | $valueObject = new ValueProxy($callback, $context, true); |
|
146 | 2 | $this->values[$key] = $valueObject->fetch(); |
|
147 | 2 | } |
|
148 | |||
149 | /** |
||
150 | * 遅延評価の値を登録する |
||
151 | * @param string $key キー |
||
152 | * @param callable $callback クロージャ |
||
153 | * @param array $context クロージャの引数リスト |
||
154 | * @return void |
||
155 | */ |
||
156 | 3 | public function registerAsLazy($key, $callback, $context = []) |
|
160 | |||
161 | /** |
||
162 | * 遅延評価の値を登録する |
||
163 | * 繰り返し実行されたときにキャッシュしない |
||
164 | * @param string $key キー |
||
165 | * @param callable $callback クロージャ |
||
166 | * @param array $context クロージャの引数リスト |
||
167 | * @return void |
||
168 | */ |
||
169 | 1 | public function registerAsLazyUnCached($key, $callback, $context = []) |
|
173 | } |
||
174 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.