@@ -22,7 +22,7 @@ |
||
22 | 22 | class HumanReadableExtension extends \Twig_Extension |
23 | 23 | { |
24 | 24 | /** |
25 | - * @return array |
|
25 | + * @return \Twig_SimpleFilter[] |
|
26 | 26 | */ |
27 | 27 | public function getFilters() |
28 | 28 | { |
@@ -41,9 +41,9 @@ |
||
41 | 41 | { |
42 | 42 | $bytes = (int) $bytes; |
43 | 43 | $sz = 'BKMGTP'; |
44 | - $factor = floor(( strlen($bytes) - 1 ) / 3); |
|
44 | + $factor = floor((strlen($bytes) - 1) / 3); |
|
45 | 45 | |
46 | - return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)).@$sz[ $factor ].( $factor ? ($octetFormat ? 'O' : 'B') : '' ); |
|
46 | + return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$sz[$factor] . ($factor ? ($octetFormat ? 'O' : 'B') : ''); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -8,18 +8,18 @@ |
||
8 | 8 | public function registerBundles() |
9 | 9 | { |
10 | 10 | $bundles = [ |
11 | - new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), |
|
12 | - new Symfony\Bundle\SecurityBundle\SecurityBundle(), |
|
13 | - new Symfony\Bundle\TwigBundle\TwigBundle(), |
|
14 | - new Symfony\Bundle\MonologBundle\MonologBundle(), |
|
15 | - new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(), |
|
16 | - new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(), |
|
17 | - new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(), |
|
18 | - new AppBundle\AppBundle(), |
|
11 | + new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), |
|
12 | + new Symfony\Bundle\SecurityBundle\SecurityBundle(), |
|
13 | + new Symfony\Bundle\TwigBundle\TwigBundle(), |
|
14 | + new Symfony\Bundle\MonologBundle\MonologBundle(), |
|
15 | + new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(), |
|
16 | + new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(), |
|
17 | + new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(), |
|
18 | + new AppBundle\AppBundle(), |
|
19 | 19 | /** |
20 | 20 | * PhpFastCache Bundle |
21 | 21 | */ |
22 | - new phpFastCache\Bundle\phpFastCacheBundle(), |
|
22 | + new phpFastCache\Bundle\phpFastCacheBundle(), |
|
23 | 23 | ]; |
24 | 24 | |
25 | 25 | if (in_array($this->getEnvironment(), ['dev', 'test'], true)) { |
@@ -39,16 +39,16 @@ |
||
39 | 39 | |
40 | 40 | public function getCacheDir() |
41 | 41 | { |
42 | - return dirname(__DIR__).'/var/cache/'.$this->getEnvironment(); |
|
42 | + return dirname(__DIR__) . '/var/cache/' . $this->getEnvironment(); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | public function getLogDir() |
46 | 46 | { |
47 | - return dirname(__DIR__).'/var/logs'; |
|
47 | + return dirname(__DIR__) . '/var/logs'; |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | public function registerContainerConfiguration(LoaderInterface $loader) |
51 | 51 | { |
52 | - $loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml'); |
|
52 | + $loader->load($this->getRootDir() . '/config/config_' . $this->getEnvironment() . '.yml'); |
|
53 | 53 | } |
54 | 54 | } |
@@ -123,8 +123,8 @@ |
||
123 | 123 | |
124 | 124 | // replace this example code with whatever you need |
125 | 125 | return $this->render('default/index.html.twig', [ |
126 | - 'pfc_test' => $pfc_test, |
|
127 | - 'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..'), |
|
126 | + 'pfc_test' => $pfc_test, |
|
127 | + 'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..'), |
|
128 | 128 | ]); |
129 | 129 | } |
130 | 130 | } |
131 | 131 | \ No newline at end of file |
@@ -28,10 +28,10 @@ discard block |
||
28 | 28 | /** |
29 | 29 | * Xcache and APC cannot coexists |
30 | 30 | */ |
31 | - try{ |
|
31 | + try { |
|
32 | 32 | $cache9 = $this->get('phpfastcache')->get('apccache'); |
33 | 33 | $cache10 = $this->get('phpfastcache')->get('apcucache'); |
34 | - }catch(phpFastCacheDriverCheckException $e){ |
|
34 | + } catch (phpFastCacheDriverCheckException $e) { |
|
35 | 35 | $cache11 = $this->get('phpfastcache')->get('xcachecache'); |
36 | 36 | } |
37 | 37 | |
@@ -49,13 +49,13 @@ discard block |
||
49 | 49 | $item8 = $cache7->getItem('test2'); |
50 | 50 | $item9 = $cache8->getItem('test2'); |
51 | 51 | |
52 | - if(isset($cache9) && isset($cache10)) |
|
52 | + if (isset($cache9) && isset($cache10)) |
|
53 | 53 | { |
54 | 54 | $item10 = $cache9->getItem('test2'); |
55 | 55 | $item11 = $cache10->getItem('test2'); |
56 | 56 | } |
57 | 57 | |
58 | - if(isset($cache11)) |
|
58 | + if (isset($cache11)) |
|
59 | 59 | { |
60 | 60 | $item12 = $cache11->getItem('test2'); |
61 | 61 | } |
@@ -79,13 +79,13 @@ discard block |
||
79 | 79 | $item8->set('Loaded from cache2')->expiresAfter(10); |
80 | 80 | $item9->set('Loaded from cache +' . str_repeat('-', rand(1000, 5000)))->expiresAfter(10); |
81 | 81 | |
82 | - if(isset($item10) && isset($item11)) |
|
82 | + if (isset($item10) && isset($item11)) |
|
83 | 83 | { |
84 | 84 | $item10->set('Loaded from cache +' . str_repeat('-', rand(1000, 5000)))->expiresAfter(10); |
85 | 85 | $item11->set('Loaded from cache +' . str_repeat('-', rand(1000, 5000)))->expiresAfter(10); |
86 | 86 | } |
87 | 87 | |
88 | - if(isset($item12)) |
|
88 | + if (isset($item12)) |
|
89 | 89 | { |
90 | 90 | $item12->set('Loaded from cache +' . str_repeat('-', rand(1000, 5000)))->expiresAfter(10); |
91 | 91 | } |
@@ -104,13 +104,13 @@ discard block |
||
104 | 104 | $cache7->save($item8); |
105 | 105 | $cache8->save($item9); |
106 | 106 | |
107 | - if(isset($cache9) && isset($cache10)) |
|
107 | + if (isset($cache9) && isset($cache10)) |
|
108 | 108 | { |
109 | 109 | $cache9->save($item10); |
110 | 110 | $cache10->save($item11); |
111 | 111 | } |
112 | 112 | |
113 | - if(isset($cache11)) |
|
113 | + if (isset($cache11)) |
|
114 | 114 | { |
115 | 115 | $cache11->save($item12); |
116 | 116 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | // replace this example code with whatever you need |
125 | 125 | return $this->render('default/index.html.twig', [ |
126 | 126 | 'pfc_test' => $pfc_test, |
127 | - 'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..'), |
|
127 | + 'base_dir' => realpath($this->getParameter('kernel.root_dir') . '/..'), |
|
128 | 128 | ]); |
129 | 129 | } |
130 | 130 | } |
131 | 131 | \ No newline at end of file |
@@ -31,7 +31,7 @@ |
||
31 | 31 | try{ |
32 | 32 | $cache9 = $this->get('phpfastcache')->get('apccache'); |
33 | 33 | $cache10 = $this->get('phpfastcache')->get('apcucache'); |
34 | - }catch(phpFastCacheDriverCheckException $e){ |
|
34 | + } catch(phpFastCacheDriverCheckException $e){ |
|
35 | 35 | $cache11 = $this->get('phpfastcache')->get('xcachecache'); |
36 | 36 | } |
37 | 37 |
@@ -46,26 +46,26 @@ |
||
46 | 46 | } |
47 | 47 | $stats[ $instanceName ] = $cache->getStats(); |
48 | 48 | $instances[ $instanceName ] = [ |
49 | - 'driverName' => $cache->getDriverName(), |
|
50 | - 'driverConfig' => $cache->getConfig(), |
|
49 | + 'driverName' => $cache->getDriverName(), |
|
50 | + 'driverConfig' => $cache->getConfig(), |
|
51 | 51 | ]; |
52 | 52 | $driverUsed[ $cache->getDriverName() ] = get_class($cache); |
53 | 53 | } |
54 | 54 | |
55 | 55 | $this->data = [ |
56 | - 'apiVersion' => phpFastCacheApi::getVersion(), |
|
57 | - 'apiChangelog' => phpFastCacheApi::getChangelog(), |
|
58 | - 'driverUsed' => $driverUsed, |
|
59 | - 'instances' => $instances, |
|
60 | - 'stats' => $stats, |
|
61 | - 'size' => $size, |
|
62 | - 'hits' => [ |
|
56 | + 'apiVersion' => phpFastCacheApi::getVersion(), |
|
57 | + 'apiChangelog' => phpFastCacheApi::getChangelog(), |
|
58 | + 'driverUsed' => $driverUsed, |
|
59 | + 'instances' => $instances, |
|
60 | + 'stats' => $stats, |
|
61 | + 'size' => $size, |
|
62 | + 'hits' => [ |
|
63 | 63 | 'read' => (int) CacheManager::$ReadHits, |
64 | 64 | 'write' => (int) CacheManager::$WriteHits, |
65 | - ], |
|
66 | - 'coreConfig' => [ |
|
65 | + ], |
|
66 | + 'coreConfig' => [ |
|
67 | 67 | 'namespacePath' => CacheManager::getNamespacePath() |
68 | - ], |
|
68 | + ], |
|
69 | 69 | ]; |
70 | 70 | } |
71 | 71 |
@@ -44,12 +44,12 @@ discard block |
||
44 | 44 | if ($cache->getStats()->getSize()) { |
45 | 45 | $size += $cache->getStats()->getSize(); |
46 | 46 | } |
47 | - $stats[ $instanceName ] = $cache->getStats(); |
|
48 | - $instances[ $instanceName ] = [ |
|
47 | + $stats[$instanceName] = $cache->getStats(); |
|
48 | + $instances[$instanceName] = [ |
|
49 | 49 | 'driverName' => $cache->getDriverName(), |
50 | 50 | 'driverConfig' => $cache->getConfig(), |
51 | 51 | ]; |
52 | - $driverUsed[ $cache->getDriverName() ] = get_class($cache); |
|
52 | + $driverUsed[$cache->getDriverName()] = get_class($cache); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | $this->data = [ |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function getStats() |
76 | 76 | { |
77 | - return $this->data[ 'stats' ]; |
|
77 | + return $this->data['stats']; |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function getInstances() |
84 | 84 | { |
85 | - return $this->data[ 'instances' ]; |
|
85 | + return $this->data['instances']; |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public function getDriverUsed() |
92 | 92 | { |
93 | - return $this->data[ 'driverUsed' ]; |
|
93 | + return $this->data['driverUsed']; |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | */ |
99 | 99 | public function getHits() |
100 | 100 | { |
101 | - return $this->data[ 'hits' ]; |
|
101 | + return $this->data['hits']; |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public function getSize() |
108 | 108 | { |
109 | - return $this->data[ 'size' ]; |
|
109 | + return $this->data['size']; |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public function getCoreConfig() |
116 | 116 | { |
117 | - return $this->data[ 'coreConfig' ]; |
|
117 | + return $this->data['coreConfig']; |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function getApiVersion() |
124 | 124 | { |
125 | - return $this->data[ 'apiVersion' ]; |
|
125 | + return $this->data['apiVersion']; |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function getApiChangelog() |
132 | 132 | { |
133 | - return $this->data[ 'apiChangelog' ]; |
|
133 | + return $this->data['apiChangelog']; |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | $callback = function($name) use ($phpFastCache, $output, &$failedInstances) |
51 | 51 | { |
52 | - try{ |
|
52 | + try { |
|
53 | 53 | if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { |
54 | 54 | $output->writeln("<fg=yellow>Clearing instance {$name} cache...</>"); |
55 | 55 | } |
@@ -57,35 +57,35 @@ discard block |
||
57 | 57 | if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { |
58 | 58 | $output->writeln("<fg=green>Cache instance {$name} cleared</>"); |
59 | 59 | } |
60 | - }catch (phpFastCacheDriverCheckException $e){ |
|
60 | + } catch (phpFastCacheDriverCheckException $e) { |
|
61 | 61 | $failedInstances[] = $name; |
62 | 62 | if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { |
63 | - $output->writeln("<fg=red>Cache instance {$name} not cleared, got exception: " . "<bg=red;options=bold>" . $e->getMessage() ."</>"); |
|
64 | - }else{ |
|
63 | + $output->writeln("<fg=red>Cache instance {$name} not cleared, got exception: " . "<bg=red;options=bold>" . $e->getMessage() . "</>"); |
|
64 | + } else { |
|
65 | 65 | $output->writeln("<fg=red>Cache instance {$name} not cleared (increase verbosity to get more information).</>"); |
66 | 66 | } |
67 | 67 | } |
68 | 68 | }; |
69 | 69 | $caches = $this->getContainer()->getParameter('phpfastcache'); |
70 | 70 | |
71 | - if($driver) { |
|
72 | - if(array_key_exists($driver, $caches['drivers'])){ |
|
71 | + if ($driver) { |
|
72 | + if (array_key_exists($driver, $caches['drivers'])) { |
|
73 | 73 | $callback($driver); |
74 | - if(!count($failedInstances)){ |
|
74 | + if (!count($failedInstances)) { |
|
75 | 75 | $io->success("Cache instance {$driver} cleared"); |
76 | - }else{ |
|
76 | + } else { |
|
77 | 77 | $io->error("Cache instance {$driver} not cleared"); |
78 | 78 | } |
79 | - }else{ |
|
79 | + } else { |
|
80 | 80 | $io->error("Cache instance {$driver} does not exists"); |
81 | 81 | } |
82 | 82 | } else { |
83 | - foreach($caches['drivers'] as $name => $parameters) { |
|
83 | + foreach ($caches['drivers'] as $name => $parameters) { |
|
84 | 84 | $callback($name); |
85 | 85 | } |
86 | - if(!count($failedInstances)){ |
|
86 | + if (!count($failedInstances)) { |
|
87 | 87 | $io->success('All caches instances got cleared'); |
88 | - }else{ |
|
88 | + } else { |
|
89 | 89 | $io->success('Almost all caches instances got cleared, except these: ' . implode(', ', $failedInstances)); |
90 | 90 | } |
91 | 91 | } |
@@ -57,11 +57,11 @@ discard block |
||
57 | 57 | if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { |
58 | 58 | $output->writeln("<fg=green>Cache instance {$name} cleared</>"); |
59 | 59 | } |
60 | - }catch (phpFastCacheDriverCheckException $e){ |
|
60 | + } catch (phpFastCacheDriverCheckException $e){ |
|
61 | 61 | $failedInstances[] = $name; |
62 | 62 | if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { |
63 | 63 | $output->writeln("<fg=red>Cache instance {$name} not cleared, got exception: " . "<bg=red;options=bold>" . $e->getMessage() ."</>"); |
64 | - }else{ |
|
64 | + } else{ |
|
65 | 65 | $output->writeln("<fg=red>Cache instance {$name} not cleared (increase verbosity to get more information).</>"); |
66 | 66 | } |
67 | 67 | } |
@@ -73,10 +73,10 @@ discard block |
||
73 | 73 | $callback($driver); |
74 | 74 | if(!count($failedInstances)){ |
75 | 75 | $io->success("Cache instance {$driver} cleared"); |
76 | - }else{ |
|
76 | + } else{ |
|
77 | 77 | $io->error("Cache instance {$driver} not cleared"); |
78 | 78 | } |
79 | - }else{ |
|
79 | + } else{ |
|
80 | 80 | $io->error("Cache instance {$driver} does not exists"); |
81 | 81 | } |
82 | 82 | } else { |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | } |
86 | 86 | if(!count($failedInstances)){ |
87 | 87 | $io->success('All caches instances got cleared'); |
88 | - }else{ |
|
88 | + } else{ |
|
89 | 89 | $io->success('Almost all caches instances got cleared, except these: ' . implode(', ', $failedInstances)); |
90 | 90 | } |
91 | 91 | } |
@@ -39,7 +39,7 @@ |
||
39 | 39 | */ |
40 | 40 | public function load(array $configs, ContainerBuilder $container) |
41 | 41 | { |
42 | - $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
|
42 | + $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); |
|
43 | 43 | $loader->load('services.yml'); |
44 | 44 | |
45 | 45 | $configuration = new Configuration(); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function __construct($drivers, Stopwatch $stopwatch = null) |
55 | 55 | { |
56 | - $this->drivers = (array) $drivers[ 'drivers' ]; |
|
56 | + $this->drivers = (array) $drivers['drivers']; |
|
57 | 57 | $this->stopwatch = $stopwatch; |
58 | 58 | } |
59 | 59 | |
@@ -67,10 +67,10 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public function createInstance($name, ExtendedCacheItemPoolInterface $instance) |
69 | 69 | { |
70 | - if (array_key_exists($name, $this->cacheInstances) && $this->cacheInstances[ $name ] instanceof ExtendedCacheItemPoolInterface) { |
|
70 | + if (array_key_exists($name, $this->cacheInstances) && $this->cacheInstances[$name] instanceof ExtendedCacheItemPoolInterface) { |
|
71 | 71 | throw new phpFastCacheDriverException("Cache instance '{$name}' already exists"); |
72 | 72 | } |
73 | - $this->cacheInstances[ $name ] = $instance; |
|
73 | + $this->cacheInstances[$name] = $instance; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | |
91 | 91 | if (!array_key_exists($name, $this->cacheInstances)) { |
92 | 92 | if (array_key_exists($name, $this->drivers)) { |
93 | - $this->createInstance($name, CacheManager::getInstance($this->drivers[ $name ][ 'type' ], $this->drivers[ $name ][ 'parameters' ])); |
|
94 | - if (!$this->cacheInstances[ $name ] instanceof ExtendedCacheItemPoolInterface) { |
|
93 | + $this->createInstance($name, CacheManager::getInstance($this->drivers[$name]['type'], $this->drivers[$name]['parameters'])); |
|
94 | + if (!$this->cacheInstances[$name] instanceof ExtendedCacheItemPoolInterface) { |
|
95 | 95 | throw new phpFastCacheDriverException("Cache instance '{$name}' does not implements ExtendedCacheItemPoolInterface"); |
96 | 96 | } |
97 | 97 | } else { |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | if ($this->stopwatch) { |
103 | 103 | $this->stopwatch->stop(__METHOD__ . "('{$name}')"); |
104 | 104 | } |
105 | - return $this->cacheInstances[ $name ]; |
|
105 | + return $this->cacheInstances[$name]; |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |