Skip to content

Commit

Permalink
bug #32796 [Cache] fix warning on PHP 7.4 (jpauli)
Browse files Browse the repository at this point in the history
This PR was merged into the 3.4 branch.

Discussion
----------

[Cache] fix warning on PHP 7.4

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | not all, still some missing I cant find
| Fixed tickets |
| License       | MIT
| Doc PR        |

Some fixes in tests for PHP 7.4

Commits
-------

3324505 [Cache] fix warning on PHP 7.4
  • Loading branch information
nicolas-grekas committed Jul 30, 2019
2 parents 3f43186 + 3324505 commit b706372
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/Symfony/Component/Cache/Adapter/AbstractAdapter.php
Expand Up @@ -49,7 +49,7 @@ protected function __construct($namespace = '', $defaultLifetime = 0)
throw new InvalidArgumentException(sprintf('Namespace must be %d chars max, %d given ("%s")', $this->maxIdLength - 24, \strlen($namespace), $namespace));
}
$this->createCacheItem = \Closure::bind(
function ($key, $value, $isHit) use ($defaultLifetime) {
static function ($key, $value, $isHit) use ($defaultLifetime) {
$item = new CacheItem();
$item->key = $key;
$item->value = $value;
Expand All @@ -63,7 +63,7 @@ function ($key, $value, $isHit) use ($defaultLifetime) {
);
$getId = function ($key) { return $this->getId((string) $key); };
$this->mergeByLifetime = \Closure::bind(
function ($deferred, $namespace, &$expiredIds) use ($getId) {
static function ($deferred, $namespace, &$expiredIds) use ($getId) {
$byLifetime = [];
$now = time();
$expiredIds = [];
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Adapter/ArrayAdapter.php
Expand Up @@ -34,7 +34,7 @@ public function __construct($defaultLifetime = 0, $storeSerialized = true)
{
$this->storeSerialized = $storeSerialized;
$this->createCacheItem = \Closure::bind(
function ($key, $value, $isHit) use ($defaultLifetime) {
static function ($key, $value, $isHit) use ($defaultLifetime) {
$item = new CacheItem();
$item->key = $key;
$item->value = $value;
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Adapter/ChainAdapter.php
Expand Up @@ -56,7 +56,7 @@ public function __construct(array $adapters, $defaultLifetime = 0)
$this->adapterCount = \count($this->adapters);

$this->syncItem = \Closure::bind(
function ($sourceItem, $item) use ($defaultLifetime) {
static function ($sourceItem, $item) use ($defaultLifetime) {
$item->value = $sourceItem->value;
$item->expiry = $sourceItem->expiry;
$item->isHit = $sourceItem->isHit;
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php
Expand Up @@ -42,7 +42,7 @@ public function __construct($file, AdapterInterface $fallbackPool)
$this->pool = $fallbackPool;
$this->zendDetectUnicode = filter_var(ini_get('zend.detect_unicode'), FILTER_VALIDATE_BOOLEAN);
$this->createCacheItem = \Closure::bind(
function ($key, $value, $isHit) {
static function ($key, $value, $isHit) {
$item = new CacheItem();
$item->key = $key;
$item->value = $value;
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Adapter/ProxyAdapter.php
Expand Up @@ -42,7 +42,7 @@ public function __construct(CacheItemPoolInterface $pool, $namespace = '', $defa
$this->namespace = '' === $namespace ? '' : CacheItem::validateKey($namespace);
$this->namespaceLen = \strlen($namespace);
$this->createCacheItem = \Closure::bind(
function ($key, $innerItem) use ($defaultLifetime, $poolHash) {
static function ($key, $innerItem) use ($defaultLifetime, $poolHash) {
$item = new CacheItem();
$item->key = $key;
$item->defaultLifetime = $defaultLifetime;
Expand Down
8 changes: 4 additions & 4 deletions src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php
Expand Up @@ -42,7 +42,7 @@ public function __construct(AdapterInterface $itemsPool, AdapterInterface $tagsP
$this->tags = $tagsPool ?: $itemsPool;
$this->knownTagVersionsTtl = $knownTagVersionsTtl;
$this->createCacheItem = \Closure::bind(
function ($key, $value, CacheItem $protoItem) {
static function ($key, $value, CacheItem $protoItem) {
$item = new CacheItem();
$item->key = $key;
$item->value = $value;
Expand All @@ -56,7 +56,7 @@ function ($key, $value, CacheItem $protoItem) {
CacheItem::class
);
$this->setCacheItemTags = \Closure::bind(
function (CacheItem $item, $key, array &$itemTags) {
static function (CacheItem $item, $key, array &$itemTags) {
if (!$item->isHit) {
return $item;
}
Expand All @@ -76,7 +76,7 @@ function (CacheItem $item, $key, array &$itemTags) {
CacheItem::class
);
$this->getTagsByKey = \Closure::bind(
function ($deferred) {
static function ($deferred) {
$tagsByKey = [];
foreach ($deferred as $key => $item) {
$tagsByKey[$key] = $item->tags;
Expand All @@ -88,7 +88,7 @@ function ($deferred) {
CacheItem::class
);
$this->invalidateTags = \Closure::bind(
function (AdapterInterface $tagsAdapter, array $tags) {
static function (AdapterInterface $tagsAdapter, array $tags) {
foreach ($tags as $v) {
$v->defaultLifetime = 0;
$v->expiry = null;
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Simple/Psr6Cache.php
Expand Up @@ -41,7 +41,7 @@ public function __construct(CacheItemPoolInterface $pool)
}
$cacheItemPrototype = &$this->cacheItemPrototype;
$createCacheItem = \Closure::bind(
function ($key, $value, $allowInt = false) use (&$cacheItemPrototype) {
static function ($key, $value, $allowInt = false) use (&$cacheItemPrototype) {
$item = clone $cacheItemPrototype;
$item->key = $allowInt && \is_int($key) ? (string) $key : CacheItem::validateKey($key);
$item->value = $value;
Expand Down
Expand Up @@ -30,7 +30,7 @@ public function __construct(ParserCacheInterface $pool)
$this->pool = $pool;

$this->createCacheItem = \Closure::bind(
function ($key, $value, $isHit) {
static function ($key, $value, $isHit) {
$item = new CacheItem();
$item->key = $key;
$item->value = $value;
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Routing/Loader/PhpFileLoader.php
Expand Up @@ -40,7 +40,7 @@ public function load($file, $type = null)

// the closure forbids access to the private scope in the included file
$loader = $this;
$load = \Closure::bind(function ($file) use ($loader) {
$load = \Closure::bind(static function ($file) use ($loader) {
return include $file;
}, null, ProtectedPhpFileLoader::class);

Expand Down

0 comments on commit b706372

Please sign in to comment.