Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

reduce arguments by reference #8

Open
wants to merge 15 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
491 changes: 256 additions & 235 deletions src/Storage/Adapter/AbstractAdapter.php

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions src/Storage/Adapter/AbstractZendServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ abstract class AbstractZendServer extends AbstractAdapter
* @return mixed Data on success, null on failure
* @throws Exception\ExceptionInterface
*/
protected function internalGetItem(& $normalizedKey, & $success = null, & $casToken = null)
protected function internalGetItem($normalizedKey, & $success = null, & $casToken = null)
{
$namespace = $this->getOptions()->getNamespace();
$prefix = ($namespace === '') ? '' : $namespace . self::NAMESPACE_SEPARATOR;
Expand All @@ -57,7 +57,7 @@ protected function internalGetItem(& $normalizedKey, & $success = null, & $casTo
* @return array Associative array of keys and values
* @throws Exception\ExceptionInterface
*/
protected function internalGetItems(array & $normalizedKeys)
protected function internalGetItems(array $normalizedKeys)
{
$namespace = $this->getOptions()->getNamespace();
if ($namespace === '') {
Expand All @@ -73,7 +73,7 @@ protected function internalGetItems(array & $normalizedKeys)
$fetch = $this->zdcFetchMulti($internalKeys);
$result = [];
$prefixL = strlen($prefix);
foreach ($fetch as $k => & $v) {
foreach ($fetch as $k => $v) {
$result[substr($k, $prefixL)] = $v;
}

Expand All @@ -87,7 +87,7 @@ protected function internalGetItems(array & $normalizedKeys)
* @return bool
* @throws Exception\ExceptionInterface
*/
protected function internalHasItem(& $normalizedKey)
protected function internalHasItem($normalizedKey)
{
$namespace = $this->getOptions()->getNamespace();
$prefix = ($namespace === '') ? '' : $namespace . self::NAMESPACE_SEPARATOR;
Expand All @@ -101,7 +101,7 @@ protected function internalHasItem(& $normalizedKey)
* @return array Array of found keys
* @throws Exception\ExceptionInterface
*/
protected function internalHasItems(array & $normalizedKeys)
protected function internalHasItems(array $normalizedKeys)
{
$namespace = $this->getOptions()->getNamespace();
if ($namespace === '') {
Expand All @@ -117,7 +117,7 @@ protected function internalHasItems(array & $normalizedKeys)
$fetch = $this->zdcFetchMulti($internalKeys);
$result = [];
$prefixL = strlen($prefix);
foreach ($fetch as $internalKey => & $value) {
foreach ($fetch as $internalKey => $value) {
$result[] = substr($internalKey, $prefixL);
}

Expand All @@ -134,7 +134,7 @@ protected function internalHasItems(array & $normalizedKeys)
* @triggers getMetadatas.post(PostEvent)
* @triggers getMetadatas.exception(ExceptionEvent)
*/
protected function internalGetMetadatas(array & $normalizedKeys)
protected function internalGetMetadatas(array $normalizedKeys)
{
$namespace = $this->getOptions()->getNamespace();
if ($namespace === '') {
Expand Down Expand Up @@ -168,7 +168,7 @@ protected function internalGetMetadatas(array & $normalizedKeys)
* @return bool
* @throws Exception\ExceptionInterface
*/
protected function internalSetItem(& $normalizedKey, & $value)
protected function internalSetItem($normalizedKey, $value)
{
$options = $this->getOptions();
$namespace = $options->getNamespace();
Expand All @@ -184,7 +184,7 @@ protected function internalSetItem(& $normalizedKey, & $value)
* @return bool
* @throws Exception\ExceptionInterface
*/
protected function internalRemoveItem(& $normalizedKey)
protected function internalRemoveItem($normalizedKey)
{
$namespace = $this->getOptions()->getNamespace();
$prefix = ($namespace === '') ? '' : $namespace . self::NAMESPACE_SEPARATOR;
Expand Down
3 changes: 1 addition & 2 deletions src/Storage/Adapter/AdapterOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

namespace Zend\Cache\Storage\Adapter;

use ArrayObject;
use Zend\Cache\Exception;
use Zend\Cache\Storage\Event;
use Zend\Cache\Storage\StorageInterface;
Expand Down Expand Up @@ -242,7 +241,7 @@ public function getWritable()
protected function triggerOptionEvent($optionName, $optionValue)
{
if ($this->adapter instanceof EventsCapableInterface) {
$event = new Event('option', $this->adapter, new ArrayObject([$optionName => $optionValue]));
$event = new Event('option', $this->adapter, [$optionName => $optionValue]);
$this->adapter->getEventManager()->triggerEvent($event);
}
}
Expand Down
45 changes: 21 additions & 24 deletions src/Storage/Adapter/Apc.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public function clearByPrefix($prefix)
* @return mixed Data on success, null on failure
* @throws Exception\ExceptionInterface
*/
protected function internalGetItem(& $normalizedKey, & $success = null, & $casToken = null)
protected function internalGetItem($normalizedKey, & $success = null, & $casToken = null)
{
$options = $this->getOptions();
$namespace = $options->getNamespace();
Expand All @@ -235,7 +235,7 @@ protected function internalGetItem(& $normalizedKey, & $success = null, & $casTo
* @return array Associative array of keys and values
* @throws Exception\ExceptionInterface
*/
protected function internalGetItems(array & $normalizedKeys)
protected function internalGetItems(array $normalizedKeys)
{
$options = $this->getOptions();
$namespace = $options->getNamespace();
Expand Down Expand Up @@ -268,7 +268,7 @@ protected function internalGetItems(array & $normalizedKeys)
* @return bool
* @throws Exception\ExceptionInterface
*/
protected function internalHasItem(& $normalizedKey)
protected function internalHasItem($normalizedKey)
{
$options = $this->getOptions();
$namespace = $options->getNamespace();
Expand All @@ -283,7 +283,7 @@ protected function internalHasItem(& $normalizedKey)
* @return array Array of found keys
* @throws Exception\ExceptionInterface
*/
protected function internalHasItems(array & $normalizedKeys)
protected function internalHasItems(array $normalizedKeys)
{
$options = $this->getOptions();
$namespace = $options->getNamespace();
Expand Down Expand Up @@ -317,7 +317,7 @@ protected function internalHasItems(array & $normalizedKeys)
* @return array|bool Metadata on success, false on failure
* @throws Exception\ExceptionInterface
*/
protected function internalGetMetadata(& $normalizedKey)
protected function internalGetMetadata($normalizedKey)
{
$options = $this->getOptions();
$namespace = $options->getNamespace();
Expand All @@ -338,8 +338,7 @@ protected function internalGetMetadata(& $normalizedKey)
return false;
}

$this->normalizeMetadata($metadata);
return $metadata;
return $this->normalizeMetadata($metadata);
}

/**
Expand All @@ -352,7 +351,7 @@ protected function internalGetMetadata(& $normalizedKey)
* @triggers getMetadatas.post(PostEvent)
* @triggers getMetadatas.exception(ExceptionEvent)
*/
protected function internalGetMetadatas(array & $normalizedKeys)
protected function internalGetMetadatas(array $normalizedKeys)
{
$keysRegExp = [];
foreach ($normalizedKeys as $normalizedKey) {
Expand Down Expand Up @@ -380,8 +379,7 @@ protected function internalGetMetadatas(array & $normalizedKeys)
continue;
}

$this->normalizeMetadata($metadata);
$result[substr($internalKey, $prefixL)] = $metadata;
$result[substr($internalKey, $prefixL)] = $this->normalizeMetadata($metadata);
}

return $result;
Expand All @@ -397,7 +395,7 @@ protected function internalGetMetadatas(array & $normalizedKeys)
* @return bool
* @throws Exception\ExceptionInterface
*/
protected function internalSetItem(& $normalizedKey, & $value)
protected function internalSetItem($normalizedKey, $value)
{
$options = $this->getOptions();
$namespace = $options->getNamespace();
Expand All @@ -422,7 +420,7 @@ protected function internalSetItem(& $normalizedKey, & $value)
* @return array Array of not stored keys
* @throws Exception\ExceptionInterface
*/
protected function internalSetItems(array & $normalizedKeyValuePairs)
protected function internalSetItems(array $normalizedKeyValuePairs)
{
$options = $this->getOptions();
$namespace = $options->getNamespace();
Expand Down Expand Up @@ -457,7 +455,7 @@ protected function internalSetItems(array & $normalizedKeyValuePairs)
* @return bool
* @throws Exception\ExceptionInterface
*/
protected function internalAddItem(& $normalizedKey, & $value)
protected function internalAddItem($normalizedKey, $value)
{
$options = $this->getOptions();
$namespace = $options->getNamespace();
Expand Down Expand Up @@ -486,7 +484,7 @@ protected function internalAddItem(& $normalizedKey, & $value)
* @return array Array of not stored keys
* @throws Exception\ExceptionInterface
*/
protected function internalAddItems(array & $normalizedKeyValuePairs)
protected function internalAddItems(array $normalizedKeyValuePairs)
{
$options = $this->getOptions();
$namespace = $options->getNamespace();
Expand Down Expand Up @@ -521,7 +519,7 @@ protected function internalAddItems(array & $normalizedKeyValuePairs)
* @return bool
* @throws Exception\ExceptionInterface
*/
protected function internalReplaceItem(& $normalizedKey, & $value)
protected function internalReplaceItem($normalizedKey, $value)
{
$options = $this->getOptions();
$namespace = $options->getNamespace();
Expand Down Expand Up @@ -550,7 +548,7 @@ protected function internalReplaceItem(& $normalizedKey, & $value)
* @return bool
* @throws Exception\ExceptionInterface
*/
protected function internalRemoveItem(& $normalizedKey)
protected function internalRemoveItem($normalizedKey)
{
$options = $this->getOptions();
$namespace = $options->getNamespace();
Expand All @@ -565,7 +563,7 @@ protected function internalRemoveItem(& $normalizedKey)
* @return array Array of not removed keys
* @throws Exception\ExceptionInterface
*/
protected function internalRemoveItems(array & $normalizedKeys)
protected function internalRemoveItems(array $normalizedKeys)
{
$options = $this->getOptions();
$namespace = $options->getNamespace();
Expand Down Expand Up @@ -598,7 +596,7 @@ protected function internalRemoveItems(array & $normalizedKeys)
* @return int|bool The new value on success, false on failure
* @throws Exception\ExceptionInterface
*/
protected function internalIncrementItem(& $normalizedKey, & $value)
protected function internalIncrementItem($normalizedKey, $value)
{
$options = $this->getOptions();
$namespace = $options->getNamespace();
Expand Down Expand Up @@ -629,7 +627,7 @@ protected function internalIncrementItem(& $normalizedKey, & $value)
* @return int|bool The new value on success, false on failure
* @throws Exception\ExceptionInterface
*/
protected function internalDecrementItem(& $normalizedKey, & $value)
protected function internalDecrementItem($normalizedKey, $value)
{
$options = $this->getOptions();
$namespace = $options->getNamespace();
Expand Down Expand Up @@ -716,12 +714,11 @@ protected function internalGetCapabilities()
* Normalize metadata to work with APC
*
* @param array $metadata
* @return void
* @return array
*/
protected function normalizeMetadata(array & $metadata)
protected function normalizeMetadata(array $metadata)
{
$apcMetadata = $metadata;
$metadata = [
return [
'internal_key' => isset($metadata['key']) ? $metadata['key'] : $metadata['info'],
'atime' => isset($metadata['access_time']) ? $metadata['access_time'] : $metadata['atime'],
'ctime' => isset($metadata['creation_time']) ? $metadata['creation_time'] : $metadata['ctime'],
Expand All @@ -743,7 +740,7 @@ protected function normalizeMetadata(array & $metadata)
* @see getItem()
* @see setItem()
*/
protected function internalCheckAndSetItem(& $token, & $normalizedKey, & $value)
protected function internalCheckAndSetItem($token, $normalizedKey, $value)
{
if (is_int($token) && is_int($value)) {
return apc_cas($normalizedKey, $token, $value);
Expand Down
Loading