From 903cc28c2035238817698dcfaf86fe7cd198c4c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Novotn=C3=BD?= Date: Sat, 18 Jan 2020 13:40:31 +0100 Subject: [PATCH] Reformat code for phpstan/phpstan ^0.12 --- README.md | 17 +++++++++++++++++ phpstan.neon.dist | 1 - src/Model/Values/Mcrouter.php | 8 ++++---- src/Model/Values/TagSet.php | 8 ++++---- src/Services/MemcachedStore.php | 14 +++++++------- 5 files changed, 32 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index acf05a3..a8f24dd 100755 --- a/README.md +++ b/README.md @@ -109,6 +109,23 @@ get __prefix__:/default/c/foo ``` +### Cache tags static cache + +```php +cache()->tags(['bop', 'zap'])->get('bar1'); +cache()->tags(['bop'])->get('bar2'); +cache()->tags(['bop', 'zap', 'foo'])->get('bar3'); +``` +``` +get tag:bop:key +get tag:zap:key +get bar1 +get bar2 +get tag:foo:key +get bar3 +``` + + ### Mcrouter configuration This configuration example is for multiple Memcached servers, one of which is local, such as a typical Kubernetes cluster. diff --git a/phpstan.neon.dist b/phpstan.neon.dist index a8ac3db..901f6de 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,7 +1,6 @@ includes: - vendor/phpstan/phpstan-mockery/extension.neon parameters: - checkMissingIterableValueType: false ignoreErrors: - message: '#Cannot access offset (.+)#' diff --git a/src/Model/Values/Mcrouter.php b/src/Model/Values/Mcrouter.php index 4771cda..a524202 100644 --- a/src/Model/Values/Mcrouter.php +++ b/src/Model/Values/Mcrouter.php @@ -21,15 +21,15 @@ class Mcrouter /** * Supported prefixes in Mcrouter * - * @var string[] + * @var array */ private $prefixes = []; /** * Mcrouter constructor * - * @param string $sharedPrefix - * @param string[] $supportedPrefixes + * @param string $sharedPrefix + * @param array $supportedPrefixes */ public function __construct(string $sharedPrefix, array $supportedPrefixes = []) { @@ -40,7 +40,7 @@ public function __construct(string $sharedPrefix, array $supportedPrefixes = []) /** * Get the cache prefixes. * - * @return string[] + * @return array */ public function getPrefixes(): array { diff --git a/src/Model/Values/TagSet.php b/src/Model/Values/TagSet.php index cc9e566..7046a51 100644 --- a/src/Model/Values/TagSet.php +++ b/src/Model/Values/TagSet.php @@ -10,7 +10,7 @@ class TagSet extends LaravelTagSet /** * Static cache for tags * - * @var string[] + * @var array */ private static $tags = []; @@ -25,7 +25,7 @@ class TagSet extends LaravelTagSet * Create a new TagSet instance. * * @param \Illuminate\Contracts\Cache\Store $store - * @param string[] $names + * @param array $names * @param \Inspirum\Mcrouter\Model\Values\Mcrouter $mcrouter */ public function __construct(Store $store, array $names, Mcrouter $mcrouter) @@ -38,7 +38,7 @@ public function __construct(Store $store, array $names, Mcrouter $mcrouter) /** * Get an array of tag identifiers for all of the tags in the set. * - * @return string[] + * @return array */ protected function tagIds() { @@ -98,7 +98,7 @@ public static function resetCachedTags(): void /** * Get cached tags from static memory * - * @return string[] + * @return array */ public static function getCachedTags(): array { diff --git a/src/Services/MemcachedStore.php b/src/Services/MemcachedStore.php index a9a179a..654f665 100644 --- a/src/Services/MemcachedStore.php +++ b/src/Services/MemcachedStore.php @@ -34,7 +34,7 @@ public function __construct(Memcached $memcached, string $prefix = '', Mcrouter /** * Begin executing a new tags operation. * - * @param string|string[] $names + * @param string|array $names * * @return \Illuminate\Cache\TaggedCache */ @@ -66,9 +66,9 @@ public function get($key) * * Items not found in the cache will have a null value. * - * @param string[] $keys + * @param array $keys * - * @return array + * @return array */ public function many(array $keys) { @@ -76,14 +76,14 @@ public function many(array $keys) return $this->getPrefixedKey($key); }, $keys); - /** @var array $values */ + /** @var array $values */ $values = $this->memcached->getMulti($prefixedKeys, Memcached::GET_PRESERVE_ORDER); if ($this->memcached->getResultCode() !== 0) { return array_fill_keys($keys, null); } - /** @var array $values */ + /** @var array $values */ $values = array_combine($keys, $values); return $values; @@ -106,8 +106,8 @@ public function put($key, $value, $seconds) /** * Store multiple items in the cache for a given number of minutes. * - * @param array $values - * @param int $seconds + * @param array $values + * @param int $seconds * * @return bool */