@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | public function __construct($input, $name) |
| 15 | 15 | { |
| 16 | 16 | if (!is_string($input)) { |
| 17 | - throw new \InvalidArgumentException('Expecting a string of PHP, got: ' . gettype($input), 11); |
|
| 17 | + throw new \InvalidArgumentException('Expecting a string of PHP, got: '.gettype($input), 11); |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | if (strlen($input) === 0) { |
@@ -40,15 +40,15 @@ discard block |
||
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | if (strpos('=,;?', substr($this->input, 0, 1)) !== false) { |
| 43 | - throw new \ErrorException('Expecting a variable name or an expression, got: ' . $this->input, 13); |
|
| 43 | + throw new \ErrorException('Expecting a variable name or an expression, got: '.$this->input, 13); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | preg_match_all( |
| 47 | 47 | '/(?<![<>=!])=(?!>|=)|[\[\]\{\}\(\),;\.]|(?!:):|->/', // punctuation |
| 48 | - preg_replace_callback('/[a-zA-Z0-9\\\\_\\x7f-\\xff]*\((?:[0-9\/%\.\s*+-]++|(?R))*+\)/', function ($match) { |
|
| 48 | + preg_replace_callback('/[a-zA-Z0-9\\\\_\\x7f-\\xff]*\((?:[0-9\/%\.\s*+-]++|(?R))*+\)/', function($match) { |
|
| 49 | 49 | // no need to keep separators in simple PHP expressions (functions calls, parentheses, calculs) |
| 50 | 50 | return str_repeat(' ', strlen($match[0])); |
| 51 | - }, preg_replace_callback('/([\'"]).*?(?<!\\\\)(?:\\\\{2})*\\1/', function ($match) { |
|
| 51 | + }, preg_replace_callback('/([\'"]).*?(?<!\\\\)(?:\\\\{2})*\\1/', function($match) { |
|
| 52 | 52 | // do not take separators in strings |
| 53 | 53 | return str_repeat(' ', strlen($match[0])); |
| 54 | 54 | }, $this->input)), |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | if (!is_null($value)) { |
| 114 | - throw new \ErrorException('Parse error on ' . substr($argument, strlen($match[1])), 15); |
|
| 114 | + throw new \ErrorException('Parse error on '.substr($argument, strlen($match[1])), 15); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | $key .= $match[1]; |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | $addToOutput(); |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - return 'array(' . implode(', ', $output) . ')'; |
|
| 157 | + return 'array('.implode(', ', $output).')'; |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | protected function parseEqual($sep, &$separators, &$result, $innerName, $subCodeHandler) |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | protected function parseSeparator($sep, &$separators, &$result, &$varname, $subCodeHandler, $innerName) |
| 175 | 175 | { |
| 176 | 176 | $handleCodeInbetween = $subCodeHandler->handleCodeInbetween($separators, $result); |
| 177 | - $var = '$__' . $this->name; |
|
| 177 | + $var = '$__'.$this->name; |
|
| 178 | 178 | |
| 179 | 179 | switch ($sep[0]) { |
| 180 | 180 | // translate the javascript's obj.attr into php's obj->attr or obj['attr'] |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | // funcall |
| 191 | 191 | case '(': |
| 192 | 192 | $arguments = $handleCodeInbetween(); |
| 193 | - $call = $varname . '(' . implode(', ', $arguments) . ')'; |
|
| 193 | + $call = $varname.'('.implode(', ', $arguments).')'; |
|
| 194 | 194 | $call = static::addDollarIfNeeded($call); |
| 195 | 195 | $varname = $var; |
| 196 | 196 | array_push($result, "{$var}={$call}"); |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | |
| 199 | 199 | case '[': |
| 200 | 200 | if (preg_match('/[a-zA-Z0-9\\\\_\\x7f-\\xff]$/', $varname)) { |
| 201 | - $varname .= $sep[0] . $innerName; |
|
| 201 | + $varname .= $sep[0].$innerName; |
|
| 202 | 202 | break; |
| 203 | 203 | } |
| 204 | 204 | case '{': |
@@ -206,12 +206,12 @@ discard block |
||
| 206 | 206 | break; |
| 207 | 207 | |
| 208 | 208 | case '=': |
| 209 | - $varname .= '=' . $this->parseEqual($sep, $separators, $result, $innerName, $subCodeHandler); |
|
| 209 | + $varname .= '='.$this->parseEqual($sep, $separators, $result, $innerName, $subCodeHandler); |
|
| 210 | 210 | break; |
| 211 | 211 | |
| 212 | 212 | default: |
| 213 | 213 | if (($innerName !== false && $innerName !== '') || $sep[0] !== ')') { |
| 214 | - $varname .= $sep[0] . $innerName; |
|
| 214 | + $varname .= $sep[0].$innerName; |
|
| 215 | 215 | } |
| 216 | 216 | break; |
| 217 | 217 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | // Else check if a class with a name that match can be loaded |
| 47 | 47 | foreach (array('Pug', 'Jade') as $namespace) { |
| 48 | - $filter = $namespace . '\\Filter\\' . implode('', array_map('ucfirst', explode('-', $name))); |
|
| 48 | + $filter = $namespace.'\\Filter\\'.implode('', array_map('ucfirst', explode('-', $name))); |
|
| 49 | 49 | if (class_exists($filter)) { |
| 50 | 50 | return $filter; |
| 51 | 51 | } |
@@ -63,6 +63,6 @@ discard block |
||
| 63 | 63 | return $filter; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - throw new \InvalidArgumentException($name . ': Filter doesn\'t exists', 17); |
|
| 66 | + throw new \InvalidArgumentException($name.': Filter doesn\'t exists', 17); |
|
| 67 | 67 | } |
| 68 | 68 | } |
@@ -48,7 +48,7 @@ |
||
| 48 | 48 | } elseif (is_array($val) || is_object($val)) { |
| 49 | 49 | $style = array(); |
| 50 | 50 | foreach ($val as $key => $property) { |
| 51 | - $style[] = $key . ':' . $property; |
|
| 51 | + $style[] = $key.':'.$property; |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | $val = implode(';', $style); |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | { |
| 23 | 23 | $input = $this->input; |
| 24 | 24 | |
| 25 | - return function ($start, $end) use ($input) { |
|
| 25 | + return function($start, $end) use ($input) { |
|
| 26 | 26 | $offset = $start[1] + strlen($start[0]); |
| 27 | 27 | |
| 28 | 28 | return substr($input, $offset, isset($end) ? $end[1] - $offset : strlen($input)); |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | $getMiddleString = $this->getMiddleString(); |
| 35 | 35 | $codeHandler = $this->codeHandler; |
| 36 | 36 | |
| 37 | - return function ($arg, $name = '') use (&$result, $codeHandler, $getMiddleString) { |
|
| 37 | + return function($arg, $name = '') use (&$result, $codeHandler, $getMiddleString) { |
|
| 38 | 38 | list($start, $end) = $arg; |
| 39 | 39 | $str = trim($getMiddleString($start, $end)); |
| 40 | 40 | |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | $handleRecursion = $this->handleRecursion($result); |
| 60 | 60 | $name = $this->name; |
| 61 | 61 | |
| 62 | - return function (&$arguments, $start, $end) use ($name, $handleRecursion) { |
|
| 62 | + return function(&$arguments, $start, $end) use ($name, $handleRecursion) { |
|
| 63 | 63 | if ($end !== false && $start[1] !== $end[1]) { |
| 64 | 64 | array_push( |
| 65 | 65 | $arguments, |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | { |
| 77 | 77 | $handleNested = $this->handleNestedExpression($result); |
| 78 | 78 | |
| 79 | - return function (&$arguments, $open, $close) use (&$separators, $handleNested) { |
|
| 79 | + return function(&$arguments, $open, $close) use (&$separators, $handleNested) { |
|
| 80 | 80 | $count = 1; |
| 81 | 81 | |
| 82 | 82 | do { |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | $scanSeparators = $this->scanSeparators($separators, $result); |
| 106 | 106 | $input = $this->input; |
| 107 | 107 | |
| 108 | - return function () use (&$separators, $input, $scanSeparators) { |
|
| 108 | + return function() use (&$separators, $input, $scanSeparators) { |
|
| 109 | 109 | $arguments = array(); |
| 110 | 110 | |
| 111 | 111 | $start = current($separators); |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | $count = $scanSeparators($arguments, $open, $close); |
| 122 | 122 | |
| 123 | 123 | if ($close && $count > 0) { |
| 124 | - throw new \ErrorException($input . "\nMissing closing: " . $close, 14); |
|
| 124 | + throw new \ErrorException($input."\nMissing closing: ".$close, 14); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | if (($sep = current($separators)) !== false) { |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | |
| 139 | 139 | public function getNext($separators) |
| 140 | 140 | { |
| 141 | - return function ($index) use ($separators) { |
|
| 141 | + return function($index) use ($separators) { |
|
| 142 | 142 | if (isset($separators[$index + 1])) { |
| 143 | 143 | return $separators[$index + 1]; |
| 144 | 144 | } |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | |
| 148 | 148 | public function addToOutput(&$output, &$key, &$value) |
| 149 | 149 | { |
| 150 | - return function () use (&$output, &$key, &$value) { |
|
| 150 | + return function() use (&$output, &$key, &$value) { |
|
| 151 | 151 | foreach (array('key', 'value') as $var) { |
| 152 | 152 | ${$var} = trim(${$var}); |
| 153 | 153 | if (empty(${$var})) { |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | } |
| 160 | 160 | $output[] = empty($value) |
| 161 | 161 | ? $key |
| 162 | - : $key . ' => ' . $value; |
|
| 162 | + : $key.' => '.$value; |
|
| 163 | 163 | $key = ''; |
| 164 | 164 | $value = null; |
| 165 | 165 | }; |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | |
| 168 | 168 | public function consume() |
| 169 | 169 | { |
| 170 | - return function (&$argument, $start) { |
|
| 170 | + return function(&$argument, $start) { |
|
| 171 | 171 | $argument = substr($argument, strlen($start)); |
| 172 | 172 | }; |
| 173 | 173 | } |
@@ -22,11 +22,11 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | protected function getNodeString(Filter $node, Compiler $compiler = null) |
| 24 | 24 | { |
| 25 | - return array_reduce($node->block->nodes, function ($result, $line) use ($compiler) { |
|
| 26 | - return $result . ($compiler |
|
| 25 | + return array_reduce($node->block->nodes, function($result, $line) use ($compiler) { |
|
| 26 | + return $result.($compiler |
|
| 27 | 27 | ? $compiler->interpolate($line->value) |
| 28 | 28 | : $line->value |
| 29 | - ) . "\n"; |
|
| 29 | + )."\n"; |
|
| 30 | 30 | }); |
| 31 | 31 | } |
| 32 | 32 | |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | $indent = strlen($nodes[0]->value) - strlen(ltrim($nodes[0]->value)); |
| 37 | 37 | $code = ''; |
| 38 | 38 | foreach ($nodes as $line) { |
| 39 | - $code .= substr($compiler->interpolate($line->value), $indent) . "\n"; |
|
| 39 | + $code .= substr($compiler->interpolate($line->value), $indent)."\n"; |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | if (method_exists($this, 'parse')) { |
@@ -44,9 +44,9 @@ discard block |
||
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | if (isset($this->tag)) { |
| 47 | - $code = '<' . $this->tag . (isset($this->textType) ? ' type="text/' . $this->textType . '"' : '') . '>' . |
|
| 48 | - $code . |
|
| 49 | - '</' . $this->tag . '>'; |
|
| 47 | + $code = '<'.$this->tag.(isset($this->textType) ? ' type="text/'.$this->textType.'"' : '').'>'. |
|
| 48 | + $code. |
|
| 49 | + '</'.$this->tag.'>'; |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | return $code; |
@@ -18,6 +18,6 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | public function __invoke(Filter $node, Compiler $compiler) |
| 20 | 20 | { |
| 21 | - return '<script type="text/javascript">' . $this->getNodeString($node, $compiler) . '</script>'; |
|
| 21 | + return '<script type="text/javascript">'.$this->getNodeString($node, $compiler).'</script>'; |
|
| 22 | 22 | } |
| 23 | 23 | } |
@@ -9,6 +9,6 @@ |
||
| 9 | 9 | { |
| 10 | 10 | public function __invoke(Filter $node, Compiler $compiler) |
| 11 | 11 | { |
| 12 | - return '<style type="text/css">' . $this->getNodeString($node, $compiler) . '</style>'; |
|
| 12 | + return '<style type="text/css">'.$this->getNodeString($node, $compiler).'</style>'; |
|
| 13 | 13 | } |
| 14 | 14 | } |
@@ -9,6 +9,6 @@ |
||
| 9 | 9 | { |
| 10 | 10 | public function __invoke(Filter $node, Compiler $compiler) |
| 11 | 11 | { |
| 12 | - return "<![CDATA[\n" . $this->getNodeString($node, $compiler) . "\n]]>"; |
|
| 12 | + return "<![CDATA[\n".$this->getNodeString($node, $compiler)."\n]]>"; |
|
| 13 | 13 | } |
| 14 | 14 | } |
@@ -23,13 +23,13 @@ |
||
| 23 | 23 | foreach ($node->block->nodes as $n) { |
| 24 | 24 | if (isset($n->value)) { |
| 25 | 25 | $data .= preg_match('/^[[:space:]]*\|(?!\|)(.*)/', $n->value, $m) |
| 26 | - ? ' ?> ' . $m[1] . '<?php ' |
|
| 27 | - : $n->value . "\n"; |
|
| 26 | + ? ' ?> '.$m[1].'<?php ' |
|
| 27 | + : $n->value."\n"; |
|
| 28 | 28 | continue; |
| 29 | 29 | } |
| 30 | - $data .= ' ?> ' . $compiler->subCompiler()->compile($n) . '<?php '; |
|
| 30 | + $data .= ' ?> '.$compiler->subCompiler()->compile($n).'<?php '; |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - return $data ? '<?php ' . $data . ' ?> ' : $data; |
|
| 33 | + return $data ? '<?php '.$data.' ?> ' : $data; |
|
| 34 | 34 | } |
| 35 | 35 | } |