@@ -79,9 +79,9 @@ |
||
| 79 | 79 | |
| 80 | 80 | if (!isset(self::$hit[ $instance ])) { |
| 81 | 81 | self::$hit[ $instance ] = array( |
| 82 | - "class" => $class, |
|
| 83 | - "storage" => $storage, |
|
| 84 | - "data" => array(), |
|
| 82 | + "class" => $class, |
|
| 83 | + "storage" => $storage, |
|
| 84 | + "data" => array(), |
|
| 85 | 85 | ); |
| 86 | 86 | if ($config[ 'cache_method' ] == 4) { |
| 87 | 87 | register_shutdown_function('phpFastCache\CacheManager::cleanCachingMethod', null); |
@@ -51,47 +51,47 @@ discard block |
||
| 51 | 51 | if (empty($config)) { |
| 52 | 52 | $config = phpFastCache::$config; |
| 53 | 53 | } |
| 54 | - if (!isset($config[ 'cache_method' ])) { |
|
| 55 | - $config[ 'cache_method' ] = phpFastCache::$config[ 'cache_method' ]; |
|
| 54 | + if (!isset($config['cache_method'])) { |
|
| 55 | + $config['cache_method'] = phpFastCache::$config['cache_method']; |
|
| 56 | 56 | } |
| 57 | - if (!isset($config[ 'limited_memory_each_object' ])) { |
|
| 58 | - $config[ 'limited_memory_each_object' ] = phpFastCache::$config[ 'limited_memory_each_object' ]; |
|
| 57 | + if (!isset($config['limited_memory_each_object'])) { |
|
| 58 | + $config['limited_memory_each_object'] = phpFastCache::$config['limited_memory_each_object']; |
|
| 59 | 59 | } |
| 60 | - if (isset(phpFastCache::$config[ 'overwrite' ]) && !in_array(phpFastCache::$config[ 'overwrite' ], array('auto', ''), true)) { |
|
| 61 | - phpFastCache::$config[ 'storage' ] = phpFastCache::$config[ 'overwrite' ]; |
|
| 62 | - $storage = phpFastCache::$config[ 'overwrite' ]; |
|
| 63 | - } else if (isset(phpFastCache::$config[ 'storage' ]) && !in_array(phpFastCache::$config[ 'storage' ], array('auto', ''), true)) { |
|
| 64 | - $storage = phpFastCache::$config[ 'storage' ]; |
|
| 60 | + if (isset(phpFastCache::$config['overwrite']) && !in_array(phpFastCache::$config['overwrite'], array('auto', ''), true)) { |
|
| 61 | + phpFastCache::$config['storage'] = phpFastCache::$config['overwrite']; |
|
| 62 | + $storage = phpFastCache::$config['overwrite']; |
|
| 63 | + } else if (isset(phpFastCache::$config['storage']) && !in_array(phpFastCache::$config['storage'], array('auto', ''), true)) { |
|
| 64 | + $storage = phpFastCache::$config['storage']; |
|
| 65 | 65 | } else if (in_array($storage, array('auto', ''), true)) { |
| 66 | 66 | $storage = phpFastCache::getAutoClass($config); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | // echo $storage."<br>"; |
| 70 | 70 | $instance = md5(serialize($config) . $storage); |
| 71 | - if (!isset(self::$instances[ $instance ]) || is_null(self::$instances[ $instance ])) { |
|
| 71 | + if (!isset(self::$instances[$instance]) || is_null(self::$instances[$instance])) { |
|
| 72 | 72 | $class = '\phpFastCache\Drivers\\' . $storage; |
| 73 | - $config[ 'storage' ] = $storage; |
|
| 74 | - $config[ 'instance' ] = $instance; |
|
| 75 | - $config[ 'class' ] = $class; |
|
| 76 | - if (!isset(self::$memory[ $instance ])) { |
|
| 77 | - self::$memory[ $instance ] = array(); |
|
| 73 | + $config['storage'] = $storage; |
|
| 74 | + $config['instance'] = $instance; |
|
| 75 | + $config['class'] = $class; |
|
| 76 | + if (!isset(self::$memory[$instance])) { |
|
| 77 | + self::$memory[$instance] = array(); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - if (!isset(self::$hit[ $instance ])) { |
|
| 81 | - self::$hit[ $instance ] = array( |
|
| 80 | + if (!isset(self::$hit[$instance])) { |
|
| 81 | + self::$hit[$instance] = array( |
|
| 82 | 82 | "class" => $class, |
| 83 | 83 | "storage" => $storage, |
| 84 | 84 | "data" => array(), |
| 85 | 85 | ); |
| 86 | - if ($config[ 'cache_method' ] == 4) { |
|
| 86 | + if ($config['cache_method'] == 4) { |
|
| 87 | 87 | register_shutdown_function('phpFastCache\CacheManager::cleanCachingMethod', null); |
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - self::$instances[ $instance ] = new $class($config); |
|
| 91 | + self::$instances[$instance] = new $class($config); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - return self::$instances[ $instance ]; |
|
| 94 | + return self::$instances[$instance]; |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -102,13 +102,13 @@ discard block |
||
| 102 | 102 | { |
| 103 | 103 | $string = strtolower($string); |
| 104 | 104 | if (in_array($string, array("normal", "traditional"))) { |
| 105 | - phpFastCache::$config[ 'cache_method' ] = 1; |
|
| 105 | + phpFastCache::$config['cache_method'] = 1; |
|
| 106 | 106 | } else if (in_array($string, array("fast", "memory"))) { |
| 107 | - phpFastCache::$config[ 'cache_method' ] = 2; |
|
| 107 | + phpFastCache::$config['cache_method'] = 2; |
|
| 108 | 108 | } else if (in_array($string, array("fastest", "phpfastcache"))) { |
| 109 | - phpFastCache::$config[ 'cache_method' ] = 3; |
|
| 109 | + phpFastCache::$config['cache_method'] = 3; |
|
| 110 | 110 | } else if (in_array($string, array("superfast", "phpfastcachex"))) { |
| 111 | - phpFastCache::$config[ 'cache_method' ] = 4; |
|
| 111 | + phpFastCache::$config['cache_method'] = 4; |
|
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | |
@@ -121,11 +121,11 @@ discard block |
||
| 121 | 121 | public static function __callStatic($name, $arguments) |
| 122 | 122 | { |
| 123 | 123 | $driver = strtolower($name); |
| 124 | - if (!isset(self::$instances[ 'loaded' ][ $driver ]) && class_exists("\\phpFastCache\\Drivers\\{$driver}")) { |
|
| 125 | - self::$instances[ 'loaded' ][ $driver ] = true; |
|
| 124 | + if (!isset(self::$instances['loaded'][$driver]) && class_exists("\\phpFastCache\\Drivers\\{$driver}")) { |
|
| 125 | + self::$instances['loaded'][$driver] = true; |
|
| 126 | 126 | } |
| 127 | - if (isset(self::$instances[ 'loaded' ][ $driver ])) { |
|
| 128 | - return self::getInstance($name, (isset($arguments[ 0 ]) ? $arguments[ 0 ] : array())); |
|
| 127 | + if (isset(self::$instances['loaded'][$driver])) { |
|
| 128 | + return self::getInstance($name, (isset($arguments[0]) ? $arguments[0] : array())); |
|
| 129 | 129 | } else { |
| 130 | 130 | return call_user_func_array(array(self::getInstance(), $name), $arguments); |
| 131 | 131 | } |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | */ |
| 161 | 161 | protected static function __CleanCachingMethod($instance) |
| 162 | 162 | { |
| 163 | - if(is_array(self::$memory[ $instance ]) && !empty(self::$memory[ $instance ])) { |
|
| 163 | + if (is_array(self::$memory[$instance]) && !empty(self::$memory[$instance])) { |
|
| 164 | 164 | $old = self::$instances[$instance]->config['cache_method']; |
| 165 | 165 | self::$instances[$instance]->config['cache_method'] = 1; |
| 166 | 166 | foreach (self::$memory[$instance] as $keyword => $object) { |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | */ |
| 134 | 134 | private function getStatusHandler() |
| 135 | 135 | { |
| 136 | - return function ($payload) { |
|
| 136 | + return function($payload) { |
|
| 137 | 137 | return StatusResponse::get($payload); |
| 138 | 138 | }; |
| 139 | 139 | } |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | */ |
| 146 | 146 | protected function getErrorHandler() |
| 147 | 147 | { |
| 148 | - return function ($payload) { |
|
| 148 | + return function($payload) { |
|
| 149 | 149 | return new ErrorResponse($payload); |
| 150 | 150 | }; |
| 151 | 151 | } |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | */ |
| 28 | 28 | public function getErrorType() |
| 29 | 29 | { |
| 30 | - list($errorType, ) = explode(' ', $this->getMessage(), 2); |
|
| 30 | + list($errorType,) = explode(' ', $this->getMessage(), 2); |
|
| 31 | 31 | |
| 32 | 32 | return $errorType; |
| 33 | 33 | } |