@@ -118,11 +118,11 @@ |
||
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
121 | - * Parse the template source and use the cached |
|
122 | - * content if is available |
|
123 | - * @param string $name |
|
124 | - * @return $this |
|
125 | - */ |
|
121 | + * Parse the template source and use the cached |
|
122 | + * content if is available |
|
123 | + * @param string $name |
|
124 | + * @return $this |
|
125 | + */ |
|
126 | 126 | public function parse(string $name): self |
127 | 127 | { |
128 | 128 | $hash = md5($name); |
@@ -57,8 +57,7 @@ discard block |
||
57 | 57 | * Class Parser |
58 | 58 | * @package Platine\Template\Parser |
59 | 59 | */ |
60 | -class Parser |
|
61 | -{ |
|
60 | +class Parser { |
|
62 | 61 | /** |
63 | 62 | * The template instance |
64 | 63 | * @var Template |
@@ -75,8 +74,7 @@ discard block |
||
75 | 74 | * Create new instance |
76 | 75 | * @param Template $template |
77 | 76 | */ |
78 | - public function __construct(Template $template) |
|
79 | - { |
|
77 | + public function __construct(Template $template) { |
|
80 | 78 | $this->template = $template; |
81 | 79 | } |
82 | 80 |
@@ -53,7 +53,6 @@ |
||
53 | 53 | * Class AbstractFilter |
54 | 54 | * @package Platine\Template\Parser |
55 | 55 | */ |
56 | -abstract class AbstractFilter |
|
57 | -{ |
|
56 | +abstract class AbstractFilter { |
|
58 | 57 | |
59 | 58 | } |
@@ -113,8 +113,8 @@ discard block |
||
113 | 113 | * Quoted fragment pattern |
114 | 114 | */ |
115 | 115 | public const QUOTED_FRAGMENT = '(?:' . self::QUOTED_STRING |
116 | - . '|(?:[^\s,\|\'"]|' |
|
117 | - . self::QUOTED_STRING . ')+)'; |
|
116 | + . '|(?:[^\s,\|\'"]|' |
|
117 | + . self::QUOTED_STRING . ')+)'; |
|
118 | 118 | |
119 | 119 | /** |
120 | 120 | * Tag attributes pattern expression |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | * Template parse pattern |
126 | 126 | */ |
127 | 127 | public const TOKENIZATION_REGEXP = '/(' . self::BLOCK_OPEN |
128 | - . '.*?' . self::BLOCK_CLOSE |
|
129 | - . '|' . self::VARIABLE_OPEN |
|
130 | - . '.*?' . self::VARIABLE_CLOSE |
|
131 | - . ')/'; |
|
128 | + . '.*?' . self::BLOCK_CLOSE |
|
129 | + . '|' . self::VARIABLE_OPEN |
|
130 | + . '.*?' . self::VARIABLE_CLOSE |
|
131 | + . ')/'; |
|
132 | 132 | } |
@@ -53,8 +53,7 @@ |
||
53 | 53 | * Class Token |
54 | 54 | * @package Platine\Template\Parser |
55 | 55 | */ |
56 | -class Token |
|
57 | -{ |
|
56 | +class Token { |
|
58 | 57 | /** |
59 | 58 | * The template opened variable |
60 | 59 | */ |
@@ -147,10 +147,10 @@ |
||
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
150 | - * Returns the class name of the tag. |
|
151 | - * |
|
152 | - * @return string |
|
153 | - */ |
|
150 | + * Returns the class name of the tag. |
|
151 | + * |
|
152 | + * @return string |
|
153 | + */ |
|
154 | 154 | protected function getName(): string |
155 | 155 | { |
156 | 156 | return strtolower(get_class($this)); |
@@ -55,8 +55,7 @@ discard block |
||
55 | 55 | * Class AbstractTag |
56 | 56 | * @package Platine\Template\Parser |
57 | 57 | */ |
58 | -abstract class AbstractTag |
|
59 | -{ |
|
58 | +abstract class AbstractTag { |
|
60 | 59 | /** |
61 | 60 | * The name of this class tag |
62 | 61 | * @var string |
@@ -87,8 +86,7 @@ discard block |
||
87 | 86 | * @param array<int, string> $tokens |
88 | 87 | * @param Parser $parser |
89 | 88 | */ |
90 | - public function __construct(string $markup, array &$tokens, Parser $parser) |
|
91 | - { |
|
89 | + public function __construct(string $markup, array &$tokens, Parser $parser) { |
|
92 | 90 | $this->markup = $markup; |
93 | 91 | $this->parser = $parser; |
94 | 92 |
@@ -95,13 +95,13 @@ |
||
95 | 95 | . Token::FILTER_SEPARATOR |
96 | 96 | . '\s*(.*)/m'; |
97 | 97 | $syntaxRegex = '/(' |
98 | - . Token::QUOTED_FRAGMENT |
|
99 | - . ')(.*)/m'; |
|
98 | + . Token::QUOTED_FRAGMENT |
|
99 | + . ')(.*)/m'; |
|
100 | 100 | $filterRegex = '/(?:\s+|' |
101 | - . Token::QUOTED_FRAGMENT |
|
102 | - . '|' |
|
103 | - . Token::FILTER_METHOD_ARGS_SEPARATOR |
|
104 | - . ')+/'; |
|
101 | + . Token::QUOTED_FRAGMENT |
|
102 | + . '|' |
|
103 | + . Token::FILTER_METHOD_ARGS_SEPARATOR |
|
104 | + . ')+/'; |
|
105 | 105 | $filterArgumentsRegex = '/(?:' |
106 | 106 | . Token::FILTER_NAME_ARG_SEPARATOR |
107 | 107 | . '|' |
@@ -55,8 +55,7 @@ discard block |
||
55 | 55 | * Class Variable |
56 | 56 | * @package Platine\Template\Parser |
57 | 57 | */ |
58 | -class Variable |
|
59 | -{ |
|
58 | +class Variable { |
|
60 | 59 | /** |
61 | 60 | * The variable markup |
62 | 61 | * @var string |
@@ -86,8 +85,7 @@ discard block |
||
86 | 85 | * @param string $markup |
87 | 86 | * @param Parser $parser |
88 | 87 | */ |
89 | - public function __construct(string $markup, Parser $parser) |
|
90 | - { |
|
88 | + public function __construct(string $markup, Parser $parser) { |
|
91 | 89 | $this->markup = $markup; |
92 | 90 | $this->parser = $parser; |
93 | 91 | |
@@ -185,8 +183,7 @@ discard block |
||
185 | 183 | * @param Context $context |
186 | 184 | * @return mixed |
187 | 185 | */ |
188 | - public function render(Context $context) |
|
189 | - { |
|
186 | + public function render(Context $context) { |
|
190 | 187 | $output = $context->get($this->name); |
191 | 188 | foreach ($this->filters as $filter) { |
192 | 189 | list($filterName, $filterArgKeys) = $filter; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | |
84 | 84 | /** |
85 | 85 | * {@inheritdoc} |
86 | - */ |
|
86 | + */ |
|
87 | 87 | public function parse(array &$tokens): void |
88 | 88 | { |
89 | 89 | $startRegex = '/^' . Token::BLOCK_OPEN . '/'; |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | |
180 | 180 | /** |
181 | 181 | * {@inheritdoc} |
182 | - */ |
|
182 | + */ |
|
183 | 183 | public function render(Context $context): string |
184 | 184 | { |
185 | 185 | return $this->renderAll($this->nodeList, $context); |
@@ -57,8 +57,7 @@ |
||
57 | 57 | * Class AbstractBlock |
58 | 58 | * @package Platine\Template\Parser |
59 | 59 | */ |
60 | -class AbstractBlock extends AbstractTag |
|
61 | -{ |
|
60 | +class AbstractBlock extends AbstractTag { |
|
62 | 61 | /** |
63 | 62 | * The node list |
64 | 63 | * @var AbstractTag[]|Variable[]|string[] |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | protected array $matches = []; |
69 | 69 | |
70 | 70 | /** |
71 | - * Create new instance |
|
72 | - * @param string $pattern |
|
73 | - */ |
|
71 | + * Create new instance |
|
72 | + * @param string $pattern |
|
73 | + */ |
|
74 | 74 | public function __construct(string $pattern) |
75 | 75 | { |
76 | 76 | $this->pattern = (substr($pattern, 0, 1) !== '/') |
@@ -79,10 +79,10 @@ discard block |
||
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
82 | - * Return the array of matches for the given value |
|
83 | - * @param string $value |
|
84 | - * @return array<int|string, array<int|string, mixed>> |
|
85 | - */ |
|
82 | + * Return the array of matches for the given value |
|
83 | + * @param string $value |
|
84 | + * @return array<int|string, array<int|string, mixed>> |
|
85 | + */ |
|
86 | 86 | public function scan(string $value): array |
87 | 87 | { |
88 | 88 | $matches = []; |
@@ -104,20 +104,20 @@ discard block |
||
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
107 | - * Whether the given value match regex |
|
108 | - * @param string $value |
|
109 | - * @return bool |
|
110 | - */ |
|
107 | + * Whether the given value match regex |
|
108 | + * @param string $value |
|
109 | + * @return bool |
|
110 | + */ |
|
111 | 111 | public function match(string $value): bool |
112 | 112 | { |
113 | 113 | return (bool) preg_match($this->pattern, $value, $this->matches); |
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
117 | - * Whether the given value match all regex |
|
118 | - * @param string $value |
|
119 | - * @return bool |
|
120 | - */ |
|
117 | + * Whether the given value match all regex |
|
118 | + * @param string $value |
|
119 | + * @return bool |
|
120 | + */ |
|
121 | 121 | public function matchAll(string $value): bool |
122 | 122 | { |
123 | 123 | return (bool) preg_match_all($this->pattern, $value, $this->matches); |
@@ -202,10 +202,10 @@ discard block |
||
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
205 | - * Quote the given value in order to use in regex expression |
|
206 | - * @param string $value |
|
207 | - * @return string |
|
208 | - */ |
|
205 | + * Quote the given value in order to use in regex expression |
|
206 | + * @param string $value |
|
207 | + * @return string |
|
208 | + */ |
|
209 | 209 | protected function quote(string $value): string |
210 | 210 | { |
211 | 211 | return preg_quote($value, '/'); |
@@ -53,8 +53,7 @@ discard block |
||
53 | 53 | * Class Lexer |
54 | 54 | * @package Platine\Template\Parser |
55 | 55 | */ |
56 | -class Lexer |
|
57 | -{ |
|
56 | +class Lexer { |
|
58 | 57 | /** |
59 | 58 | * The lexer pattern |
60 | 59 | * @var string |
@@ -71,8 +70,7 @@ discard block |
||
71 | 70 | * Create new instance |
72 | 71 | * @param string $pattern |
73 | 72 | */ |
74 | - public function __construct(string $pattern) |
|
75 | - { |
|
73 | + public function __construct(string $pattern) { |
|
76 | 74 | $this->pattern = (substr($pattern, 0, 1) !== '/') |
77 | 75 | ? '/' . $this->quote($pattern) . '/' |
78 | 76 | : $pattern; |
@@ -150,8 +148,7 @@ discard block |
||
150 | 148 | * @param int $index |
151 | 149 | * @return array<int, mixed> |
152 | 150 | */ |
153 | - public function getArrayMatch(int $index = -1) |
|
154 | - { |
|
151 | + public function getArrayMatch(int $index = -1) { |
|
155 | 152 | if ($index === -1) { |
156 | 153 | return $this->matches; |
157 | 154 | } |
@@ -182,8 +179,7 @@ discard block |
||
182 | 179 | * @param int $index |
183 | 180 | * @return mixed |
184 | 181 | */ |
185 | - public function getMixedMatch(int $index) |
|
186 | - { |
|
182 | + public function getMixedMatch(int $index) { |
|
187 | 183 | if (array_key_exists($index, $this->matches)) { |
188 | 184 | return $this->matches[$index]; |
189 | 185 | } |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
90 | - * {@inheritdoc} |
|
91 | - */ |
|
90 | + * {@inheritdoc} |
|
91 | + */ |
|
92 | 92 | public function read(string $key, bool $unserialize = true) |
93 | 93 | { |
94 | 94 | if (!$this->exists($key)) { |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
108 | - * {@inheritdoc} |
|
109 | - */ |
|
108 | + * {@inheritdoc} |
|
109 | + */ |
|
110 | 110 | public function exists(string $key): bool |
111 | 111 | { |
112 | 112 | $file = $this->getFilePath($key); |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
122 | - * {@inheritdoc} |
|
123 | - */ |
|
122 | + * {@inheritdoc} |
|
123 | + */ |
|
124 | 124 | public function write(string $key, $value, bool $serialize = true): bool |
125 | 125 | { |
126 | 126 | $file = $this->getFilePath($key); |
@@ -137,8 +137,8 @@ discard block |
||
137 | 137 | |
138 | 138 | |
139 | 139 | /** |
140 | - * {@inheritdoc} |
|
141 | - */ |
|
140 | + * {@inheritdoc} |
|
141 | + */ |
|
142 | 142 | public function flush(bool $expired = false): bool |
143 | 143 | { |
144 | 144 | $list = glob(sprintf('%s%s*', $this->path, $this->prefix)); |
@@ -57,8 +57,7 @@ discard block |
||
57 | 57 | * Class FileCache |
58 | 58 | * @package Platine\Template\Cache |
59 | 59 | */ |
60 | -class FileCache extends AbstractCache |
|
61 | -{ |
|
60 | +class FileCache extends AbstractCache { |
|
62 | 61 | /** |
63 | 62 | * The cache directory to use |
64 | 63 | * @var string |
@@ -69,8 +68,7 @@ discard block |
||
69 | 68 | * Create new instance |
70 | 69 | * @param Configuration|null $config |
71 | 70 | */ |
72 | - public function __construct(?Configuration $config = null) |
|
73 | - { |
|
71 | + public function __construct(?Configuration $config = null) { |
|
74 | 72 | parent::__construct($config); |
75 | 73 | $dir = $this->config->get('cache_dir'); |
76 | 74 | $path = Helper::normalizePath($dir); |
@@ -89,8 +87,7 @@ discard block |
||
89 | 87 | /** |
90 | 88 | * {@inheritdoc} |
91 | 89 | */ |
92 | - public function read(string $key, bool $unserialize = true) |
|
93 | - { |
|
90 | + public function read(string $key, bool $unserialize = true) { |
|
94 | 91 | if (!$this->exists($key)) { |
95 | 92 | return false; |
96 | 93 | } |
@@ -56,24 +56,24 @@ discard block |
||
56 | 56 | class NullCache extends AbstractCache |
57 | 57 | { |
58 | 58 | /** |
59 | - * {@inheritdoc} |
|
60 | - */ |
|
59 | + * {@inheritdoc} |
|
60 | + */ |
|
61 | 61 | public function read(string $key, bool $unserialize = false) |
62 | 62 | { |
63 | 63 | return false; |
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
67 | - * {@inheritdoc} |
|
68 | - */ |
|
67 | + * {@inheritdoc} |
|
68 | + */ |
|
69 | 69 | public function exists(string $key): bool |
70 | 70 | { |
71 | 71 | return false; |
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
75 | - * {@inheritdoc} |
|
76 | - */ |
|
75 | + * {@inheritdoc} |
|
76 | + */ |
|
77 | 77 | public function write(string $key, $value, bool $serialize = false): bool |
78 | 78 | { |
79 | 79 | return true; |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | |
82 | 82 | |
83 | 83 | /** |
84 | - * {@inheritdoc} |
|
85 | - */ |
|
84 | + * {@inheritdoc} |
|
85 | + */ |
|
86 | 86 | public function flush(bool $expired = false): bool |
87 | 87 | { |
88 | 88 | return true; |
@@ -53,13 +53,11 @@ |
||
53 | 53 | * Class NullCache |
54 | 54 | * @package Platine\Template\Cache |
55 | 55 | */ |
56 | -class NullCache extends AbstractCache |
|
57 | -{ |
|
56 | +class NullCache extends AbstractCache { |
|
58 | 57 | /** |
59 | 58 | * {@inheritdoc} |
60 | 59 | */ |
61 | - public function read(string $key, bool $unserialize = false) |
|
62 | - { |
|
60 | + public function read(string $key, bool $unserialize = false) { |
|
63 | 61 | return false; |
64 | 62 | } |
65 | 63 |