Skip to content

Commit

Permalink
Code styling/Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
tedivm committed Apr 15, 2014
1 parent 1b2e7fe commit 8e929d1
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
6 changes: 4 additions & 2 deletions src/Stash/Driver/Apc.php
Expand Up @@ -32,7 +32,8 @@ class Apc implements DriverInterface
* * ttl - This is the maximum time the item will be stored.
* * namespace - This should be used when multiple projects may use the same library.
*
* @param array $options
* @param array $options
* @throws \Stash\Exception\RuntimeException
*/
public function __construct(array $options = array())
{
Expand Down Expand Up @@ -145,8 +146,9 @@ public function purge()
public static function isAvailable()
{
// HHVM has some of the APC extension, but not all of it.
if(!class_exists('\APCIterator'))
if (!class_exists('\APCIterator')) {
return false;
}

return (extension_loaded('apc') && ini_get('apc.enabled'))
&& ((php_sapi_name() !== 'cli') || ini_get('apc.enable_cli'));
Expand Down
7 changes: 2 additions & 5 deletions src/Stash/Driver/Composite.php
Expand Up @@ -89,14 +89,11 @@ public function getData($key)
}

/**
* This function takes an array as its first argument and the expiration time as the second. This array contains two
* items, "expiration" describing when the data expires and "data", which is the item that needs to be
* stored. This function needs to store that data in such a way that it can be retrieved exactly as it was sent. The
* expiration time needs to be stored with this data.
*
* @param array $key
* @param array $data
* @param $expiration
* @param int $expiration
*
* @return bool
*/
public function storeData($key, $data, $expiration)
Expand Down
1 change: 1 addition & 0 deletions src/Stash/Driver/Ephemeral.php
Expand Up @@ -39,6 +39,7 @@ public function __destruct()
public function getData($key)
{
$key = $this->getKeyIndex($key);

return isset($this->store[$key]) ? $this->store[$key] : false;
}

Expand Down
12 changes: 6 additions & 6 deletions src/Stash/Driver/FileSystem.php
Expand Up @@ -139,7 +139,7 @@ protected static function getDataFromFile($path)
if (!file_exists($path)) {
return false;
}

include($path);

// If the item does not exist we should return false. However, it's
Expand Down Expand Up @@ -217,13 +217,13 @@ public function storeData($key, $data, $expiration)
$storeString .= '/* Type: ' . gettype($data) . ' */' . PHP_EOL;
$storeString .= "\$data = {$dataString};" . PHP_EOL;
}

$result = file_put_contents($path, $storeString, LOCK_EX);

// If opcache is switched on, it will try to cache the PHP data file
// The new php opcode caching system only revalidates against the source files once every few seconds,
// so some changes will not be caught.
// This fix immediately invalidates that opcode cache after a file is written,
// The new php opcode caching system only revalidates against the source files once every few seconds,
// so some changes will not be caught.
// This fix immediately invalidates that opcode cache after a file is written,
// so that future includes are not using the stale opcode cached file.
if (function_exists('opcache_invalidate')) {
opcache_invalidate($path, true);
Expand Down
6 changes: 4 additions & 2 deletions src/Stash/Pool.php
Expand Up @@ -83,6 +83,7 @@ public function setItemClass($class)
. ' must inherit from \Stash\Interfaces\ItemInterface');

$this->itemClass = $class;

return true;
}

Expand All @@ -92,7 +93,7 @@ public function setItemClass($class)
*
* @example $cache = $pool->getItem('permissions', 'user', '4', '2');
*
* @param string|array $key, $key, $key...
* @param string|array $key, $key, $key...
* @return \Stash\Interfaces\ItemInterface
*/
public function getItem()
Expand Down Expand Up @@ -236,8 +237,9 @@ public function setLogger($logger)

protected function logException($message, $exception)
{
if(!isset($this->logger))
if (!isset($this->logger)) {
return false;
}

$this->logger->critical($message,
array('exception' => $exception));
Expand Down

0 comments on commit 8e929d1

Please sign in to comment.