@@ -54,8 +54,8 @@ |
||
54 | 54 | protected function getSource(string $path): ViewSource |
55 | 55 | { |
56 | 56 | $loader = new ViewLoader([ |
57 | - 'default' => __DIR__ . '/fixtures/default', |
|
58 | - 'other' => __DIR__ . '/fixtures/other', |
|
57 | + 'default' => __DIR__.'/fixtures/default', |
|
58 | + 'other' => __DIR__.'/fixtures/other', |
|
59 | 59 | ]); |
60 | 60 | |
61 | 61 | return $loader->withExtension('php')->load($path); |
@@ -130,8 +130,8 @@ |
||
130 | 130 | protected function getView(ContextInterface $context, string $path): ViewInterface |
131 | 131 | { |
132 | 132 | $loader = new ViewLoader([ |
133 | - 'default' => __DIR__ . '/fixtures/default', |
|
134 | - 'other' => __DIR__ . '/fixtures/other', |
|
133 | + 'default' => __DIR__.'/fixtures/default', |
|
134 | + 'other' => __DIR__.'/fixtures/other', |
|
135 | 135 | ]); |
136 | 136 | |
137 | 137 | $engine = new NativeEngine(new Container()); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | public function getID(): string |
31 | 31 | { |
32 | 32 | $calculated = ''; |
33 | - foreach ($this->dependencies as $dependency) { |
|
33 | + foreach ($this->dependencies as $dependency){ |
|
34 | 34 | $calculated .= "[{$dependency->getName()}={$dependency->getValue()}]"; |
35 | 35 | } |
36 | 36 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function resolveValue(string $dependency) |
63 | 63 | { |
64 | - if (!isset($this->dependencies[$dependency])) { |
|
64 | + if (!isset($this->dependencies[$dependency])){ |
|
65 | 65 | throw new ContextException("Undefined context dependency '{$dependency}'."); |
66 | 66 | } |
67 | 67 |
@@ -30,7 +30,8 @@ discard block |
||
30 | 30 | public function getID(): string |
31 | 31 | { |
32 | 32 | $calculated = ''; |
33 | - foreach ($this->dependencies as $dependency) { |
|
33 | + foreach ($this->dependencies as $dependency) |
|
34 | + { |
|
34 | 35 | $calculated .= "[{$dependency->getName()}={$dependency->getValue()}]"; |
35 | 36 | } |
36 | 37 | |
@@ -61,7 +62,8 @@ discard block |
||
61 | 62 | */ |
62 | 63 | public function resolveValue(string $dependency) |
63 | 64 | { |
64 | - if (!isset($this->dependencies[$dependency])) { |
|
65 | + if (!isset($this->dependencies[$dependency])) |
|
66 | + { |
|
65 | 67 | throw new ContextException("Undefined context dependency '{$dependency}'."); |
66 | 68 | } |
67 | 69 |
@@ -29,7 +29,7 @@ |
||
29 | 29 | */ |
30 | 30 | private function process(ViewSource $source, ContextInterface $context): ViewSource |
31 | 31 | { |
32 | - foreach ($this->processors as $processor) { |
|
32 | + foreach ($this->processors as $processor){ |
|
33 | 33 | $source = $processor->process($source, $context); |
34 | 34 | } |
35 | 35 |
@@ -29,7 +29,8 @@ |
||
29 | 29 | */ |
30 | 30 | private function process(ViewSource $source, ContextInterface $context): ViewSource |
31 | 31 | { |
32 | - foreach ($this->processors as $processor) { |
|
32 | + foreach ($this->processors as $processor) |
|
33 | + { |
|
33 | 34 | $source = $processor->process($source, $context); |
34 | 35 | } |
35 | 36 |
@@ -69,7 +69,8 @@ discard block |
||
69 | 69 | public function getDependencies(): array |
70 | 70 | { |
71 | 71 | $dependencies = []; |
72 | - foreach ($this->config['dependencies'] as $dependency) { |
|
72 | + foreach ($this->config['dependencies'] as $dependency) |
|
73 | + { |
|
73 | 74 | $dependencies[] = $this->wire($dependency); |
74 | 75 | } |
75 | 76 | |
@@ -86,7 +87,8 @@ discard block |
||
86 | 87 | public function getEngines(): array |
87 | 88 | { |
88 | 89 | $engines = []; |
89 | - foreach ($this->config['engines'] as $engine) { |
|
90 | + foreach ($this->config['engines'] as $engine) |
|
91 | + { |
|
90 | 92 | $engines[] = $this->wire($engine); |
91 | 93 | } |
92 | 94 | |
@@ -101,11 +103,13 @@ discard block |
||
101 | 103 | */ |
102 | 104 | private function wire($item): Autowire |
103 | 105 | { |
104 | - if ($item instanceof Autowire) { |
|
106 | + if ($item instanceof Autowire) |
|
107 | + { |
|
105 | 108 | return $item; |
106 | 109 | } |
107 | 110 | |
108 | - if (is_string($item)) { |
|
111 | + if (is_string($item)) |
|
112 | + { |
|
109 | 113 | return new Autowire($item); |
110 | 114 | } |
111 | 115 |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | public function getCacheDirectory(): string |
42 | 42 | { |
43 | - return rtrim($this->config['cache']['directory'], '/') . '/'; |
|
43 | + return rtrim($this->config['cache']['directory'], '/').'/'; |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | public function getDependencies(): array |
62 | 62 | { |
63 | 63 | $dependencies = []; |
64 | - foreach ($this->config['dependencies'] as $dependency) { |
|
64 | + foreach ($this->config['dependencies'] as $dependency){ |
|
65 | 65 | $dependencies[] = $this->wire($dependency); |
66 | 66 | } |
67 | 67 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | public function getEngines(): array |
79 | 79 | { |
80 | 80 | $engines = []; |
81 | - foreach ($this->config['engines'] as $engine) { |
|
81 | + foreach ($this->config['engines'] as $engine){ |
|
82 | 82 | $engines[] = $this->wire($engine); |
83 | 83 | } |
84 | 84 | |
@@ -92,11 +92,11 @@ discard block |
||
92 | 92 | */ |
93 | 93 | private function wire($item): Autowire |
94 | 94 | { |
95 | - if ($item instanceof Autowire) { |
|
95 | + if ($item instanceof Autowire){ |
|
96 | 96 | return $item; |
97 | 97 | } |
98 | 98 | |
99 | - if (is_string($item)) { |
|
99 | + if (is_string($item)){ |
|
100 | 100 | return new Autowire($item); |
101 | 101 | } |
102 | 102 |
@@ -44,7 +44,7 @@ |
||
44 | 44 | */ |
45 | 45 | public function getLoader(): LoaderInterface |
46 | 46 | { |
47 | - if (empty($this->loader)) { |
|
47 | + if (empty($this->loader)){ |
|
48 | 48 | throw new EngineException('No associated loader found'); |
49 | 49 | } |
50 | 50 |
@@ -44,7 +44,8 @@ |
||
44 | 44 | */ |
45 | 45 | public function getLoader(): LoaderInterface |
46 | 46 | { |
47 | - if (empty($this->loader)) { |
|
47 | + if (empty($this->loader)) |
|
48 | + { |
|
48 | 49 | throw new EngineException('No associated loader found'); |
49 | 50 | } |
50 | 51 |
@@ -49,21 +49,21 @@ |
||
49 | 49 | ob_start(); |
50 | 50 | $__outputLevel__ = ob_get_level(); |
51 | 51 | |
52 | - try { |
|
52 | + try{ |
|
53 | 53 | ContainerScope::runScope($this->container, function () use ($data): void { |
54 | 54 | extract($data, EXTR_OVERWRITE); |
55 | 55 | // render view in context and output buffer scope, context can be accessed using $this->context |
56 | 56 | require $this->view->getFilename(); |
57 | 57 | }); |
58 | - } catch (\Throwable $e) { |
|
59 | - while (ob_get_level() >= $__outputLevel__) { |
|
58 | + }catch (\Throwable $e){ |
|
59 | + while (ob_get_level() >= $__outputLevel__){ |
|
60 | 60 | ob_end_clean(); |
61 | 61 | } |
62 | 62 | |
63 | 63 | throw new RenderException($e); |
64 | - } finally { |
|
64 | + }finally{ |
|
65 | 65 | //Closing all nested buffers |
66 | - while (ob_get_level() > $__outputLevel__) { |
|
66 | + while (ob_get_level() > $__outputLevel__){ |
|
67 | 67 | ob_end_clean(); |
68 | 68 | } |
69 | 69 | } |
@@ -49,21 +49,28 @@ |
||
49 | 49 | ob_start(); |
50 | 50 | $__outputLevel__ = ob_get_level(); |
51 | 51 | |
52 | - try { |
|
52 | + try |
|
53 | + { |
|
53 | 54 | ContainerScope::runScope($this->container, function () use ($data): void { |
54 | 55 | extract($data, EXTR_OVERWRITE); |
55 | 56 | // render view in context and output buffer scope, context can be accessed using $this->context |
56 | 57 | require $this->view->getFilename(); |
57 | 58 | }); |
58 | - } catch (\Throwable $e) { |
|
59 | - while (ob_get_level() >= $__outputLevel__) { |
|
59 | + } |
|
60 | + catch (\Throwable $e) |
|
61 | + { |
|
62 | + while (ob_get_level() >= $__outputLevel__) |
|
63 | + { |
|
60 | 64 | ob_end_clean(); |
61 | 65 | } |
62 | 66 | |
63 | 67 | throw new RenderException($e); |
64 | - } finally { |
|
68 | + } |
|
69 | + finally |
|
70 | + { |
|
65 | 71 | //Closing all nested buffers |
66 | - while (ob_get_level() > $__outputLevel__) { |
|
72 | + while (ob_get_level() > $__outputLevel__) |
|
73 | + { |
|
67 | 74 | ob_end_clean(); |
68 | 75 | } |
69 | 76 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public function reset(ContextInterface $context = null): void |
25 | 25 | { |
26 | - if (empty($context)) { |
|
26 | + if (empty($context)){ |
|
27 | 27 | $this->cache = []; |
28 | 28 | return; |
29 | 29 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public function resetPath(string $path): void |
40 | 40 | { |
41 | - foreach ($this->cache as &$cache) { |
|
41 | + foreach ($this->cache as &$cache){ |
|
42 | 42 | unset($cache[$path], $cache); |
43 | 43 | } |
44 | 44 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | */ |
73 | 73 | public function get(ContextInterface $context, string $path): ViewInterface |
74 | 74 | { |
75 | - if (!$this->has($context, $path)) { |
|
75 | + if (!$this->has($context, $path)){ |
|
76 | 76 | throw new CacheException("No cache is available for {$path}."); |
77 | 77 | } |
78 | 78 |
@@ -23,7 +23,8 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public function reset(ContextInterface $context = null): void |
25 | 25 | { |
26 | - if (empty($context)) { |
|
26 | + if (empty($context)) |
|
27 | + { |
|
27 | 28 | $this->cache = []; |
28 | 29 | return; |
29 | 30 | } |
@@ -38,7 +39,8 @@ discard block |
||
38 | 39 | */ |
39 | 40 | public function resetPath(string $path): void |
40 | 41 | { |
41 | - foreach ($this->cache as &$cache) { |
|
42 | + foreach ($this->cache as &$cache) |
|
43 | + { |
|
42 | 44 | unset($cache[$path], $cache); |
43 | 45 | } |
44 | 46 | } |
@@ -72,7 +74,8 @@ discard block |
||
72 | 74 | */ |
73 | 75 | public function get(ContextInterface $context, string $path): ViewInterface |
74 | 76 | { |
75 | - if (!$this->has($context, $path)) { |
|
77 | + if (!$this->has($context, $path)) |
|
78 | + { |
|
76 | 79 | throw new CacheException("No cache is available for {$path}."); |
77 | 80 | } |
78 | 81 |
@@ -90,8 +90,8 @@ |
||
90 | 90 | $this->assertEquals($allowRule, $manager->getRule(static::ROLE, static::PERMISSION)); |
91 | 91 | |
92 | 92 | // test pattern permission |
93 | - $this->assertEquals($manager, $manager->associate(static::ROLE, static::PERMISSION . '.*', AllowRule::class)); |
|
94 | - $this->assertEquals($allowRule, $manager->getRule(static::ROLE, static::PERMISSION . '.' . static::PERMISSION)); |
|
93 | + $this->assertEquals($manager, $manager->associate(static::ROLE, static::PERMISSION.'.*', AllowRule::class)); |
|
94 | + $this->assertEquals($allowRule, $manager->getRule(static::ROLE, static::PERMISSION.'.'.static::PERMISSION)); |
|
95 | 95 | |
96 | 96 | $this->assertEquals($manager, $manager->deassociate(static::ROLE, static::PERMISSION)); |
97 | 97 | $this->assertEquals($forbidRule, $manager->getRule(static::ROLE, static::PERMISSION)); |