@@ -10,7 +10,7 @@ |
||
10 | 10 | |
11 | 11 | class Brackets implements \Transphporm\Parser\Tokenizable { |
12 | 12 | |
13 | - private $types = [ |
|
13 | + private $types = [ |
|
14 | 14 | Tokenizer::OPEN_BRACKET => ['(', ')'], |
15 | 15 | Tokenizer::OPEN_BRACE => ['{', '}'], |
16 | 16 | Tokenizer::OPEN_SQUARE_BRACKET => ['[', ']'] |
@@ -42,9 +42,9 @@ discard block |
||
42 | 42 | } |
43 | 43 | |
44 | 44 | public function setLocale($locale) { |
45 | - $format = new \Transphporm\Module\Format($locale); |
|
46 | - $this->modules[get_class($format)] = $format; |
|
47 | - } |
|
45 | + $format = new \Transphporm\Module\Format($locale); |
|
46 | + $this->modules[get_class($format)] = $format; |
|
47 | + } |
|
48 | 48 | |
49 | 49 | public function addPath($dir) { |
50 | 50 | $this->filePath->addPath($dir); |
@@ -100,15 +100,15 @@ discard block |
||
100 | 100 | |
101 | 101 | //Load a template, firstly check if it's a file or a valid string |
102 | 102 | private function loadTemplate() { |
103 | - $result = ['cache' => $this->template, 'headers' => []]; |
|
103 | + $result = ['cache' => $this->template, 'headers' => []]; |
|
104 | 104 | if (strpos($this->template, "\n") === false && is_file($this->template)) $result = $this->loadTemplateFromFile($this->template); |
105 | 105 | return $result; |
106 | 106 | } |
107 | 107 | |
108 | - private function loadTemplateFromFile($file) { |
|
109 | - $xml = $this->cache->load($this->cacheKey . $file, filemtime($file)); |
|
110 | - return $xml ? $xml : ['cache' => file_get_contents($file) ?: "", 'headers' => []]; |
|
111 | - } |
|
108 | + private function loadTemplateFromFile($file) { |
|
109 | + $xml = $this->cache->load($this->cacheKey . $file, filemtime($file)); |
|
110 | + return $xml ? $xml : ['cache' => file_get_contents($file) ?: "", 'headers' => []]; |
|
111 | + } |
|
112 | 112 | |
113 | 113 | public function setCache(\ArrayAccess $cache) { |
114 | 114 | $this->cache = new Cache($cache); |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | } |
52 | 52 | |
53 | 53 | private function getSheetLoader() { |
54 | - $tssRules = is_file((string)$this->tss) ? new SheetLoader\TSSFile($this->tss, $this->filePath, $this->cache, $this->time) : new SheetLoader\TSSString($this->tss, $this->filePath); |
|
54 | + $tssRules = is_file((string) $this->tss) ? new SheetLoader\TSSFile($this->tss, $this->filePath, $this->cache, $this->time) : new SheetLoader\TSSString($this->tss, $this->filePath); |
|
55 | 55 | return new SheetLoader\SheetLoader($this->cache, $this->filePath, $tssRules, $this->time); |
56 | 56 | } |
57 | 57 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | 'headers' => array_merge($result['headers'], $headers), |
73 | 73 | 'body' => $this->doPostProcessing($template)->output($document) |
74 | 74 | ]; |
75 | - $this->cache->write($tssCache->getCacheKey($data) . $this->template, $result); |
|
75 | + $this->cache->write($tssCache->getCacheKey($data).$this->template, $result); |
|
76 | 76 | } |
77 | 77 | unset($result['cache'], $result['renderTime']); |
78 | 78 | return (object) $result; |
@@ -82,10 +82,10 @@ discard block |
||
82 | 82 | $elementData = new \Transphporm\Hook\ElementData(new \SplObjectStorage(), $data); |
83 | 83 | $functionSet = new FunctionSet($elementData); |
84 | 84 | //To be a valid XML document it must have a root element, automatically wrap it in <template> to ensure it does |
85 | - $template = new Template($this->isValidDoc($body) ? str_ireplace('<!doctype', '<!DOCTYPE', $body) : '<template>' . $body . '</template>' ); |
|
85 | + $template = new Template($this->isValidDoc($body) ? str_ireplace('<!doctype', '<!DOCTYPE', $body) : '<template>'.$body.'</template>'); |
|
86 | 86 | |
87 | 87 | $valueParser = new Parser\Value($functionSet); |
88 | - $this->config = new Config($functionSet, $valueParser, $elementData, new Hook\Formatter(), new Parser\CssToXpath($functionSet, $template->getPrefix(), md5((string)$this->tss)), $this->filePath, $headers); |
|
88 | + $this->config = new Config($functionSet, $valueParser, $elementData, new Hook\Formatter(), new Parser\CssToXpath($functionSet, $template->getPrefix(), md5((string) $this->tss)), $this->filePath, $headers); |
|
89 | 89 | |
90 | 90 | foreach ($this->modules as $module) $module->load($this->config); |
91 | 91 | return $template; |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | } |
107 | 107 | |
108 | 108 | private function loadTemplateFromFile($file) { |
109 | - $xml = $this->cache->load($this->cacheKey . $file, filemtime($file)); |
|
109 | + $xml = $this->cache->load($this->cacheKey.$file, filemtime($file)); |
|
110 | 110 | return $xml ? $xml : ['cache' => file_get_contents($file) ?: "", 'headers' => []]; |
111 | 111 | } |
112 | 112 |
@@ -28,7 +28,9 @@ discard block |
||
28 | 28 | $this->cache = new Cache(new \ArrayObject()); |
29 | 29 | $this->filePath = new FilePath(); |
30 | 30 | $modules = is_array($modules) ? $modules : $this->defaultModules; |
31 | - foreach ($modules as $module) $this->loadModule(new $module); |
|
31 | + foreach ($modules as $module) { |
|
32 | + $this->loadModule(new $module); |
|
33 | + } |
|
32 | 34 | } |
33 | 35 | |
34 | 36 | //Allow setting the time used by Transphporm for caching. This is for testing purposes |
@@ -87,7 +89,9 @@ discard block |
||
87 | 89 | $valueParser = new Parser\Value($functionSet); |
88 | 90 | $this->config = new Config($functionSet, $valueParser, $elementData, new Hook\Formatter(), new Parser\CssToXpath($functionSet, $template->getPrefix(), md5((string)$this->tss)), $this->filePath, $headers); |
89 | 91 | |
90 | - foreach ($this->modules as $module) $module->load($this->config); |
|
92 | + foreach ($this->modules as $module) { |
|
93 | + $module->load($this->config); |
|
94 | + } |
|
91 | 95 | return $template; |
92 | 96 | } |
93 | 97 | |
@@ -101,7 +105,9 @@ discard block |
||
101 | 105 | //Load a template, firstly check if it's a file or a valid string |
102 | 106 | private function loadTemplate() { |
103 | 107 | $result = ['cache' => $this->template, 'headers' => []]; |
104 | - if (strpos($this->template, "\n") === false && is_file($this->template)) $result = $this->loadTemplateFromFile($this->template); |
|
108 | + if (strpos($this->template, "\n") === false && is_file($this->template)) { |
|
109 | + $result = $this->loadTemplateFromFile($this->template); |
|
110 | + } |
|
105 | 111 | return $result; |
106 | 112 | } |
107 | 113 | |
@@ -120,6 +126,8 @@ discard block |
||
120 | 126 | |
121 | 127 | public function __destruct() { |
122 | 128 | //Required hack as DomXPath can only register static functions clear the statically stored instance to avoid memory leaks |
123 | - if (isset($this->config)) $this->config->getCssToXpath()->cleanup(); |
|
129 | + if (isset($this->config)) { |
|
130 | + $this->config->getCssToXpath()->cleanup(); |
|
131 | + } |
|
124 | 132 | } |
125 | 133 | } |
@@ -17,8 +17,8 @@ discard block |
||
17 | 17 | $this->fileName = $fileName; |
18 | 18 | $this->filePath = $filePath; |
19 | 19 | $this->cache = $cache; |
20 | - $this->time = isset($time) ? $time : time(); |
|
21 | - $this->cacheName = $this->fileName; |
|
20 | + $this->time = isset($time) ? $time : time(); |
|
21 | + $this->cacheName = $this->fileName; |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | private function getRulesFromCache($file) { |
@@ -77,15 +77,15 @@ discard block |
||
77 | 77 | } |
78 | 78 | |
79 | 79 | //write the sheet to cache |
80 | - public function write($rules, $imports = []) { |
|
80 | + public function write($rules, $imports = []) { |
|
81 | 81 | $existing = $this->cache->load($this->fileName, filemtime($this->fileName)); |
82 | 82 | if (isset($existing['import']) && empty($imports)) $imports = $existing['import']; |
83 | 83 | $this->cache->write($this->cacheName, ['rules' => $rules, 'import' => $imports, 'minFreq' => $this->getMinUpdateFreq($rules), 'ctime' => $this->time, 'cacheKey' => $this->cacheKey]); |
84 | 84 | |
85 | 85 | return $rules; |
86 | - } |
|
86 | + } |
|
87 | 87 | |
88 | - //Gets the minimum update-frequency for a sheet's rules |
|
88 | + //Gets the minimum update-frequency for a sheet's rules |
|
89 | 89 | private function getMinUpdateFreq($rules) { |
90 | 90 | $min = \PHP_INT_MAX; |
91 | 91 |
@@ -61,7 +61,7 @@ |
||
61 | 61 | if ($this->cacheKey) { |
62 | 62 | $parser = new \Transphporm\Parser\Value($data); |
63 | 63 | $cacheKey = $parser->parseTokens($this->cacheKey)[0]; |
64 | - $this->cacheName = $cacheKey . $this->fileName; |
|
64 | + $this->cacheName = $cacheKey.$this->fileName; |
|
65 | 65 | return $cacheKey; |
66 | 66 | } |
67 | 67 | else return $this->fileName; |
@@ -32,7 +32,9 @@ discard block |
||
32 | 32 | if ($rules) { |
33 | 33 | foreach ($rules['import'] as $file) { |
34 | 34 | //Check that the import file hasn't been changed since the cache was written |
35 | - if (filemtime($file) > $rules['ctime']) return false; |
|
35 | + if (filemtime($file) > $rules['ctime']) { |
|
36 | + return false; |
|
37 | + } |
|
36 | 38 | } |
37 | 39 | } |
38 | 40 | |
@@ -48,10 +50,14 @@ discard block |
||
48 | 50 | |
49 | 51 | $rules = $this->getRulesFromCache($this->fileName); |
50 | 52 | //Nothing was cached or the TSS file has changed, update is required |
51 | - if (empty($rules)) return true; |
|
53 | + if (empty($rules)) { |
|
54 | + return true; |
|
55 | + } |
|
52 | 56 | |
53 | 57 | //Find the sheet's minimum update-frequency, if it hasn't passed then no updates are required |
54 | - if ($rules['ctime']+$rules['minFreq'] <= $this->time) return true; |
|
58 | + if ($rules['ctime']+$rules['minFreq'] <= $this->time) { |
|
59 | + return true; |
|
60 | + } |
|
55 | 61 | |
56 | 62 | return false; |
57 | 63 | } |
@@ -63,15 +69,19 @@ discard block |
||
63 | 69 | $cacheKey = $parser->parseTokens($this->cacheKey)[0]; |
64 | 70 | $this->cacheName = $cacheKey . $this->fileName; |
65 | 71 | return $cacheKey; |
72 | + } else { |
|
73 | + return $this->fileName; |
|
66 | 74 | } |
67 | - else return $this->fileName; |
|
68 | 75 | } |
69 | 76 | |
70 | 77 | public function getRules($cssToXpath, $valueParser, $sheetLoader, $indexStart) { |
71 | 78 | $rules = $this->getRulesFromCache($this->fileName); |
72 | 79 | $this->filePath->addPath(dirname(realpath($this->fileName))); |
73 | - if (empty($rules)) $tss = file_get_contents($this->fileName); |
|
74 | - else return $rules['rules']; |
|
80 | + if (empty($rules)) { |
|
81 | + $tss = file_get_contents($this->fileName); |
|
82 | + } else { |
|
83 | + return $rules['rules']; |
|
84 | + } |
|
75 | 85 | |
76 | 86 | return $tss == null ? [] : (new \Transphporm\Parser\Sheet($tss, $cssToXpath, $valueParser, $this->filePath, $sheetLoader))->parse($indexStart); |
77 | 87 | } |
@@ -79,7 +89,9 @@ discard block |
||
79 | 89 | //write the sheet to cache |
80 | 90 | public function write($rules, $imports = []) { |
81 | 91 | $existing = $this->cache->load($this->fileName, filemtime($this->fileName)); |
82 | - if (isset($existing['import']) && empty($imports)) $imports = $existing['import']; |
|
92 | + if (isset($existing['import']) && empty($imports)) { |
|
93 | + $imports = $existing['import']; |
|
94 | + } |
|
83 | 95 | $this->cache->write($this->cacheName, ['rules' => $rules, 'import' => $imports, 'minFreq' => $this->getMinUpdateFreq($rules), 'ctime' => $this->time, 'cacheKey' => $this->cacheKey]); |
84 | 96 | |
85 | 97 | return $rules; |
@@ -91,7 +103,9 @@ discard block |
||
91 | 103 | |
92 | 104 | foreach ($rules as $rule) { |
93 | 105 | $ruleFreq = $rule->getUpdateFrequency(); |
94 | - if ($ruleFreq < $min) $min = $ruleFreq; |
|
106 | + if ($ruleFreq < $min) { |
|
107 | + $min = $ruleFreq; |
|
108 | + } |
|
95 | 109 | } |
96 | 110 | |
97 | 111 | return $min; |
@@ -10,7 +10,7 @@ |
||
10 | 10 | public function run(array $args, \DomElement $element) { |
11 | 11 | $const_name = strtoupper(trim($args[0])); |
12 | 12 | if (!defined($const_name)) { |
13 | - throw new \Exception($const_name . ' is not a defined constant'); |
|
13 | + throw new \Exception($const_name.' is not a defined constant'); |
|
14 | 14 | } |
15 | 15 | return constant($const_name); |
16 | 16 | } |
@@ -21,7 +21,7 @@ |
||
21 | 21 | $templateFunction = new \Transphporm\TSSFunction\Template($config->getElementData(), $config->getCssToXpath(), $baseDir); |
22 | 22 | $functionSet->addFunction('template', $templateFunction); |
23 | 23 | $functionSet->addFunction('json', new \Transphporm\TSSFunction\Json($baseDir)); |
24 | - $functionSet->addFunction('constant', new \Transphporm\TSSFunction\Constant()); |
|
24 | + $functionSet->addFunction('constant', new \Transphporm\TSSFunction\Constant()); |
|
25 | 25 | |
26 | 26 | // Register HTML formatter here because it uses the template function |
27 | 27 | $config->registerFormatter(new \Transphporm\Formatter\HTMLFormatter($templateFunction)); |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | } |
40 | 40 | |
41 | 41 | public function add($token) { |
42 | - if ($token instanceof Tokens) $this->tokens = array_merge($this->tokens, $token->tokens); |
|
42 | + if ($token instanceof Tokens) $this->tokens = array_merge($this->tokens, $token->tokens); |
|
43 | 43 | else $this->tokens[] = $token; |
44 | 44 | } |
45 | 45 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | if ($token['type'] === $tokenType) $i++; |
88 | 88 | else $splitTokens[$i][] = $token; |
89 | 89 | } |
90 | - return array_map(function ($tokens) { |
|
90 | + return array_map(function($tokens) { |
|
91 | 91 | return new Tokens($tokens); |
92 | 92 | }, $splitTokens); |
93 | 93 | //return $splitTokens; |
@@ -39,8 +39,11 @@ discard block |
||
39 | 39 | } |
40 | 40 | |
41 | 41 | public function add($token) { |
42 | - if ($token instanceof Tokens) $this->tokens = array_merge($this->tokens, $token->tokens); |
|
43 | - else $this->tokens[] = $token; |
|
42 | + if ($token instanceof Tokens) { |
|
43 | + $this->tokens = array_merge($this->tokens, $token->tokens); |
|
44 | + } else { |
|
45 | + $this->tokens[] = $token; |
|
46 | + } |
|
44 | 47 | } |
45 | 48 | |
46 | 49 | |
@@ -54,9 +57,13 @@ discard block |
||
54 | 57 | |
55 | 58 | private function getKeyToSlice($tokenType) { |
56 | 59 | $keys = $this->getKeysOfTokenType($tokenType); |
57 | - if (empty($keys)) return false; |
|
60 | + if (empty($keys)) { |
|
61 | + return false; |
|
62 | + } |
|
58 | 63 | $key = $keys[0]; |
59 | - for ($i = 0; $key < $this->iterator && isset($keys[$i]); $i++) $key = $keys[$i]; |
|
64 | + for ($i = 0; $key < $this->iterator && isset($keys[$i]); $i++) { |
|
65 | + $key = $keys[$i]; |
|
66 | + } |
|
60 | 67 | return $key; |
61 | 68 | } |
62 | 69 | |
@@ -70,10 +77,17 @@ discard block |
||
70 | 77 | |
71 | 78 | private function sliceTokens($tokenType, $type, $increment = false) { |
72 | 79 | $key = $this->getKeyToSlice($tokenType); |
73 | - if ($key === false) return new Tokens([]); |
|
74 | - if ($increment) $key++; |
|
75 | - if ($type === "from") return new Tokens(array_slice($this->tokens, $key)); |
|
76 | - else return new Tokens(array_slice($this->tokens, $this->iterator, $key)); |
|
80 | + if ($key === false) { |
|
81 | + return new Tokens([]); |
|
82 | + } |
|
83 | + if ($increment) { |
|
84 | + $key++; |
|
85 | + } |
|
86 | + if ($type === "from") { |
|
87 | + return new Tokens(array_slice($this->tokens, $key)); |
|
88 | + } else { |
|
89 | + return new Tokens(array_slice($this->tokens, $this->iterator, $key)); |
|
90 | + } |
|
77 | 91 | } |
78 | 92 | |
79 | 93 | public function skip($count) { |
@@ -84,8 +98,11 @@ discard block |
||
84 | 98 | $splitTokens = []; |
85 | 99 | $i = 0; |
86 | 100 | foreach ($this->tokens as $token) { |
87 | - if ($token['type'] === $tokenType) $i++; |
|
88 | - else $splitTokens[$i][] = $token; |
|
101 | + if ($token['type'] === $tokenType) { |
|
102 | + $i++; |
|
103 | + } else { |
|
104 | + $splitTokens[$i][] = $token; |
|
105 | + } |
|
89 | 106 | } |
90 | 107 | return array_map(function ($tokens) { |
91 | 108 | return new Tokens($tokens); |
@@ -109,7 +126,9 @@ discard block |
||
109 | 126 | |
110 | 127 | public function removeLine() { |
111 | 128 | $tokens = $this->tokens; |
112 | - foreach ($tokens as &$token) unset($token['line']); |
|
129 | + foreach ($tokens as &$token) { |
|
130 | + unset($token['line']); |
|
131 | + } |
|
113 | 132 | return new Tokens($tokens); |
114 | 133 | } |
115 | 134 |
@@ -14,12 +14,12 @@ |
||
14 | 14 | |
15 | 15 | public function decimal($num, $decimals) { |
16 | 16 | if (!is_numeric($num)) return $num; |
17 | - return number_format((float)$num, $decimals, $this->locale['decimal_separator'], $this->locale['thousands_separator']); |
|
17 | + return number_format((float) $num, $decimals, $this->locale['decimal_separator'], $this->locale['thousands_separator']); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | public function currency($num) { |
21 | 21 | $num = $this->decimal($num, $this->locale['currency_decimals']); |
22 | - if ($this->locale['currency_position'] === 'before') return $this->locale['currency'] . $num; |
|
23 | - else return $num . $this->locale['currency']; |
|
22 | + if ($this->locale['currency_position'] === 'before') return $this->locale['currency'].$num; |
|
23 | + else return $num.$this->locale['currency']; |
|
24 | 24 | } |
25 | 25 | } |
@@ -13,13 +13,18 @@ |
||
13 | 13 | } |
14 | 14 | |
15 | 15 | public function decimal($num, $decimals) { |
16 | - if (!is_numeric($num)) return $num; |
|
16 | + if (!is_numeric($num)) { |
|
17 | + return $num; |
|
18 | + } |
|
17 | 19 | return number_format((float)$num, $decimals, $this->locale['decimal_separator'], $this->locale['thousands_separator']); |
18 | 20 | } |
19 | 21 | |
20 | 22 | public function currency($num) { |
21 | 23 | $num = $this->decimal($num, $this->locale['currency_decimals']); |
22 | - if ($this->locale['currency_position'] === 'before') return $this->locale['currency'] . $num; |
|
23 | - else return $num . $this->locale['currency']; |
|
24 | + if ($this->locale['currency_position'] === 'before') { |
|
25 | + return $this->locale['currency'] . $num; |
|
26 | + } else { |
|
27 | + return $num . $this->locale['currency']; |
|
28 | + } |
|
24 | 29 | } |
25 | 30 | } |
@@ -9,9 +9,13 @@ |
||
9 | 9 | class PostProcess implements \Transphporm\Hook { |
10 | 10 | public function run(\DomElement $element) { |
11 | 11 | $transphporm = $element->getAttribute('transphporm'); |
12 | - if ($transphporm === 'remove') $element->parentNode->removeChild($element); |
|
13 | - else if ($transphporm === 'text') $element->parentNode->replaceChild($element->firstChild, $element); |
|
14 | - else $element->removeAttribute('transphporm'); |
|
12 | + if ($transphporm === 'remove') { |
|
13 | + $element->parentNode->removeChild($element); |
|
14 | + } else if ($transphporm === 'text') { |
|
15 | + $element->parentNode->replaceChild($element->firstChild, $element); |
|
16 | + } else { |
|
17 | + $element->removeAttribute('transphporm'); |
|
18 | + } |
|
15 | 19 | } |
16 | 20 | |
17 | 21 | public function runOnImmutableElements(): bool { |
@@ -9,13 +9,13 @@ |
||
9 | 9 | private $functionSet; |
10 | 10 | private $elementData; |
11 | 11 | private $line; |
12 | - private $filePath; |
|
12 | + private $filePath; |
|
13 | 13 | |
14 | 14 | public function __construct(\Transphporm\FunctionSet $functionSet, \Transphporm\Hook\ElementData $elementData, &$line, \Transphporm\FilePath $filePath) { |
15 | 15 | $this->functionSet = $functionSet; |
16 | 16 | $this->elementData = $elementData; |
17 | 17 | $this->line = &$line; |
18 | - $this->filePath = $filePath; |
|
18 | + $this->filePath = $filePath; |
|
19 | 19 | } |
20 | 20 | |
21 | 21 |
@@ -22,7 +22,9 @@ discard block |
||
22 | 22 | |
23 | 23 | public function run(array $values, \DomElement $element, array $rules, \Transphporm\Hook\PseudoMatcher $pseudoMatcher, array $properties = []) { |
24 | 24 | $values = $this->fixEmpty($values); |
25 | - if ($element->getAttribute('transphporm') === 'added') return $element->parentNode->removeChild($element); |
|
25 | + if ($element->getAttribute('transphporm') === 'added') { |
|
26 | + return $element->parentNode->removeChild($element); |
|
27 | + } |
|
26 | 28 | $this->handleContentModeAppend($element, $rules); |
27 | 29 | $max = $this->getMax($values); |
28 | 30 | $count = 0; |
@@ -36,10 +38,14 @@ discard block |
||
36 | 38 | |
37 | 39 | |
38 | 40 | foreach ($repeat as $key => $iteration) { |
39 | - if ($count+1 > $max) break; |
|
41 | + if ($count+1 > $max) { |
|
42 | + break; |
|
43 | + } |
|
40 | 44 | $clone = $this->cloneElement($element, $iteration, $key, $count++); |
41 | 45 | //Re-run the hook on the new element, but use the iterated data |
42 | - if ($hook) $hook->run($clone); |
|
46 | + if ($hook) { |
|
47 | + $hook->run($clone); |
|
48 | + } |
|
43 | 49 | } |
44 | 50 | |
45 | 51 | //Remove the original element |
@@ -73,7 +79,9 @@ discard block |
||
73 | 79 | } |
74 | 80 | |
75 | 81 | private function fixEmpty($value) { |
76 | - if (empty($value[0])) $value[0] = []; |
|
82 | + if (empty($value[0])) { |
|
83 | + $value[0] = []; |
|
84 | + } |
|
77 | 85 | return $value; |
78 | 86 | } |
79 | 87 | |
@@ -89,7 +97,9 @@ discard block |
||
89 | 97 | |
90 | 98 | private function tagElement($element, $count) { |
91 | 99 | //Mark all but one of the nodes as having been added by transphporm, when the hook is run again, these are removed |
92 | - if ($count > 0) $element->setAttribute('transphporm', 'added'); |
|
100 | + if ($count > 0) { |
|
101 | + $element->setAttribute('transphporm', 'added'); |
|
102 | + } |
|
93 | 103 | } |
94 | 104 | |
95 | 105 | private function getMax($values) { |
@@ -101,10 +111,14 @@ discard block |
||
101 | 111 | // for this rule e.g. repeat: data(); content: "foo" |
102 | 112 | // The content property still needs to be used |
103 | 113 | // But for rules that are just { repeat: data(); } this can be skipped. |
104 | - if (empty($newRules)) return false; |
|
114 | + if (empty($newRules)) { |
|
115 | + return false; |
|
116 | + } |
|
105 | 117 | |
106 | 118 | $hook = new \Transphporm\Hook\PropertyHook($newRules, $this->line, null, $this->line, $pseudoMatcher, new \Transphporm\Parser\Value($this->functionSet), $this->functionSet, $this->filePath); |
107 | - foreach ($properties as $name => $property) $hook->registerProperty($name, $property); |
|
119 | + foreach ($properties as $name => $property) { |
|
120 | + $hook->registerProperty($name, $property); |
|
121 | + } |
|
108 | 122 | return $hook; |
109 | 123 | } |
110 | 124 | } |