@@ -89,8 +89,8 @@ discard block |
||
| 89 | 89 | protected mixed $right = null; |
| 90 | 90 | |
| 91 | 91 | /** |
| 92 | - * {@inheritdoc} |
|
| 93 | - */ |
|
| 92 | + * {@inheritdoc} |
|
| 93 | + */ |
|
| 94 | 94 | public function __construct(string $markup, &$tokens, Parser $parser) |
| 95 | 95 | { |
| 96 | 96 | parent::__construct($markup, $tokens, $parser); |
@@ -107,16 +107,16 @@ discard block |
||
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
| 110 | - * {@inheritdoc} |
|
| 111 | - */ |
|
| 110 | + * {@inheritdoc} |
|
| 111 | + */ |
|
| 112 | 112 | protected function endTag(): void |
| 113 | 113 | { |
| 114 | 114 | $this->pushNodeList(); |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /** |
| 118 | - * {@inheritdoc} |
|
| 119 | - */ |
|
| 118 | + * {@inheritdoc} |
|
| 119 | + */ |
|
| 120 | 120 | protected function unknownTag(string $tag, string $param, array $tokens): void |
| 121 | 121 | { |
| 122 | 122 | $whenLexer = new Lexer('/' . Token::QUOTED_FRAGMENT . '/'); |
@@ -149,8 +149,8 @@ discard block |
||
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | /** |
| 152 | - * {@inheritdoc} |
|
| 153 | - */ |
|
| 152 | + * {@inheritdoc} |
|
| 153 | + */ |
|
| 154 | 154 | public function render(Context $context): string |
| 155 | 155 | { |
| 156 | 156 | $output = ''; |
@@ -62,8 +62,7 @@ discard block |
||
| 62 | 62 | * @class CaseTag |
| 63 | 63 | * @package Platine\Template\Tag |
| 64 | 64 | */ |
| 65 | -class CaseTag extends AbstractCondition |
|
| 66 | -{ |
|
| 65 | +class CaseTag extends AbstractCondition { |
|
| 67 | 66 | /** |
| 68 | 67 | * Stack of node list |
| 69 | 68 | * @var array<int, array<int, mixed>> |
@@ -91,8 +90,7 @@ discard block |
||
| 91 | 90 | /** |
| 92 | 91 | * {@inheritdoc} |
| 93 | 92 | */ |
| 94 | - public function __construct(string $markup, &$tokens, Parser $parser) |
|
| 95 | - { |
|
| 93 | + public function __construct(string $markup, &$tokens, Parser $parser) { |
|
| 96 | 94 | parent::__construct($markup, $tokens, $parser); |
| 97 | 95 | |
| 98 | 96 | $lexer = new Lexer('/' . Token::QUOTED_FRAGMENT . '/'); |
@@ -95,8 +95,8 @@ discard block |
||
| 95 | 95 | protected mixed $variable; |
| 96 | 96 | |
| 97 | 97 | /** |
| 98 | - * {@inheritdoc} |
|
| 99 | - */ |
|
| 98 | + * {@inheritdoc} |
|
| 99 | + */ |
|
| 100 | 100 | public function __construct(string $markup, &$tokens, Parser $parser) |
| 101 | 101 | { |
| 102 | 102 | $lexer = new Lexer( |
@@ -140,8 +140,8 @@ discard block |
||
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | /** |
| 143 | - * {@inheritdoc} |
|
| 144 | - */ |
|
| 143 | + * {@inheritdoc} |
|
| 144 | + */ |
|
| 145 | 145 | public function parse(array &$tokens): void |
| 146 | 146 | { |
| 147 | 147 | $source = $this->parser->getLoader()->read($this->templateName); |
@@ -165,8 +165,8 @@ discard block |
||
| 165 | 165 | |
| 166 | 166 | |
| 167 | 167 | /** |
| 168 | - * {@inheritdoc} |
|
| 169 | - */ |
|
| 168 | + * {@inheritdoc} |
|
| 169 | + */ |
|
| 170 | 170 | public function render(Context $context): string |
| 171 | 171 | { |
| 172 | 172 | $result = ''; |
@@ -61,8 +61,7 @@ discard block |
||
| 61 | 61 | * @class IncludeTag |
| 62 | 62 | * @package Platine\Template\Tag |
| 63 | 63 | */ |
| 64 | -class IncludeTag extends AbstractTag |
|
| 65 | -{ |
|
| 64 | +class IncludeTag extends AbstractTag { |
|
| 66 | 65 | /** |
| 67 | 66 | * The name of the template |
| 68 | 67 | * @var string |
@@ -97,8 +96,7 @@ discard block |
||
| 97 | 96 | /** |
| 98 | 97 | * {@inheritdoc} |
| 99 | 98 | */ |
| 100 | - public function __construct(string $markup, &$tokens, Parser $parser) |
|
| 101 | - { |
|
| 99 | + public function __construct(string $markup, &$tokens, Parser $parser) { |
|
| 102 | 100 | $lexer = new Lexer( |
| 103 | 101 | '/("[^"]+"|\'[^\']+\'|[^\'"\s]+)(\s+(with|for)\s+(' |
| 104 | 102 | . Token::QUOTED_FRAGMENT |
@@ -56,8 +56,8 @@ |
||
| 56 | 56 | class IfnotTag extends IfTag |
| 57 | 57 | { |
| 58 | 58 | /** |
| 59 | - * {@inheritdoc} |
|
| 60 | - */ |
|
| 59 | + * {@inheritdoc} |
|
| 60 | + */ |
|
| 61 | 61 | protected function negateCondition(mixed $value): mixed |
| 62 | 62 | { |
| 63 | 63 | return !$value; |
@@ -53,8 +53,7 @@ |
||
| 53 | 53 | * @class IfnotTag |
| 54 | 54 | * @package Platine\Template\Tag |
| 55 | 55 | */ |
| 56 | -class IfnotTag extends IfTag |
|
| 57 | -{ |
|
| 56 | +class IfnotTag extends IfTag { |
|
| 58 | 57 | /** |
| 59 | 58 | * {@inheritdoc} |
| 60 | 59 | */ |
@@ -82,8 +82,8 @@ discard block |
||
| 82 | 82 | protected string $hash; |
| 83 | 83 | |
| 84 | 84 | /** |
| 85 | - * {@inheritdoc} |
|
| 86 | - */ |
|
| 85 | + * {@inheritdoc} |
|
| 86 | + */ |
|
| 87 | 87 | public function __construct(string $markup, &$tokens, Parser $parser) |
| 88 | 88 | { |
| 89 | 89 | $lexer = new Lexer('/("[^"]+"|\'[^\']+\')?/'); |
@@ -104,8 +104,8 @@ discard block |
||
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
| 107 | - * {@inheritdoc} |
|
| 108 | - */ |
|
| 107 | + * {@inheritdoc} |
|
| 108 | + */ |
|
| 109 | 109 | public function parse(array &$tokens): void |
| 110 | 110 | { |
| 111 | 111 | $source = $this->parser->getLoader()->read($this->templateName); |
@@ -185,8 +185,8 @@ discard block |
||
| 185 | 185 | |
| 186 | 186 | |
| 187 | 187 | /** |
| 188 | - * {@inheritdoc} |
|
| 189 | - */ |
|
| 188 | + * {@inheritdoc} |
|
| 189 | + */ |
|
| 190 | 190 | public function render(Context $context): string |
| 191 | 191 | { |
| 192 | 192 | $context->push(); |
@@ -61,8 +61,7 @@ discard block |
||
| 61 | 61 | * @class ExtendsTag |
| 62 | 62 | * @package Platine\Template\Tag |
| 63 | 63 | */ |
| 64 | -class ExtendsTag extends AbstractTag |
|
| 65 | -{ |
|
| 64 | +class ExtendsTag extends AbstractTag { |
|
| 66 | 65 | /** |
| 67 | 66 | * The name of the template |
| 68 | 67 | * @var string |
@@ -84,8 +83,7 @@ discard block |
||
| 84 | 83 | /** |
| 85 | 84 | * {@inheritdoc} |
| 86 | 85 | */ |
| 87 | - public function __construct(string $markup, &$tokens, Parser $parser) |
|
| 88 | - { |
|
| 86 | + public function __construct(string $markup, &$tokens, Parser $parser) { |
|
| 89 | 87 | $lexer = new Lexer('/("[^"]+"|\'[^\']+\')?/'); |
| 90 | 88 | if ($lexer->match($markup) && $lexer->isMatchNotNull(1)) { |
| 91 | 89 | $this->templateName = substr( |
@@ -106,8 +106,8 @@ discard block |
||
| 106 | 106 | protected int|string $start; |
| 107 | 107 | |
| 108 | 108 | /** |
| 109 | - * {@inheritdoc} |
|
| 110 | - */ |
|
| 109 | + * {@inheritdoc} |
|
| 110 | + */ |
|
| 111 | 111 | public function __construct(string $markup, &$tokens, Parser $parser) |
| 112 | 112 | { |
| 113 | 113 | parent::__construct($markup, $tokens, $parser); |
@@ -143,8 +143,8 @@ discard block |
||
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | /** |
| 146 | - * {@inheritdoc} |
|
| 147 | - */ |
|
| 146 | + * {@inheritdoc} |
|
| 147 | + */ |
|
| 148 | 148 | public function render(Context $context): string |
| 149 | 149 | { |
| 150 | 150 | if (!$context->hasRegister('for')) { |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | * The loop start value |
| 104 | 104 | * @var int|string |
| 105 | 105 | */ |
| 106 | - protected int|string $start; |
|
| 106 | + protected int | string $start; |
|
| 107 | 107 | |
| 108 | 108 | /** |
| 109 | 109 | * {@inheritdoc} |
@@ -194,8 +194,8 @@ discard block |
||
| 194 | 194 | 'index0' => $index, |
| 195 | 195 | 'rindex' => $length - $index, |
| 196 | 196 | 'rindex0' => $length - $index - 1, |
| 197 | - 'first' => ((int)$index === 0), |
|
| 198 | - 'last' => ((int)$index === ($length - 1)), |
|
| 197 | + 'first' => ((int) $index === 0), |
|
| 198 | + 'last' => ((int) $index === ($length - 1)), |
|
| 199 | 199 | ]); |
| 200 | 200 | |
| 201 | 201 | $result .= $this->renderAll($this->nodeList, $context); |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | $offset = 0; |
| 245 | 245 | if (isset($this->attributes['offset'])) { |
| 246 | 246 | $forRegister = $context->getRegister('for'); |
| 247 | - $offset = ($this->attributes['offset'] === 'continue') |
|
| 247 | + $offset = ($this->attributes['offset'] === 'continue') |
|
| 248 | 248 | ? (isset($forRegister[$this->name]) |
| 249 | 249 | ? (int) $forRegister[$this->name] |
| 250 | 250 | : 0) |
@@ -281,8 +281,8 @@ discard block |
||
| 281 | 281 | 'index0' => $index, |
| 282 | 282 | 'rindex' => $length - $index, |
| 283 | 283 | 'rindex0' => $length - $index - 1, |
| 284 | - 'first' => ((int)$index === 0), |
|
| 285 | - 'last' => ((int)$index === ($length - 1)), |
|
| 284 | + 'first' => ((int) $index === 0), |
|
| 285 | + 'last' => ((int) $index === ($length - 1)), |
|
| 286 | 286 | ]); |
| 287 | 287 | |
| 288 | 288 | $result .= $this->renderAll($this->nodeList, $context); |
@@ -62,8 +62,7 @@ discard block |
||
| 62 | 62 | * @class ForTag |
| 63 | 63 | * @package Platine\Template\Tag |
| 64 | 64 | */ |
| 65 | -class ForTag extends AbstractBlock |
|
| 66 | -{ |
|
| 65 | +class ForTag extends AbstractBlock { |
|
| 67 | 66 | /** |
| 68 | 67 | * Type digit |
| 69 | 68 | */ |
@@ -108,8 +107,7 @@ discard block |
||
| 108 | 107 | /** |
| 109 | 108 | * {@inheritdoc} |
| 110 | 109 | */ |
| 111 | - public function __construct(string $markup, &$tokens, Parser $parser) |
|
| 112 | - { |
|
| 110 | + public function __construct(string $markup, &$tokens, Parser $parser) { |
|
| 113 | 111 | parent::__construct($markup, $tokens, $parser); |
| 114 | 112 | |
| 115 | 113 | $lexerCollection = new Lexer('/(\w+)\s+in\s+(' . Token::VARIABLE_NAME . ')/'); |
@@ -73,8 +73,8 @@ discard block |
||
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
| 76 | - * {@inheritdoc} |
|
| 77 | - */ |
|
| 76 | + * {@inheritdoc} |
|
| 77 | + */ |
|
| 78 | 78 | public function read(string $key, bool $unserialize = true): mixed |
| 79 | 79 | { |
| 80 | 80 | $success = false; |
@@ -84,16 +84,16 @@ discard block |
||
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
| 87 | - * {@inheritdoc} |
|
| 88 | - */ |
|
| 87 | + * {@inheritdoc} |
|
| 88 | + */ |
|
| 89 | 89 | public function exists(string $key): bool |
| 90 | 90 | { |
| 91 | 91 | return apcu_exists($this->prefix . $key) === true; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | /** |
| 95 | - * {@inheritdoc} |
|
| 96 | - */ |
|
| 95 | + * {@inheritdoc} |
|
| 96 | + */ |
|
| 97 | 97 | public function write(string $key, mixed $value, bool $serialize = true): bool |
| 98 | 98 | { |
| 99 | 99 | return apcu_store($this->prefix . $key, $value, $this->expire); |
@@ -101,8 +101,8 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | |
| 103 | 103 | /** |
| 104 | - * {@inheritdoc} |
|
| 105 | - */ |
|
| 104 | + * {@inheritdoc} |
|
| 105 | + */ |
|
| 106 | 106 | public function flush(bool $expired = false): bool |
| 107 | 107 | { |
| 108 | 108 | return apcu_clear_cache(); |
@@ -56,14 +56,12 @@ |
||
| 56 | 56 | * @class ApcCache |
| 57 | 57 | * @package Platine\Template\Cache |
| 58 | 58 | */ |
| 59 | -class ApcCache extends AbstractCache |
|
| 60 | -{ |
|
| 59 | +class ApcCache extends AbstractCache { |
|
| 61 | 60 | /** |
| 62 | 61 | * Create new instance |
| 63 | 62 | * @param Configuration|null $config |
| 64 | 63 | */ |
| 65 | - public function __construct(?Configuration $config = null) |
|
| 66 | - { |
|
| 64 | + public function __construct(?Configuration $config = null) { |
|
| 67 | 65 | parent::__construct($config); |
| 68 | 66 | |
| 69 | 67 | if ((!extension_loaded('apcu')) || !((bool) ini_get('apc.enabled'))) { |
@@ -62,8 +62,8 @@ discard block |
||
| 62 | 62 | protected array $data = []; |
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | - * {@inheritdoc} |
|
| 66 | - */ |
|
| 65 | + * {@inheritdoc} |
|
| 66 | + */ |
|
| 67 | 67 | public function read(string $key, bool $unserialize = false): mixed |
| 68 | 68 | { |
| 69 | 69 | if ($this->exists($key) === false) { |
@@ -74,16 +74,16 @@ discard block |
||
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
| 77 | - * {@inheritdoc} |
|
| 78 | - */ |
|
| 77 | + * {@inheritdoc} |
|
| 78 | + */ |
|
| 79 | 79 | public function exists(string $key): bool |
| 80 | 80 | { |
| 81 | 81 | return isset($this->data[$key]); |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
| 85 | - * {@inheritdoc} |
|
| 86 | - */ |
|
| 85 | + * {@inheritdoc} |
|
| 86 | + */ |
|
| 87 | 87 | public function write(string $key, mixed $value, bool $serialize = false): bool |
| 88 | 88 | { |
| 89 | 89 | $this->data[$key] = $value; |
@@ -93,8 +93,8 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | |
| 95 | 95 | /** |
| 96 | - * {@inheritdoc} |
|
| 97 | - */ |
|
| 96 | + * {@inheritdoc} |
|
| 97 | + */ |
|
| 98 | 98 | public function flush(bool $expired = false): bool |
| 99 | 99 | { |
| 100 | 100 | $this->data = []; |
@@ -53,8 +53,7 @@ |
||
| 53 | 53 | * @class MemoryCache |
| 54 | 54 | * @package Platine\Template\Cache |
| 55 | 55 | */ |
| 56 | -class MemoryCache extends AbstractCache |
|
| 57 | -{ |
|
| 56 | +class MemoryCache extends AbstractCache { |
|
| 58 | 57 | /** |
| 59 | 58 | * The cache data |
| 60 | 59 | * @var array<string, mixed> |
@@ -55,8 +55,7 @@ discard block |
||
| 55 | 55 | * @class AbstractCache |
| 56 | 56 | * @package Platine\Template\Cache |
| 57 | 57 | */ |
| 58 | -abstract class AbstractCache |
|
| 59 | -{ |
|
| 58 | +abstract class AbstractCache { |
|
| 60 | 59 | /** |
| 61 | 60 | * The cache expiration in second |
| 62 | 61 | * @var int |
@@ -79,8 +78,7 @@ discard block |
||
| 79 | 78 | * Create new instance |
| 80 | 79 | * @param Configuration|null $config |
| 81 | 80 | */ |
| 82 | - public function __construct(?Configuration $config = null) |
|
| 83 | - { |
|
| 81 | + public function __construct(?Configuration $config = null) { |
|
| 84 | 82 | $this->config = $config ?? new Configuration([]); |
| 85 | 83 | |
| 86 | 84 | $this->expire = $this->config->get('cache_expire'); |
@@ -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): mixed |
| 93 | 93 | { |
| 94 | 94 | if ($this->exists($key) === false) { |
@@ -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, mixed $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); |