8000 Merge branch '3.4' into 4.0 · symfony/cache@c0d079e · GitHub
[go: up one dir, main page]

Skip to content

Commit c0d079e

Browse files
Merge branch '3.4' into 4.0
* 3.4: Fix Clidumper tests Enable the fixer enforcing fully-qualified calls for compiler-optimized functions Apply fixers Disable the native_constant_invocation fixer until it can be scoped Update the list of excluded files for the CS fixer
2 parents 016e71c + 76875f4 commit c0d079e

32 files changed

+106
-106
lines changed

Adapter/AbstractAdapter.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ abstract class AbstractAdapter implements AdapterInterface, LoggerAwareInterface
3636
protected function __construct(string $namespace = '', int $defaultLifetime = 0)
3737
{
3838
$this->namespace = '' === $namespace ? '' : CacheItem::validateKey($namespace).':';
39-
if (null !== $this->maxIdLength && strlen($namespace) > $this->maxIdLength - 24) {
40-
throw new InvalidArgumentException(sprintf('Namespace must be %d chars max, %d given ("%s")', $this->maxIdLength - 24, strlen($namespace), $namespace));
39+
if (null !== $this->maxIdLength && \strlen($namespace) > $this->maxIdLength - 24) {
40+
throw new InvalidArgumentException(sprintf('Namespace must be %d chars max, %d given ("%s")', $this->maxIdLength - 24, \strlen($namespace), $namespace));
4141
}
4242
$this->createCacheItem = \Closure::bind(
4343
function ($key, $value, $isHit) use ($defaultLifetime) {
@@ -124,8 +124,8 @@ public static function createSystemCache($namespace, $defaultLifetime, $version,
124124

125125
public static function createConnection($dsn, array $options = array())
126126
{
127-
if (!is_string($dsn)) {
128-
throw new InvalidArgumentException(sprintf('The %s() method expect argument #1 to be string, %s given.', __METHOD__, gettype($dsn)));
127+
if (!\is_string($dsn)) {
128+
throw new InvalidArgumentException(sprintf('The %s() method expect argument #1 to be string, %s given.', __METHOD__, \gettype($dsn)));
129129
}
130130
if (0 === strpos($dsn, 'redis://')) {
131131
return RedisAdapter::createConnection($dsn, $options);
@@ -234,11 +234,11 @@ public function commit()
234234
continue;
235235
}
236236
if (\is_array($e) || 1 === \count($values)) {
237-
foreach (is_array($e) ? $e : array_keys($values) as $id) {
237+
foreach (\is_array($e) ? $e : array_keys($values) as $id) {
238238
$ok = false;
239239
$v = $values[$id];
240-
$type = is_object($v) ? get_class($v) : gettype($v);
241-
CacheItem::log($this->logger, 'Failed to save key "{key}" ({type})', array('key' => substr($id, strlen($this->namespace)), 'type' => $type, 'exception' => $e instanceof \Exception ? $e : null));
240+
$type = \is_object($v) ? \get_class($v) : \gettype($v);
241+
CacheItem::log($this->logger, 'Failed to save key "{key}" ({type})', array('key' => substr($id, \strlen($this->namespace)), 'type' => $type, 'exception' => $e instanceof \Exception ? $e : null));
242242
}
243243
} else {
244244
foreach ($values as $id => $v) {
@@ -259,8 +259,8 @@ public function commit()
259259
continue;
260260
}
261261
$ok = false;
262-
$type = is_object($v) ? get_class($v) : gettype($v);
263-
CacheItem::log($this->logger, 'Failed to save key "{key}" ({type})', array('key' => substr($id, strlen($this->namespace)), 'type' => $type, 'exception' => $e instanceof \Exception ? $e : null));
262+
$type = \is_object($v) ? \get_class($v) : \gettype($v);
263+
CacheItem::log($this->logger, 'Failed to save key "{key}" ({type})', array('key' => substr($id, \strlen($this->namespace)), 'type' => $type, 'exception' => $e instanceof \Exception ? $e : null));
264264
}
265265
}
266266

Adapter/ArrayAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public function save(CacheItemInterface $item)
121121
try {
122122
$value = serialize($value);
123123
} catch (\Exception $e) {
124-
$type = is_object($value) ? get_class($value) : gettype($value);
124+
$type = \is_object($value) ? \get_class($value) : \gettype($value);
125125
CacheItem::log($this->logger, 'Failed to save key "{key}" ({type})', array('key' => $key, 'type' => $type, 'exception' => $e));
126126

127127
return false;

Adapter/ChainAdapter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function __construct(array $adapters, int $defaultLifetime = 0)
4444

4545
foreach ($adapters as $adapter) {
4646
if (!$adapter instanceof CacheItemPoolInterface) {
47-
throw new InvalidArgumentException(sprintf('The class "%s" does not implement the "%s" interface.', get_class($adapter), CacheItemPoolInterface::class));
47+
throw new InvalidArgumentException(sprintf('The class "%s" does not implement the "%s" interface.', \get_class($adapter), CacheItemPoolInterface::class));
4848
}
4949

5050
if ($adapter instanceof AdapterInterface) {
@@ -53,7 +53,7 @@ public function __construct(array $adapters, int $defaultLifetime = 0)
5353
$this->adapters[] = new ProxyAdapter($adapter);
5454
}
5555
}
56-
$this->adapterCount = count($this->adapters);
56+
$this->adapterCount = \count($this->adapters);
5757

5858
$this->syncItem = \Closure::bind(
5959
function ($sourceItem, $item) use ($defaultLifetime) {

Adapter/PhpArrayAdapter.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public static function create($file, CacheItemPoolInterface $fallbackPool)
8383
public function getItem($key)
8484
{
8585
if (!\is_string($key)) {
86-
throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', is_object($key) ? get_class($key) : gettype($key)));
86+
throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', \is_object($key) ? \get_class($key) : \gettype($key)));
8787
}
8888
if (null === $this->values) {
8989
$this->initialize();
@@ -118,7 +118,7 @@ public function getItems(array $keys = array())
118118
{
119119
foreach ($keys as $key) {
120120
if (!\is_string($key)) {
121-
throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', is_object($key) ? get_class($key) : gettype($key)));
121+
throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', \is_object($key) ? \get_class($key) : \gettype($key)));
122122
}
123123
}
124124
if (null === $this->values) {
@@ -134,7 +134,7 @@ public function getItems(array $keys = array())
134134
public function hasItem($key)
135135
{
136136
if (!\is_string($key)) {
137-
throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', is_object($key) ? get_class($key) : gettype($key)));
137+
throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', \is_object($key) ? \get_class($key) : \gettype($key)));
138138
}
139139
if (null === $this->values) {
140140
$this->initialize();
@@ -149,7 +149,7 @@ public function hasItem($key)
149149
public function deleteItem($key)
150150
{
151151
if (!\is_string($key)) {
152-
throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', is_object($key) ? get_class($key) : gettype($key)));
152+
throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', \is_object($key) ? \get_class($key) : \gettype($key)));
153153
}
154154
if (null === $this->values) {
155155
$this->initialize();
@@ -168,7 +168,7 @@ public function deleteItems(array $keys)
168168

169169
foreach ($keys as $key) {
170170
if (!\is_string($key)) {
171-
throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', is_object($key) ? get_class($key) : gettype($key)));
171+
throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', \is_object($key) ? \get_class($key) : \gettype($key)));
172172
}
173173

174174
if (isset($this->values[$key])) {

Adapter/ProxyAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function __construct(CacheItemPoolInterface $pool, string $namespace = ''
3535
$this->pool = $pool;
3636
$this->poolHash = $poolHash = spl_object_hash($pool);
3737
$this->namespace = '' === $namespace ? '' : CacheItem::validateKey($namespace);
38-
$this->namespaceLen = strlen($namespace);
38+
$this->namespaceLen = \strlen($namespace);
3939
$this->createCacheItem = \Closure::bind(
4040
function ($key, $innerItem) use ($defaultLifetime, $poolHash) {
4141
$item = new CacheItem();

CacheItem.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function expiresAt($expiration)
7474
} elseif ($expiration instanceof \DateTimeInterface) {
7575
$this->expiry = (int) $expiration->format('U');
7676
} else {
77-
throw new InvalidArgumentException(sprintf('Expiration date must implement DateTimeInterface or be null, "%s" given', is_object($expiration) ? get_class($expiration) : gettype($expiration)));
77+
throw new InvalidArgumentException(sprintf('Expiration date must implement DateTimeInterface or be null, "%s" given', \is_object($expiration) ? \get_class($expiration) : \gettype($expiration)));
7878
}
7979

8080
return $this;
@@ -92,7 +92,7 @@ public function expiresAfter($time)
9292
} elseif (\is_int($time)) {
9393
$this->expiry = $time + time();
9494
} else {
95-
throw new InvalidArgumentException(sprintf('Expiration date must be an integer, a DateInterval or null, "%s" given', is_object($time) ? get_class($time) : gettype($time)));
95+
throw new InvalidArgumentException(sprintf('Expiration date must be an integer, a DateInterval or null, "%s" given', \is_object($time) ? \get_class($time) : \gettype($time)));
9696
}
9797

9898
return $this;
@@ -114,7 +114,7 @@ public function tag($tags)
114114
}
115115
foreach ($tags as $tag) {
116116
if (!\is_string($tag)) {
117-
throw new InvalidArgumentException(sprintf('Cache tag must be string, "%s" given', is_object($tag) ? get_class($tag) : gettype($tag)));
117+
throw new InvalidArgumentException(sprintf('Cache tag must be string, "%s" given', \is_object($tag) ? \get_class($tag) : \gettype($tag)));
118118
}
119119
if (isset($this->tags[$tag])) {
120120
continue;
@@ -153,7 +153,7 @@ public function getPreviousTags()
153153
public static function validateKey($key)
154154
{
155155
if (!\is_string($key)) {
156-
throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given', is_object($key) ? get_class($key) : gettype($key)));
156+
throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given', \is_object($key) ? \get_class($key) : \gettype($key)));
157157
}
158158
if ('' === 10000 $key) {
159159
throw new InvalidArgumentException('Cache key length must be greater than zero');

Simple/AbstractCache.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ protected function __construct(string $namespace = '', int $defaultLifetime = 0)
3535
{
3636
$this->defaultLifetime = max(0, $defaultLifetime);
3737
$this->namespace = '' === $namespace ? '' : CacheItem::validateKey($namespace).':';
38-
if (null !== $this->maxIdLength && strlen($namespace) > $this->maxIdLength - 24) {
39-
throw new InvalidArgumentException(sprintf('Namespace must be %d chars max, %d given ("%s")', $this->maxIdLength - 24, strlen($namespace), $namespace));
38+
if (null !== $this->maxIdLength && \strlen($namespace) > $this->maxIdLength - 24) {
39+
throw new InvalidArgumentException(sprintf('Namespace must be %d chars max, %d given ("%s")', $this->maxIdLength - 24, \strlen($namespace), $namespace));
4040
}
4141
}
4242

@@ -76,7 +76,7 @@ public function getMultiple($keys, $default = null)
7676
if ($keys instanceof \Traversable) {
7777
$keys = iterator_to_array($keys, false);
7878
} elseif (!\is_array($keys)) {
79-
throw new InvalidArgumentException(sprintf('Cache keys must be array or Traversable, "%s" given', is_object($keys) ? get_class($keys) : gettype($keys)));
79+
throw new InvalidArgumentException(sprintf('Cache keys must be array or Traversable, "%s" given', \is_object($keys) ? \get_class($keys) : \gettype($keys)));
8080
}
8181
$ids = array();
8282

@@ -100,7 +100,7 @@ public function getMultiple($keys, $default = null)
100100
public function setMultiple($values, $ttl = null)
101101
{
102102
if (!\is_array($values) && !$values instanceof \Traversable) {
103-
throw new InvalidArgumentException(sprintf('Cache values must be array or Traversable, "%s" given', is_object($values) ? get_class($values) : gettype($values)));
103+
throw new InvalidArgumentException(sprintf('Cache values must be array or Traversable, "%s" given', \is_object($values) ? \get_class($values) : \gettype($values)));
104104
}
105105
$valuesById = array();
106106

@@ -123,7 +123,7 @@ public function setMultiple($values, $ttl = null)
123123
}
124124
$keys = array();
125125
foreach (\is_array($e) ? $e : array_keys($valuesById) as $id) {
126-
$keys[] = substr($id, strlen($this->namespace));
126+
$keys[] = substr($id, \strlen($this->namespace));
127127
}
128128
CacheItem::log($this->logger, 'Failed to save values', array('keys' => $keys, 'exception' => $e instanceof \Exception ? $e : null));
129129

@@ -138,7 +138,7 @@ public function deleteMultiple($keys)
138138
if ($keys instanceof \Traversable) {
139139
$keys = iterator_to_array($keys, false);
140140
} elseif (!\is_array($keys)) {
141-
throw new InvalidArgumentException(sprintf('Cache keys must be array or Traversable, "%s" given', is_object($keys) ? get_class($keys) : gettype($keys)));
141+
throw new InvalidArgumentException(sprintf('Cache keys must be array or Traversable, "%s" given', \is_object($keys) ? \get_class($keys) : \gettype($keys)));
142142
}
143143

144144
return $this->deleteItems($keys);
@@ -156,7 +156,7 @@ private function normalizeTtl($ttl)
156156
return 0 < $ttl ? $ttl : false;
157157
}
158158

159-
throw new InvalidArgumentException(sprintf('Expiration date must be an integer, a DateInterval or null, "%s" given', is_object($ttl) ? get_class($ttl) : gettype($ttl)));
159+
throw new InvalidArgumentException(sprintf('Expiration date must be an integer, a DateInterval or null, "%s" given', \is_object($ttl) ? \get_class($ttl) : \gettype($ttl)));
160160
}
161161

162162
private function generateValues($values, &$keys, $default)

Simple/ArrayCache.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function getMultiple($keys, $default = null)
5858
if ($keys instanceof \Traversable) {
5959
$keys = iterator_to_array($keys, false);
6060
} elseif (!\is_array($keys)) {
61-
throw new InvalidArgumentException(sprintf('Cache keys must be array or Traversable, "%s" given', is_object($keys) ? get_class($keys) : gettype($keys)));
61+
throw new InvalidArgumentException(sprintf('Cache keys must be array or Traversable, "%s" given', \is_object($keys) ? \get_class($keys) : \gettype($keys)));
6262
}
6363
foreach ($keys as $key) {
6464
CacheItem::validateKey($key);
@@ -73,7 +73,7 @@ public function getMultiple($keys, $default = null)
7373
public function deleteMultiple($keys)
7474
{
7575
if (!\is_array($keys) && !$keys instanceof \Traversable) {
76-
throw new InvalidArgumentException(sprintf('Cache keys must be array or Traversable, "%s" given', is_object($keys) ? get_class($keys) : gettype($keys)));
76+
throw new InvalidArgumentException(sprintf('Cache keys must be array or Traversable, "%s" given', \is_object($keys) ? \get_class($keys) : \gettype($keys)));
7777
}
7878
foreach ($keys as $key) {
7979
$this->delete($key);
@@ -98,7 +98,7 @@ public function set($key, $value, $ttl = null)
9898
public function setMultiple($values, $ttl = null)
9999
{
100100
if (!\is_array($values) && !$values instanceof \Traversable) {
101-
throw new InvalidArgumentException(sprintf('Cache values must be array or Traversable, "%s" given', is_object($values) ? get_class($values) : gettype($values)));
101+
throw new InvalidArgumentException(sprintf('Cache values must be array or Traversable, "%s" given', \is_object($values) ? \get_class($values) : \gettype($values)));
102102
}
103103
$valuesArray = array();
104104

@@ -114,7 +114,7 @@ public function setMultiple($values, $ttl = null)
114114
try {
115115
$valuesArray[$key] = serialize($value);
116116
} catch (\Exception $e) {
117-
$type = is_object($value) ? get_class($value) : gettype($value);
117+
$type = \is_object($value) ? \get_class($value) : \gettype($value);
118118
CacheItem::log($this->logger, 'Failed to save key "{key}" ({type})', array('key' => $key, 'type' => $type, 'exception' => $e));
119119

120120
return false;
@@ -143,6 +143,6 @@ private function normalizeTtl($ttl)
143143
return 0 < $ttl ? $ttl : false;
144144
}
145145

146-
throw new InvalidArgumentException(sprintf('Expiration date must be an integer, a DateInterval or null, "%s" given', is_object($ttl) ? get_class($ttl) : gettype($ttl)));
146+
throw new InvalidArgumentException(sprintf('Expiration date must be an integer, a DateInterval or null, "%s" given', \is_object($ttl) ? \get_class($ttl) : \gettype($ttl)));
147147
}
148148
}

Simple/ChainCache.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ public function __construct(array $caches, int $defaultLifetime = 0)
4343

4444
foreach ($caches as $cache) {
4545
if (!$cache instanceof CacheInterface) {
46-
throw new InvalidArgumentException(sprintf('The class "%s" does not implement the "%s" interface.', get_class($cache), CacheInterface::class));
46+
throw new InvalidArgumentException(sprintf('The class "%s" does not implement the "%s" interface.', \get_class($cache), CacheInterface::class));
4747
}
4848
}
4949

5050
$this->miss = new \stdClass();
5151
$this->caches = array_values($caches);
52-
$this->cacheCount = count($this->caches);
52+
$this->cacheCount = \count($this->caches);
5353
$this->defaultLifetime = 0 < $defaultLifetime ? $defaultLifetime : null;
5454
}
5555

0 commit comments

Comments
 (0)
0