@@ -341,6 +341,10 @@ |
||
| 341 | 341 | return $file; |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | + /** |
|
| 345 | + * @param string $class |
|
| 346 | + * @param string $ext |
|
| 347 | + */ |
|
| 344 | 348 | private function findFileWithExtension($class, $ext) |
| 345 | 349 | { |
| 346 | 350 | // PSR-4 lookup |
@@ -344,14 +344,14 @@ discard block |
||
| 344 | 344 | private function findFileWithExtension($class, $ext) |
| 345 | 345 | { |
| 346 | 346 | // PSR-4 lookup |
| 347 | - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; |
|
| 347 | + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR).$ext; |
|
| 348 | 348 | |
| 349 | 349 | $first = $class[0]; |
| 350 | 350 | if (isset($this->prefixLengthsPsr4[$first])) { |
| 351 | 351 | foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) { |
| 352 | 352 | if (0 === strpos($class, $prefix)) { |
| 353 | 353 | foreach ($this->prefixDirsPsr4[$prefix] as $dir) { |
| 354 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { |
|
| 354 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.substr($logicalPathPsr4, $length))) { |
|
| 355 | 355 | return $file; |
| 356 | 356 | } |
| 357 | 357 | } |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | |
| 362 | 362 | // PSR-4 fallback dirs |
| 363 | 363 | foreach ($this->fallbackDirsPsr4 as $dir) { |
| 364 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { |
|
| 364 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr4)) { |
|
| 365 | 365 | return $file; |
| 366 | 366 | } |
| 367 | 367 | } |
@@ -373,14 +373,14 @@ discard block |
||
| 373 | 373 | . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); |
| 374 | 374 | } else { |
| 375 | 375 | // PEAR-like class name |
| 376 | - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; |
|
| 376 | + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR).$ext; |
|
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | if (isset($this->prefixesPsr0[$first])) { |
| 380 | 380 | foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { |
| 381 | 381 | if (0 === strpos($class, $prefix)) { |
| 382 | 382 | foreach ($dirs as $dir) { |
| 383 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
| 383 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
| 384 | 384 | return $file; |
| 385 | 385 | } |
| 386 | 386 | } |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | |
| 391 | 391 | // PSR-0 fallback dirs |
| 392 | 392 | foreach ($this->fallbackDirsPsr0 as $dir) { |
| 393 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
| 393 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
| 394 | 394 | return $file; |
| 395 | 395 | } |
| 396 | 396 | } |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | /** |
| 203 | - * @param $method |
|
| 203 | + * @param string $method |
|
| 204 | 204 | * @param $arguments |
| 205 | 205 | * |
| 206 | 206 | * @throws \BadMethodCallException If the 'apply' rely on non existing method |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | /** |
| 258 | - * @param $input |
|
| 258 | + * @param string $input |
|
| 259 | 259 | * |
| 260 | 260 | * @throws \ErrorException |
| 261 | 261 | * |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | /** |
| 313 | 313 | * @param string $text |
| 314 | 314 | * |
| 315 | - * @return mixed |
|
| 315 | + * @return string |
|
| 316 | 316 | */ |
| 317 | 317 | public function interpolate($text) |
| 318 | 318 | { |
@@ -379,6 +379,9 @@ discard block |
||
| 379 | 379 | return $statements; |
| 380 | 380 | } |
| 381 | 381 | |
| 382 | + /** |
|
| 383 | + * @param string $arg |
|
| 384 | + */ |
|
| 382 | 385 | protected function handleArgumentValue($arg) |
| 383 | 386 | { |
| 384 | 387 | if (preg_match('/^"(?:\\\\.|[^"\\\\])*"|\'(?:\\\\.|[^\'\\\\])*\'/', $arg)) { |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | */ |
| 178 | 178 | protected function closingTag() |
| 179 | 179 | { |
| 180 | - return '?>' . ($this->prettyprint ? ' ' : ''); |
|
| 180 | + return '?>'.($this->prettyprint ? ' ' : ''); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | /** |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | |
| 194 | 194 | // Separate in several lines to get a useable line number in case of an error occurs |
| 195 | 195 | if ($this->phpSingleLine) { |
| 196 | - $code = str_replace(array('<?php', '?>'), array("<?php\n", "\n" . $this->closingTag()), $code); |
|
| 196 | + $code = str_replace(array('<?php', '?>'), array("<?php\n", "\n".$this->closingTag()), $code); |
|
| 197 | 197 | } |
| 198 | 198 | // Remove the $ wich are not needed |
| 199 | 199 | return $code; |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | protected function buffer($line, $indent = null) |
| 224 | 224 | { |
| 225 | 225 | if ($indent === true || ($indent === null && $this->prettyprint)) { |
| 226 | - $line = $this->indent() . $line . $this->newline(); |
|
| 226 | + $line = $this->indent().$line.$this->newline(); |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | $this->buffer[] = $line; |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | */ |
| 237 | 237 | protected function isConstant($str) |
| 238 | 238 | { |
| 239 | - return preg_match('/^' . static::CONSTANT_VALUE . '$/', trim($str)); |
|
| 239 | + return preg_match('/^'.static::CONSTANT_VALUE.'$/', trim($str)); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | /** |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | $quote = substr($match[1], 0, 1); |
| 291 | 291 | |
| 292 | 292 | if (strlen(trim($match[2]))) { |
| 293 | - throw new \ErrorException('Unexpected value: ' . $match[2], 8); |
|
| 293 | + throw new \ErrorException('Unexpected value: '.$match[2], 8); |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | array_push($resultsString, $match[1]); |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | $arg = static::convertVarPath($arg); |
| 353 | 353 | |
| 354 | 354 | // add dollar if missing |
| 355 | - if (preg_match('/^' . static::VARNAME . '(\s*,.+)?$/', $arg)) { |
|
| 355 | + if (preg_match('/^'.static::VARNAME.'(\s*,.+)?$/', $arg)) { |
|
| 356 | 356 | $arg = static::addDollarIfNeeded($arg); |
| 357 | 357 | } |
| 358 | 358 | |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | // if we have a php variable assume that the string is good php |
| 366 | - if (strpos('{[', substr($arg, 0, 1)) === false && preg_match('/&?\${1,2}' . static::VARNAME . '|[A-Za-z0-9_\\\\]+::/', $arg)) { |
|
| 366 | + if (strpos('{[', substr($arg, 0, 1)) === false && preg_match('/&?\${1,2}'.static::VARNAME.'|[A-Za-z0-9_\\\\]+::/', $arg)) { |
|
| 367 | 367 | array_push($variables, $arg); |
| 368 | 368 | continue; |
| 369 | 369 | } |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | try { |
| 393 | 393 | return $this->handleCode(preg_replace('#/\*(.*)\*/#', '', $arg)); |
| 394 | 394 | } catch (\Exception $e) { |
| 395 | - throw new ParserException('Pug.php did not understand ' . $arg, 10, $e); |
|
| 395 | + throw new ParserException('Pug.php did not understand '.$arg, 10, $e); |
|
| 396 | 396 | } |
| 397 | 397 | } |
| 398 | 398 | } |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | protected function createPhpBlock($code, $statements = null) |
| 407 | 407 | { |
| 408 | 408 | if ($statements === null) { |
| 409 | - return '<?php ' . $code . ' ' . $this->closingTag(); |
|
| 409 | + return '<?php '.$code.' '.$this->closingTag(); |
|
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | $codeFormat = array_pop($statements); |
@@ -415,20 +415,20 @@ discard block |
||
| 415 | 415 | if (count($statements) === 0) { |
| 416 | 416 | $phpString = call_user_func_array('sprintf', $codeFormat); |
| 417 | 417 | |
| 418 | - return '<?php ' . $phpString . ' ' . $this->closingTag(); |
|
| 418 | + return '<?php '.$phpString.' '.$this->closingTag(); |
|
| 419 | 419 | } |
| 420 | 420 | |
| 421 | 421 | $stmtString = ''; |
| 422 | 422 | foreach ($statements as $stmt) { |
| 423 | - $stmtString .= $this->newline() . $this->indent() . $stmt . ';'; |
|
| 423 | + $stmtString .= $this->newline().$this->indent().$stmt.';'; |
|
| 424 | 424 | } |
| 425 | 425 | |
| 426 | - $stmtString .= $this->newline() . $this->indent(); |
|
| 426 | + $stmtString .= $this->newline().$this->indent(); |
|
| 427 | 427 | $stmtString .= call_user_func_array('sprintf', $codeFormat); |
| 428 | 428 | |
| 429 | 429 | $phpString = '<?php '; |
| 430 | 430 | $phpString .= $stmtString; |
| 431 | - $phpString .= $this->newline() . $this->indent() . ' ' . $this->closingTag(); |
|
| 431 | + $phpString .= $this->newline().$this->indent().' '.$this->closingTag(); |
|
| 432 | 432 | |
| 433 | 433 | return $phpString; |
| 434 | 434 | } |
@@ -87,6 +87,10 @@ discard block |
||
| 87 | 87 | return $this->escapeIfNeeded($escaped, '$__value'); |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | + /** |
|
| 91 | + * @param string $key |
|
| 92 | + * @param string $value |
|
| 93 | + */ |
|
| 90 | 94 | protected function getAttributeValue($escaped, $key, $value, &$classesCheck, &$valueCheck) |
| 91 | 95 | { |
| 92 | 96 | if ($this->isConstant($value)) { |
@@ -113,6 +117,10 @@ discard block |
||
| 113 | 117 | : $value; |
| 114 | 118 | } |
| 115 | 119 | |
| 120 | + /** |
|
| 121 | + * @param string $key |
|
| 122 | + * @param callable $value |
|
| 123 | + */ |
|
| 116 | 124 | protected function compileAttributeValue($key, $value, $attr, $valueCheck) |
| 117 | 125 | { |
| 118 | 126 | return $value === true || $attr['value'] === true |
@@ -11,19 +11,19 @@ discard block |
||
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | return is_null($valueCheck) |
| 14 | - ? ' ' . $key . '=' . $this->quote . $value . $this->quote |
|
| 14 | + ? ' '.$key.'='.$this->quote.$value.$this->quote |
|
| 15 | 15 | : $this->createCode('if (true === ($__value = %1$s)) { ', $valueCheck) |
| 16 | 16 | . $this->getBooleanAttributeDisplayCode($key) |
| 17 | 17 | . $this->createCode('} else if (\\Jade\\Compiler::isDisplayable($__value)) { ') |
| 18 | - . ' ' . $key . '=' . $this->quote . $value . $this->quote |
|
| 18 | + . ' '.$key.'='.$this->quote.$value.$this->quote |
|
| 19 | 19 | . $this->createCode('}'); |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | protected function getBooleanAttributeDisplayCode($key) |
| 23 | 23 | { |
| 24 | - return ' ' . $key . ($this->terse |
|
| 24 | + return ' '.$key.($this->terse |
|
| 25 | 25 | ? '' |
| 26 | - : '=' . $this->quote . $key . $this->quote |
|
| 26 | + : '='.$this->quote.$key.$this->quote |
|
| 27 | 27 | ); |
| 28 | 28 | } |
| 29 | 29 | |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | $statements = $this->createStatements($value); |
| 46 | 46 | $classes[] = $statements[0][0]; |
| 47 | 47 | } |
| 48 | - $addClasses = '" " . implode(" ", array(' . implode(', ', $classes) . '))'; |
|
| 48 | + $addClasses = '" " . implode(" ", array('.implode(', ', $classes).'))'; |
|
| 49 | 49 | $classes = array(); |
| 50 | 50 | $classesCheck = array(); |
| 51 | 51 | } |
@@ -53,25 +53,25 @@ discard block |
||
| 53 | 53 | $statements = $this->createStatements($value); |
| 54 | 54 | |
| 55 | 55 | return $this->createCode( |
| 56 | - '$__attributes = ' . $this->getValueStatement($statements) . ';' . |
|
| 57 | - 'if (is_array($__attributes)) { ' . |
|
| 58 | - '$__attributes["class"] = trim(' . |
|
| 59 | - '$__classes = (empty($__classes) ? "" : $__classes . " ") . ' . |
|
| 60 | - '(isset($__attributes["class"]) ? (is_array($__attributes["class"]) ? implode(" ", $__attributes["class"]) : $__attributes["class"]) : "") . ' . |
|
| 61 | - $addClasses . |
|
| 62 | - '); ' . |
|
| 63 | - 'if (empty($__attributes["class"])) { ' . |
|
| 64 | - 'unset($__attributes["class"]); ' . |
|
| 65 | - '} ' . |
|
| 66 | - '} ' . |
|
| 67 | - '\\Jade\\Compiler::displayAttributes($__attributes, ' . var_export($this->quote, true) . ', ' . var_export($this->terse, true) . ');'); |
|
| 56 | + '$__attributes = '.$this->getValueStatement($statements).';'. |
|
| 57 | + 'if (is_array($__attributes)) { '. |
|
| 58 | + '$__attributes["class"] = trim('. |
|
| 59 | + '$__classes = (empty($__classes) ? "" : $__classes . " ") . '. |
|
| 60 | + '(isset($__attributes["class"]) ? (is_array($__attributes["class"]) ? implode(" ", $__attributes["class"]) : $__attributes["class"]) : "") . '. |
|
| 61 | + $addClasses. |
|
| 62 | + '); '. |
|
| 63 | + 'if (empty($__attributes["class"])) { '. |
|
| 64 | + 'unset($__attributes["class"]); '. |
|
| 65 | + '} '. |
|
| 66 | + '} '. |
|
| 67 | + '\\Jade\\Compiler::displayAttributes($__attributes, '.var_export($this->quote, true).', '.var_export($this->terse, true).');'); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | protected function getClassAttribute($value, &$classesCheck) |
| 71 | 71 | { |
| 72 | 72 | $statements = $this->createStatements($value); |
| 73 | 73 | $value = is_array($statements[0]) ? $statements[0][0] : $statements[0]; |
| 74 | - $classesCheck[] = '(is_array($_a = ' . $value . ') ? implode(" ", $_a) : $_a)'; |
|
| 74 | + $classesCheck[] = '(is_array($_a = '.$value.') ? implode(" ", $_a) : $_a)'; |
|
| 75 | 75 | |
| 76 | 76 | return $this->keepNullAttributes ? '' : 'null'; |
| 77 | 77 | } |
@@ -154,11 +154,11 @@ discard block |
||
| 154 | 154 | protected function getClassesCode(&$classes, &$classesCheck) |
| 155 | 155 | { |
| 156 | 156 | return trim($this->createCode( |
| 157 | - '$__classes = implode(" ", ' . |
|
| 158 | - 'array_unique(explode(" ", (empty($__classes) ? "" : $__classes) . ' . |
|
| 159 | - var_export(implode(' ', $classes), true) . ' . ' . |
|
| 160 | - 'implode(" ", array(' . implode(', ', $classesCheck) . ')) ' . |
|
| 161 | - ')) ' . |
|
| 157 | + '$__classes = implode(" ", '. |
|
| 158 | + 'array_unique(explode(" ", (empty($__classes) ? "" : $__classes) . '. |
|
| 159 | + var_export(implode(' ', $classes), true).' . '. |
|
| 160 | + 'implode(" ", array('.implode(', ', $classesCheck).')) '. |
|
| 161 | + ')) '. |
|
| 162 | 162 | ');' |
| 163 | 163 | )); |
| 164 | 164 | } |
@@ -166,12 +166,12 @@ discard block |
||
| 166 | 166 | protected function getClassesDisplayCode() |
| 167 | 167 | { |
| 168 | 168 | return trim($this->createCode( |
| 169 | - 'if (!empty($__classes)) { ' . |
|
| 170 | - '?> ' . (isset($this->options['classAttribute']) |
|
| 169 | + 'if (!empty($__classes)) { '. |
|
| 170 | + '?> '.(isset($this->options['classAttribute']) |
|
| 171 | 171 | ? $this->options['classAttribute'] |
| 172 | 172 | : 'class' |
| 173 | - ) . '=' . $this->quote . '<?php echo $__classes; ?>' . $this->quote . '<?php ' . |
|
| 174 | - '} ' . |
|
| 173 | + ).'='.$this->quote.'<?php echo $__classes; ?>'.$this->quote.'<?php '. |
|
| 174 | + '} '. |
|
| 175 | 175 | 'unset($__classes); ' |
| 176 | 176 | )); |
| 177 | 177 | } |
@@ -133,7 +133,7 @@ |
||
| 133 | 133 | * |
| 134 | 134 | * @param string $directory the directory to search in pug templates |
| 135 | 135 | * |
| 136 | - * @return array count of cached files and error count |
|
| 136 | + * @return integer[] count of cached files and error count |
|
| 137 | 137 | */ |
| 138 | 138 | public function cacheDirectory($directory) |
| 139 | 139 | { |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | protected function getCachePath($name) |
| 25 | 25 | { |
| 26 | - return str_replace('//', '/', $this->pug->getOption('cache') . '/' . $name) . '.php'; |
|
| 26 | + return str_replace('//', '/', $this->pug->getOption('cache').'/'.$name).'.php'; |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | { |
| 75 | 75 | if (is_file($input)) { |
| 76 | 76 | $path = $this->getCachePath( |
| 77 | - ($this->pug->getOption('keepBaseName') ? basename($input) : '') . |
|
| 77 | + ($this->pug->getOption('keepBaseName') ? basename($input) : ''). |
|
| 78 | 78 | $this->hashPrint(realpath($input)) |
| 79 | 79 | ); |
| 80 | 80 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | $cacheFolder = $this->pug->getOption('cache'); |
| 94 | 94 | |
| 95 | 95 | if (!is_dir($cacheFolder)) { |
| 96 | - throw new \ErrorException($cacheFolder . ': Cache directory seem\'s to not exists', 5); |
|
| 96 | + throw new \ErrorException($cacheFolder.': Cache directory seem\'s to not exists', 5); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | return $cacheFolder; |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | if ($object === '.' || $object === '..') { |
| 147 | 147 | continue; |
| 148 | 148 | } |
| 149 | - $input = $directory . DIRECTORY_SEPARATOR . $object; |
|
| 149 | + $input = $directory.DIRECTORY_SEPARATOR.$object; |
|
| 150 | 150 | if (is_dir($input)) { |
| 151 | 151 | list($subSuccess, $subErrors) = $this->cacheDirectory($input); |
| 152 | 152 | $success += $subSuccess; |
@@ -26,6 +26,10 @@ discard block |
||
| 26 | 26 | $this->separators = array(); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | + /** |
|
| 30 | + * @param string $input |
|
| 31 | + * @param string $name |
|
| 32 | + */ |
|
| 29 | 33 | public function innerCode($input, $name) |
| 30 | 34 | { |
| 31 | 35 | $handler = new static($input, $name); |
@@ -119,6 +123,9 @@ discard block |
||
| 119 | 123 | $consume($argument, $match[0]); |
| 120 | 124 | } |
| 121 | 125 | |
| 126 | + /** |
|
| 127 | + * @param string[] $match |
|
| 128 | + */ |
|
| 122 | 129 | protected function parseArrayElement(&$argument, $match, $consume, &$quote, &$key, &$value) |
| 123 | 130 | { |
| 124 | 131 | switch ($match[2]) { |
@@ -171,6 +178,9 @@ discard block |
||
| 171 | 178 | return $handleRecursion(array($sep, end($separators))); |
| 172 | 179 | } |
| 173 | 180 | |
| 181 | + /** |
|
| 182 | + * @param SubCodeHandler $subCodeHandler |
|
| 183 | + */ |
|
| 174 | 184 | protected function parseSeparator($sep, &$separators, &$result, &$varname, $subCodeHandler, $innerName) |
| 175 | 185 | { |
| 176 | 186 | $handleCodeInbetween = $subCodeHandler->handleCodeInbetween($separators, $result); |
@@ -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 | } |
@@ -7,7 +7,6 @@ discard block |
||
| 7 | 7 | abstract class CodeVisitor extends TagVisitor |
| 8 | 8 | { |
| 9 | 9 | /** |
| 10 | - * @param Nodes\Code $node |
|
| 11 | 10 | */ |
| 12 | 11 | protected function visitCodeConditional(array $matches) |
| 13 | 12 | { |
@@ -44,7 +43,7 @@ discard block |
||
| 44 | 43 | } |
| 45 | 44 | |
| 46 | 45 | /** |
| 47 | - * @param Nodes\Code $node |
|
| 46 | + * @param Code $node |
|
| 48 | 47 | */ |
| 49 | 48 | protected function visitCodeOpening(Code $node) |
| 50 | 49 | { |
@@ -68,7 +67,7 @@ discard block |
||
| 68 | 67 | } |
| 69 | 68 | |
| 70 | 69 | /** |
| 71 | - * @param Nodes\Code $node |
|
| 70 | + * @param Code $node |
|
| 72 | 71 | */ |
| 73 | 72 | protected function visitCode(Code $node) |
| 74 | 73 | { |
@@ -56,8 +56,6 @@ |
||
| 56 | 56 | * Return true if the ending quote of the string is escaped. |
| 57 | 57 | * |
| 58 | 58 | * @param object|array $anything object or array (PHP >= 7) that contains a callable |
| 59 | - * @param string|int $key|$method key or method name |
|
| 60 | - * @param bool $isMethod true if the second argument is a method |
|
| 61 | 59 | * |
| 62 | 60 | * @return string |
| 63 | 61 | */ |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | public static function addDollarIfNeeded($call) |
| 19 | 19 | { |
| 20 | 20 | if ($call === 'Inf') { |
| 21 | - throw new \InvalidArgumentException($call . ' cannot be read from PHP', 16); |
|
| 21 | + throw new \InvalidArgumentException($call.' cannot be read from PHP', 16); |
|
| 22 | 22 | } |
| 23 | 23 | if ($call === 'undefined') { |
| 24 | 24 | return 'null'; |
@@ -26,13 +26,13 @@ discard block |
||
| 26 | 26 | $firstChar = substr($call, 0, 1); |
| 27 | 27 | if ( |
| 28 | 28 | !in_array($firstChar, array('$', '\\')) && |
| 29 | - !preg_match('#^(?:' . CompilerConfig::VARNAME . '\\s*\\(|(?:null|false|true)(?![a-z]))#i', $call) && |
|
| 29 | + !preg_match('#^(?:'.CompilerConfig::VARNAME.'\\s*\\(|(?:null|false|true)(?![a-z]))#i', $call) && |
|
| 30 | 30 | ( |
| 31 | - preg_match('#^' . CompilerConfig::VARNAME . '#', $call) || |
|
| 31 | + preg_match('#^'.CompilerConfig::VARNAME.'#', $call) || |
|
| 32 | 32 | $firstChar === '_' |
| 33 | 33 | ) |
| 34 | 34 | ) { |
| 35 | - $call = '$' . $call; |
|
| 35 | + $call = '$'.$call; |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | return $call; |
@@ -63,9 +63,9 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | public static function getGetter($anything, $key) |
| 65 | 65 | { |
| 66 | - return '\\Jade\\Compiler::getPropertyFromAnything(' . |
|
| 67 | - static::addDollarIfNeeded($anything) . ', ' . |
|
| 68 | - var_export($key, true) . |
|
| 66 | + return '\\Jade\\Compiler::getPropertyFromAnything('. |
|
| 67 | + static::addDollarIfNeeded($anything).', '. |
|
| 68 | + var_export($key, true). |
|
| 69 | 69 | ')'; |
| 70 | 70 | } |
| 71 | 71 | } |
@@ -73,7 +73,6 @@ |
||
| 73 | 73 | /** |
| 74 | 74 | * Get property from object. |
| 75 | 75 | * |
| 76 | - * @param object $object source object |
|
| 77 | 76 | * @param mixed $key key to retrive from the object or the array |
| 78 | 77 | * |
| 79 | 78 | * @return mixed |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | { |
| 83 | 83 | return isset($anything->$key) |
| 84 | 84 | ? $anything->$key |
| 85 | - : (method_exists($anything, $method = 'get' . ucfirst($key)) |
|
| 85 | + : (method_exists($anything, $method = 'get'.ucfirst($key)) |
|
| 86 | 86 | ? $anything->$method() |
| 87 | 87 | : (method_exists($anything, $key) |
| 88 | 88 | ? array($anything, $key) |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | $value = static::joinAny($attribute['value']); |
| 127 | 127 | $attributes['class'] = empty($attributes['class']) |
| 128 | 128 | ? $value |
| 129 | - : static::joinAny($attributes['class']) . ' ' . $value; |
|
| 129 | + : static::joinAny($attributes['class']).' '.$value; |
|
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | 132 | if (isset($attributes['class'])) { |
@@ -148,10 +148,10 @@ discard block |
||
| 148 | 148 | foreach ($attributes as $key => $value) { |
| 149 | 149 | if ($key !== 'class' && $value !== false && $value !== 'null') { |
| 150 | 150 | if ($value === true) { |
| 151 | - echo ' ' . $key . ($terse ? '' : '=' . $quote . $key . $quote); |
|
| 151 | + echo ' '.$key.($terse ? '' : '='.$quote.$key.$quote); |
|
| 152 | 152 | continue; |
| 153 | 153 | } |
| 154 | - echo ' ' . $key . '=' . $quote . htmlspecialchars($value) . $quote; |
|
| 154 | + echo ' '.$key.'='.$quote.htmlspecialchars($value).$quote; |
|
| 155 | 155 | } |
| 156 | 156 | } |
| 157 | 157 | } |
@@ -179,7 +179,7 @@ |
||
| 179 | 179 | * |
| 180 | 180 | * @param array $value |
| 181 | 181 | * |
| 182 | - * @return string|mixed |
|
| 182 | + * @return string |
|
| 183 | 183 | */ |
| 184 | 184 | protected static function joinAny($value) |
| 185 | 185 | { |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | return $match[0]; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - $var = ($match[0] === ',' ? ',' : '') . $match[1]; |
|
| 52 | + $var = ($match[0] === ',' ? ',' : '').$match[1]; |
|
| 53 | 53 | foreach (explode('.', substr($match[2], 1)) as $name) { |
| 54 | 54 | if (!empty($name)) { |
| 55 | 55 | $var = CommonUtils::getGetter($var, $name, false); |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | protected static function convertVarPath($arg, $regexp = '/^%s|,%s/') |
| 71 | 71 | { |
| 72 | - $pattern = '\s*(\\${0,2}' . static::VARNAME . ')((\.' . static::VARNAME . ')*)'; |
|
| 72 | + $pattern = '\s*(\\${0,2}'.static::VARNAME.')((\.'.static::VARNAME.')*)'; |
|
| 73 | 73 | |
| 74 | 74 | return preg_replace_callback( |
| 75 | 75 | str_replace('%s', $pattern, $regexp), |