Skip to content

Commit

Permalink
Updated source code using new cs fixers
Browse files Browse the repository at this point in the history
  • Loading branch information
tedivm committed Nov 23, 2014
1 parent dbcb170 commit a6c9a2f
Show file tree
Hide file tree
Showing 37 changed files with 49 additions and 97 deletions.
3 changes: 0 additions & 3 deletions src/Stash/Driver/Apc.php
Expand Up @@ -80,7 +80,6 @@ public function setOptions(array $options = array())
*/
public function __destruct()
{

}

/**
Expand Down Expand Up @@ -124,7 +123,6 @@ public function clear($key = null)
apc_delete($item['key']);
}
} while (!$emptyIterator);

}

return true;
Expand Down Expand Up @@ -201,5 +199,4 @@ protected function getCacheTime($expiration)

return $this->ttl < $life ? $this->ttl : $life;
}

}
2 changes: 0 additions & 2 deletions src/Stash/Driver/BlackHole.php
Expand Up @@ -21,7 +21,6 @@
*/
class BlackHole implements DriverInterface
{

/**
* NOOP constructor
*/
Expand Down Expand Up @@ -69,5 +68,4 @@ public static function isAvailable()
{
return true;
}

}
1 change: 0 additions & 1 deletion src/Stash/Driver/Composite.php
Expand Up @@ -25,7 +25,6 @@
*/
class Composite implements DriverInterface
{

/**
* The drivers this driver encapsulates.
*
Expand Down
3 changes: 0 additions & 3 deletions src/Stash/Driver/Ephemeral.php
Expand Up @@ -23,7 +23,6 @@
*/
class Ephemeral implements DriverInterface
{

/**
* Contains the cached data.
*
Expand All @@ -38,15 +37,13 @@ class Ephemeral implements DriverInterface
*/
public function setOptions(array $options = array())
{

}

/**
* {@inheritdoc}
*/
public function __destruct()
{

}

/**
Expand Down
4 changes: 1 addition & 3 deletions src/Stash/Driver/FileSystem.php
Expand Up @@ -225,7 +225,7 @@ public function storeData($key, $data, $expiration)
$path = $this->makePath($key);

// MAX_PATH is 260 - http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx
if (strlen($path) > 259 && stripos(PHP_OS,'WIN') === 0) {
if (strlen($path) > 259 && stripos(PHP_OS, 'WIN') === 0) {
throw new Stash\Exception\WindowsPathMaxLengthException();
}

Expand Down Expand Up @@ -384,7 +384,6 @@ public function purge()
if (is_numeric($data['expiration']) && $data['expiration'] <= $startTime) {
unlink($filename);
}

}
unset($directoryIt);

Expand All @@ -411,5 +410,4 @@ public static function isAvailable()
{
return true;
}

}
1 change: 0 additions & 1 deletion src/Stash/Driver/FileSystem/NativeEncoder.php
Expand Up @@ -66,7 +66,6 @@ public function serialize($key, $data, $expiration = null)
$storeString .= "\$data[{$keyString}] = {$dataString};" . PHP_EOL;
}
} else {

$dataString = $this->encode($data);
$storeString .= '/* Type: ' . gettype($data) . ' */' . PHP_EOL;
$storeString .= "\$data = {$dataString};" . PHP_EOL;
Expand Down
2 changes: 0 additions & 2 deletions src/Stash/Driver/FileSystem/SerializerEncoder.php
Expand Up @@ -13,7 +13,6 @@

class SerializerEncoder implements EncoderInterface
{

public function deserialize($path)
{
if (!file_exists($path)) {
Expand Down Expand Up @@ -46,5 +45,4 @@ public function getExtension()
{
return '.pser';
}

}
1 change: 0 additions & 1 deletion src/Stash/Driver/Memcache.php
Expand Up @@ -118,7 +118,6 @@ protected function normalizeServerConfig($servers)

$normalizedServers = array();
foreach ($servers as $server) {

$host = '127.0.0.1';
if (isset($server['host'])) {
$host = $server['host'];
Expand Down
21 changes: 9 additions & 12 deletions src/Stash/Driver/Redis.php
Expand Up @@ -29,7 +29,7 @@ class Redis implements DriverInterface
*
* @var array
*/
protected $defaultOptions = array ();
protected $defaultOptions = array();

/**
* The Redis drivers.
Expand Down Expand Up @@ -85,20 +85,19 @@ public function __construct()
*/
public function setOptions(array $options = array())
{
if(!self::isAvailable())
if (!self::isAvailable()) {
throw new \RuntimeException('Unable to load Redis driver without PhpRedis extension.');
}

// Normalize Server Options
if (isset($options['servers'])) {

$unprocessedServers = (is_array($options['servers']))
? $options['servers']
: array($options['servers']);
unset($options['servers']);

$servers = array();
foreach ($unprocessedServers as $server) {

$ttl = '.1';
if (isset($server['ttl'])) {
$ttl = $server['ttl'];
Expand All @@ -109,7 +108,6 @@ public function setOptions(array $options = array())
if (isset($server['socket'])) {
$servers[] = array('socket' => $server['socket'], 'ttl' => $ttl);
} else {

$host = '127.0.0.1';
if (isset($server['server'])) {
$host = $server['server'];
Expand All @@ -127,7 +125,6 @@ public function setOptions(array $options = array())
$servers[] = array('server' => $host, 'port' => $port, 'ttl' => $ttl);
}
}

} else {
$servers = array(array('server' => '127.0.0.1', 'port' => '6379', 'ttl' => 0.1));
}
Expand All @@ -152,13 +149,12 @@ public function setOptions(array $options = array())
}

// auth - just password
if(isset($options['password']))
if (isset($options['password'])) {
$redis->auth($options['password']);
}

$this->redis = $redis;

} else {

$redisArrayOptions = array();
foreach ($this->redisArrayOptionNames as $optionName) {
if (array_key_exists($optionName, $options)) {
Expand All @@ -169,8 +165,9 @@ public function setOptions(array $options = array())
$serverArray = array();
foreach ($servers as $server) {
$serverString = $server['server'];
if(isset($server['port']))
if (isset($server['port'])) {
$serverString .= ':' . $server['port'];
}

$serverArray[] = $serverString;
}
Expand All @@ -179,8 +176,9 @@ public function setOptions(array $options = array())
}

// select database
if(isset($options['database']))
if (isset($options['database'])) {
$redis->select($options['database']);
}

$this->redis = $redis;
}
Expand Down Expand Up @@ -309,5 +307,4 @@ protected function makeKeyString($key, $path = false)

return $path ? $pathKey : md5($keyString);
}

}
5 changes: 2 additions & 3 deletions src/Stash/Driver/Sqlite.php
Expand Up @@ -200,7 +200,6 @@ protected function getSqliteDriver($key, $name = false)
}

$file = $key;

} else {
if (!is_array($key)) {
return false;
Expand All @@ -223,9 +222,9 @@ protected function getSqliteDriver($key, $name = false)

$driverClass = $this->driverClass;

if(is_null($driverClass))

if (is_null($driverClass)) {
return false;
}

$driver = new $driverClass($file, $this->dirPerms, $this->filePerms, $this->busyTimeout);

Expand Down
1 change: 0 additions & 1 deletion src/Stash/DriverList.php
Expand Up @@ -110,5 +110,4 @@ public static function getDrivers()
{
return self::getAvailableDrivers();
}

}
4 changes: 2 additions & 2 deletions src/Stash/Exception/WindowsPathMaxLengthException.php
Expand Up @@ -30,8 +30,8 @@
*/
class WindowsPathMaxLengthException extends \Exception implements Exception
{
public function __construct($message="",$code=0,$previous=null)
public function __construct($message="", $code=0, $previous=null)
{
parent::__construct("Cache path exceeds Windows PHP MAX_LENGTH of 260 characters. " . $message,$code,$previous);
parent::__construct("Cache path exceeds Windows PHP MAX_LENGTH of 260 characters. " . $message, $code, $previous);
}
}
1 change: 0 additions & 1 deletion src/Stash/Interfaces/ItemInterface.php
Expand Up @@ -13,7 +13,6 @@

interface ItemInterface
{

/**
* Sets the Parent Pool for the Item class to use.
*
Expand Down
1 change: 0 additions & 1 deletion src/Stash/Invalidation.php
Expand Up @@ -47,5 +47,4 @@ class Invalidation
* it actually expires. While one item is regenerating the rest are still using the cached data as it is still good.
*/
const PRECOMPUTE = 4;

}
10 changes: 5 additions & 5 deletions src/Stash/Item.php
Expand Up @@ -262,8 +262,9 @@ private function executeGet($invalidation, $arg, $arg2)
*/
public function isMiss()
{
if (!isset($this->isHit))
if (!isset($this->isHit)) {
$this->get();
}

if ($this->isDisabled()) {
return true;
Expand All @@ -277,7 +278,7 @@ public function isMiss()
*/
public function lock($ttl = null)
{
if ($this->isDisabled()) {
if ($this->isDisabled()) {
return true;
}

Expand Down Expand Up @@ -402,9 +403,9 @@ protected function setDriver(DriverInterface $driver)
*/
protected function logException($message, $exception)
{
if(!isset($this->logger))

if (!isset($this->logger)) {
return false;
}

$this->logger->critical($message,
array('exception' => $exception,
Expand Down Expand Up @@ -616,5 +617,4 @@ protected function setupKey($key)
array_unshift($key, 'cache');
$this->key = array_map('strtolower', $key);
}

}
20 changes: 11 additions & 9 deletions src/Stash/Pool.php
Expand Up @@ -24,7 +24,6 @@
*/
class Pool implements PoolInterface
{

/**
* The cacheDriver being used by the system. While this class handles all of the higher functions, it's the cache
* driver here that handles all of the storage/retrieval functionality. This value is set by the constructor.
Expand Down Expand Up @@ -83,13 +82,15 @@ public function __construct(DriverInterface $driver = null)
*/
public function setItemClass($class)
{
if(!class_exists($class))
if (!class_exists($class)) {
throw new \InvalidArgumentException('Item class ' . $class . ' does not exist');
}

$interfaces = class_implements($class, true);

if(!in_array('Stash\Interfaces\ItemInterface', $interfaces))
if (!in_array('Stash\Interfaces\ItemInterface', $interfaces)) {
throw new \InvalidArgumentException('Item class ' . $class . ' must inherit from \Stash\Interfaces\ItemInterface');
}

$this->itemClass = $class;

Expand Down Expand Up @@ -138,11 +139,13 @@ public function getItem()
$item->setPool($this);
$item->setKey($key, $namespace);

if($this->isDisabled)
if ($this->isDisabled) {
$item->disable();
}

if(isset($this->logger))
if (isset($this->logger)) {
$item->setLogger($this->logger);
}

return $item;
}
Expand All @@ -159,7 +162,7 @@ public function getItemIterator($keys)
$items[] = $this->getItem($key);
}

return new \ArrayIterator($items);
return new \ArrayIterator($items);
}

/**
Expand All @@ -177,11 +180,9 @@ public function flush()
$normalizedNamespace = strtolower($this->namespace);
$results = $driver->clear(array('cache', $normalizedNamespace))
&& $driver->clear(array('sp', $normalizedNamespace));

} else {
$results = $driver->clear();
}

} catch (\Exception $e) {
$this->isDisabled = true;
$this->logException('Flushing Cache Pool caused exception.', $e);
Expand Down Expand Up @@ -226,8 +227,9 @@ public function setDriver(DriverInterface $driver)
*/
public function getDriver()
{
if(!isset($this->driver))
if (!isset($this->driver)) {
$this->driver = new Ephemeral();
}

return $this->driver;
}
Expand Down

0 comments on commit a6c9a2f

Please sign in to comment.