Skip to content

Commit

Permalink
Reformat code for phpstan/phpstan ^0.12
Browse files Browse the repository at this point in the history
  • Loading branch information
tomas-novotny committed Jan 18, 2020
1 parent 00ec59b commit 903cc28
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 16 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
includes:
- vendor/phpstan/phpstan-mockery/extension.neon
parameters:
checkMissingIterableValueType: false
ignoreErrors:
-
message: '#Cannot access offset (.+)#'
Expand Down
8 changes: 4 additions & 4 deletions src/Model/Values/Mcrouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ class Mcrouter
/**
* Supported prefixes in Mcrouter
*
* @var string[]
* @var array<string>
*/
private $prefixes = [];

/**
* Mcrouter constructor
*
* @param string $sharedPrefix
* @param string[] $supportedPrefixes
* @param string $sharedPrefix
* @param array<string> $supportedPrefixes
*/
public function __construct(string $sharedPrefix, array $supportedPrefixes = [])
{
Expand All @@ -40,7 +40,7 @@ public function __construct(string $sharedPrefix, array $supportedPrefixes = [])
/**
* Get the cache prefixes.
*
* @return string[]
* @return array<string>
*/
public function getPrefixes(): array
{
Expand Down
8 changes: 4 additions & 4 deletions src/Model/Values/TagSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class TagSet extends LaravelTagSet
/**
* Static cache for tags
*
* @var string[]
* @var array<string>
*/
private static $tags = [];

Expand All @@ -25,7 +25,7 @@ class TagSet extends LaravelTagSet
* Create a new TagSet instance.
*
* @param \Illuminate\Contracts\Cache\Store $store
* @param string[] $names
* @param array<string> $names
* @param \Inspirum\Mcrouter\Model\Values\Mcrouter $mcrouter
*/
public function __construct(Store $store, array $names, Mcrouter $mcrouter)
Expand All @@ -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<string>
*/
protected function tagIds()
{
Expand Down Expand Up @@ -98,7 +98,7 @@ public static function resetCachedTags(): void
/**
* Get cached tags from static memory
*
* @return string[]
* @return array<string>
*/
public static function getCachedTags(): array
{
Expand Down
14 changes: 7 additions & 7 deletions src/Services/MemcachedStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> $names
*
* @return \Illuminate\Cache\TaggedCache
*/
Expand Down Expand Up @@ -66,24 +66,24 @@ public function get($key)
*
* Items not found in the cache will have a null value.
*
* @param string[] $keys
* @param array<string> $keys
*
* @return array
* @return array<string,mixed>
*/
public function many(array $keys)
{
$prefixedKeys = array_map(function ($key) {
return $this->getPrefixedKey($key);
}, $keys);

/** @var array $values */
/** @var array<mixed> $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<mixed> $values */
$values = array_combine($keys, $values);

return $values;
Expand All @@ -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<string,mixed> $values
* @param int $seconds
*
* @return bool
*/
Expand Down

0 comments on commit 903cc28

Please sign in to comment.