[Cache] Added reserved characters constant for CacheItem
This commit is contained in:
parent
f0aff8c4d5
commit
d8533066de
@ -129,8 +129,8 @@ final class CacheItem implements ItemInterface
|
||||
if ('' === $tag) {
|
||||
throw new InvalidArgumentException('Cache tag length must be greater than zero');
|
||||
}
|
||||
if (false !== strpbrk($tag, '{}()/\@:')) {
|
||||
throw new InvalidArgumentException(sprintf('Cache tag "%s" contains reserved characters {}()/\@:', $tag));
|
||||
if (false !== strpbrk($tag, self::RESERVED_CHARACTERS)) {
|
||||
throw new InvalidArgumentException(sprintf('Cache tag "%s" contains reserved characters %s', $tag, self::RESERVED_CHARACTERS));
|
||||
}
|
||||
$this->newMetadata[self::METADATA_TAGS][$tag] = $tag;
|
||||
}
|
||||
@ -173,8 +173,8 @@ final class CacheItem implements ItemInterface
|
||||
if ('' === $key) {
|
||||
throw new InvalidArgumentException('Cache key length must be greater than zero');
|
||||
}
|
||||
if (false !== strpbrk($key, '{}()/\@:')) {
|
||||
throw new InvalidArgumentException(sprintf('Cache key "%s" contains reserved characters {}()/\@:', $key));
|
||||
if (false !== strpbrk($key, self::RESERVED_CHARACTERS)) {
|
||||
throw new InvalidArgumentException(sprintf('Cache key "%s" contains reserved characters %s', $key, self::RESERVED_CHARACTERS));
|
||||
}
|
||||
|
||||
return $key;
|
||||
|
@ -24,7 +24,7 @@
|
||||
"php": "^7.1.3",
|
||||
"psr/cache": "~1.0",
|
||||
"psr/log": "~1.0",
|
||||
"symfony/cache-contracts": "^1.1|^2",
|
||||
"symfony/cache-contracts": "^1.1.7|^2",
|
||||
"symfony/service-contracts": "^1.1|^2",
|
||||
"symfony/var-exporter": "^4.2|^5.0"
|
||||
},
|
||||
|
@ -37,6 +37,11 @@ interface ItemInterface extends CacheItemInterface
|
||||
*/
|
||||
const METADATA_TAGS = 'tags';
|
||||
|
||||
/**
|
||||
* Reserved characters that cannot be used in a key or tag.
|
||||
*/
|
||||
const RESERVED_CHARACTERS = '{}()/\@:';
|
||||
|
||||
/**
|
||||
* Adds a tag to a cache item.
|
||||
*
|
||||
|
Reference in New Issue
Block a user