Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a9dfcd8

Browse filesBrowse files
[Cache] Remove silenced warning tiggered by PhpArrayAdapter
1 parent be882c4 commit a9dfcd8
Copy full SHA for a9dfcd8

File tree

1 file changed

+16
-22
lines changed
Filter options

1 file changed

+16
-22
lines changed

‎src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php
+16-22Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,12 @@ public function warmUp(array $values)
163163
*/
164164
public function getItem($key)
165165
{
166-
if (null === $this->values) {
167-
$this->initialize();
168-
}
169-
170166
if (!is_string($key)) {
171167
throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', is_object($key) ? get_class($key) : gettype($key)));
172168
}
173-
169+
if (null === $this->values) {
170+
$this->initialize();
171+
}
174172
if (!isset($this->values[$key])) {
175173
return $this->fallbackPool->getItem($key);
176174
}
@@ -203,15 +201,14 @@ public function getItem($key)
203201
*/
204202
public function getItems(array $keys = array())
205203
{
206-
if (null === $this->values) {
207-
$this->initialize();
208-
}
209-
210204
foreach ($keys as $key) {
211205
if (!is_string($key)) {
212206
throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', is_object($key) ? get_class($key) : gettype($key)));
213207
}
214208
}
209+
if (null === $this->values) {
210+
$this->initialize();
211+
}
215212

216213
return $this->generateItems($keys);
217214
}
@@ -221,13 +218,12 @@ public function getItems(array $keys = array())
221218
*/
222219
public function hasItem($key)
223220
{
224-
if (null === $this->values) {
225-
$this->initialize();
226-
}
227-
228221
if (!is_string($key)) {
229222
throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', is_object($key) ? get_class($key) : gettype($key)));
230223
}
224+
if (null === $this->values) {
225+
$this->initialize();
226+
}
231227

232228
return isset($this->values[$key]) || $this->fallbackPool->hasItem($key);
233229
}
@@ -249,13 +245,12 @@ public function clear()
249245
*/
250246
public function deleteItem($key)
251247
{
252-
if (null === $this->values) {
253-
$this->initialize();
254-
}
255-
256248
if (!is_string($key)) {
257249
throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', is_object($key) ? get_class($key) : gettype($key)));
258250
}
251+
if (null === $this->values) {
252+
$this->initialize();
253+
}
259254

260255
return !isset($this->values[$key]) && $this->fallbackPool->deleteItem($key);
261256
}
@@ -265,10 +260,6 @@ public function deleteItem($key)
265260
*/
266261
public function deleteItems(array $keys)
267262
{
268-
if (null === $this->values) {
269-
$this->initialize();
270-
}
271-
272263
$deleted = true;
273264
$fallbackKeys = array();
274265

@@ -283,6 +274,9 @@ public function deleteItems(array $keys)
283274
$fallbackKeys[] = $key;
284275
}
285276
}
277+
if (null === $this->values) {
278+
$this->initialize();
279+
}
286280

287281
if ($fallbackKeys) {
288282
$deleted = $this->fallbackPool->deleteItems($fallbackKeys) && $deleted;
@@ -328,7 +322,7 @@ public function commit()
328322
*/
329323
private function initialize()
330324
{
331-
$this->values = @(include $this->file) ?: array();
325+
$this->values = file_exists($this->file) ? (include $this->file ?: array()) : array();
332326
}
333327

334328
/**

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.