@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -$extensionPath = PATH_site . 'typo3conf/ext/moox_core/'; |
|
| 3 | +$extensionPath = PATH_site.'typo3conf/ext/moox_core/'; |
|
| 4 | 4 | return array( |
| 5 | - 'Less_Autoloader' => $extensionPath . 'Contrib/less.php/Autoloader.php', |
|
| 5 | + 'Less_Autoloader' => $extensionPath.'Contrib/less.php/Autoloader.php', |
|
| 6 | 6 | ); |
@@ -222,6 +222,7 @@ discard block |
||
| 222 | 222 | /** |
| 223 | 223 | * Run pre-compile visitors |
| 224 | 224 | * |
| 225 | + * @param Less_Tree_Ruleset $root |
|
| 225 | 226 | */ |
| 226 | 227 | private function PreVisitors($root){ |
| 227 | 228 | |
@@ -238,6 +239,7 @@ discard block |
||
| 238 | 239 | /** |
| 239 | 240 | * Run post-compile visitors |
| 240 | 241 | * |
| 242 | + * @param Less_Tree_Ruleset $evaldRoot |
|
| 241 | 243 | */ |
| 242 | 244 | private function PostVisitors($evaldRoot){ |
| 243 | 245 | |
@@ -275,8 +277,7 @@ discard block |
||
| 275 | 277 | * Parse a Less string into css |
| 276 | 278 | * |
| 277 | 279 | * @param string $str The string to convert |
| 278 | - * @param string $uri_root The url of the file |
|
| 279 | - * @return Less_Tree_Ruleset|Less_Parser |
|
| 280 | + * @return Less_Parser |
|
| 280 | 281 | */ |
| 281 | 282 | public function parse( $str, $file_uri = null ){ |
| 282 | 283 | |
@@ -574,6 +575,7 @@ discard block |
||
| 574 | 575 | /** |
| 575 | 576 | * Set up the input buffer |
| 576 | 577 | * |
| 578 | + * @param string|null $file_path |
|
| 577 | 579 | */ |
| 578 | 580 | public function SetInput( $file_path ){ |
| 579 | 581 | |
@@ -606,6 +608,9 @@ discard block |
||
| 606 | 608 | } |
| 607 | 609 | |
| 608 | 610 | |
| 611 | + /** |
|
| 612 | + * @param string|null $file_path |
|
| 613 | + */ |
|
| 609 | 614 | public function CacheFile( $file_path ){ |
| 610 | 615 | |
| 611 | 616 | if( $file_path && $this->CacheEnabled() ){ |
@@ -661,7 +666,7 @@ discard block |
||
| 661 | 666 | /** |
| 662 | 667 | * Parse from a token, regexp or string, and move forward if match |
| 663 | 668 | * |
| 664 | - * @param array $toks |
|
| 669 | + * @param string[] $toks |
|
| 665 | 670 | * @return array |
| 666 | 671 | */ |
| 667 | 672 | private function match($toks){ |
@@ -2446,6 +2451,9 @@ discard block |
||
| 2446 | 2451 | |
| 2447 | 2452 | } |
| 2448 | 2453 | |
| 2454 | + /** |
|
| 2455 | + * @param string $re |
|
| 2456 | + */ |
|
| 2449 | 2457 | private function rulePropertyMatch( $re, &$offset, &$length, &$index, &$name ){ |
| 2450 | 2458 | preg_match($re, $this->input, $a, 0, $offset); |
| 2451 | 2459 | if( $a ){ |
@@ -2511,6 +2519,9 @@ discard block |
||
| 2511 | 2519 | return $obj; |
| 2512 | 2520 | } |
| 2513 | 2521 | |
| 2522 | + /** |
|
| 2523 | + * @param string $class |
|
| 2524 | + */ |
|
| 2514 | 2525 | public function NewObj1($class, $arg){ |
| 2515 | 2526 | $obj = new $class( $arg ); |
| 2516 | 2527 | if( $this->CacheEnabled() ){ |
@@ -2519,6 +2530,9 @@ discard block |
||
| 2519 | 2530 | return $obj; |
| 2520 | 2531 | } |
| 2521 | 2532 | |
| 2533 | + /** |
|
| 2534 | + * @param string $class |
|
| 2535 | + */ |
|
| 2522 | 2536 | public function NewObj2($class, $args){ |
| 2523 | 2537 | $obj = new $class( $args[0], $args[1] ); |
| 2524 | 2538 | if( $this->CacheEnabled() ){ |
@@ -2527,6 +2541,9 @@ discard block |
||
| 2527 | 2541 | return $obj; |
| 2528 | 2542 | } |
| 2529 | 2543 | |
| 2544 | + /** |
|
| 2545 | + * @param string $class |
|
| 2546 | + */ |
|
| 2530 | 2547 | public function NewObj3($class, $args){ |
| 2531 | 2548 | $obj = new $class( $args[0], $args[1], $args[2] ); |
| 2532 | 2549 | if( $this->CacheEnabled() ){ |
@@ -2535,6 +2552,9 @@ discard block |
||
| 2535 | 2552 | return $obj; |
| 2536 | 2553 | } |
| 2537 | 2554 | |
| 2555 | + /** |
|
| 2556 | + * @param string $class |
|
| 2557 | + */ |
|
| 2538 | 2558 | public function NewObj4($class, $args){ |
| 2539 | 2559 | $obj = new $class( $args[0], $args[1], $args[2], $args[3] ); |
| 2540 | 2560 | if( $this->CacheEnabled() ){ |
@@ -2543,6 +2563,9 @@ discard block |
||
| 2543 | 2563 | return $obj; |
| 2544 | 2564 | } |
| 2545 | 2565 | |
| 2566 | + /** |
|
| 2567 | + * @param string $class |
|
| 2568 | + */ |
|
| 2546 | 2569 | public function NewObj5($class, $args){ |
| 2547 | 2570 | $obj = new $class( $args[0], $args[1], $args[2], $args[3], $args[4] ); |
| 2548 | 2571 | if( $this->CacheEnabled() ){ |
@@ -2551,6 +2574,9 @@ discard block |
||
| 2551 | 2574 | return $obj; |
| 2552 | 2575 | } |
| 2553 | 2576 | |
| 2577 | + /** |
|
| 2578 | + * @param string $class |
|
| 2579 | + */ |
|
| 2554 | 2580 | public function NewObj6($class, $args){ |
| 2555 | 2581 | $obj = new $class( $args[0], $args[1], $args[2], $args[3], $args[4], $args[5] ); |
| 2556 | 2582 | if( $this->CacheEnabled() ){ |
@@ -2559,6 +2585,9 @@ discard block |
||
| 2559 | 2585 | return $obj; |
| 2560 | 2586 | } |
| 2561 | 2587 | |
| 2588 | + /** |
|
| 2589 | + * @param string $class |
|
| 2590 | + */ |
|
| 2562 | 2591 | public function NewObj7($class, $args){ |
| 2563 | 2592 | $obj = new $class( $args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6] ); |
| 2564 | 2593 | if( $this->CacheEnabled() ){ |
@@ -2777,11 +2806,19 @@ discard block |
||
| 2777 | 2806 | 'yellowgreen'=>'#9acd32' |
| 2778 | 2807 | ); |
| 2779 | 2808 | |
| 2809 | + /** |
|
| 2810 | + * @param string $color |
|
| 2811 | + */ |
|
| 2780 | 2812 | public static function hasOwnProperty($color) { |
| 2781 | 2813 | return isset(self::$colors[$color]); |
| 2782 | 2814 | } |
| 2783 | 2815 | |
| 2784 | 2816 | |
| 2817 | + /** |
|
| 2818 | + * @param string $color |
|
| 2819 | + * |
|
| 2820 | + * @return string |
|
| 2821 | + */ |
|
| 2785 | 2822 | public static function color($color) { |
| 2786 | 2823 | return self::$colors[$color]; |
| 2787 | 2824 | } |
@@ -3020,6 +3057,11 @@ discard block |
||
| 3020 | 3057 | } |
| 3021 | 3058 | } |
| 3022 | 3059 | |
| 3060 | + /** |
|
| 3061 | + * @param integer $r |
|
| 3062 | + * @param integer $g |
|
| 3063 | + * @param integer $b |
|
| 3064 | + */ |
|
| 3023 | 3065 | public function rgb ($r = null, $g = null, $b = null){ |
| 3024 | 3066 | if (is_null($r) || is_null($g) || is_null($b)) { |
| 3025 | 3067 | throw new Less_Exception_Compiler("rgb expects three parameters"); |
@@ -3968,6 +4010,10 @@ discard block |
||
| 3968 | 4010 | // Color Blending |
| 3969 | 4011 | // ref: http://www.w3.org/TR/compositing-1 |
| 3970 | 4012 | |
| 4013 | + /** |
|
| 4014 | + * @param Less_Tree_Color $color1 |
|
| 4015 | + * @param Less_Tree_Color $color2 |
|
| 4016 | + */ |
|
| 3971 | 4017 | public function colorBlend( $mode, $color1, $color2 ){ |
| 3972 | 4018 | $ab = $color1->alpha; // backdrop |
| 3973 | 4019 | $as = $color2->alpha; // source |
@@ -4332,6 +4378,9 @@ discard block |
||
| 4332 | 4378 | $this->_visitFnCache = array_flip($this->_visitFnCache); |
| 4333 | 4379 | } |
| 4334 | 4380 | |
| 4381 | + /** |
|
| 4382 | + * @param Less_Tree_Ruleset $node |
|
| 4383 | + */ |
|
| 4335 | 4384 | public function visitObj( $node ){ |
| 4336 | 4385 | |
| 4337 | 4386 | $funcName = 'visit'.$node->type; |
@@ -4841,6 +4890,9 @@ discard block |
||
| 4841 | 4890 | public $isTransparentKeyword; |
| 4842 | 4891 | public $type = 'Color'; |
| 4843 | 4892 | |
| 4893 | + /** |
|
| 4894 | + * @param boolean $isTransparentKeyword |
|
| 4895 | + */ |
|
| 4844 | 4896 | public function __construct($rgb, $a = 1, $isTransparentKeyword = null ){ |
| 4845 | 4897 | |
| 4846 | 4898 | if( $isTransparentKeyword ){ |
@@ -5202,10 +5254,16 @@ discard block |
||
| 5202 | 5254 | } |
| 5203 | 5255 | } |
| 5204 | 5256 | |
| 5257 | + /** |
|
| 5258 | + * @param integer $v |
|
| 5259 | + */ |
|
| 5205 | 5260 | public static function value( $v ){ |
| 5206 | 5261 | self::$value_ = $v; |
| 5207 | 5262 | } |
| 5208 | 5263 | |
| 5264 | + /** |
|
| 5265 | + * @param string $e |
|
| 5266 | + */ |
|
| 5209 | 5267 | public static function error( $e ){ |
| 5210 | 5268 | self::$error_ = $e; |
| 5211 | 5269 | } |
@@ -6001,7 +6059,6 @@ discard block |
||
| 6001 | 6059 | /** |
| 6002 | 6060 | * Using the import directories, get the full absolute path and uri of the import |
| 6003 | 6061 | * |
| 6004 | - * @param Less_Tree_Import $evald |
|
| 6005 | 6062 | */ |
| 6006 | 6063 | public function PathAndUri(){ |
| 6007 | 6064 | |
@@ -6127,6 +6184,7 @@ discard block |
||
| 6127 | 6184 | /** |
| 6128 | 6185 | * @param boolean $index |
| 6129 | 6186 | * @param boolean $escaped |
| 6187 | + * @param string[] $string |
|
| 6130 | 6188 | */ |
| 6131 | 6189 | public function __construct($string, $index, $escaped){ |
| 6132 | 6190 | $this->escaped = $escaped; |
@@ -7056,6 +7114,9 @@ discard block |
||
| 7056 | 7114 | return isset($this->_variables[$name]) ? $this->_variables[$name] : null; |
| 7057 | 7115 | } |
| 7058 | 7116 | |
| 7117 | + /** |
|
| 7118 | + * @param Less_Tree_Media $self |
|
| 7119 | + */ |
|
| 7059 | 7120 | public function find( $selector, $self = null ){ |
| 7060 | 7121 | |
| 7061 | 7122 | $key = implode(' ',$selector->_oelements); |
@@ -7803,6 +7864,9 @@ discard block |
||
| 7803 | 7864 | public $isEvald; |
| 7804 | 7865 | public $type = 'Url'; |
| 7805 | 7866 | |
| 7867 | + /** |
|
| 7868 | + * @param boolean $isEvald |
|
| 7869 | + */ |
|
| 7806 | 7870 | public function __construct($value, $currentFileInfo = null, $isEvald = null){ |
| 7807 | 7871 | $this->value = $value; |
| 7808 | 7872 | $this->currentFileInfo = $currentFileInfo; |
@@ -8315,6 +8379,9 @@ discard block |
||
| 8315 | 8379 | return new Less_Tree_Mixin_Definition($this->name, $this->params, $this->rules, $this->condition, $this->variadic, $env->frames ); |
| 8316 | 8380 | } |
| 8317 | 8381 | |
| 8382 | + /** |
|
| 8383 | + * @param boolean $important |
|
| 8384 | + */ |
|
| 8318 | 8385 | public function evalCall($env, $args = NULL, $important = NULL) { |
| 8319 | 8386 | |
| 8320 | 8387 | Less_Environment::$mixin_stack++; |
@@ -9478,6 +9545,9 @@ discard block |
||
| 9478 | 9545 | return new Less_Tree_Expression( $mapped ); |
| 9479 | 9546 | } |
| 9480 | 9547 | |
| 9548 | + /** |
|
| 9549 | + * @param Less_Tree_Expression[] $values |
|
| 9550 | + */ |
|
| 9481 | 9551 | public static function toValue($values){ |
| 9482 | 9552 | //return new Less_Tree_Value($values); ?? |
| 9483 | 9553 | |
@@ -9789,11 +9859,17 @@ discard block |
||
| 9789 | 9859 | //$this->emitChunk(true); |
| 9790 | 9860 | } |
| 9791 | 9861 | |
| 9862 | + /** |
|
| 9863 | + * @param integer $pos |
|
| 9864 | + */ |
|
| 9792 | 9865 | public function CharCode($pos){ |
| 9793 | 9866 | return ord($this->input[$pos]); |
| 9794 | 9867 | } |
| 9795 | 9868 | |
| 9796 | 9869 | |
| 9870 | + /** |
|
| 9871 | + * @param integer $index |
|
| 9872 | + */ |
|
| 9797 | 9873 | public function fail( $msg, $index = null ){ |
| 9798 | 9874 | |
| 9799 | 9875 | if( !$index ){ |
@@ -10325,7 +10401,7 @@ discard block |
||
| 10325 | 10401 | * @param integer $generatedColumn The column number in generated file |
| 10326 | 10402 | * @param integer $originalLine The line number in original file |
| 10327 | 10403 | * @param integer $originalColumn The column number in original file |
| 10328 | - * @param string $sourceFile The original source file |
|
| 10404 | + * @param string $fileInfo |
|
| 10329 | 10405 | */ |
| 10330 | 10406 | public function addMapping($generatedLine, $generatedColumn, $originalLine, $originalColumn, $fileInfo ){ |
| 10331 | 10407 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | // which will then be passed around by reference. |
| 79 | 79 | if( $env instanceof Less_Environment ){ |
| 80 | 80 | $this->env = $env; |
| 81 | - }else{ |
|
| 81 | + } else{ |
|
| 82 | 82 | $this->SetOptions(Less_Parser::$default_options); |
| 83 | 83 | $this->Reset( $env ); |
| 84 | 84 | } |
@@ -157,8 +157,9 @@ discard block |
||
| 157 | 157 | * @param string $name function name |
| 158 | 158 | */ |
| 159 | 159 | public function unregisterFunction($name) { |
| 160 | - if( isset($this->env->functions[$name]) ) |
|
| 161 | - unset($this->env->functions[$name]); |
|
| 160 | + if( isset($this->env->functions[$name]) ) { |
|
| 161 | + unset($this->env->functions[$name]); |
|
| 162 | + } |
|
| 162 | 163 | } |
| 163 | 164 | |
| 164 | 165 | |
@@ -195,7 +196,7 @@ discard block |
||
| 195 | 196 | // will also save file |
| 196 | 197 | // FIXME: should happen somewhere else? |
| 197 | 198 | $css = $generator->generateCSS(); |
| 198 | - }else{ |
|
| 199 | + } else{ |
|
| 199 | 200 | $css = $evaldRoot->toCSS(); |
| 200 | 201 | } |
| 201 | 202 | |
@@ -257,7 +258,7 @@ discard block |
||
| 257 | 258 | |
| 258 | 259 | if( property_exists($plugin,'isPreVisitor') && $plugin->isPreVisitor ){ |
| 259 | 260 | array_unshift( $visitors, $plugin); |
| 260 | - }else{ |
|
| 261 | + } else{ |
|
| 261 | 262 | $visitors[] = $plugin; |
| 262 | 263 | } |
| 263 | 264 | } |
@@ -283,7 +284,7 @@ discard block |
||
| 283 | 284 | if( !$file_uri ){ |
| 284 | 285 | $uri_root = ''; |
| 285 | 286 | $filename = 'anonymous-file-'.Less_Parser::$next_id++.'.less'; |
| 286 | - }else{ |
|
| 287 | + } else{ |
|
| 287 | 288 | $file_uri = self::WinPath($file_uri); |
| 288 | 289 | $filename = $file_uri; |
| 289 | 290 | $uri_root = dirname($file_uri); |
@@ -342,7 +343,7 @@ discard block |
||
| 342 | 343 | if( $returnRoot ){ |
| 343 | 344 | $rules = $this->GetRules( $filename ); |
| 344 | 345 | $return = new Less_Tree_Ruleset(array(), $rules ); |
| 345 | - }else{ |
|
| 346 | + } else{ |
|
| 346 | 347 | $this->_parse( $filename ); |
| 347 | 348 | $return = $this; |
| 348 | 349 | } |
@@ -389,7 +390,7 @@ discard block |
||
| 389 | 390 | $currentFileInfo['entryUri'] = $this->env->currentFileInfo['entryUri']; |
| 390 | 391 | $currentFileInfo['rootpath'] = $this->env->currentFileInfo['rootpath']; |
| 391 | 392 | |
| 392 | - }else{ |
|
| 393 | + } else{ |
|
| 393 | 394 | $currentFileInfo['entryPath'] = $dirname; |
| 394 | 395 | $currentFileInfo['entryUri'] = $uri_root; |
| 395 | 396 | $currentFileInfo['rootpath'] = $dirname; |
@@ -422,13 +423,13 @@ discard block |
||
| 422 | 423 | } |
| 423 | 424 | throw new Less_Exception_Parser('Less.php cache directory couldn\'t be created: '.$dir); |
| 424 | 425 | |
| 425 | - }elseif( !is_dir($dir) ){ |
|
| 426 | + } elseif( !is_dir($dir) ){ |
|
| 426 | 427 | throw new Less_Exception_Parser('Less.php cache directory doesn\'t exist: '.$dir); |
| 427 | 428 | |
| 428 | - }elseif( !is_writable($dir) ){ |
|
| 429 | + } elseif( !is_writable($dir) ){ |
|
| 429 | 430 | throw new Less_Exception_Parser('Less.php cache directory isn\'t writable: '.$dir); |
| 430 | 431 | |
| 431 | - }else{ |
|
| 432 | + } else{ |
|
| 432 | 433 | $dir = self::WinPath($dir); |
| 433 | 434 | Less_Cache::$cache_dir = rtrim($dir,'/').'/'; |
| 434 | 435 | return true; |
@@ -505,7 +506,7 @@ discard block |
||
| 505 | 506 | } |
| 506 | 507 | } |
| 507 | 508 | |
| 508 | - }elseif( file_exists($cache_file) ){ |
|
| 509 | + } elseif( file_exists($cache_file) ){ |
|
| 509 | 510 | switch(Less_Parser::$options['cache_method']){ |
| 510 | 511 | |
| 511 | 512 | // Using serialize |
@@ -548,7 +549,7 @@ discard block |
||
| 548 | 549 | ); |
| 549 | 550 | } |
| 550 | 551 | |
| 551 | - }else{ |
|
| 552 | + } else{ |
|
| 552 | 553 | //msg('write cache file'); |
| 553 | 554 | switch(Less_Parser::$options['cache_method']){ |
| 554 | 555 | case 'serialize': |
@@ -683,10 +684,10 @@ discard block |
||
| 683 | 684 | return count($match) === 1 ? $match[0] : $match; |
| 684 | 685 | } |
| 685 | 686 | |
| 686 | - }elseif( $char === '#' ){ |
|
| 687 | + } elseif( $char === '#' ){ |
|
| 687 | 688 | $match = $this->MatchChar($tok[1]); |
| 688 | 689 | |
| 689 | - }else{ |
|
| 690 | + } else{ |
|
| 690 | 691 | // Non-terminal, match using a function call |
| 691 | 692 | $match = $this->$tok(); |
| 692 | 693 | |
@@ -791,7 +792,7 @@ discard block |
||
| 791 | 792 | $result = $this->MatchChar($tok); |
| 792 | 793 | if( !$result ){ |
| 793 | 794 | $this->Error( $msg ? "Expected '" . $tok . "' got '" . $this->input[$this->pos] . "'" : $msg ); |
| 794 | - }else{ |
|
| 795 | + } else{ |
|
| 795 | 796 | return $result; |
| 796 | 797 | } |
| 797 | 798 | } |
@@ -861,7 +862,7 @@ discard block |
||
| 861 | 862 | |
| 862 | 863 | if( $node ){ |
| 863 | 864 | $root[] = $node; |
| 864 | - }elseif( !$this->MatchReg('/\\G[\s\n;]+/') ){ |
|
| 865 | + } elseif( !$this->MatchReg('/\\G[\s\n;]+/') ){ |
|
| 865 | 866 | break; |
| 866 | 867 | } |
| 867 | 868 | |
@@ -1300,7 +1301,7 @@ discard block |
||
| 1300 | 1301 | $returned = $this->parseMixinArgs(true); |
| 1301 | 1302 | $args = $returned['args']; |
| 1302 | 1303 | $this->expectChar(')'); |
| 1303 | - }else{ |
|
| 1304 | + } else{ |
|
| 1304 | 1305 | $args = array(); |
| 1305 | 1306 | } |
| 1306 | 1307 | |
@@ -1362,7 +1363,7 @@ discard block |
||
| 1362 | 1363 | |
| 1363 | 1364 | if( $isSemiColonSeperated ){ |
| 1364 | 1365 | $argsSemiColon[] = array('variadic'=>true); |
| 1365 | - }else{ |
|
| 1366 | + } else{ |
|
| 1366 | 1367 | $argsComma[] = array('variadic'=>true); |
| 1367 | 1368 | } |
| 1368 | 1369 | break; |
@@ -1424,18 +1425,18 @@ discard block |
||
| 1424 | 1425 | } |
| 1425 | 1426 | |
| 1426 | 1427 | $nameLoop = ($name = $val->name); |
| 1427 | - }elseif( !$isCall && $this->MatchReg('/\\G\.{3}/') ){ |
|
| 1428 | + } elseif( !$isCall && $this->MatchReg('/\\G\.{3}/') ){ |
|
| 1428 | 1429 | $returner['variadic'] = true; |
| 1429 | 1430 | if( $this->MatchChar(";") && !$isSemiColonSeperated ){ |
| 1430 | 1431 | $isSemiColonSeperated = true; |
| 1431 | 1432 | } |
| 1432 | 1433 | if( $isSemiColonSeperated ){ |
| 1433 | 1434 | $argsSemiColon[] = array('name'=> $arg->name, 'variadic' => true); |
| 1434 | - }else{ |
|
| 1435 | + } else{ |
|
| 1435 | 1436 | $argsComma[] = array('name'=> $arg->name, 'variadic' => true); |
| 1436 | 1437 | } |
| 1437 | 1438 | break; |
| 1438 | - }elseif( !$isCall ){ |
|
| 1439 | + } elseif( !$isCall ){ |
|
| 1439 | 1440 | $name = $nameLoop = $val->name; |
| 1440 | 1441 | $value = null; |
| 1441 | 1442 | } |
@@ -1541,7 +1542,7 @@ discard block |
||
| 1541 | 1542 | } |
| 1542 | 1543 | |
| 1543 | 1544 | $this->restore(); |
| 1544 | - }else{ |
|
| 1545 | + } else{ |
|
| 1545 | 1546 | $this->forget(); |
| 1546 | 1547 | } |
| 1547 | 1548 | } |
@@ -1578,7 +1579,7 @@ discard block |
||
| 1578 | 1579 | $value = $this->MatchReg('/\\G[0-9]+/'); |
| 1579 | 1580 | if( $value ){ |
| 1580 | 1581 | $value = $value[0]; |
| 1581 | - }else{ |
|
| 1582 | + } else{ |
|
| 1582 | 1583 | $value = $this->parseEntitiesVariable(); |
| 1583 | 1584 | if( !$value ){ |
| 1584 | 1585 | return; |
@@ -1615,10 +1616,10 @@ discard block |
||
| 1615 | 1616 | if( ($v = $this->parseSelector()) && $this->MatchChar(')') ){ |
| 1616 | 1617 | $e = $this->NewObj1('Less_Tree_Paren',$v); |
| 1617 | 1618 | $this->forget(); |
| 1618 | - }else{ |
|
| 1619 | + } else{ |
|
| 1619 | 1620 | $this->restore(); |
| 1620 | 1621 | } |
| 1621 | - }else{ |
|
| 1622 | + } else{ |
|
| 1622 | 1623 | $this->forget(); |
| 1623 | 1624 | } |
| 1624 | 1625 | } |
@@ -1687,11 +1688,11 @@ discard block |
||
| 1687 | 1688 | while( ($isLess && ($extend = $this->parseExtend())) || ($isLess && ($when = $this->MatchReg('/\\Gwhen/') )) || ($e = $this->parseElement()) ){ |
| 1688 | 1689 | if( $when ){ |
| 1689 | 1690 | $condition = $this->expect('parseConditions', 'expected condition'); |
| 1690 | - }elseif( $condition ){ |
|
| 1691 | + } elseif( $condition ){ |
|
| 1691 | 1692 | //error("CSS guard can only be used at the end of selector"); |
| 1692 | - }elseif( $extend ){ |
|
| 1693 | + } elseif( $extend ){ |
|
| 1693 | 1694 | $extendList = array_merge($extendList,$extend); |
| 1694 | - }else{ |
|
| 1695 | + } else{ |
|
| 1695 | 1696 | //if( count($extendList) ){ |
| 1696 | 1697 | //error("Extend can only be used at the end of selector"); |
| 1697 | 1698 | //} |
@@ -1873,7 +1874,7 @@ discard block |
||
| 1873 | 1874 | //if( !$tryAnonymous && is_string($name) && $name[0] === '@' ){ |
| 1874 | 1875 | if( !$tryAnonymous && (Less_Parser::$options['compress'] || $isVariable) ){ |
| 1875 | 1876 | $value = $this->MatchFuncs( array('parseValue','parseAnonymousValue')); |
| 1876 | - }else{ |
|
| 1877 | + } else{ |
|
| 1877 | 1878 | $value = $this->MatchFuncs( array('parseAnonymousValue','parseValue')); |
| 1878 | 1879 | } |
| 1879 | 1880 | |
@@ -1894,14 +1895,14 @@ discard block |
||
| 1894 | 1895 | if( $value && $this->parseEnd() ){ |
| 1895 | 1896 | $this->forget(); |
| 1896 | 1897 | return $this->NewObj6('Less_Tree_Rule',array( $name, $value, $important, $merge, $startOfRule, $this->env->currentFileInfo)); |
| 1897 | - }else{ |
|
| 1898 | + } else{ |
|
| 1898 | 1899 | $this->furthest = $this->pos; |
| 1899 | 1900 | $this->restore(); |
| 1900 | 1901 | if( $value && !$tryAnonymous ){ |
| 1901 | 1902 | return $this->parseRule(true); |
| 1902 | 1903 | } |
| 1903 | 1904 | } |
| 1904 | - }else{ |
|
| 1905 | + } else{ |
|
| 1905 | 1906 | $this->forget(); |
| 1906 | 1907 | } |
| 1907 | 1908 | } |
@@ -2006,8 +2007,9 @@ discard block |
||
| 2006 | 2007 | } else { |
| 2007 | 2008 | return null; |
| 2008 | 2009 | } |
| 2009 | - } else |
|
| 2010 | - return null; |
|
| 2010 | + } else { |
|
| 2011 | + return null; |
|
| 2012 | + } |
|
| 2011 | 2013 | } |
| 2012 | 2014 | } while ($e); |
| 2013 | 2015 | |
@@ -2023,12 +2025,16 @@ discard block |
||
| 2023 | 2025 | $e = $this->parseMediaFeature(); |
| 2024 | 2026 | if( $e ){ |
| 2025 | 2027 | $features[] = $e; |
| 2026 | - if (!$this->MatchChar(',')) break; |
|
| 2027 | - }else{ |
|
| 2028 | + if (!$this->MatchChar(',')) { |
|
| 2029 | + break; |
|
| 2030 | + } |
|
| 2031 | + } else{ |
|
| 2028 | 2032 | $e = $this->parseEntitiesVariable(); |
| 2029 | 2033 | if( $e ){ |
| 2030 | 2034 | $features[] = $e; |
| 2031 | - if (!$this->MatchChar(',')) break; |
|
| 2035 | + if (!$this->MatchChar(',')) { |
|
| 2036 | + break; |
|
| 2037 | + } |
|
| 2032 | 2038 | } |
| 2033 | 2039 | } |
| 2034 | 2040 | } while ($e); |
@@ -2076,7 +2082,9 @@ discard block |
||
| 2076 | 2082 | |
| 2077 | 2083 | $name = $this->MatchReg('/\\G@[a-z-]+/'); |
| 2078 | 2084 | |
| 2079 | - if( !$name ) return; |
|
| 2085 | + if( !$name ) { |
|
| 2086 | + return; |
|
| 2087 | + } |
|
| 2080 | 2088 | $name = $name[0]; |
| 2081 | 2089 | |
| 2082 | 2090 | |
@@ -2259,7 +2267,7 @@ discard block |
||
| 2259 | 2267 | $op = $this->MatchReg('/\\G[-+]\s+/'); |
| 2260 | 2268 | if( $op ){ |
| 2261 | 2269 | $op = $op[0]; |
| 2262 | - }else{ |
|
| 2270 | + } else{ |
|
| 2263 | 2271 | if( !$isSpaced ){ |
| 2264 | 2272 | $op = $this->match(array('#+','#-')); |
| 2265 | 2273 | } |
@@ -2312,7 +2320,9 @@ discard block |
||
| 2312 | 2320 | $negate = false; |
| 2313 | 2321 | $c = null; |
| 2314 | 2322 | |
| 2315 | - if ($this->MatchReg('/\\Gnot/')) $negate = true; |
|
| 2323 | + if ($this->MatchReg('/\\Gnot/')) { |
|
| 2324 | + $negate = true; |
|
| 2325 | + } |
|
| 2316 | 2326 | $this->expectChar('('); |
| 2317 | 2327 | $a = $this->MatchFuncs(array('parseAddition','parseEntitiesKeyword','parseEntitiesQuoted')); |
| 2318 | 2328 | |
@@ -2436,7 +2446,7 @@ discard block |
||
| 2436 | 2446 | foreach($name as $k => $s ){ |
| 2437 | 2447 | if( !$s || $s[0] !== '@' ){ |
| 2438 | 2448 | $name[$k] = $this->NewObj1('Less_Tree_Keyword',$s); |
| 2439 | - }else{ |
|
| 2449 | + } else{ |
|
| 2440 | 2450 | $name[$k] = $this->NewObj3('Less_Tree_Variable',array('@' . substr($s,2,-1), $index[$k], $this->env->currentFileInfo)); |
| 2441 | 2451 | } |
| 2442 | 2452 | } |
@@ -2492,7 +2502,7 @@ discard block |
||
| 2492 | 2502 | $floor = floor($i); |
| 2493 | 2503 | if( ($ceil - $i) <= ($i - $floor) ){ |
| 2494 | 2504 | return $ceil/$precision; |
| 2495 | - }else{ |
|
| 2505 | + } else{ |
|
| 2496 | 2506 | return $floor/$precision; |
| 2497 | 2507 | } |
| 2498 | 2508 | } |
@@ -2591,7 +2601,7 @@ discard block |
||
| 2591 | 2601 | unset($arg->cache_string); |
| 2592 | 2602 | return $string; |
| 2593 | 2603 | |
| 2594 | - }elseif( $type === 'array' ){ |
|
| 2604 | + } elseif( $type === 'array' ){ |
|
| 2595 | 2605 | $string = ' Array('; |
| 2596 | 2606 | foreach($arg as $k => $a){ |
| 2597 | 2607 | $string .= var_export($k,true).' => '.self::ArgString($a).','; |
@@ -2865,7 +2875,7 @@ discard block |
||
| 2865 | 2875 | '^^' => '^^' |
| 2866 | 2876 | ); |
| 2867 | 2877 | |
| 2868 | - }else{ |
|
| 2878 | + } else{ |
|
| 2869 | 2879 | |
| 2870 | 2880 | Less_Environment::$_outputMap = array( |
| 2871 | 2881 | ',' => ', ', |
@@ -2927,7 +2937,7 @@ discard block |
||
| 2927 | 2937 | if( !$path_len || ( $path[$path_len-1] === '..') ){ |
| 2928 | 2938 | $path[] = $segment; |
| 2929 | 2939 | $path_len++; |
| 2930 | - }else{ |
|
| 2940 | + } else{ |
|
| 2931 | 2941 | array_pop($path); |
| 2932 | 2942 | $path_len--; |
| 2933 | 2943 | } |
@@ -3061,10 +3071,15 @@ discard block |
||
| 3061 | 3071 | */ |
| 3062 | 3072 | public function hsla_hue($h, $m1, $m2){ |
| 3063 | 3073 | $h = $h < 0 ? $h + 1 : ($h > 1 ? $h - 1 : $h); |
| 3064 | - if ($h * 6 < 1) return $m1 + ($m2 - $m1) * $h * 6; |
|
| 3065 | - else if ($h * 2 < 1) return $m2; |
|
| 3066 | - else if ($h * 3 < 2) return $m1 + ($m2 - $m1) * (2/3 - $h) * 6; |
|
| 3067 | - else return $m1; |
|
| 3074 | + if ($h * 6 < 1) { |
|
| 3075 | + return $m1 + ($m2 - $m1) * $h * 6; |
|
| 3076 | + } else if ($h * 2 < 1) { |
|
| 3077 | + return $m2; |
|
| 3078 | + } else if ($h * 3 < 2) { |
|
| 3079 | + return $m1 + ($m2 - $m1) * (2/3 - $h) * 6; |
|
| 3080 | + } else { |
|
| 3081 | + return $m1; |
|
| 3082 | + } |
|
| 3068 | 3083 | } |
| 3069 | 3084 | |
| 3070 | 3085 | public function hsv($h, $s, $v) { |
@@ -3549,7 +3564,7 @@ discard block |
||
| 3549 | 3564 | if( is_numeric($x) && is_numeric($y) ){ |
| 3550 | 3565 | $x = new Less_Tree_Dimension($x); |
| 3551 | 3566 | $y = new Less_Tree_Dimension($y); |
| 3552 | - }elseif( !($x instanceof Less_Tree_Dimension) || !($y instanceof Less_Tree_Dimension) ){ |
|
| 3567 | + } elseif( !($x instanceof Less_Tree_Dimension) || !($y instanceof Less_Tree_Dimension) ){ |
|
| 3553 | 3568 | throw new Less_Exception_Compiler('Arguments must be numbers'); |
| 3554 | 3569 | } |
| 3555 | 3570 | |
@@ -3579,7 +3594,7 @@ discard block |
||
| 3579 | 3594 | |
| 3580 | 3595 | if( $unit === null ){ |
| 3581 | 3596 | $unit = $args[0]->unit; |
| 3582 | - }else{ |
|
| 3597 | + } else{ |
|
| 3583 | 3598 | $args[0] = $args[0]->unify(); |
| 3584 | 3599 | } |
| 3585 | 3600 | $args[0] = (float)$args[0]->value; |
@@ -3624,13 +3639,13 @@ discard block |
||
| 3624 | 3639 | if( $current->unit->toString() === '' && !$unitClone ){ |
| 3625 | 3640 | $temp = new Less_Tree_Dimension($current->value, $unitClone); |
| 3626 | 3641 | $currentUnified = $temp->unify(); |
| 3627 | - }else{ |
|
| 3642 | + } else{ |
|
| 3628 | 3643 | $currentUnified = $current->unify(); |
| 3629 | 3644 | } |
| 3630 | 3645 | |
| 3631 | 3646 | if( $currentUnified->unit->toString() === "" && !$unitStatic ){ |
| 3632 | 3647 | $unit = $unitStatic; |
| 3633 | - }else{ |
|
| 3648 | + } else{ |
|
| 3634 | 3649 | $unit = $currentUnified->unit->toString(); |
| 3635 | 3650 | } |
| 3636 | 3651 | |
@@ -3644,9 +3659,9 @@ discard block |
||
| 3644 | 3659 | |
| 3645 | 3660 | if( isset($values['']) && $unit !== '' && $unit === $unitStatic ){ |
| 3646 | 3661 | $j = $values['']; |
| 3647 | - }elseif( isset($values[$unit]) ){ |
|
| 3662 | + } elseif( isset($values[$unit]) ){ |
|
| 3648 | 3663 | $j = $values[$unit]; |
| 3649 | - }else{ |
|
| 3664 | + } else{ |
|
| 3650 | 3665 | |
| 3651 | 3666 | if( $unitStatic && $unit !== $unitStatic ){ |
| 3652 | 3667 | throw new Less_Exception_Compiler( 'incompatible types'); |
@@ -3660,7 +3675,7 @@ discard block |
||
| 3660 | 3675 | if( $order[$j]->unit->toString() === "" && $unitClone ){ |
| 3661 | 3676 | $temp = new Less_Tree_Dimension( $order[$j]->value, $unitClone); |
| 3662 | 3677 | $referenceUnified = $temp->unify(); |
| 3663 | - }else{ |
|
| 3678 | + } else{ |
|
| 3664 | 3679 | $referenceUnified = $order[$j]->unify(); |
| 3665 | 3680 | } |
| 3666 | 3681 | if( ($isMin && $currentUnified->value < $referenceUnified->value) || (!$isMin && $currentUnified->value > $referenceUnified->value) ){ |
@@ -3786,7 +3801,7 @@ discard block |
||
| 3786 | 3801 | } |
| 3787 | 3802 | return null; |
| 3788 | 3803 | |
| 3789 | - }elseif( (int)$index === 0 ){ |
|
| 3804 | + } elseif( (int)$index === 0 ){ |
|
| 3790 | 3805 | return $values; |
| 3791 | 3806 | } |
| 3792 | 3807 | |
@@ -3844,14 +3859,14 @@ discard block |
||
| 3844 | 3859 | $useBase64 = !in_array($charset,array('US-ASCII', 'UTF-8')); |
| 3845 | 3860 | if( $useBase64 ){ $mimetype .= ';base64'; } |
| 3846 | 3861 | |
| 3847 | - }else{ |
|
| 3862 | + } else{ |
|
| 3848 | 3863 | $useBase64 = preg_match('/;base64$/',$mimetype); |
| 3849 | 3864 | } |
| 3850 | 3865 | |
| 3851 | 3866 | |
| 3852 | 3867 | if( file_exists($filePath) ){ |
| 3853 | 3868 | $buf = @file_get_contents($filePath); |
| 3854 | - }else{ |
|
| 3869 | + } else{ |
|
| 3855 | 3870 | $buf = false; |
| 3856 | 3871 | } |
| 3857 | 3872 | |
@@ -3921,7 +3936,7 @@ discard block |
||
| 3921 | 3936 | if( is_object($stops[$i]) && property_exists($stops[$i],'value') ){ |
| 3922 | 3937 | $color = $stops[$i]->value[0]; |
| 3923 | 3938 | $position = $stops[$i]->value[1]; |
| 3924 | - }else{ |
|
| 3939 | + } else{ |
|
| 3925 | 3940 | $color = $stops[$i]; |
| 3926 | 3941 | $position = null; |
| 3927 | 3942 | } |
@@ -3931,9 +3946,9 @@ discard block |
||
| 3931 | 3946 | } |
| 3932 | 3947 | if( $position ){ |
| 3933 | 3948 | $positionValue = $position->toCSS(); |
| 3934 | - }elseif( $i === 0 ){ |
|
| 3949 | + } elseif( $i === 0 ){ |
|
| 3935 | 3950 | $positionValue = '0%'; |
| 3936 | - }else{ |
|
| 3951 | + } else{ |
|
| 3937 | 3952 | $positionValue = '100%'; |
| 3938 | 3953 | } |
| 3939 | 3954 | $alpha = $color->alpha; |
@@ -3945,7 +3960,7 @@ discard block |
||
| 3945 | 3960 | |
| 3946 | 3961 | if( $useBase64 ){ |
| 3947 | 3962 | $returner = "'data:image/svg+xml;base64,".base64_encode($returner)."'"; |
| 3948 | - }else{ |
|
| 3963 | + } else{ |
|
| 3949 | 3964 | $returner = "'data:image/svg+xml,".$returner."'"; |
| 3950 | 3965 | } |
| 3951 | 3966 | |
@@ -4349,7 +4364,7 @@ discard block |
||
| 4349 | 4364 | $this->$funcName( $node ); |
| 4350 | 4365 | } |
| 4351 | 4366 | |
| 4352 | - }else{ |
|
| 4367 | + } else{ |
|
| 4353 | 4368 | $node->accept($this); |
| 4354 | 4369 | } |
| 4355 | 4370 | |
@@ -4392,7 +4407,7 @@ discard block |
||
| 4392 | 4407 | } |
| 4393 | 4408 | } |
| 4394 | 4409 | |
| 4395 | - }else{ |
|
| 4410 | + } else{ |
|
| 4396 | 4411 | $node->accept($this); |
| 4397 | 4412 | } |
| 4398 | 4413 | |
@@ -4407,7 +4422,7 @@ discard block |
||
| 4407 | 4422 | if( $evald ){ |
| 4408 | 4423 | if( is_array($evald) ){ |
| 4409 | 4424 | self::flatten($evald,$newNodes); |
| 4410 | - }else{ |
|
| 4425 | + } else{ |
|
| 4411 | 4426 | $newNodes[] = $evald; |
| 4412 | 4427 | } |
| 4413 | 4428 | } |
@@ -4426,7 +4441,7 @@ discard block |
||
| 4426 | 4441 | foreach($item as $nestedItem){ |
| 4427 | 4442 | if( is_array($nestedItem) ){ |
| 4428 | 4443 | self::flatten( $nestedItem, $out); |
| 4429 | - }else{ |
|
| 4444 | + } else{ |
|
| 4430 | 4445 | $out[] = $nestedItem; |
| 4431 | 4446 | } |
| 4432 | 4447 | } |
@@ -4544,7 +4559,7 @@ discard block |
||
| 4544 | 4559 | |
| 4545 | 4560 | if( is_string($this->value) ){ |
| 4546 | 4561 | $output->add( $this->value ); |
| 4547 | - }else{ |
|
| 4562 | + } else{ |
|
| 4548 | 4563 | $this->value->genCSS( $output); |
| 4549 | 4564 | } |
| 4550 | 4565 | |
@@ -4776,7 +4791,7 @@ discard block |
||
| 4776 | 4791 | if( $nameLC === 'default' ){ |
| 4777 | 4792 | $result = Less_Tree_DefaultFunc::compile(); |
| 4778 | 4793 | |
| 4779 | - }else{ |
|
| 4794 | + } else{ |
|
| 4780 | 4795 | |
| 4781 | 4796 | if( method_exists('Less_Functions',$nameLC) ){ // 1. |
| 4782 | 4797 | try { |
@@ -4853,11 +4868,11 @@ discard block |
||
| 4853 | 4868 | $this->rgb = array(); |
| 4854 | 4869 | if( is_array($rgb) ){ |
| 4855 | 4870 | $this->rgb = $rgb; |
| 4856 | - }else if( strlen($rgb) == 6 ){ |
|
| 4871 | + } else if( strlen($rgb) == 6 ){ |
|
| 4857 | 4872 | foreach(str_split($rgb, 2) as $c){ |
| 4858 | 4873 | $this->rgb[] = hexdec($c); |
| 4859 | 4874 | } |
| 4860 | - }else{ |
|
| 4875 | + } else{ |
|
| 4861 | 4876 | foreach(str_split($rgb, 1) as $c){ |
| 4862 | 4877 | $this->rgb[] = hexdec($c.$c); |
| 4863 | 4878 | } |
@@ -4912,7 +4927,7 @@ discard block |
||
| 4912 | 4927 | |
| 4913 | 4928 | $glue = ($compress ? ',' : ', '); |
| 4914 | 4929 | return "rgba(" . implode($glue, $values) . ")"; |
| 4915 | - }else{ |
|
| 4930 | + } else{ |
|
| 4916 | 4931 | |
| 4917 | 4932 | $color = $this->toRGB(); |
| 4918 | 4933 | |
@@ -5154,9 +5169,9 @@ discard block |
||
| 5154 | 5169 | default: |
| 5155 | 5170 | if( Less_Parser::is_method($a, 'compare') ){ |
| 5156 | 5171 | $result = $a->compare($b); |
| 5157 | - }elseif( Less_Parser::is_method($b, 'compare') ){ |
|
| 5172 | + } elseif( Less_Parser::is_method($b, 'compare') ){ |
|
| 5158 | 5173 | $result = $b->compare($a); |
| 5159 | - }else{ |
|
| 5174 | + } else{ |
|
| 5160 | 5175 | throw new Less_Exception_Compiler('Unable to perform comparison', null, $this->index); |
| 5161 | 5176 | } |
| 5162 | 5177 | |
@@ -5239,7 +5254,7 @@ discard block |
||
| 5239 | 5254 | public function compile($env){ |
| 5240 | 5255 | if( $this->frames ){ |
| 5241 | 5256 | $frames = $this->frames; |
| 5242 | - }else{ |
|
| 5257 | + } else{ |
|
| 5243 | 5258 | $frames = $env->frames; |
| 5244 | 5259 | } |
| 5245 | 5260 | return new Less_Tree_DetachedRuleset($this->ruleset, $frames); |
@@ -5272,9 +5287,9 @@ discard block |
||
| 5272 | 5287 | |
| 5273 | 5288 | if( $unit && ($unit instanceof Less_Tree_Unit) ){ |
| 5274 | 5289 | $this->unit = $unit; |
| 5275 | - }elseif( $unit ){ |
|
| 5290 | + } elseif( $unit ){ |
|
| 5276 | 5291 | $this->unit = new Less_Tree_Unit( array($unit) ); |
| 5277 | - }else{ |
|
| 5292 | + } else{ |
|
| 5278 | 5293 | $this->unit = new Less_Tree_Unit( ); |
| 5279 | 5294 | } |
| 5280 | 5295 | } |
@@ -5347,9 +5362,9 @@ discard block |
||
| 5347 | 5362 | if( !$unit->numerator && !$unit->denominator ){ |
| 5348 | 5363 | $unit->numerator = $other->unit->numerator; |
| 5349 | 5364 | $unit->denominator = $other->unit->denominator; |
| 5350 | - }elseif( !$other->unit->numerator && !$other->unit->denominator ){ |
|
| 5365 | + } elseif( !$other->unit->numerator && !$other->unit->denominator ){ |
|
| 5351 | 5366 | // do nothing |
| 5352 | - }else{ |
|
| 5367 | + } else{ |
|
| 5353 | 5368 | $other = $other->convertTo( $this->unit->usedUnits()); |
| 5354 | 5369 | |
| 5355 | 5370 | if( Less_Parser::$options['strictUnits'] && $other->unit->toString() !== $unit->toCSS() ){ |
@@ -5358,13 +5373,13 @@ discard block |
||
| 5358 | 5373 | |
| 5359 | 5374 | $value = Less_Functions::operate( $op, $this->value, $other->value); |
| 5360 | 5375 | } |
| 5361 | - }elseif( $op === '*' ){ |
|
| 5376 | + } elseif( $op === '*' ){ |
|
| 5362 | 5377 | $unit->numerator = array_merge($unit->numerator, $other->unit->numerator); |
| 5363 | 5378 | $unit->denominator = array_merge($unit->denominator, $other->unit->denominator); |
| 5364 | 5379 | sort($unit->numerator); |
| 5365 | 5380 | sort($unit->denominator); |
| 5366 | 5381 | $unit->cancel(); |
| 5367 | - }elseif( $op === '/' ){ |
|
| 5382 | + } elseif( $op === '/' ){ |
|
| 5368 | 5383 | $unit->numerator = array_merge($unit->numerator, $other->unit->denominator); |
| 5369 | 5384 | $unit->denominator = array_merge($unit->denominator, $other->unit->numerator); |
| 5370 | 5385 | sort($unit->numerator); |
@@ -5615,7 +5630,7 @@ discard block |
||
| 5615 | 5630 | |
| 5616 | 5631 | if( $this->value_is_object ){ |
| 5617 | 5632 | $value = $this->value->toCSS(); |
| 5618 | - }else{ |
|
| 5633 | + } else{ |
|
| 5619 | 5634 | $value = $this->value; |
| 5620 | 5635 | } |
| 5621 | 5636 | |
@@ -5674,7 +5689,7 @@ discard block |
||
| 5674 | 5689 | } |
| 5675 | 5690 | $returnValue = new Less_Tree_Expression($ret); |
| 5676 | 5691 | |
| 5677 | - }else{ |
|
| 5692 | + } else{ |
|
| 5678 | 5693 | |
| 5679 | 5694 | if( ($this->value[0] instanceof Less_Tree_Expression) && $this->value[0]->parens && !$this->value[0]->parensInOp ){ |
| 5680 | 5695 | $doubleParen = true; |
@@ -5691,7 +5706,7 @@ discard block |
||
| 5691 | 5706 | if( !$this->parensInOp ){ |
| 5692 | 5707 | Less_Environment::$parensStack--; |
| 5693 | 5708 | |
| 5694 | - }elseif( !Less_Environment::isMathOn() && !$doubleParen ){ |
|
| 5709 | + } elseif( !Less_Environment::isMathOn() && !$doubleParen ){ |
|
| 5695 | 5710 | $returnValue = new Less_Tree_Paren($returnValue); |
| 5696 | 5711 | |
| 5697 | 5712 | } |
@@ -5910,7 +5925,7 @@ discard block |
||
| 5910 | 5925 | $path = ( isset($this->css) || preg_match('/(\.[a-z]*$)|([\?;].*)$/',$path)) ? $path : $path . '.less'; |
| 5911 | 5926 | } else if ($this->path instanceof Less_Tree_URL) { |
| 5912 | 5927 | $path = $this->path->value->value; |
| 5913 | - }else{ |
|
| 5928 | + } else{ |
|
| 5914 | 5929 | return null; |
| 5915 | 5930 | } |
| 5916 | 5931 | |
@@ -5962,7 +5977,7 @@ discard block |
||
| 5962 | 5977 | |
| 5963 | 5978 | if( $path_and_uri ){ |
| 5964 | 5979 | list($full_path, $uri) = $path_and_uri; |
| 5965 | - }else{ |
|
| 5980 | + } else{ |
|
| 5966 | 5981 | $full_path = $uri = $evald->getPath(); |
| 5967 | 5982 | } |
| 5968 | 5983 | |
@@ -6015,7 +6030,7 @@ discard block |
||
| 6015 | 6030 | //if the path is relative, the file should be in the current directory |
| 6016 | 6031 | $import_dirs[ $this->currentFileInfo['currentDirectory'] ] = $this->currentFileInfo['uri_root']; |
| 6017 | 6032 | |
| 6018 | - }else{ |
|
| 6033 | + } else{ |
|
| 6019 | 6034 | //otherwise, the file should be relative to the server root |
| 6020 | 6035 | $import_dirs[ $this->currentFileInfo['entryPath'] ] = $this->currentFileInfo['entryUri']; |
| 6021 | 6036 | |
@@ -6035,7 +6050,7 @@ discard block |
||
| 6035 | 6050 | $full_path = $path; |
| 6036 | 6051 | return array( $full_path, $uri ); |
| 6037 | 6052 | } |
| 6038 | - }elseif( !empty($rootpath) ){ |
|
| 6053 | + } elseif( !empty($rootpath) ){ |
|
| 6039 | 6054 | |
| 6040 | 6055 | |
| 6041 | 6056 | if( $rooturi ){ |
@@ -6334,11 +6349,13 @@ discard block |
||
| 6334 | 6349 | } |
| 6335 | 6350 | |
| 6336 | 6351 | public function permute($arr) { |
| 6337 | - if (!$arr) |
|
| 6338 | - return array(); |
|
| 6352 | + if (!$arr) { |
|
| 6353 | + return array(); |
|
| 6354 | + } |
|
| 6339 | 6355 | |
| 6340 | - if (count($arr) == 1) |
|
| 6341 | - return $arr[0]; |
|
| 6356 | + if (count($arr) == 1) { |
|
| 6357 | + return $arr[0]; |
|
| 6358 | + } |
|
| 6342 | 6359 | |
| 6343 | 6360 | $result = array(); |
| 6344 | 6361 | $rest = $this->permute(array_slice($arr, 1)); |
@@ -6356,7 +6373,9 @@ discard block |
||
| 6356 | 6373 | |
| 6357 | 6374 | public function bubbleSelectors($selectors) { |
| 6358 | 6375 | |
| 6359 | - if( !$selectors) return; |
|
| 6376 | + if( !$selectors) { |
|
| 6377 | + return; |
|
| 6378 | + } |
|
| 6360 | 6379 | |
| 6361 | 6380 | $this->rules = array(new Less_Tree_Ruleset( $selectors, array($this->rules[0]))); |
| 6362 | 6381 | } |
@@ -6477,7 +6496,7 @@ discard block |
||
| 6477 | 6496 | if( $a instanceof Less_Tree_Dimension && $b instanceof Less_Tree_Color ){ |
| 6478 | 6497 | $a = $a->toColor(); |
| 6479 | 6498 | |
| 6480 | - }elseif( $b instanceof Less_Tree_Dimension && $a instanceof Less_Tree_Color ){ |
|
| 6499 | + } elseif( $b instanceof Less_Tree_Dimension && $a instanceof Less_Tree_Color ){ |
|
| 6481 | 6500 | $b = $b->toColor(); |
| 6482 | 6501 | |
| 6483 | 6502 | } |
@@ -6672,7 +6691,7 @@ discard block |
||
| 6672 | 6691 | try{ |
| 6673 | 6692 | $this->value->genCSS( $output); |
| 6674 | 6693 | |
| 6675 | - }catch( Less_Exception_Parser $e ){ |
|
| 6694 | + } catch( Less_Exception_Parser $e ){ |
|
| 6676 | 6695 | $e->index = $this->index; |
| 6677 | 6696 | $e->currentFile = $this->currentFileInfo; |
| 6678 | 6697 | throw $e; |
@@ -6688,7 +6707,7 @@ discard block |
||
| 6688 | 6707 | // things faster (~10% for benchmark.less): |
| 6689 | 6708 | if( count($name) === 1 && $name[0] instanceof Less_Tree_Keyword ){ |
| 6690 | 6709 | $name = $name[0]->value; |
| 6691 | - }else{ |
|
| 6710 | + } else{ |
|
| 6692 | 6711 | $name = $this->CompileName($env,$name); |
| 6693 | 6712 | } |
| 6694 | 6713 | } |
@@ -6707,13 +6726,13 @@ discard block |
||
| 6707 | 6726 | |
| 6708 | 6727 | if( Less_Environment::$mixin_stack ){ |
| 6709 | 6728 | $return = new Less_Tree_Rule($name, $evaldValue, $this->important, $this->merge, $this->index, $this->currentFileInfo, $this->inline); |
| 6710 | - }else{ |
|
| 6729 | + } else{ |
|
| 6711 | 6730 | $this->name = $name; |
| 6712 | 6731 | $this->value = $evaldValue; |
| 6713 | 6732 | $return = $this; |
| 6714 | 6733 | } |
| 6715 | 6734 | |
| 6716 | - }catch( Less_Exception_Parser $e ){ |
|
| 6735 | + } catch( Less_Exception_Parser $e ){ |
|
| 6717 | 6736 | if( !is_numeric($e->index) ){ |
| 6718 | 6737 | $e->index = $this->index; |
| 6719 | 6738 | $e->currentFile = $this->currentFileInfo; |
@@ -6798,7 +6817,7 @@ discard block |
||
| 6798 | 6817 | for($i = 0,$paths_len; $i < $paths_len; $i++ ){ |
| 6799 | 6818 | $this->paths[$i] = $visitor->visitArray($this->paths[$i]); |
| 6800 | 6819 | } |
| 6801 | - }elseif( $this->selectors ){ |
|
| 6820 | + } elseif( $this->selectors ){ |
|
| 6802 | 6821 | $this->selectors = $visitor->visitArray($this->selectors); |
| 6803 | 6822 | } |
| 6804 | 6823 | |
@@ -6897,7 +6916,7 @@ discard block |
||
| 6897 | 6916 | if( !$ruleset->variable($r->name) ){ |
| 6898 | 6917 | $temp[] = $r; |
| 6899 | 6918 | } |
| 6900 | - }else{ |
|
| 6919 | + } else{ |
|
| 6901 | 6920 | $temp[] = $r; |
| 6902 | 6921 | } |
| 6903 | 6922 | } |
@@ -6907,7 +6926,7 @@ discard block |
||
| 6907 | 6926 | $i += $temp_count; |
| 6908 | 6927 | $ruleset->resetCache(); |
| 6909 | 6928 | |
| 6910 | - }elseif( $rule instanceof Less_Tree_RulesetCall ){ |
|
| 6929 | + } elseif( $rule instanceof Less_Tree_RulesetCall ){ |
|
| 6911 | 6930 | |
| 6912 | 6931 | $rule = $rule->compile($env); |
| 6913 | 6932 | $rules = array(); |
@@ -6955,7 +6974,7 @@ discard block |
||
| 6955 | 6974 | |
| 6956 | 6975 | if( $this->rules && $hasOnePassingSelector ){ |
| 6957 | 6976 | $rules = $this->rules; |
| 6958 | - }else{ |
|
| 6977 | + } else{ |
|
| 6959 | 6978 | $rules = array(); |
| 6960 | 6979 | } |
| 6961 | 6980 | |
@@ -6993,7 +7012,7 @@ discard block |
||
| 6993 | 7012 | $temp_count = count($rules)-1; |
| 6994 | 7013 | $i += $temp_count; |
| 6995 | 7014 | $rules_len += $temp_count; |
| 6996 | - }else{ |
|
| 7015 | + } else{ |
|
| 6997 | 7016 | array_splice($this->rules, $i, 1, array($rules)); |
| 6998 | 7017 | } |
| 6999 | 7018 | |
@@ -7008,7 +7027,7 @@ discard block |
||
| 7008 | 7027 | foreach($this->rules as $rule){ |
| 7009 | 7028 | if( $rule instanceof Less_Tree_Rule || $rule instanceof Less_Tree_Ruleset ){ |
| 7010 | 7029 | $important_rules[] = $rule->makeImportant(); |
| 7011 | - }else{ |
|
| 7030 | + } else{ |
|
| 7012 | 7031 | $important_rules[] = $rule; |
| 7013 | 7032 | } |
| 7014 | 7033 | } |
@@ -7109,7 +7128,7 @@ discard block |
||
| 7109 | 7128 | if( Less_Environment::$tabLevel ){ |
| 7110 | 7129 | $tabRuleStr = "\n".str_repeat( ' ' , Less_Environment::$tabLevel ); |
| 7111 | 7130 | $tabSetStr = "\n".str_repeat( ' ' , Less_Environment::$tabLevel-1 ); |
| 7112 | - }else{ |
|
| 7131 | + } else{ |
|
| 7113 | 7132 | $tabSetStr = $tabRuleStr = "\n"; |
| 7114 | 7133 | } |
| 7115 | 7134 | } |
@@ -7122,7 +7141,7 @@ discard block |
||
| 7122 | 7141 | $class = get_class($rule); |
| 7123 | 7142 | if( ($class === 'Less_Tree_Media') || ($class === 'Less_Tree_Directive') || ($this->root && $class === 'Less_Tree_Comment') || ($class === 'Less_Tree_Ruleset' && $rule->rules) ){ |
| 7124 | 7143 | $rulesetNodes[] = $rule; |
| 7125 | - }else{ |
|
| 7144 | + } else{ |
|
| 7126 | 7145 | $ruleNodes[] = $rule; |
| 7127 | 7146 | } |
| 7128 | 7147 | } |
@@ -7174,7 +7193,7 @@ discard block |
||
| 7174 | 7193 | |
| 7175 | 7194 | if( !Less_Environment::$lastRule ){ |
| 7176 | 7195 | $output->add( $tabRuleStr ); |
| 7177 | - }else{ |
|
| 7196 | + } else{ |
|
| 7178 | 7197 | Less_Environment::$lastRule = false; |
| 7179 | 7198 | } |
| 7180 | 7199 | } |
@@ -7190,7 +7209,7 @@ discard block |
||
| 7190 | 7209 | |
| 7191 | 7210 | if( $ruleNodes_len && $firstRuleset ){ |
| 7192 | 7211 | $output->add( $space ); |
| 7193 | - }elseif( !$firstRuleset ){ |
|
| 7212 | + } elseif( !$firstRuleset ){ |
|
| 7194 | 7213 | $output->add( $space ); |
| 7195 | 7214 | } |
| 7196 | 7215 | $firstRuleset = false; |
@@ -7238,7 +7257,7 @@ discard block |
||
| 7238 | 7257 | foreach($context as $context_el){ |
| 7239 | 7258 | $paths[] = array_merge($context_el, array($selector) ); |
| 7240 | 7259 | } |
| 7241 | - }else { |
|
| 7260 | + } else { |
|
| 7242 | 7261 | $paths[] = array($selector); |
| 7243 | 7262 | } |
| 7244 | 7263 | return; |
@@ -7292,7 +7311,7 @@ discard block |
||
| 7292 | 7311 | $sel[0]->elements[] = new Less_Tree_Element($el->combinator, '', $el->index, $el->currentFileInfo ); |
| 7293 | 7312 | } |
| 7294 | 7313 | $selectorsMultiplied[] = $sel; |
| 7295 | - }else { |
|
| 7314 | + } else { |
|
| 7296 | 7315 | |
| 7297 | 7316 | // and the parent selectors |
| 7298 | 7317 | foreach($context as $parentSel){ |
@@ -7312,8 +7331,7 @@ discard block |
||
| 7312 | 7331 | $lastSelector = array_pop($newSelectorPath); |
| 7313 | 7332 | $newJoinedSelector = $selector->createDerived( array_slice($lastSelector->elements,0) ); |
| 7314 | 7333 | $newJoinedSelectorEmpty = false; |
| 7315 | - } |
|
| 7316 | - else { |
|
| 7334 | + } else { |
|
| 7317 | 7335 | $newJoinedSelector = $selector->createDerived(array()); |
| 7318 | 7336 | } |
| 7319 | 7337 | |
@@ -7377,7 +7395,7 @@ discard block |
||
| 7377 | 7395 | if( $sel ){ |
| 7378 | 7396 | $last = count($sel)-1; |
| 7379 | 7397 | $sel[$last] = $sel[$last]->createDerived( array_merge($sel[$last]->elements, $elements) ); |
| 7380 | - }else{ |
|
| 7398 | + } else{ |
|
| 7381 | 7399 | $sel[] = new Less_Tree_Selector( $elements ); |
| 7382 | 7400 | } |
| 7383 | 7401 | } |
@@ -7637,9 +7655,9 @@ discard block |
||
| 7637 | 7655 | |
| 7638 | 7656 | if( $this->numerator ){ |
| 7639 | 7657 | $output->add( $this->numerator[0] ); |
| 7640 | - }elseif( $this->denominator ){ |
|
| 7658 | + } elseif( $this->denominator ){ |
|
| 7641 | 7659 | $output->add( $this->denominator[0] ); |
| 7642 | - }elseif( !Less_Parser::$options['strictUnits'] && $this->backupUnit ){ |
|
| 7660 | + } elseif( !Less_Parser::$options['strictUnits'] && $this->backupUnit ){ |
|
| 7643 | 7661 | $output->add( $this->backupUnit ); |
| 7644 | 7662 | return ; |
| 7645 | 7663 | } |
@@ -7735,7 +7753,7 @@ discard block |
||
| 7735 | 7753 | for( $i = 0; $i < $count; $i++ ){ |
| 7736 | 7754 | $this->numerator[] = $atomicUnit; |
| 7737 | 7755 | } |
| 7738 | - }elseif( $count < 0 ){ |
|
| 7756 | + } elseif( $count < 0 ){ |
|
| 7739 | 7757 | for( $i = 0; $i < -$count; $i++ ){ |
| 7740 | 7758 | $this->denominator[] = $atomicUnit; |
| 7741 | 7759 | } |
@@ -7941,7 +7959,7 @@ discard block |
||
| 7941 | 7959 | if( $this->name[1] === '@' ){ |
| 7942 | 7960 | $v = new Less_Tree_Variable(substr($this->name, 1), $this->index + 1, $this->currentFileInfo); |
| 7943 | 7961 | $name = '@' . $v->compile($env)->value; |
| 7944 | - }else{ |
|
| 7962 | + } else{ |
|
| 7945 | 7963 | $name = $this->name; |
| 7946 | 7964 | } |
| 7947 | 7965 | |
@@ -8051,7 +8069,7 @@ discard block |
||
| 8051 | 8069 | |
| 8052 | 8070 | $candidates[] = $candidate; |
| 8053 | 8071 | } |
| 8054 | - }else{ |
|
| 8072 | + } else{ |
|
| 8055 | 8073 | $candidates[] = $candidate; |
| 8056 | 8074 | } |
| 8057 | 8075 | |
@@ -8109,7 +8127,7 @@ discard block |
||
| 8109 | 8127 | if( $isOneFound ){ |
| 8110 | 8128 | throw new Less_Exception_Compiler('No matching definition was found for `'.$this->Format( $args ).'`', null, $this->index, $this->currentFileInfo); |
| 8111 | 8129 | |
| 8112 | - }else{ |
|
| 8130 | + } else{ |
|
| 8113 | 8131 | throw new Less_Exception_Compiler(trim($this->selector->toCSS()) . " is undefined in ".$this->currentFileInfo['filename'], null, $this->index); |
| 8114 | 8132 | } |
| 8115 | 8133 | |
@@ -8129,7 +8147,7 @@ discard block |
||
| 8129 | 8147 | } |
| 8130 | 8148 | if( is_object($a['value']) ){ |
| 8131 | 8149 | $argValue += $a['value']->toCSS(); |
| 8132 | - }else{ |
|
| 8150 | + } else{ |
|
| 8133 | 8151 | $argValue += '???'; |
| 8134 | 8152 | } |
| 8135 | 8153 | $message[] = $argValue; |
@@ -8271,7 +8289,7 @@ discard block |
||
| 8271 | 8289 | } |
| 8272 | 8290 | $expression = new Less_Tree_Expression($varargs); |
| 8273 | 8291 | array_unshift($frame->rules, new Less_Tree_Rule($param['name'], $expression->compile($env))); |
| 8274 | - }else{ |
|
| 8292 | + } else{ |
|
| 8275 | 8293 | $val = ($arg && $arg['value']) ? $arg['value'] : false; |
| 8276 | 8294 | |
| 8277 | 8295 | if ($val) { |
@@ -8323,7 +8341,7 @@ discard block |
||
| 8323 | 8341 | |
| 8324 | 8342 | if( $this->frames ){ |
| 8325 | 8343 | $mixinFrames = array_merge($this->frames, $env->frames); |
| 8326 | - }else{ |
|
| 8344 | + } else{ |
|
| 8327 | 8345 | $mixinFrames = $env->frames; |
| 8328 | 8346 | } |
| 8329 | 8347 | |
@@ -8386,7 +8404,7 @@ discard block |
||
| 8386 | 8404 | if( $argsLength > count($this->params) ){ |
| 8387 | 8405 | return false; |
| 8388 | 8406 | } |
| 8389 | - }else{ |
|
| 8407 | + } else{ |
|
| 8390 | 8408 | if( $argsLength < ($this->required - 1)){ |
| 8391 | 8409 | return false; |
| 8392 | 8410 | } |
@@ -8704,7 +8722,7 @@ discard block |
||
| 8704 | 8722 | if( !$selectors ){ |
| 8705 | 8723 | $rulesetNode->selectors = null; |
| 8706 | 8724 | $rulesetNode->rules = null; |
| 8707 | - }else{ |
|
| 8725 | + } else{ |
|
| 8708 | 8726 | $context = end($this->contexts); //$context = $this->contexts[ count($this->contexts) - 1]; |
| 8709 | 8727 | $paths = $rulesetNode->joinSelectors( $context, $selectors); |
| 8710 | 8728 | } |
@@ -8838,7 +8856,7 @@ discard block |
||
| 8838 | 8856 | try{ |
| 8839 | 8857 | $selectorOne = $extendsToAdd[0]->selfSelectors[0]->toCSS(); |
| 8840 | 8858 | $selectorTwo = $extendsToAdd[0]->selector->toCSS(); |
| 8841 | - }catch(Exception $e){ |
|
| 8859 | + } catch(Exception $e){ |
|
| 8842 | 8860 | $selectorOne = "{unable to calculate}"; |
| 8843 | 8861 | $selectorTwo = "{unable to calculate}"; |
| 8844 | 8862 | } |
@@ -9153,7 +9171,7 @@ discard block |
||
| 9153 | 9171 | if( $currentSelectorPathIndex === $match['pathIndex'] && $matchIndex > 0 ){ |
| 9154 | 9172 | $last_key = count($path)-1; |
| 9155 | 9173 | $path[$last_key]->elements = array_merge($path[$last_key]->elements,$newElements); |
| 9156 | - }else{ |
|
| 9174 | + } else{ |
|
| 9157 | 9175 | $path = array_merge( $path, array_slice( $selectorPath, $currentSelectorPathIndex, $match['pathIndex'] )); |
| 9158 | 9176 | $path[] = new Less_Tree_Selector( $newElements ); |
| 9159 | 9177 | } |
@@ -9400,7 +9418,7 @@ discard block |
||
| 9400 | 9418 | |
| 9401 | 9419 | if( !isset($ruleCache[$rule->name]) ){ |
| 9402 | 9420 | $ruleCache[$rule->name] = $rule; |
| 9403 | - }else{ |
|
| 9421 | + } else{ |
|
| 9404 | 9422 | $ruleList =& $ruleCache[$rule->name]; |
| 9405 | 9423 | |
| 9406 | 9424 | if( $ruleList instanceof Less_Tree_Rule || $ruleList instanceof Less_Tree_NameValue ){ |
@@ -9410,7 +9428,7 @@ discard block |
||
| 9410 | 9428 | $ruleCSS = $rule->toCSS(); |
| 9411 | 9429 | if( array_search($ruleCSS,$ruleList) !== false ){ |
| 9412 | 9430 | array_splice($rules,$i,1); |
| 9413 | - }else{ |
|
| 9431 | + } else{ |
|
| 9414 | 9432 | $ruleList[] = $ruleCSS; |
| 9415 | 9433 | } |
| 9416 | 9434 | } |
@@ -9436,7 +9454,7 @@ discard block |
||
| 9436 | 9454 | |
| 9437 | 9455 | if( !isset($groups[$key]) ){ |
| 9438 | 9456 | $groups[$key] = array(); |
| 9439 | - }else{ |
|
| 9457 | + } else{ |
|
| 9440 | 9458 | array_splice($rules, $i--, 1); |
| 9441 | 9459 | $rules_len--; |
| 9442 | 9460 | } |
@@ -9798,7 +9816,7 @@ discard block |
||
| 9798 | 9816 | |
| 9799 | 9817 | if( !$index ){ |
| 9800 | 9818 | $this->index = $this->parserCurrentIndex; |
| 9801 | - }else{ |
|
| 9819 | + } else{ |
|
| 9802 | 9820 | $this->index = $index; |
| 9803 | 9821 | } |
| 9804 | 9822 | $this->message = 'ParseError: '.$msg; |
@@ -9905,7 +9923,7 @@ discard block |
||
| 9905 | 9923 | $inputSource = substr($this->contentsMap[$url], 0, $index); |
| 9906 | 9924 | $sourceLines = explode("\n", $inputSource); |
| 9907 | 9925 | $sourceColumns = end($sourceLines); |
| 9908 | - }else{ |
|
| 9926 | + } else{ |
|
| 9909 | 9927 | throw new Exception('Filename '.$url.' not in contentsMap'); |
| 9910 | 9928 | } |
| 9911 | 9929 | |
@@ -9924,7 +9942,7 @@ discard block |
||
| 9924 | 9942 | strlen($sourceColumns), // original_column |
| 9925 | 9943 | $fileInfo |
| 9926 | 9944 | ); |
| 9927 | - }else{ |
|
| 9945 | + } else{ |
|
| 9928 | 9946 | for($i = 0, $count = count($lines); $i < $count; $i++){ |
| 9929 | 9947 | $this->generator->addMapping( |
| 9930 | 9948 | $this->lineNumber + $i + 1, // generated_line |
@@ -9939,7 +9957,7 @@ discard block |
||
| 9939 | 9957 | |
| 9940 | 9958 | if(count($lines) === 1){ |
| 9941 | 9959 | $this->column += strlen($columns); |
| 9942 | - }else{ |
|
| 9960 | + } else{ |
|
| 9943 | 9961 | $this->lineNumber += count($lines) - 1; |
| 9944 | 9962 | $this->column = strlen($columns); |
| 9945 | 9963 | } |
@@ -873,7 +873,7 @@ discard block |
||
| 873 | 873 | break; |
| 874 | 874 | } |
| 875 | 875 | |
| 876 | - if( $this->PeekChar('}') ){ |
|
| 876 | + if( $this->PeekChar('}') ){ |
|
| 877 | 877 | break; |
| 878 | 878 | } |
| 879 | 879 | } |
@@ -944,8 +944,8 @@ discard block |
||
| 944 | 944 | $this->MatchChar('~'); |
| 945 | 945 | } |
| 946 | 946 | |
| 947 | - // Fix for #124: match escaped newlines |
|
| 948 | - //$str = $this->MatchReg('/\\G"((?:[^"\\\\\r\n]|\\\\.)*)"|\'((?:[^\'\\\\\r\n]|\\\\.)*)\'/'); |
|
| 947 | + // Fix for #124: match escaped newlines |
|
| 948 | + //$str = $this->MatchReg('/\\G"((?:[^"\\\\\r\n]|\\\\.)*)"|\'((?:[^\'\\\\\r\n]|\\\\.)*)\'/'); |
|
| 949 | 949 | $str = $this->MatchReg('/\\G"((?:[^"\\\\\r\n]|\\\\.|\\\\\r\n|\\\\[\n\r\f])*)"|\'((?:[^\'\\\\\r\n]|\\\\.|\\\\\r\n|\\\\[\n\r\f])*)\'/'); |
| 950 | 950 | |
| 951 | 951 | if( $str ){ |
@@ -2869,8 +2869,8 @@ discard block |
||
| 2869 | 2869 | '~' => '~', |
| 2870 | 2870 | '>' => '>', |
| 2871 | 2871 | '|' => '|', |
| 2872 | - '^' => '^', |
|
| 2873 | - '^^' => '^^' |
|
| 2872 | + '^' => '^', |
|
| 2873 | + '^^' => '^^' |
|
| 2874 | 2874 | ); |
| 2875 | 2875 | |
| 2876 | 2876 | }else{ |
@@ -2885,8 +2885,8 @@ discard block |
||
| 2885 | 2885 | '~' => ' ~ ', |
| 2886 | 2886 | '>' => ' > ', |
| 2887 | 2887 | '|' => '|', |
| 2888 | - '^' => ' ^ ', |
|
| 2889 | - '^^' => ' ^^ ' |
|
| 2888 | + '^' => ' ^ ', |
|
| 2889 | + '^^' => ' ^^ ' |
|
| 2890 | 2890 | ); |
| 2891 | 2891 | |
| 2892 | 2892 | } |
@@ -4157,18 +4157,18 @@ discard block |
||
| 4157 | 4157 | // this map is intentionally incomplete |
| 4158 | 4158 | // if you want more, install 'mime' dep |
| 4159 | 4159 | static $_types = array( |
| 4160 | - '.htm' => 'text/html', |
|
| 4161 | - '.html'=> 'text/html', |
|
| 4162 | - '.gif' => 'image/gif', |
|
| 4163 | - '.jpg' => 'image/jpeg', |
|
| 4164 | - '.jpeg'=> 'image/jpeg', |
|
| 4165 | - '.png' => 'image/png', |
|
| 4166 | - '.ttf' => 'application/x-font-ttf', |
|
| 4167 | - '.otf' => 'application/x-font-otf', |
|
| 4168 | - '.eot' => 'application/vnd.ms-fontobject', |
|
| 4169 | - '.woff' => 'application/x-font-woff', |
|
| 4170 | - '.svg' => 'image/svg+xml', |
|
| 4171 | - ); |
|
| 4160 | + '.htm' => 'text/html', |
|
| 4161 | + '.html'=> 'text/html', |
|
| 4162 | + '.gif' => 'image/gif', |
|
| 4163 | + '.jpg' => 'image/jpeg', |
|
| 4164 | + '.jpeg'=> 'image/jpeg', |
|
| 4165 | + '.png' => 'image/png', |
|
| 4166 | + '.ttf' => 'application/x-font-ttf', |
|
| 4167 | + '.otf' => 'application/x-font-otf', |
|
| 4168 | + '.eot' => 'application/vnd.ms-fontobject', |
|
| 4169 | + '.woff' => 'application/x-font-woff', |
|
| 4170 | + '.svg' => 'image/svg+xml', |
|
| 4171 | + ); |
|
| 4172 | 4172 | |
| 4173 | 4173 | public static function lookup( $filepath ){ |
| 4174 | 4174 | $parts = explode('.',$filepath); |
@@ -4204,13 +4204,13 @@ discard block |
||
| 4204 | 4204 | } |
| 4205 | 4205 | |
| 4206 | 4206 | |
| 4207 | - /** |
|
| 4208 | - * Generate CSS by adding it to the output object |
|
| 4209 | - * |
|
| 4210 | - * @param Less_Output $output The output |
|
| 4211 | - * @return void |
|
| 4212 | - */ |
|
| 4213 | - public function genCSS($output){} |
|
| 4207 | + /** |
|
| 4208 | + * Generate CSS by adding it to the output object |
|
| 4209 | + * |
|
| 4210 | + * @param Less_Output $output The output |
|
| 4211 | + * @return void |
|
| 4212 | + */ |
|
| 4213 | + public function genCSS($output){} |
|
| 4214 | 4214 | |
| 4215 | 4215 | |
| 4216 | 4216 | /** |
@@ -4543,9 +4543,9 @@ discard block |
||
| 4543 | 4543 | return $this; |
| 4544 | 4544 | } |
| 4545 | 4545 | |
| 4546 | - /** |
|
| 4547 | - * @see Less_Tree::genCSS |
|
| 4548 | - */ |
|
| 4546 | + /** |
|
| 4547 | + * @see Less_Tree::genCSS |
|
| 4548 | + */ |
|
| 4549 | 4549 | public function genCSS( $output ){ |
| 4550 | 4550 | |
| 4551 | 4551 | $output->add( "alpha(opacity=" ); |
@@ -4595,7 +4595,7 @@ discard block |
||
| 4595 | 4595 | return new Less_Tree_Anonymous($this->value, $this->index, $this->currentFileInfo, $this->mapLines); |
| 4596 | 4596 | } |
| 4597 | 4597 | |
| 4598 | - public function compare($x){ |
|
| 4598 | + public function compare($x){ |
|
| 4599 | 4599 | if( !is_object($x) ){ |
| 4600 | 4600 | return -1; |
| 4601 | 4601 | } |
@@ -4610,9 +4610,9 @@ discard block |
||
| 4610 | 4610 | return $left < $right ? -1 : 1; |
| 4611 | 4611 | } |
| 4612 | 4612 | |
| 4613 | - /** |
|
| 4614 | - * @see Less_Tree::genCSS |
|
| 4615 | - */ |
|
| 4613 | + /** |
|
| 4614 | + * @see Less_Tree::genCSS |
|
| 4615 | + */ |
|
| 4616 | 4616 | public function genCSS( $output ){ |
| 4617 | 4617 | $output->add( $this->value, $this->currentFileInfo, $this->index, $this->mapLines ); |
| 4618 | 4618 | } |
@@ -4636,12 +4636,12 @@ discard block |
||
| 4636 | 4636 | public $value; |
| 4637 | 4637 | public $type = 'Assignment'; |
| 4638 | 4638 | |
| 4639 | - public function __construct($key, $val) { |
|
| 4639 | + public function __construct($key, $val) { |
|
| 4640 | 4640 | $this->key = $key; |
| 4641 | 4641 | $this->value = $val; |
| 4642 | 4642 | } |
| 4643 | 4643 | |
| 4644 | - public function accept( $visitor ){ |
|
| 4644 | + public function accept( $visitor ){ |
|
| 4645 | 4645 | $this->value = $visitor->visitObj( $this->value ); |
| 4646 | 4646 | } |
| 4647 | 4647 | |
@@ -4649,9 +4649,9 @@ discard block |
||
| 4649 | 4649 | return new Less_Tree_Assignment( $this->key, $this->value->compile($env)); |
| 4650 | 4650 | } |
| 4651 | 4651 | |
| 4652 | - /** |
|
| 4653 | - * @see Less_Tree::genCSS |
|
| 4654 | - */ |
|
| 4652 | + /** |
|
| 4653 | + * @see Less_Tree::genCSS |
|
| 4654 | + */ |
|
| 4655 | 4655 | public function genCSS( $output ){ |
| 4656 | 4656 | $output->add( $this->key . '=' ); |
| 4657 | 4657 | $this->value->genCSS( $output ); |
@@ -4676,13 +4676,13 @@ discard block |
||
| 4676 | 4676 | public $value; |
| 4677 | 4677 | public $type = 'Attribute'; |
| 4678 | 4678 | |
| 4679 | - public function __construct($key, $op, $value){ |
|
| 4679 | + public function __construct($key, $op, $value){ |
|
| 4680 | 4680 | $this->key = $key; |
| 4681 | 4681 | $this->op = $op; |
| 4682 | 4682 | $this->value = $value; |
| 4683 | 4683 | } |
| 4684 | 4684 | |
| 4685 | - public function compile($env){ |
|
| 4685 | + public function compile($env){ |
|
| 4686 | 4686 | |
| 4687 | 4687 | $key_obj = is_object($this->key); |
| 4688 | 4688 | $val_obj = is_object($this->value); |
@@ -4697,14 +4697,14 @@ discard block |
||
| 4697 | 4697 | $val_obj ? $this->value->compile($env) : $this->value); |
| 4698 | 4698 | } |
| 4699 | 4699 | |
| 4700 | - /** |
|
| 4701 | - * @see Less_Tree::genCSS |
|
| 4702 | - */ |
|
| 4703 | - public function genCSS( $output ){ |
|
| 4700 | + /** |
|
| 4701 | + * @see Less_Tree::genCSS |
|
| 4702 | + */ |
|
| 4703 | + public function genCSS( $output ){ |
|
| 4704 | 4704 | $output->add( $this->toCSS() ); |
| 4705 | 4705 | } |
| 4706 | 4706 | |
| 4707 | - public function toCSS(){ |
|
| 4707 | + public function toCSS(){ |
|
| 4708 | 4708 | $value = $this->key; |
| 4709 | 4709 | |
| 4710 | 4710 | if( $this->op ){ |
@@ -4724,13 +4724,13 @@ discard block |
||
| 4724 | 4724 | * @subpackage tree |
| 4725 | 4725 | */ |
| 4726 | 4726 | class Less_Tree_Call extends Less_Tree{ |
| 4727 | - public $value; |
|
| 4727 | + public $value; |
|
| 4728 | 4728 | |
| 4729 | - protected $name; |
|
| 4730 | - protected $args; |
|
| 4731 | - protected $index; |
|
| 4732 | - protected $currentFileInfo; |
|
| 4733 | - public $type = 'Call'; |
|
| 4729 | + protected $name; |
|
| 4730 | + protected $args; |
|
| 4731 | + protected $index; |
|
| 4732 | + protected $currentFileInfo; |
|
| 4733 | + public $type = 'Call'; |
|
| 4734 | 4734 | |
| 4735 | 4735 | public function __construct($name, $args, $index, $currentFileInfo = null ){ |
| 4736 | 4736 | $this->name = $name; |
@@ -4739,23 +4739,23 @@ discard block |
||
| 4739 | 4739 | $this->currentFileInfo = $currentFileInfo; |
| 4740 | 4740 | } |
| 4741 | 4741 | |
| 4742 | - public function accept( $visitor ){ |
|
| 4742 | + public function accept( $visitor ){ |
|
| 4743 | 4743 | $this->args = $visitor->visitArray( $this->args ); |
| 4744 | 4744 | } |
| 4745 | 4745 | |
| 4746 | - // |
|
| 4747 | - // When evaluating a function call, |
|
| 4748 | - // we either find the function in `tree.functions` [1], |
|
| 4749 | - // in which case we call it, passing the evaluated arguments, |
|
| 4750 | - // or we simply print it out as it appeared originally [2]. |
|
| 4751 | - // |
|
| 4752 | - // The *functions.js* file contains the built-in functions. |
|
| 4753 | - // |
|
| 4754 | - // The reason why we evaluate the arguments, is in the case where |
|
| 4755 | - // we try to pass a variable to a function, like: `saturate(@color)`. |
|
| 4756 | - // The function should receive the value, not the variable. |
|
| 4757 | - // |
|
| 4758 | - public function compile($env=null){ |
|
| 4746 | + // |
|
| 4747 | + // When evaluating a function call, |
|
| 4748 | + // we either find the function in `tree.functions` [1], |
|
| 4749 | + // in which case we call it, passing the evaluated arguments, |
|
| 4750 | + // or we simply print it out as it appeared originally [2]. |
|
| 4751 | + // |
|
| 4752 | + // The *functions.js* file contains the built-in functions. |
|
| 4753 | + // |
|
| 4754 | + // The reason why we evaluate the arguments, is in the case where |
|
| 4755 | + // we try to pass a variable to a function, like: `saturate(@color)`. |
|
| 4756 | + // The function should receive the value, not the variable. |
|
| 4757 | + // |
|
| 4758 | + public function compile($env=null){ |
|
| 4759 | 4759 | $args = array(); |
| 4760 | 4760 | foreach($this->args as $a){ |
| 4761 | 4761 | $args[] = $a->compile($env); |
@@ -4810,11 +4810,11 @@ discard block |
||
| 4810 | 4810 | |
| 4811 | 4811 | |
| 4812 | 4812 | return new Less_Tree_Call( $this->name, $args, $this->index, $this->currentFileInfo ); |
| 4813 | - } |
|
| 4813 | + } |
|
| 4814 | 4814 | |
| 4815 | - /** |
|
| 4816 | - * @see Less_Tree::genCSS |
|
| 4817 | - */ |
|
| 4815 | + /** |
|
| 4816 | + * @see Less_Tree::genCSS |
|
| 4817 | + */ |
|
| 4818 | 4818 | public function genCSS( $output ){ |
| 4819 | 4819 | |
| 4820 | 4820 | $output->add( $this->name . '(', $this->currentFileInfo, $this->index ); |
@@ -4830,9 +4830,9 @@ discard block |
||
| 4830 | 4830 | } |
| 4831 | 4831 | |
| 4832 | 4832 | |
| 4833 | - //public function toCSS(){ |
|
| 4834 | - // return $this->compile()->toCSS(); |
|
| 4835 | - //} |
|
| 4833 | + //public function toCSS(){ |
|
| 4834 | + // return $this->compile()->toCSS(); |
|
| 4835 | + //} |
|
| 4836 | 4836 | |
| 4837 | 4837 | } |
| 4838 | 4838 | |
@@ -4985,7 +4985,7 @@ discard block |
||
| 4985 | 4985 | } |
| 4986 | 4986 | |
| 4987 | 4987 | //Adapted from http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript |
| 4988 | - public function toHSV() { |
|
| 4988 | + public function toHSV() { |
|
| 4989 | 4989 | $r = $this->rgb[0] / 255; |
| 4990 | 4990 | $g = $this->rgb[1] / 255; |
| 4991 | 4991 | $b = $this->rgb[2] / 255; |
@@ -5033,7 +5033,7 @@ discard block |
||
| 5033 | 5033 | $x->alpha === $this->alpha) ? 0 : -1; |
| 5034 | 5034 | } |
| 5035 | 5035 | |
| 5036 | - public function toHex( $v ){ |
|
| 5036 | + public function toHex( $v ){ |
|
| 5037 | 5037 | |
| 5038 | 5038 | $ret = '#'; |
| 5039 | 5039 | foreach($v as $c){ |
@@ -5087,9 +5087,9 @@ discard block |
||
| 5087 | 5087 | $this->currentFileInfo = $currentFileInfo; |
| 5088 | 5088 | } |
| 5089 | 5089 | |
| 5090 | - /** |
|
| 5091 | - * @see Less_Tree::genCSS |
|
| 5092 | - */ |
|
| 5090 | + /** |
|
| 5091 | + * @see Less_Tree::genCSS |
|
| 5092 | + */ |
|
| 5093 | 5093 | public function genCSS( $output ){ |
| 5094 | 5094 | //if( $this->debugInfo ){ |
| 5095 | 5095 | //$output->add( tree.debugInfo($env, $this), $this->currentFileInfo, $this->index); |
@@ -5146,7 +5146,7 @@ discard block |
||
| 5146 | 5146 | $this->rvalue = $visitor->visitObj( $this->rvalue ); |
| 5147 | 5147 | } |
| 5148 | 5148 | |
| 5149 | - public function compile($env) { |
|
| 5149 | + public function compile($env) { |
|
| 5150 | 5150 | $a = $this->lvalue->compile($env); |
| 5151 | 5151 | $b = $this->rvalue->compile($env); |
| 5152 | 5152 | |
@@ -5185,7 +5185,7 @@ discard block |
||
| 5185 | 5185 | } |
| 5186 | 5186 | |
| 5187 | 5187 | return $this->negate ? !$result : $result; |
| 5188 | - } |
|
| 5188 | + } |
|
| 5189 | 5189 | |
| 5190 | 5190 | } |
| 5191 | 5191 | |
@@ -5201,7 +5201,7 @@ discard block |
||
| 5201 | 5201 | static $error_; |
| 5202 | 5202 | static $value_; |
| 5203 | 5203 | |
| 5204 | - public static function compile(){ |
|
| 5204 | + public static function compile(){ |
|
| 5205 | 5205 | if( self::$error_ ){ |
| 5206 | 5206 | throw new Exception(self::$error_); |
| 5207 | 5207 | } |
@@ -5210,15 +5210,15 @@ discard block |
||
| 5210 | 5210 | } |
| 5211 | 5211 | } |
| 5212 | 5212 | |
| 5213 | - public static function value( $v ){ |
|
| 5213 | + public static function value( $v ){ |
|
| 5214 | 5214 | self::$value_ = $v; |
| 5215 | 5215 | } |
| 5216 | 5216 | |
| 5217 | - public static function error( $e ){ |
|
| 5217 | + public static function error( $e ){ |
|
| 5218 | 5218 | self::$error_ = $e; |
| 5219 | 5219 | } |
| 5220 | 5220 | |
| 5221 | - public static function reset(){ |
|
| 5221 | + public static function reset(){ |
|
| 5222 | 5222 | self::$value_ = self::$error_ = null; |
| 5223 | 5223 | } |
| 5224 | 5224 | } |
@@ -5235,16 +5235,16 @@ discard block |
||
| 5235 | 5235 | public $frames; |
| 5236 | 5236 | public $type = 'DetachedRuleset'; |
| 5237 | 5237 | |
| 5238 | - public function __construct( $ruleset, $frames = null ){ |
|
| 5238 | + public function __construct( $ruleset, $frames = null ){ |
|
| 5239 | 5239 | $this->ruleset = $ruleset; |
| 5240 | 5240 | $this->frames = $frames; |
| 5241 | 5241 | } |
| 5242 | 5242 | |
| 5243 | - public function accept($visitor) { |
|
| 5243 | + public function accept($visitor) { |
|
| 5244 | 5244 | $this->ruleset = $visitor->visitObj($this->ruleset); |
| 5245 | 5245 | } |
| 5246 | 5246 | |
| 5247 | - public function compile($env){ |
|
| 5247 | + public function compile($env){ |
|
| 5248 | 5248 | if( $this->frames ){ |
| 5249 | 5249 | $frames = $this->frames; |
| 5250 | 5250 | }else{ |
@@ -5253,7 +5253,7 @@ discard block |
||
| 5253 | 5253 | return new Less_Tree_DetachedRuleset($this->ruleset, $frames); |
| 5254 | 5254 | } |
| 5255 | 5255 | |
| 5256 | - public function callEval($env) { |
|
| 5256 | + public function callEval($env) { |
|
| 5257 | 5257 | if( $this->frames ){ |
| 5258 | 5258 | return $this->ruleset->compile( $env->copyEvalEnv( array_merge($this->frames,$env->frames) ) ); |
| 5259 | 5259 | } |
@@ -5275,8 +5275,8 @@ discard block |
||
| 5275 | 5275 | public $unit; |
| 5276 | 5276 | public $type = 'Dimension'; |
| 5277 | 5277 | |
| 5278 | - public function __construct($value, $unit = null){ |
|
| 5279 | - $this->value = floatval($value); |
|
| 5278 | + public function __construct($value, $unit = null){ |
|
| 5279 | + $this->value = floatval($value); |
|
| 5280 | 5280 | |
| 5281 | 5281 | if( $unit && ($unit instanceof Less_Tree_Unit) ){ |
| 5282 | 5282 | $this->unit = $unit; |
@@ -5285,23 +5285,23 @@ discard block |
||
| 5285 | 5285 | }else{ |
| 5286 | 5286 | $this->unit = new Less_Tree_Unit( ); |
| 5287 | 5287 | } |
| 5288 | - } |
|
| 5288 | + } |
|
| 5289 | 5289 | |
| 5290 | - public function accept( $visitor ){ |
|
| 5290 | + public function accept( $visitor ){ |
|
| 5291 | 5291 | $this->unit = $visitor->visitObj( $this->unit ); |
| 5292 | 5292 | } |
| 5293 | 5293 | |
| 5294 | - public function compile(){ |
|
| 5295 | - return $this; |
|
| 5296 | - } |
|
| 5294 | + public function compile(){ |
|
| 5295 | + return $this; |
|
| 5296 | + } |
|
| 5297 | 5297 | |
| 5298 | - public function toColor() { |
|
| 5299 | - return new Less_Tree_Color(array($this->value, $this->value, $this->value)); |
|
| 5300 | - } |
|
| 5298 | + public function toColor() { |
|
| 5299 | + return new Less_Tree_Color(array($this->value, $this->value, $this->value)); |
|
| 5300 | + } |
|
| 5301 | 5301 | |
| 5302 | - /** |
|
| 5303 | - * @see Less_Tree::genCSS |
|
| 5304 | - */ |
|
| 5302 | + /** |
|
| 5303 | + * @see Less_Tree::genCSS |
|
| 5304 | + */ |
|
| 5305 | 5305 | public function genCSS( $output ){ |
| 5306 | 5306 | |
| 5307 | 5307 | if( Less_Parser::$options['strictUnits'] && !$this->unit->isSingular() ){ |
@@ -5334,18 +5334,18 @@ discard block |
||
| 5334 | 5334 | $this->unit->genCSS( $output ); |
| 5335 | 5335 | } |
| 5336 | 5336 | |
| 5337 | - public function __toString(){ |
|
| 5338 | - return $this->toCSS(); |
|
| 5339 | - } |
|
| 5337 | + public function __toString(){ |
|
| 5338 | + return $this->toCSS(); |
|
| 5339 | + } |
|
| 5340 | 5340 | |
| 5341 | - // In an operation between two Dimensions, |
|
| 5342 | - // we default to the first Dimension's unit, |
|
| 5343 | - // so `1px + 2em` will yield `3px`. |
|
| 5341 | + // In an operation between two Dimensions, |
|
| 5342 | + // we default to the first Dimension's unit, |
|
| 5343 | + // so `1px + 2em` will yield `3px`. |
|
| 5344 | 5344 | |
| 5345 | - /** |
|
| 5346 | - * @param string $op |
|
| 5347 | - */ |
|
| 5348 | - public function operate( $op, $other){ |
|
| 5345 | + /** |
|
| 5346 | + * @param string $op |
|
| 5347 | + */ |
|
| 5348 | + public function operate( $op, $other){ |
|
| 5349 | 5349 | |
| 5350 | 5350 | $value = Less_Functions::operate( $op, $this->value, $other->value); |
| 5351 | 5351 | $unit = clone $this->unit; |
@@ -5380,7 +5380,7 @@ discard block |
||
| 5380 | 5380 | $unit->cancel(); |
| 5381 | 5381 | } |
| 5382 | 5382 | return new Less_Tree_Dimension( $value, $unit); |
| 5383 | - } |
|
| 5383 | + } |
|
| 5384 | 5384 | |
| 5385 | 5385 | public function compare($other) { |
| 5386 | 5386 | if ($other instanceof Less_Tree_Dimension) { |
@@ -5410,11 +5410,11 @@ discard block |
||
| 5410 | 5410 | } |
| 5411 | 5411 | } |
| 5412 | 5412 | |
| 5413 | - public function unify() { |
|
| 5413 | + public function unify() { |
|
| 5414 | 5414 | return $this->convertTo(array('length'=> 'px', 'duration'=> 's', 'angle' => 'rad' )); |
| 5415 | 5415 | } |
| 5416 | 5416 | |
| 5417 | - public function convertTo($conversions) { |
|
| 5417 | + public function convertTo($conversions) { |
|
| 5418 | 5418 | $value = $this->value; |
| 5419 | 5419 | $unit = clone $this->unit; |
| 5420 | 5420 | |
@@ -5460,7 +5460,7 @@ discard block |
||
| 5460 | 5460 | $unit->cancel(); |
| 5461 | 5461 | |
| 5462 | 5462 | return new Less_Tree_Dimension( $value, $unit); |
| 5463 | - } |
|
| 5463 | + } |
|
| 5464 | 5464 | } |
| 5465 | 5465 | |
| 5466 | 5466 | |
@@ -5495,7 +5495,7 @@ discard block |
||
| 5495 | 5495 | } |
| 5496 | 5496 | |
| 5497 | 5497 | |
| 5498 | - public function accept( $visitor ){ |
|
| 5498 | + public function accept( $visitor ){ |
|
| 5499 | 5499 | if( $this->rules ){ |
| 5500 | 5500 | $this->rules = $visitor->visitObj( $this->rules ); |
| 5501 | 5501 | } |
@@ -5505,10 +5505,10 @@ discard block |
||
| 5505 | 5505 | } |
| 5506 | 5506 | |
| 5507 | 5507 | |
| 5508 | - /** |
|
| 5509 | - * @see Less_Tree::genCSS |
|
| 5510 | - */ |
|
| 5511 | - public function genCSS( $output ){ |
|
| 5508 | + /** |
|
| 5509 | + * @see Less_Tree::genCSS |
|
| 5510 | + */ |
|
| 5511 | + public function genCSS( $output ){ |
|
| 5512 | 5512 | $value = $this->value; |
| 5513 | 5513 | $rules = $this->rules; |
| 5514 | 5514 | $output->add( $this->name, $this->currentFileInfo, $this->index ); |
@@ -5593,7 +5593,7 @@ discard block |
||
| 5593 | 5593 | $this->currentFileInfo = $currentFileInfo; |
| 5594 | 5594 | } |
| 5595 | 5595 | |
| 5596 | - public function accept( $visitor ){ |
|
| 5596 | + public function accept( $visitor ){ |
|
| 5597 | 5597 | if( $this->value_is_object ){ //object or string |
| 5598 | 5598 | $this->value = $visitor->visitObj( $this->value ); |
| 5599 | 5599 | } |
@@ -5612,9 +5612,9 @@ discard block |
||
| 5612 | 5612 | return $this; |
| 5613 | 5613 | } |
| 5614 | 5614 | |
| 5615 | - /** |
|
| 5616 | - * @see Less_Tree::genCSS |
|
| 5617 | - */ |
|
| 5615 | + /** |
|
| 5616 | + * @see Less_Tree::genCSS |
|
| 5617 | + */ |
|
| 5618 | 5618 | public function genCSS( $output ){ |
| 5619 | 5619 | $output->add( $this->toCSS(), $this->currentFileInfo, $this->index ); |
| 5620 | 5620 | } |
@@ -5657,7 +5657,7 @@ discard block |
||
| 5657 | 5657 | $this->parens = $parens; |
| 5658 | 5658 | } |
| 5659 | 5659 | |
| 5660 | - public function accept( $visitor ){ |
|
| 5660 | + public function accept( $visitor ){ |
|
| 5661 | 5661 | $this->value = $visitor->visitArray( $this->value ); |
| 5662 | 5662 | } |
| 5663 | 5663 | |
@@ -5707,10 +5707,10 @@ discard block |
||
| 5707 | 5707 | return $returnValue; |
| 5708 | 5708 | } |
| 5709 | 5709 | |
| 5710 | - /** |
|
| 5711 | - * @see Less_Tree::genCSS |
|
| 5712 | - */ |
|
| 5713 | - public function genCSS( $output ){ |
|
| 5710 | + /** |
|
| 5711 | + * @see Less_Tree::genCSS |
|
| 5712 | + */ |
|
| 5713 | + public function genCSS( $output ){ |
|
| 5714 | 5714 | $val_len = count($this->value); |
| 5715 | 5715 | for( $i = 0; $i < $val_len; $i++ ){ |
| 5716 | 5716 | $this->value[$i]->genCSS( $output ); |
@@ -5720,7 +5720,7 @@ discard block |
||
| 5720 | 5720 | } |
| 5721 | 5721 | } |
| 5722 | 5722 | |
| 5723 | - public function throwAwayComments() { |
|
| 5723 | + public function throwAwayComments() { |
|
| 5724 | 5724 | |
| 5725 | 5725 | if( is_array($this->value) ){ |
| 5726 | 5726 | $new_value = array(); |
@@ -5761,7 +5761,7 @@ discard block |
||
| 5761 | 5761 | /** |
| 5762 | 5762 | * @param integer $index |
| 5763 | 5763 | */ |
| 5764 | - public function __construct($selector, $option, $index){ |
|
| 5764 | + public function __construct($selector, $option, $index){ |
|
| 5765 | 5765 | static $i = 0; |
| 5766 | 5766 | $this->selector = $selector; |
| 5767 | 5767 | $this->option = $option; |
@@ -5782,18 +5782,18 @@ discard block |
||
| 5782 | 5782 | $this->parent_ids = array($this->object_id); |
| 5783 | 5783 | } |
| 5784 | 5784 | |
| 5785 | - public function accept( $visitor ){ |
|
| 5785 | + public function accept( $visitor ){ |
|
| 5786 | 5786 | $this->selector = $visitor->visitObj( $this->selector ); |
| 5787 | 5787 | } |
| 5788 | 5788 | |
| 5789 | - public function compile( $env ){ |
|
| 5789 | + public function compile( $env ){ |
|
| 5790 | 5790 | Less_Parser::$has_extends = true; |
| 5791 | 5791 | $this->selector = $this->selector->compile($env); |
| 5792 | 5792 | return $this; |
| 5793 | 5793 | //return new Less_Tree_Extend( $this->selector->compile($env), $this->option, $this->index); |
| 5794 | 5794 | } |
| 5795 | 5795 | |
| 5796 | - public function findSelfSelectors( $selectors ){ |
|
| 5796 | + public function findSelfSelectors( $selectors ){ |
|
| 5797 | 5797 | $selfElements = array(); |
| 5798 | 5798 | |
| 5799 | 5799 | |
@@ -5839,7 +5839,7 @@ discard block |
||
| 5839 | 5839 | public $root; |
| 5840 | 5840 | public $type = 'Import'; |
| 5841 | 5841 | |
| 5842 | - public function __construct($path, $features, $options, $index, $currentFileInfo = null ){ |
|
| 5842 | + public function __construct($path, $features, $options, $index, $currentFileInfo = null ){ |
|
| 5843 | 5843 | $this->options = $options; |
| 5844 | 5844 | $this->index = $index; |
| 5845 | 5845 | $this->path = $path; |
@@ -5870,7 +5870,7 @@ discard block |
||
| 5870 | 5870 | // ruleset. |
| 5871 | 5871 | // |
| 5872 | 5872 | |
| 5873 | - public function accept($visitor){ |
|
| 5873 | + public function accept($visitor){ |
|
| 5874 | 5874 | |
| 5875 | 5875 | if( $this->features ){ |
| 5876 | 5876 | $this->features = $visitor->visitObj($this->features); |
@@ -5882,10 +5882,10 @@ discard block |
||
| 5882 | 5882 | } |
| 5883 | 5883 | } |
| 5884 | 5884 | |
| 5885 | - /** |
|
| 5886 | - * @see Less_Tree::genCSS |
|
| 5887 | - */ |
|
| 5888 | - public function genCSS( $output ){ |
|
| 5885 | + /** |
|
| 5886 | + * @see Less_Tree::genCSS |
|
| 5887 | + */ |
|
| 5888 | + public function genCSS( $output ){ |
|
| 5889 | 5889 | if( $this->css ){ |
| 5890 | 5890 | |
| 5891 | 5891 | $output->add( '@import ', $this->currentFileInfo, $this->index ); |
@@ -5899,7 +5899,7 @@ discard block |
||
| 5899 | 5899 | } |
| 5900 | 5900 | } |
| 5901 | 5901 | |
| 5902 | - public function toCSS(){ |
|
| 5902 | + public function toCSS(){ |
|
| 5903 | 5903 | $features = $this->features ? ' ' . $this->features->toCSS() : ''; |
| 5904 | 5904 | |
| 5905 | 5905 | if ($this->css) { |
@@ -5912,7 +5912,7 @@ discard block |
||
| 5912 | 5912 | /** |
| 5913 | 5913 | * @return string |
| 5914 | 5914 | */ |
| 5915 | - public function getPath(){ |
|
| 5915 | + public function getPath(){ |
|
| 5916 | 5916 | if ($this->path instanceof Less_Tree_Quoted) { |
| 5917 | 5917 | $path = $this->path->value; |
| 5918 | 5918 | $path = ( isset($this->css) || preg_match('/(\.[a-z]*$)|([\?;].*)$/',$path)) ? $path : $path . '.less'; |
@@ -5926,11 +5926,11 @@ discard block |
||
| 5926 | 5926 | return preg_replace('/[\?#][^\?]*$/','',$path); |
| 5927 | 5927 | } |
| 5928 | 5928 | |
| 5929 | - public function compileForImport( $env ){ |
|
| 5929 | + public function compileForImport( $env ){ |
|
| 5930 | 5930 | return new Less_Tree_Import( $this->path->compile($env), $this->features, $this->options, $this->index, $this->currentFileInfo); |
| 5931 | 5931 | } |
| 5932 | 5932 | |
| 5933 | - public function compilePath($env) { |
|
| 5933 | + public function compilePath($env) { |
|
| 5934 | 5934 | $path = $this->path->compile($env); |
| 5935 | 5935 | $rootpath = ''; |
| 5936 | 5936 | if( $this->currentFileInfo && $this->currentFileInfo['rootpath'] ){ |
@@ -5954,7 +5954,7 @@ discard block |
||
| 5954 | 5954 | return $path; |
| 5955 | 5955 | } |
| 5956 | 5956 | |
| 5957 | - public function compile( $env ){ |
|
| 5957 | + public function compile( $env ){ |
|
| 5958 | 5958 | |
| 5959 | 5959 | $evald = $this->compileForImport($env); |
| 5960 | 5960 | |
@@ -6011,7 +6011,7 @@ discard block |
||
| 6011 | 6011 | * |
| 6012 | 6012 | * @param Less_Tree_Import $evald |
| 6013 | 6013 | */ |
| 6014 | - public function PathAndUri(){ |
|
| 6014 | + public function PathAndUri(){ |
|
| 6015 | 6015 | |
| 6016 | 6016 | $evald_path = $this->getPath(); |
| 6017 | 6017 | |
@@ -6074,7 +6074,7 @@ discard block |
||
| 6074 | 6074 | * |
| 6075 | 6075 | * @return Less_Tree_Media|array |
| 6076 | 6076 | */ |
| 6077 | - public function ParseImport( $full_path, $uri, $env ){ |
|
| 6077 | + public function ParseImport( $full_path, $uri, $env ){ |
|
| 6078 | 6078 | |
| 6079 | 6079 | $import_env = clone $env; |
| 6080 | 6080 | if( (isset($this->options['reference']) && $this->options['reference']) || isset($this->currentFileInfo['reference']) ){ |
@@ -6171,9 +6171,9 @@ discard block |
||
| 6171 | 6171 | return $this; |
| 6172 | 6172 | } |
| 6173 | 6173 | |
| 6174 | - /** |
|
| 6175 | - * @see Less_Tree::genCSS |
|
| 6176 | - */ |
|
| 6174 | + /** |
|
| 6175 | + * @see Less_Tree::genCSS |
|
| 6176 | + */ |
|
| 6177 | 6177 | public function genCSS( $output ){ |
| 6178 | 6178 | |
| 6179 | 6179 | if( $this->value === '%') { |
@@ -6221,15 +6221,15 @@ discard block |
||
| 6221 | 6221 | $this->rules[0]->allowImports = true; |
| 6222 | 6222 | } |
| 6223 | 6223 | |
| 6224 | - public function accept( $visitor ){ |
|
| 6224 | + public function accept( $visitor ){ |
|
| 6225 | 6225 | $this->features = $visitor->visitObj($this->features); |
| 6226 | 6226 | $this->rules = $visitor->visitArray($this->rules); |
| 6227 | 6227 | } |
| 6228 | 6228 | |
| 6229 | - /** |
|
| 6230 | - * @see Less_Tree::genCSS |
|
| 6231 | - */ |
|
| 6232 | - public function genCSS( $output ){ |
|
| 6229 | + /** |
|
| 6230 | + * @see Less_Tree::genCSS |
|
| 6231 | + */ |
|
| 6232 | + public function genCSS( $output ){ |
|
| 6233 | 6233 | |
| 6234 | 6234 | $output->add( '@media ', $this->currentFileInfo, $this->index ); |
| 6235 | 6235 | $this->features->genCSS( $output ); |
@@ -6277,7 +6277,7 @@ discard block |
||
| 6277 | 6277 | $el = new Less_Tree_Element('','&', $this->index, $this->currentFileInfo ); |
| 6278 | 6278 | $sels = array( new Less_Tree_Selector(array($el), array(), null, $this->index, $this->currentFileInfo) ); |
| 6279 | 6279 | $sels[0]->mediaEmpty = true; |
| 6280 | - return $sels; |
|
| 6280 | + return $sels; |
|
| 6281 | 6281 | } |
| 6282 | 6282 | |
| 6283 | 6283 | public function markReferenced(){ |
@@ -6362,7 +6362,7 @@ discard block |
||
| 6362 | 6362 | return $result; |
| 6363 | 6363 | } |
| 6364 | 6364 | |
| 6365 | - public function bubbleSelectors($selectors) { |
|
| 6365 | + public function bubbleSelectors($selectors) { |
|
| 6366 | 6366 | |
| 6367 | 6367 | if( !$selectors) return; |
| 6368 | 6368 | |
@@ -6397,7 +6397,7 @@ discard block |
||
| 6397 | 6397 | $this->currentFileInfo = $currentFileInfo; |
| 6398 | 6398 | } |
| 6399 | 6399 | |
| 6400 | - public function genCSS( $output ){ |
|
| 6400 | + public function genCSS( $output ){ |
|
| 6401 | 6401 | |
| 6402 | 6402 | $output->add( |
| 6403 | 6403 | $this->name |
@@ -6424,7 +6424,7 @@ discard block |
||
| 6424 | 6424 | public $value; |
| 6425 | 6425 | public $type = 'Negative'; |
| 6426 | 6426 | |
| 6427 | - public function __construct($node){ |
|
| 6427 | + public function __construct($node){ |
|
| 6428 | 6428 | $this->value = $node; |
| 6429 | 6429 | } |
| 6430 | 6430 | |
@@ -6432,15 +6432,15 @@ discard block |
||
| 6432 | 6432 | // $this->value = $visitor->visit($this->value); |
| 6433 | 6433 | //} |
| 6434 | 6434 | |
| 6435 | - /** |
|
| 6436 | - * @see Less_Tree::genCSS |
|
| 6437 | - */ |
|
| 6438 | - public function genCSS( $output ){ |
|
| 6435 | + /** |
|
| 6436 | + * @see Less_Tree::genCSS |
|
| 6437 | + */ |
|
| 6438 | + public function genCSS( $output ){ |
|
| 6439 | 6439 | $output->add( '-' ); |
| 6440 | 6440 | $this->value->genCSS( $output ); |
| 6441 | 6441 | } |
| 6442 | 6442 | |
| 6443 | - public function compile($env) { |
|
| 6443 | + public function compile($env) { |
|
| 6444 | 6444 | if( Less_Environment::isMathOn() ){ |
| 6445 | 6445 | $ret = new Less_Tree_Operation('*', array( new Less_Tree_Dimension(-1), $this->value ) ); |
| 6446 | 6446 | return $ret->compile($env); |
@@ -6471,7 +6471,7 @@ discard block |
||
| 6471 | 6471 | $this->isSpaced = $isSpaced; |
| 6472 | 6472 | } |
| 6473 | 6473 | |
| 6474 | - public function accept($visitor) { |
|
| 6474 | + public function accept($visitor) { |
|
| 6475 | 6475 | $this->operands = $visitor->visitArray($this->operands); |
| 6476 | 6476 | } |
| 6477 | 6477 | |
@@ -6501,10 +6501,10 @@ discard block |
||
| 6501 | 6501 | } |
| 6502 | 6502 | |
| 6503 | 6503 | |
| 6504 | - /** |
|
| 6505 | - * @see Less_Tree::genCSS |
|
| 6506 | - */ |
|
| 6507 | - public function genCSS( $output ){ |
|
| 6504 | + /** |
|
| 6505 | + * @see Less_Tree::genCSS |
|
| 6506 | + */ |
|
| 6507 | + public function genCSS( $output ){ |
|
| 6508 | 6508 | $this->operands[0]->genCSS( $output ); |
| 6509 | 6509 | if( $this->isSpaced ){ |
| 6510 | 6510 | $output->add( " " ); |
@@ -6534,14 +6534,14 @@ discard block |
||
| 6534 | 6534 | $this->value = $value; |
| 6535 | 6535 | } |
| 6536 | 6536 | |
| 6537 | - public function accept($visitor){ |
|
| 6537 | + public function accept($visitor){ |
|
| 6538 | 6538 | $this->value = $visitor->visitObj($this->value); |
| 6539 | 6539 | } |
| 6540 | 6540 | |
| 6541 | - /** |
|
| 6542 | - * @see Less_Tree::genCSS |
|
| 6543 | - */ |
|
| 6544 | - public function genCSS( $output ){ |
|
| 6541 | + /** |
|
| 6542 | + * @see Less_Tree::genCSS |
|
| 6543 | + */ |
|
| 6544 | + public function genCSS( $output ){ |
|
| 6545 | 6545 | $output->add( '(' ); |
| 6546 | 6546 | $this->value->genCSS( $output ); |
| 6547 | 6547 | $output->add( ')' ); |
@@ -6581,18 +6581,18 @@ discard block |
||
| 6581 | 6581 | $this->currentFileInfo = $currentFileInfo; |
| 6582 | 6582 | } |
| 6583 | 6583 | |
| 6584 | - /** |
|
| 6585 | - * @see Less_Tree::genCSS |
|
| 6586 | - */ |
|
| 6587 | - public function genCSS( $output ){ |
|
| 6584 | + /** |
|
| 6585 | + * @see Less_Tree::genCSS |
|
| 6586 | + */ |
|
| 6587 | + public function genCSS( $output ){ |
|
| 6588 | 6588 | if( !$this->escaped ){ |
| 6589 | 6589 | $output->add( $this->quote, $this->currentFileInfo, $this->index ); |
| 6590 | - } |
|
| 6591 | - $output->add( $this->value ); |
|
| 6592 | - if( !$this->escaped ){ |
|
| 6590 | + } |
|
| 6591 | + $output->add( $this->value ); |
|
| 6592 | + if( !$this->escaped ){ |
|
| 6593 | 6593 | $output->add( $this->quote ); |
| 6594 | - } |
|
| 6595 | - } |
|
| 6594 | + } |
|
| 6595 | + } |
|
| 6596 | 6596 | |
| 6597 | 6597 | public function compile($env){ |
| 6598 | 6598 | |
@@ -6617,7 +6617,7 @@ discard block |
||
| 6617 | 6617 | return new Less_Tree_Quoted($this->quote . $value . $this->quote, $value, $this->escaped, $this->index, $this->currentFileInfo); |
| 6618 | 6618 | } |
| 6619 | 6619 | |
| 6620 | - public function compare($x) { |
|
| 6620 | + public function compare($x) { |
|
| 6621 | 6621 | |
| 6622 | 6622 | if( !Less_Parser::is_method($x, 'toCSS') ){ |
| 6623 | 6623 | return -1; |
@@ -6667,14 +6667,14 @@ discard block |
||
| 6667 | 6667 | $this->variable = ( is_string($name) && $name[0] === '@'); |
| 6668 | 6668 | } |
| 6669 | 6669 | |
| 6670 | - public function accept($visitor) { |
|
| 6670 | + public function accept($visitor) { |
|
| 6671 | 6671 | $this->value = $visitor->visitObj( $this->value ); |
| 6672 | 6672 | } |
| 6673 | 6673 | |
| 6674 | - /** |
|
| 6675 | - * @see Less_Tree::genCSS |
|
| 6676 | - */ |
|
| 6677 | - public function genCSS( $output ){ |
|
| 6674 | + /** |
|
| 6675 | + * @see Less_Tree::genCSS |
|
| 6676 | + */ |
|
| 6677 | + public function genCSS( $output ){ |
|
| 6678 | 6678 | |
| 6679 | 6679 | $output->add( $this->name . Less_Environment::$_outputMap[': '], $this->currentFileInfo, $this->index); |
| 6680 | 6680 | try{ |
@@ -6735,7 +6735,7 @@ discard block |
||
| 6735 | 6735 | } |
| 6736 | 6736 | |
| 6737 | 6737 | |
| 6738 | - public function CompileName( $env, $name ){ |
|
| 6738 | + public function CompileName( $env, $name ){ |
|
| 6739 | 6739 | $output = new Less_Output(); |
| 6740 | 6740 | foreach($name as $n){ |
| 6741 | 6741 | $n->compile($env)->genCSS($output); |
@@ -6743,7 +6743,7 @@ discard block |
||
| 6743 | 6743 | return $output->toString(); |
| 6744 | 6744 | } |
| 6745 | 6745 | |
| 6746 | - public function makeImportant(){ |
|
| 6746 | + public function makeImportant(){ |
|
| 6747 | 6747 | return new Less_Tree_Rule($this->name, $this->value, '!important', $this->merge, $this->index, $this->currentFileInfo, $this->inline); |
| 6748 | 6748 | } |
| 6749 | 6749 | |
@@ -6845,14 +6845,14 @@ discard block |
||
| 6845 | 6845 | } |
| 6846 | 6846 | } |
| 6847 | 6847 | |
| 6848 | - // Evaluate everything else |
|
| 6848 | + // Evaluate everything else |
|
| 6849 | 6849 | for( $i=0; $i<$rsRuleCnt; $i++ ){ |
| 6850 | 6850 | $rule = $ruleset->rules[$i]; |
| 6851 | 6851 | |
| 6852 | - // for rulesets, check if it is a css guard and can be removed |
|
| 6852 | + // for rulesets, check if it is a css guard and can be removed |
|
| 6853 | 6853 | if( $rule instanceof Less_Tree_Ruleset && $rule->selectors && count($rule->selectors) === 1 ){ |
| 6854 | 6854 | |
| 6855 | - // check if it can be folded in (e.g. & where) |
|
| 6855 | + // check if it can be folded in (e.g. & where) |
|
| 6856 | 6856 | if( $rule->selectors[0]->isJustParentSelector() ){ |
| 6857 | 6857 | array_splice($ruleset->rules,$i--,1); |
| 6858 | 6858 | $rsRuleCnt--; |
@@ -6865,9 +6865,9 @@ discard block |
||
| 6865 | 6865 | } |
| 6866 | 6866 | } |
| 6867 | 6867 | |
| 6868 | - } |
|
| 6869 | - } |
|
| 6870 | - } |
|
| 6868 | + } |
|
| 6869 | + } |
|
| 6870 | + } |
|
| 6871 | 6871 | |
| 6872 | 6872 | |
| 6873 | 6873 | // Pop the stack |
@@ -7404,13 +7404,13 @@ discard block |
||
| 7404 | 7404 | public $variable; |
| 7405 | 7405 | public $type = "RulesetCall"; |
| 7406 | 7406 | |
| 7407 | - public function __construct($variable){ |
|
| 7407 | + public function __construct($variable){ |
|
| 7408 | 7408 | $this->variable = $variable; |
| 7409 | 7409 | } |
| 7410 | 7410 | |
| 7411 | - public function accept($visitor) {} |
|
| 7411 | + public function accept($visitor) {} |
|
| 7412 | 7412 | |
| 7413 | - public function compile( $env ){ |
|
| 7413 | + public function compile( $env ){ |
|
| 7414 | 7414 | $variable = new Less_Tree_Variable($this->variable); |
| 7415 | 7415 | $detachedRuleset = $variable->compile($env); |
| 7416 | 7416 | return $detachedRuleset->callEval($env); |
@@ -7464,7 +7464,7 @@ discard block |
||
| 7464 | 7464 | $this->CacheElements(); |
| 7465 | 7465 | } |
| 7466 | 7466 | |
| 7467 | - public function accept($visitor) { |
|
| 7467 | + public function accept($visitor) { |
|
| 7468 | 7468 | $this->elements = $visitor->visitArray($this->elements); |
| 7469 | 7469 | $this->extendList = $visitor->visitArray($this->extendList); |
| 7470 | 7470 | if( $this->condition ){ |
@@ -7476,7 +7476,7 @@ discard block |
||
| 7476 | 7476 | } |
| 7477 | 7477 | } |
| 7478 | 7478 | |
| 7479 | - public function createDerived( $elements, $extendList = null, $evaldCondition = null ){ |
|
| 7479 | + public function createDerived( $elements, $extendList = null, $evaldCondition = null ){ |
|
| 7480 | 7480 | $newSelector = new Less_Tree_Selector( $elements, ($extendList ? $extendList : $this->extendList), null, $this->index, $this->currentFileInfo, $this->isReferenced); |
| 7481 | 7481 | $newSelector->evaldCondition = $evaldCondition ? $evaldCondition : $this->evaldCondition; |
| 7482 | 7482 | return $newSelector; |
@@ -7561,7 +7561,7 @@ discard block |
||
| 7561 | 7561 | /** |
| 7562 | 7562 | * @see Less_Tree::genCSS |
| 7563 | 7563 | */ |
| 7564 | - public function genCSS( $output, $firstSelector = true ){ |
|
| 7564 | + public function genCSS( $output, $firstSelector = true ){ |
|
| 7565 | 7565 | |
| 7566 | 7566 | if( !$firstSelector && $this->elements[0]->combinator === "" ){ |
| 7567 | 7567 | $output->add(' ', $this->currentFileInfo, $this->index); |
@@ -7572,15 +7572,15 @@ discard block |
||
| 7572 | 7572 | } |
| 7573 | 7573 | } |
| 7574 | 7574 | |
| 7575 | - public function markReferenced(){ |
|
| 7575 | + public function markReferenced(){ |
|
| 7576 | 7576 | $this->isReferenced = true; |
| 7577 | 7577 | } |
| 7578 | 7578 | |
| 7579 | - public function getIsReferenced(){ |
|
| 7579 | + public function getIsReferenced(){ |
|
| 7580 | 7580 | return !isset($this->currentFileInfo['reference']) || !$this->currentFileInfo['reference'] || $this->isReferenced; |
| 7581 | 7581 | } |
| 7582 | 7582 | |
| 7583 | - public function getIsOutput(){ |
|
| 7583 | + public function getIsOutput(){ |
|
| 7584 | 7584 | return $this->evaldCondition; |
| 7585 | 7585 | } |
| 7586 | 7586 | |
@@ -7602,9 +7602,9 @@ discard block |
||
| 7602 | 7602 | $this->value = $value; |
| 7603 | 7603 | } |
| 7604 | 7604 | |
| 7605 | - /** |
|
| 7606 | - * @see Less_Tree::genCSS |
|
| 7607 | - */ |
|
| 7605 | + /** |
|
| 7606 | + * @see Less_Tree::genCSS |
|
| 7607 | + */ |
|
| 7608 | 7608 | public function genCSS( $output ){ |
| 7609 | 7609 | $output->add( $this->value ); |
| 7610 | 7610 | } |
@@ -7629,19 +7629,19 @@ discard block |
||
| 7629 | 7629 | public $backupUnit; |
| 7630 | 7630 | public $type = 'Unit'; |
| 7631 | 7631 | |
| 7632 | - public function __construct($numerator = array(), $denominator = array(), $backupUnit = null ){ |
|
| 7632 | + public function __construct($numerator = array(), $denominator = array(), $backupUnit = null ){ |
|
| 7633 | 7633 | $this->numerator = $numerator; |
| 7634 | 7634 | $this->denominator = $denominator; |
| 7635 | 7635 | $this->backupUnit = $backupUnit; |
| 7636 | 7636 | } |
| 7637 | 7637 | |
| 7638 | - public function __clone(){ |
|
| 7638 | + public function __clone(){ |
|
| 7639 | 7639 | } |
| 7640 | 7640 | |
| 7641 | - /** |
|
| 7642 | - * @see Less_Tree::genCSS |
|
| 7643 | - */ |
|
| 7644 | - public function genCSS( $output ){ |
|
| 7641 | + /** |
|
| 7642 | + * @see Less_Tree::genCSS |
|
| 7643 | + */ |
|
| 7644 | + public function genCSS( $output ){ |
|
| 7645 | 7645 | |
| 7646 | 7646 | if( $this->numerator ){ |
| 7647 | 7647 | $output->add( $this->numerator[0] ); |
@@ -7653,7 +7653,7 @@ discard block |
||
| 7653 | 7653 | } |
| 7654 | 7654 | } |
| 7655 | 7655 | |
| 7656 | - public function toString(){ |
|
| 7656 | + public function toString(){ |
|
| 7657 | 7657 | $returnStr = implode('*',$this->numerator); |
| 7658 | 7658 | foreach($this->denominator as $d){ |
| 7659 | 7659 | $returnStr .= '/'.$d; |
@@ -7661,7 +7661,7 @@ discard block |
||
| 7661 | 7661 | return $returnStr; |
| 7662 | 7662 | } |
| 7663 | 7663 | |
| 7664 | - public function __toString(){ |
|
| 7664 | + public function __toString(){ |
|
| 7665 | 7665 | return $this->toString(); |
| 7666 | 7666 | } |
| 7667 | 7667 | |
@@ -7669,33 +7669,33 @@ discard block |
||
| 7669 | 7669 | /** |
| 7670 | 7670 | * @param Less_Tree_Unit $other |
| 7671 | 7671 | */ |
| 7672 | - public function compare($other) { |
|
| 7672 | + public function compare($other) { |
|
| 7673 | 7673 | return $this->is( $other->toString() ) ? 0 : -1; |
| 7674 | 7674 | } |
| 7675 | 7675 | |
| 7676 | - public function is($unitString){ |
|
| 7676 | + public function is($unitString){ |
|
| 7677 | 7677 | return $this->toString() === $unitString; |
| 7678 | 7678 | } |
| 7679 | 7679 | |
| 7680 | - public function isLength(){ |
|
| 7680 | + public function isLength(){ |
|
| 7681 | 7681 | $css = $this->toCSS(); |
| 7682 | 7682 | return !!preg_match('/px|em|%|in|cm|mm|pc|pt|ex/',$css); |
| 7683 | 7683 | } |
| 7684 | 7684 | |
| 7685 | - public function isAngle() { |
|
| 7685 | + public function isAngle() { |
|
| 7686 | 7686 | return isset( Less_Tree_UnitConversions::$angle[$this->toCSS()] ); |
| 7687 | 7687 | } |
| 7688 | 7688 | |
| 7689 | - public function isEmpty(){ |
|
| 7689 | + public function isEmpty(){ |
|
| 7690 | 7690 | return !$this->numerator && !$this->denominator; |
| 7691 | 7691 | } |
| 7692 | 7692 | |
| 7693 | - public function isSingular() { |
|
| 7693 | + public function isSingular() { |
|
| 7694 | 7694 | return count($this->numerator) <= 1 && !$this->denominator; |
| 7695 | 7695 | } |
| 7696 | 7696 | |
| 7697 | 7697 | |
| 7698 | - public function usedUnits(){ |
|
| 7698 | + public function usedUnits(){ |
|
| 7699 | 7699 | $result = array(); |
| 7700 | 7700 | |
| 7701 | 7701 | foreach(Less_Tree_UnitConversions::$groups as $groupName){ |
@@ -7717,7 +7717,7 @@ discard block |
||
| 7717 | 7717 | return $result; |
| 7718 | 7718 | } |
| 7719 | 7719 | |
| 7720 | - public function cancel(){ |
|
| 7720 | + public function cancel(){ |
|
| 7721 | 7721 | $counter = array(); |
| 7722 | 7722 | $backup = null; |
| 7723 | 7723 | |
@@ -7817,14 +7817,14 @@ discard block |
||
| 7817 | 7817 | $this->isEvald = $isEvald; |
| 7818 | 7818 | } |
| 7819 | 7819 | |
| 7820 | - public function accept( $visitor ){ |
|
| 7820 | + public function accept( $visitor ){ |
|
| 7821 | 7821 | $this->value = $visitor->visitObj($this->value); |
| 7822 | 7822 | } |
| 7823 | 7823 | |
| 7824 | - /** |
|
| 7825 | - * @see Less_Tree::genCSS |
|
| 7826 | - */ |
|
| 7827 | - public function genCSS( $output ){ |
|
| 7824 | + /** |
|
| 7825 | + * @see Less_Tree::genCSS |
|
| 7826 | + */ |
|
| 7827 | + public function genCSS( $output ){ |
|
| 7828 | 7828 | $output->add( 'url(' ); |
| 7829 | 7829 | $this->value->genCSS( $output ); |
| 7830 | 7830 | $output->add( ')' ); |
@@ -7888,7 +7888,7 @@ discard block |
||
| 7888 | 7888 | $this->value = $value; |
| 7889 | 7889 | } |
| 7890 | 7890 | |
| 7891 | - public function accept($visitor) { |
|
| 7891 | + public function accept($visitor) { |
|
| 7892 | 7892 | $this->value = $visitor->visitArray($this->value); |
| 7893 | 7893 | } |
| 7894 | 7894 | |
@@ -7905,9 +7905,9 @@ discard block |
||
| 7905 | 7905 | return $ret[0]; |
| 7906 | 7906 | } |
| 7907 | 7907 | |
| 7908 | - /** |
|
| 7909 | - * @see Less_Tree::genCSS |
|
| 7910 | - */ |
|
| 7908 | + /** |
|
| 7909 | + * @see Less_Tree::genCSS |
|
| 7910 | + */ |
|
| 7911 | 7911 | function genCSS( $output ){ |
| 7912 | 7912 | $len = count($this->value); |
| 7913 | 7913 | for($i = 0; $i < $len; $i++ ){ |
@@ -7935,14 +7935,14 @@ discard block |
||
| 7935 | 7935 | public $evaluating = false; |
| 7936 | 7936 | public $type = 'Variable'; |
| 7937 | 7937 | |
| 7938 | - /** |
|
| 7939 | - * @param string $name |
|
| 7940 | - */ |
|
| 7941 | - public function __construct($name, $index = null, $currentFileInfo = null) { |
|
| 7942 | - $this->name = $name; |
|
| 7943 | - $this->index = $index; |
|
| 7938 | + /** |
|
| 7939 | + * @param string $name |
|
| 7940 | + */ |
|
| 7941 | + public function __construct($name, $index = null, $currentFileInfo = null) { |
|
| 7942 | + $this->name = $name; |
|
| 7943 | + $this->index = $index; |
|
| 7944 | 7944 | $this->currentFileInfo = $currentFileInfo; |
| 7945 | - } |
|
| 7945 | + } |
|
| 7946 | 7946 | |
| 7947 | 7947 | public function compile($env) { |
| 7948 | 7948 | |
@@ -8367,8 +8367,8 @@ discard block |
||
| 8367 | 8367 | |
| 8368 | 8368 | // set array to prevent error on array_merge |
| 8369 | 8369 | if(!is_array($this->frames)) { |
| 8370 | - $this->frames = array(); |
|
| 8371 | - } |
|
| 8370 | + $this->frames = array(); |
|
| 8371 | + } |
|
| 8372 | 8372 | |
| 8373 | 8373 | $frame = $this->compileParams($env, array_merge($this->frames,$env->frames), $args ); |
| 8374 | 8374 | |
@@ -8437,21 +8437,21 @@ discard block |
||
| 8437 | 8437 | /** |
| 8438 | 8438 | * @param Less_Tree_Ruleset $root |
| 8439 | 8439 | */ |
| 8440 | - public function run($root){ |
|
| 8440 | + public function run($root){ |
|
| 8441 | 8441 | $root = $this->visitObj($root); |
| 8442 | 8442 | $root->allExtends =& $this->allExtendsStack[0]; |
| 8443 | 8443 | return $root; |
| 8444 | 8444 | } |
| 8445 | 8445 | |
| 8446 | - public function visitRule($ruleNode, &$visitDeeper ){ |
|
| 8446 | + public function visitRule($ruleNode, &$visitDeeper ){ |
|
| 8447 | 8447 | $visitDeeper = false; |
| 8448 | 8448 | } |
| 8449 | 8449 | |
| 8450 | - public function visitMixinDefinition( $mixinDefinitionNode, &$visitDeeper ){ |
|
| 8450 | + public function visitMixinDefinition( $mixinDefinitionNode, &$visitDeeper ){ |
|
| 8451 | 8451 | $visitDeeper = false; |
| 8452 | 8452 | } |
| 8453 | 8453 | |
| 8454 | - public function visitRuleset($rulesetNode){ |
|
| 8454 | + public function visitRuleset($rulesetNode){ |
|
| 8455 | 8455 | |
| 8456 | 8456 | if( $rulesetNode->root ){ |
| 8457 | 8457 | return; |
@@ -8487,7 +8487,7 @@ discard block |
||
| 8487 | 8487 | $this->contexts[] = $rulesetNode->selectors; |
| 8488 | 8488 | } |
| 8489 | 8489 | |
| 8490 | - public function allExtendsStackPush($rulesetNode, $selectorPath, $extend, &$j){ |
|
| 8490 | + public function allExtendsStackPush($rulesetNode, $selectorPath, $extend, &$j){ |
|
| 8491 | 8491 | $this->foundExtends = true; |
| 8492 | 8492 | $extend = clone $extend; |
| 8493 | 8493 | $extend->findSelfSelectors( $selectorPath ); |
@@ -8502,27 +8502,27 @@ discard block |
||
| 8502 | 8502 | } |
| 8503 | 8503 | |
| 8504 | 8504 | |
| 8505 | - public function visitRulesetOut( $rulesetNode ){ |
|
| 8505 | + public function visitRulesetOut( $rulesetNode ){ |
|
| 8506 | 8506 | if( !is_object($rulesetNode) || !$rulesetNode->root ){ |
| 8507 | 8507 | array_pop($this->contexts); |
| 8508 | 8508 | } |
| 8509 | 8509 | } |
| 8510 | 8510 | |
| 8511 | - public function visitMedia( $mediaNode ){ |
|
| 8511 | + public function visitMedia( $mediaNode ){ |
|
| 8512 | 8512 | $mediaNode->allExtends = array(); |
| 8513 | 8513 | $this->allExtendsStack[] =& $mediaNode->allExtends; |
| 8514 | 8514 | } |
| 8515 | 8515 | |
| 8516 | - public function visitMediaOut(){ |
|
| 8516 | + public function visitMediaOut(){ |
|
| 8517 | 8517 | array_pop($this->allExtendsStack); |
| 8518 | 8518 | } |
| 8519 | 8519 | |
| 8520 | - public function visitDirective( $directiveNode ){ |
|
| 8520 | + public function visitDirective( $directiveNode ){ |
|
| 8521 | 8521 | $directiveNode->allExtends = array(); |
| 8522 | 8522 | $this->allExtendsStack[] =& $directiveNode->allExtends; |
| 8523 | 8523 | } |
| 8524 | 8524 | |
| 8525 | - public function visitDirectiveOut(){ |
|
| 8525 | + public function visitDirectiveOut(){ |
|
| 8526 | 8526 | array_pop($this->allExtendsStack); |
| 8527 | 8527 | } |
| 8528 | 8528 | } |
@@ -8686,15 +8686,15 @@ discard block |
||
| 8686 | 8686 | return $this->visitObj($root); |
| 8687 | 8687 | } |
| 8688 | 8688 | |
| 8689 | - public function visitRule( $ruleNode, &$visitDeeper ){ |
|
| 8689 | + public function visitRule( $ruleNode, &$visitDeeper ){ |
|
| 8690 | 8690 | $visitDeeper = false; |
| 8691 | 8691 | } |
| 8692 | 8692 | |
| 8693 | - public function visitMixinDefinition( $mixinDefinitionNode, &$visitDeeper ){ |
|
| 8693 | + public function visitMixinDefinition( $mixinDefinitionNode, &$visitDeeper ){ |
|
| 8694 | 8694 | $visitDeeper = false; |
| 8695 | 8695 | } |
| 8696 | 8696 | |
| 8697 | - public function visitRuleset( $rulesetNode ){ |
|
| 8697 | + public function visitRuleset( $rulesetNode ){ |
|
| 8698 | 8698 | |
| 8699 | 8699 | $paths = array(); |
| 8700 | 8700 | |
@@ -8723,11 +8723,11 @@ discard block |
||
| 8723 | 8723 | $this->contexts[] = $paths; //different from less.js. Placed after joinSelectors() so that $this->contexts will get correct $paths |
| 8724 | 8724 | } |
| 8725 | 8725 | |
| 8726 | - public function visitRulesetOut(){ |
|
| 8726 | + public function visitRulesetOut(){ |
|
| 8727 | 8727 | array_pop($this->contexts); |
| 8728 | 8728 | } |
| 8729 | 8729 | |
| 8730 | - public function visitMedia($mediaNode) { |
|
| 8730 | + public function visitMedia($mediaNode) { |
|
| 8731 | 8731 | $context = end($this->contexts); //$context = $this->contexts[ count($this->contexts) - 1]; |
| 8732 | 8732 | |
| 8733 | 8733 | if( !count($context) || (is_object($context[0]) && $context[0]->multiMedia) ){ |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -require_once( dirname(__FILE__).'/Cache.php'); |
|
| 3 | +require_once(dirname(__FILE__).'/Cache.php'); |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * Class for parsing and compiling less files into css |
@@ -9,28 +9,28 @@ discard block |
||
| 9 | 9 | * @subpackage parser |
| 10 | 10 | * |
| 11 | 11 | */ |
| 12 | -class Less_Parser{ |
|
| 12 | +class Less_Parser { |
|
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * Default parser options |
| 17 | 17 | */ |
| 18 | 18 | public static $default_options = array( |
| 19 | - 'compress' => false, // option - whether to compress |
|
| 20 | - 'strictUnits' => false, // whether units need to evaluate correctly |
|
| 21 | - 'strictMath' => false, // whether math has to be within parenthesis |
|
| 22 | - 'relativeUrls' => true, // option - whether to adjust URL's to be relative |
|
| 23 | - 'urlArgs' => array(), // whether to add args into url tokens |
|
| 19 | + 'compress' => false, // option - whether to compress |
|
| 20 | + 'strictUnits' => false, // whether units need to evaluate correctly |
|
| 21 | + 'strictMath' => false, // whether math has to be within parenthesis |
|
| 22 | + 'relativeUrls' => true, // option - whether to adjust URL's to be relative |
|
| 23 | + 'urlArgs' => array(), // whether to add args into url tokens |
|
| 24 | 24 | 'numPrecision' => 8, |
| 25 | 25 | |
| 26 | 26 | 'import_dirs' => array(), |
| 27 | 27 | 'import_callback' => null, |
| 28 | 28 | 'cache_dir' => null, |
| 29 | - 'cache_method' => 'php', // false, 'serialize', 'php', 'var_export', 'callback'; |
|
| 29 | + 'cache_method' => 'php', // false, 'serialize', 'php', 'var_export', 'callback'; |
|
| 30 | 30 | 'cache_callback_get' => null, |
| 31 | 31 | 'cache_callback_set' => null, |
| 32 | 32 | |
| 33 | - 'sourceMap' => false, // whether to output a source map |
|
| 33 | + 'sourceMap' => false, // whether to output a source map |
|
| 34 | 34 | 'sourceMapBasepath' => null, |
| 35 | 35 | 'sourceMapWriteTo' => null, |
| 36 | 36 | 'sourceMapURL' => null, |
@@ -42,10 +42,10 @@ discard block |
||
| 42 | 42 | public static $options = array(); |
| 43 | 43 | |
| 44 | 44 | |
| 45 | - private $input; // Less input string |
|
| 46 | - private $input_len; // input string length |
|
| 47 | - private $pos; // current index in `input` |
|
| 48 | - private $saveStack = array(); // holds state for backtracking |
|
| 45 | + private $input; // Less input string |
|
| 46 | + private $input_len; // input string length |
|
| 47 | + private $pos; // current index in `input` |
|
| 48 | + private $saveStack = array(); // holds state for backtracking |
|
| 49 | 49 | private $furthest; |
| 50 | 50 | private $mb_internal_encoding = ''; // for remember exists value of mbstring.internal_encoding |
| 51 | 51 | |
@@ -73,15 +73,15 @@ discard block |
||
| 73 | 73 | /** |
| 74 | 74 | * @param Less_Environment|array|null $env |
| 75 | 75 | */ |
| 76 | - public function __construct( $env = null ){ |
|
| 76 | + public function __construct($env = null) { |
|
| 77 | 77 | |
| 78 | 78 | // Top parser on an import tree must be sure there is one "env" |
| 79 | 79 | // which will then be passed around by reference. |
| 80 | - if( $env instanceof Less_Environment ){ |
|
| 80 | + if ($env instanceof Less_Environment) { |
|
| 81 | 81 | $this->env = $env; |
| 82 | - }else{ |
|
| 82 | + }else { |
|
| 83 | 83 | $this->SetOptions(Less_Parser::$default_options); |
| 84 | - $this->Reset( $env ); |
|
| 84 | + $this->Reset($env); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | // mbstring.func_overload > 1 bugfix |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | * Reset the parser state completely |
| 100 | 100 | * |
| 101 | 101 | */ |
| 102 | - public function Reset( $options = null ){ |
|
| 102 | + public function Reset($options = null) { |
|
| 103 | 103 | $this->rules = array(); |
| 104 | 104 | self::$imports = array(); |
| 105 | 105 | self::$has_extends = false; |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | $this->env->Init(); |
| 111 | 111 | |
| 112 | 112 | //set new options |
| 113 | - if( is_array($options) ){ |
|
| 113 | + if (is_array($options)) { |
|
| 114 | 114 | $this->SetOptions(Less_Parser::$default_options); |
| 115 | 115 | $this->SetOptions($options); |
| 116 | 116 | } |
@@ -121,9 +121,9 @@ discard block |
||
| 121 | 121 | * options: import_dirs, cache_dir, cache_method |
| 122 | 122 | * |
| 123 | 123 | */ |
| 124 | - public function SetOptions( $options ){ |
|
| 125 | - foreach($options as $option => $value){ |
|
| 126 | - $this->SetOption($option,$value); |
|
| 124 | + public function SetOptions($options) { |
|
| 125 | + foreach ($options as $option => $value) { |
|
| 126 | + $this->SetOption($option, $value); |
|
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | 129 | |
@@ -131,16 +131,16 @@ discard block |
||
| 131 | 131 | * Set one compiler option |
| 132 | 132 | * |
| 133 | 133 | */ |
| 134 | - public function SetOption($option,$value){ |
|
| 134 | + public function SetOption($option, $value) { |
|
| 135 | 135 | |
| 136 | - switch($option){ |
|
| 136 | + switch ($option) { |
|
| 137 | 137 | |
| 138 | 138 | case 'import_dirs': |
| 139 | 139 | $this->SetImportDirs($value); |
| 140 | 140 | return; |
| 141 | 141 | |
| 142 | 142 | case 'cache_dir': |
| 143 | - if( is_string($value) ){ |
|
| 143 | + if (is_string($value)) { |
|
| 144 | 144 | Less_Cache::SetCacheDir($value); |
| 145 | 145 | Less_Cache::CheckCacheDir(); |
| 146 | 146 | } |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | * @param string $name function name |
| 167 | 167 | */ |
| 168 | 168 | public function unregisterFunction($name) { |
| 169 | - if( isset($this->env->functions[$name]) ) |
|
| 169 | + if (isset($this->env->functions[$name])) |
|
| 170 | 170 | unset($this->env->functions[$name]); |
| 171 | 171 | } |
| 172 | 172 | |
@@ -176,16 +176,16 @@ discard block |
||
| 176 | 176 | * |
| 177 | 177 | * @return string |
| 178 | 178 | */ |
| 179 | - public function getCss(){ |
|
| 179 | + public function getCss() { |
|
| 180 | 180 | |
| 181 | 181 | $precision = ini_get('precision'); |
| 182 | - @ini_set('precision',16); |
|
| 182 | + @ini_set('precision', 16); |
|
| 183 | 183 | $locale = setlocale(LC_NUMERIC, 0); |
| 184 | 184 | setlocale(LC_NUMERIC, "C"); |
| 185 | 185 | |
| 186 | 186 | try { |
| 187 | 187 | |
| 188 | - $root = new Less_Tree_Ruleset(array(), $this->rules ); |
|
| 188 | + $root = new Less_Tree_Ruleset(array(), $this->rules); |
|
| 189 | 189 | $root->root = true; |
| 190 | 190 | $root->firstRoot = true; |
| 191 | 191 | |
@@ -199,16 +199,16 @@ discard block |
||
| 199 | 199 | |
| 200 | 200 | $this->PostVisitors($evaldRoot); |
| 201 | 201 | |
| 202 | - if( Less_Parser::$options['sourceMap'] ){ |
|
| 203 | - $generator = new Less_SourceMap_Generator($evaldRoot, Less_Parser::$contentsMap, Less_Parser::$options ); |
|
| 202 | + if (Less_Parser::$options['sourceMap']) { |
|
| 203 | + $generator = new Less_SourceMap_Generator($evaldRoot, Less_Parser::$contentsMap, Less_Parser::$options); |
|
| 204 | 204 | // will also save file |
| 205 | 205 | // FIXME: should happen somewhere else? |
| 206 | 206 | $css = $generator->generateCSS(); |
| 207 | - }else{ |
|
| 207 | + }else { |
|
| 208 | 208 | $css = $evaldRoot->toCSS(); |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - if( Less_Parser::$options['compress'] ){ |
|
| 211 | + if (Less_Parser::$options['compress']) { |
|
| 212 | 212 | $css = preg_replace('/(^(\s)+)|((\s)+$)/', '', $css); |
| 213 | 213 | } |
| 214 | 214 | |
@@ -217,12 +217,12 @@ discard block |
||
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | //reset php settings |
| 220 | - @ini_set('precision',$precision); |
|
| 220 | + @ini_set('precision', $precision); |
|
| 221 | 221 | setlocale(LC_NUMERIC, $locale); |
| 222 | 222 | |
| 223 | 223 | // If you previously defined $this->mb_internal_encoding |
| 224 | 224 | // is required to return the encoding as it was before |
| 225 | - if ($this->mb_internal_encoding != '') { |
|
| 225 | + if ($this->mb_internal_encoding!='') { |
|
| 226 | 226 | @ini_set("mbstring.internal_encoding", $this->mb_internal_encoding); |
| 227 | 227 | $this->mb_internal_encoding = ''; |
| 228 | 228 | } |
@@ -241,11 +241,11 @@ discard block |
||
| 241 | 241 | * Run pre-compile visitors |
| 242 | 242 | * |
| 243 | 243 | */ |
| 244 | - private function PreVisitors($root){ |
|
| 244 | + private function PreVisitors($root) { |
|
| 245 | 245 | |
| 246 | - if( Less_Parser::$options['plugins'] ){ |
|
| 247 | - foreach(Less_Parser::$options['plugins'] as $plugin){ |
|
| 248 | - if( !empty($plugin->isPreEvalVisitor) ){ |
|
| 246 | + if (Less_Parser::$options['plugins']) { |
|
| 247 | + foreach (Less_Parser::$options['plugins'] as $plugin) { |
|
| 248 | + if (!empty($plugin->isPreEvalVisitor)) { |
|
| 249 | 249 | $plugin->run($root); |
| 250 | 250 | } |
| 251 | 251 | } |
@@ -257,32 +257,32 @@ discard block |
||
| 257 | 257 | * Run post-compile visitors |
| 258 | 258 | * |
| 259 | 259 | */ |
| 260 | - private function PostVisitors($evaldRoot){ |
|
| 260 | + private function PostVisitors($evaldRoot) { |
|
| 261 | 261 | |
| 262 | 262 | $visitors = array(); |
| 263 | 263 | $visitors[] = new Less_Visitor_joinSelector(); |
| 264 | - if( self::$has_extends ){ |
|
| 264 | + if (self::$has_extends) { |
|
| 265 | 265 | $visitors[] = new Less_Visitor_processExtends(); |
| 266 | 266 | } |
| 267 | 267 | $visitors[] = new Less_Visitor_toCSS(); |
| 268 | 268 | |
| 269 | 269 | |
| 270 | - if( Less_Parser::$options['plugins'] ){ |
|
| 271 | - foreach(Less_Parser::$options['plugins'] as $plugin){ |
|
| 272 | - if( property_exists($plugin,'isPreEvalVisitor') && $plugin->isPreEvalVisitor ){ |
|
| 270 | + if (Less_Parser::$options['plugins']) { |
|
| 271 | + foreach (Less_Parser::$options['plugins'] as $plugin) { |
|
| 272 | + if (property_exists($plugin, 'isPreEvalVisitor') && $plugin->isPreEvalVisitor) { |
|
| 273 | 273 | continue; |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | - if( property_exists($plugin,'isPreVisitor') && $plugin->isPreVisitor ){ |
|
| 277 | - array_unshift( $visitors, $plugin); |
|
| 278 | - }else{ |
|
| 276 | + if (property_exists($plugin, 'isPreVisitor') && $plugin->isPreVisitor) { |
|
| 277 | + array_unshift($visitors, $plugin); |
|
| 278 | + }else { |
|
| 279 | 279 | $visitors[] = $plugin; |
| 280 | 280 | } |
| 281 | 281 | } |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | |
| 285 | - for($i = 0; $i < count($visitors); $i++ ){ |
|
| 285 | + for ($i = 0; $i<count($visitors); $i++) { |
|
| 286 | 286 | $visitors[$i]->run($evaldRoot); |
| 287 | 287 | } |
| 288 | 288 | |
@@ -296,12 +296,12 @@ discard block |
||
| 296 | 296 | * @param string $uri_root The url of the file |
| 297 | 297 | * @return Less_Tree_Ruleset|Less_Parser |
| 298 | 298 | */ |
| 299 | - public function parse( $str, $file_uri = null ){ |
|
| 299 | + public function parse($str, $file_uri = null) { |
|
| 300 | 300 | |
| 301 | - if( !$file_uri ){ |
|
| 301 | + if (!$file_uri) { |
|
| 302 | 302 | $uri_root = ''; |
| 303 | 303 | $filename = 'anonymous-file-'.Less_Parser::$next_id++.'.less'; |
| 304 | - }else{ |
|
| 304 | + }else { |
|
| 305 | 305 | $file_uri = self::WinPath($file_uri); |
| 306 | 306 | $filename = $file_uri; |
| 307 | 307 | $uri_root = dirname($file_uri); |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | $this->input = $str; |
| 315 | 315 | $this->_parse(); |
| 316 | 316 | |
| 317 | - if( $previousFileInfo ){ |
|
| 317 | + if ($previousFileInfo) { |
|
| 318 | 318 | $this->env->currentFileInfo = $previousFileInfo; |
| 319 | 319 | } |
| 320 | 320 | |
@@ -331,16 +331,16 @@ discard block |
||
| 331 | 331 | * @param bool $returnRoot Indicates whether the return value should be a css string a root node |
| 332 | 332 | * @return Less_Tree_Ruleset|Less_Parser |
| 333 | 333 | */ |
| 334 | - public function parseFile( $filename, $uri_root = '', $returnRoot = false){ |
|
| 334 | + public function parseFile($filename, $uri_root = '', $returnRoot = false) { |
|
| 335 | 335 | |
| 336 | - if( !file_exists($filename) ){ |
|
| 336 | + if (!file_exists($filename)) { |
|
| 337 | 337 | $this->Error(sprintf('File `%s` not found.', $filename)); |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | |
| 341 | 341 | // fix uri_root? |
| 342 | 342 | // Instead of The mixture of file path for the first argument and directory path for the second argument has bee |
| 343 | - if( !$returnRoot && !empty($uri_root) && basename($uri_root) == basename($filename) ){ |
|
| 343 | + if (!$returnRoot && !empty($uri_root) && basename($uri_root)==basename($filename)) { |
|
| 344 | 344 | $uri_root = dirname($uri_root); |
| 345 | 345 | } |
| 346 | 346 | |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | $previousFileInfo = $this->env->currentFileInfo; |
| 349 | 349 | |
| 350 | 350 | |
| 351 | - if( $filename ){ |
|
| 351 | + if ($filename) { |
|
| 352 | 352 | $filename = self::WinPath(realpath($filename)); |
| 353 | 353 | } |
| 354 | 354 | $uri_root = self::WinPath($uri_root); |
@@ -357,15 +357,15 @@ discard block |
||
| 357 | 357 | |
| 358 | 358 | self::AddParsedFile($filename); |
| 359 | 359 | |
| 360 | - if( $returnRoot ){ |
|
| 361 | - $rules = $this->GetRules( $filename ); |
|
| 362 | - $return = new Less_Tree_Ruleset(array(), $rules ); |
|
| 363 | - }else{ |
|
| 364 | - $this->_parse( $filename ); |
|
| 360 | + if ($returnRoot) { |
|
| 361 | + $rules = $this->GetRules($filename); |
|
| 362 | + $return = new Less_Tree_Ruleset(array(), $rules); |
|
| 363 | + }else { |
|
| 364 | + $this->_parse($filename); |
|
| 365 | 365 | $return = $this; |
| 366 | 366 | } |
| 367 | 367 | |
| 368 | - if( $previousFileInfo ){ |
|
| 368 | + if ($previousFileInfo) { |
|
| 369 | 369 | $this->env->currentFileInfo = $previousFileInfo; |
| 370 | 370 | } |
| 371 | 371 | |
@@ -378,9 +378,9 @@ discard block |
||
| 378 | 378 | * @param array $vars |
| 379 | 379 | * @return Less_Parser |
| 380 | 380 | */ |
| 381 | - public function ModifyVars( $vars ){ |
|
| 381 | + public function ModifyVars($vars) { |
|
| 382 | 382 | |
| 383 | - $this->input = Less_Parser::serializeVars( $vars ); |
|
| 383 | + $this->input = Less_Parser::serializeVars($vars); |
|
| 384 | 384 | $this->_parse(); |
| 385 | 385 | |
| 386 | 386 | return $this; |
@@ -390,24 +390,24 @@ discard block |
||
| 390 | 390 | /** |
| 391 | 391 | * @param string $filename |
| 392 | 392 | */ |
| 393 | - public function SetFileInfo( $filename, $uri_root = ''){ |
|
| 393 | + public function SetFileInfo($filename, $uri_root = '') { |
|
| 394 | 394 | |
| 395 | 395 | $filename = Less_Environment::normalizePath($filename); |
| 396 | - $dirname = preg_replace('/[^\/\\\\]*$/','',$filename); |
|
| 396 | + $dirname = preg_replace('/[^\/\\\\]*$/', '', $filename); |
|
| 397 | 397 | |
| 398 | - if( !empty($uri_root) ){ |
|
| 399 | - $uri_root = rtrim($uri_root,'/').'/'; |
|
| 398 | + if (!empty($uri_root)) { |
|
| 399 | + $uri_root = rtrim($uri_root, '/').'/'; |
|
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | $currentFileInfo = array(); |
| 403 | 403 | |
| 404 | 404 | //entry info |
| 405 | - if( isset($this->env->currentFileInfo) ){ |
|
| 405 | + if (isset($this->env->currentFileInfo)) { |
|
| 406 | 406 | $currentFileInfo['entryPath'] = $this->env->currentFileInfo['entryPath']; |
| 407 | 407 | $currentFileInfo['entryUri'] = $this->env->currentFileInfo['entryUri']; |
| 408 | 408 | $currentFileInfo['rootpath'] = $this->env->currentFileInfo['rootpath']; |
| 409 | 409 | |
| 410 | - }else{ |
|
| 410 | + }else { |
|
| 411 | 411 | $currentFileInfo['entryPath'] = $dirname; |
| 412 | 412 | $currentFileInfo['entryUri'] = $uri_root; |
| 413 | 413 | $currentFileInfo['rootpath'] = $dirname; |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | |
| 421 | 421 | |
| 422 | 422 | //inherit reference |
| 423 | - if( isset($this->env->currentFileInfo['reference']) && $this->env->currentFileInfo['reference'] ){ |
|
| 423 | + if (isset($this->env->currentFileInfo['reference']) && $this->env->currentFileInfo['reference']) { |
|
| 424 | 424 | $currentFileInfo['reference'] = true; |
| 425 | 425 | } |
| 426 | 426 | |
@@ -432,23 +432,23 @@ discard block |
||
| 432 | 432 | * @deprecated 1.5.1.2 |
| 433 | 433 | * |
| 434 | 434 | */ |
| 435 | - public function SetCacheDir( $dir ){ |
|
| 435 | + public function SetCacheDir($dir) { |
|
| 436 | 436 | |
| 437 | - if( !file_exists($dir) ){ |
|
| 438 | - if( mkdir($dir) ){ |
|
| 437 | + if (!file_exists($dir)) { |
|
| 438 | + if (mkdir($dir)) { |
|
| 439 | 439 | return true; |
| 440 | 440 | } |
| 441 | 441 | throw new Less_Exception_Parser('Less.php cache directory couldn\'t be created: '.$dir); |
| 442 | 442 | |
| 443 | - }elseif( !is_dir($dir) ){ |
|
| 443 | + }elseif (!is_dir($dir)) { |
|
| 444 | 444 | throw new Less_Exception_Parser('Less.php cache directory doesn\'t exist: '.$dir); |
| 445 | 445 | |
| 446 | - }elseif( !is_writable($dir) ){ |
|
| 446 | + }elseif (!is_writable($dir)) { |
|
| 447 | 447 | throw new Less_Exception_Parser('Less.php cache directory isn\'t writable: '.$dir); |
| 448 | 448 | |
| 449 | - }else{ |
|
| 449 | + }else { |
|
| 450 | 450 | $dir = self::WinPath($dir); |
| 451 | - Less_Cache::$cache_dir = rtrim($dir,'/').'/'; |
|
| 451 | + Less_Cache::$cache_dir = rtrim($dir, '/').'/'; |
|
| 452 | 452 | return true; |
| 453 | 453 | } |
| 454 | 454 | } |
@@ -459,20 +459,20 @@ discard block |
||
| 459 | 459 | * |
| 460 | 460 | * @param array $dirs |
| 461 | 461 | */ |
| 462 | - public function SetImportDirs( $dirs ){ |
|
| 462 | + public function SetImportDirs($dirs) { |
|
| 463 | 463 | Less_Parser::$options['import_dirs'] = array(); |
| 464 | 464 | |
| 465 | - foreach($dirs as $path => $uri_root){ |
|
| 465 | + foreach ($dirs as $path => $uri_root) { |
|
| 466 | 466 | |
| 467 | 467 | $path = self::WinPath($path); |
| 468 | - if( !empty($path) ){ |
|
| 469 | - $path = rtrim($path,'/').'/'; |
|
| 468 | + if (!empty($path)) { |
|
| 469 | + $path = rtrim($path, '/').'/'; |
|
| 470 | 470 | } |
| 471 | 471 | |
| 472 | - if ( !is_callable($uri_root) ){ |
|
| 472 | + if (!is_callable($uri_root)) { |
|
| 473 | 473 | $uri_root = self::WinPath($uri_root); |
| 474 | - if( !empty($uri_root) ){ |
|
| 475 | - $uri_root = rtrim($uri_root,'/').'/'; |
|
| 474 | + if (!empty($uri_root)) { |
|
| 475 | + $uri_root = rtrim($uri_root, '/').'/'; |
|
| 476 | 476 | } |
| 477 | 477 | } |
| 478 | 478 | |
@@ -483,8 +483,8 @@ discard block |
||
| 483 | 483 | /** |
| 484 | 484 | * @param string $file_path |
| 485 | 485 | */ |
| 486 | - private function _parse( $file_path = null ){ |
|
| 487 | - $this->rules = array_merge($this->rules, $this->GetRules( $file_path )); |
|
| 486 | + private function _parse($file_path = null) { |
|
| 487 | + $this->rules = array_merge($this->rules, $this->GetRules($file_path)); |
|
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | |
@@ -494,33 +494,33 @@ discard block |
||
| 494 | 494 | * |
| 495 | 495 | * @param string|null $file_path |
| 496 | 496 | */ |
| 497 | - private function GetRules( $file_path ){ |
|
| 497 | + private function GetRules($file_path) { |
|
| 498 | 498 | |
| 499 | 499 | $this->SetInput($file_path); |
| 500 | 500 | |
| 501 | - $cache_file = $this->CacheFile( $file_path ); |
|
| 502 | - if( $cache_file ){ |
|
| 503 | - if( Less_Parser::$options['cache_method'] == 'callback' ){ |
|
| 504 | - if( is_callable(Less_Parser::$options['cache_callback_get']) ){ |
|
| 501 | + $cache_file = $this->CacheFile($file_path); |
|
| 502 | + if ($cache_file) { |
|
| 503 | + if (Less_Parser::$options['cache_method']=='callback') { |
|
| 504 | + if (is_callable(Less_Parser::$options['cache_callback_get'])) { |
|
| 505 | 505 | $cache = call_user_func_array( |
| 506 | 506 | Less_Parser::$options['cache_callback_get'], |
| 507 | 507 | array($this, $file_path, $cache_file) |
| 508 | 508 | ); |
| 509 | 509 | |
| 510 | - if( $cache ){ |
|
| 510 | + if ($cache) { |
|
| 511 | 511 | $this->UnsetInput(); |
| 512 | 512 | return $cache; |
| 513 | 513 | } |
| 514 | 514 | } |
| 515 | 515 | |
| 516 | - }elseif( file_exists($cache_file) ){ |
|
| 517 | - switch(Less_Parser::$options['cache_method']){ |
|
| 516 | + }elseif (file_exists($cache_file)) { |
|
| 517 | + switch (Less_Parser::$options['cache_method']) { |
|
| 518 | 518 | |
| 519 | 519 | // Using serialize |
| 520 | 520 | // Faster but uses more memory |
| 521 | 521 | case 'serialize': |
| 522 | 522 | $cache = unserialize(file_get_contents($cache_file)); |
| 523 | - if( $cache ){ |
|
| 523 | + if ($cache) { |
|
| 524 | 524 | touch($cache_file); |
| 525 | 525 | $this->UnsetInput(); |
| 526 | 526 | return $cache; |
@@ -539,7 +539,7 @@ discard block |
||
| 539 | 539 | |
| 540 | 540 | $rules = $this->parsePrimary(); |
| 541 | 541 | |
| 542 | - if( $this->pos < $this->input_len ){ |
|
| 542 | + if ($this->pos<$this->input_len) { |
|
| 543 | 543 | throw new Less_Exception_Chunk($this->input, null, $this->furthest, $this->env->currentFileInfo); |
| 544 | 544 | } |
| 545 | 545 | |
@@ -547,27 +547,27 @@ discard block |
||
| 547 | 547 | |
| 548 | 548 | |
| 549 | 549 | //save the cache |
| 550 | - if( $cache_file ){ |
|
| 551 | - if( Less_Parser::$options['cache_method'] == 'callback' ){ |
|
| 552 | - if( is_callable(Less_Parser::$options['cache_callback_set']) ){ |
|
| 550 | + if ($cache_file) { |
|
| 551 | + if (Less_Parser::$options['cache_method']=='callback') { |
|
| 552 | + if (is_callable(Less_Parser::$options['cache_callback_set'])) { |
|
| 553 | 553 | call_user_func_array( |
| 554 | 554 | Less_Parser::$options['cache_callback_set'], |
| 555 | 555 | array($this, $file_path, $cache_file, $rules) |
| 556 | 556 | ); |
| 557 | 557 | } |
| 558 | 558 | |
| 559 | - }else{ |
|
| 559 | + }else { |
|
| 560 | 560 | //msg('write cache file'); |
| 561 | - switch(Less_Parser::$options['cache_method']){ |
|
| 561 | + switch (Less_Parser::$options['cache_method']) { |
|
| 562 | 562 | case 'serialize': |
| 563 | - file_put_contents( $cache_file, serialize($rules) ); |
|
| 563 | + file_put_contents($cache_file, serialize($rules)); |
|
| 564 | 564 | break; |
| 565 | 565 | case 'php': |
| 566 | - file_put_contents( $cache_file, '<?php return '.self::ArgString($rules).'; ?>' ); |
|
| 566 | + file_put_contents($cache_file, '<?php return '.self::ArgString($rules).'; ?>'); |
|
| 567 | 567 | break; |
| 568 | 568 | case 'var_export': |
| 569 | 569 | //Requires __set_state() |
| 570 | - file_put_contents( $cache_file, '<?php return '.var_export($rules,true).'; ?>' ); |
|
| 570 | + file_put_contents($cache_file, '<?php return '.var_export($rules, true).'; ?>'); |
|
| 571 | 571 | break; |
| 572 | 572 | } |
| 573 | 573 | |
@@ -583,10 +583,10 @@ discard block |
||
| 583 | 583 | * Set up the input buffer |
| 584 | 584 | * |
| 585 | 585 | */ |
| 586 | - public function SetInput( $file_path ){ |
|
| 586 | + public function SetInput($file_path) { |
|
| 587 | 587 | |
| 588 | - if( $file_path ){ |
|
| 589 | - $this->input = file_get_contents( $file_path ); |
|
| 588 | + if ($file_path) { |
|
| 589 | + $this->input = file_get_contents($file_path); |
|
| 590 | 590 | } |
| 591 | 591 | |
| 592 | 592 | $this->pos = $this->furthest = 0; |
@@ -596,7 +596,7 @@ discard block |
||
| 596 | 596 | $this->input_len = strlen($this->input); |
| 597 | 597 | |
| 598 | 598 | |
| 599 | - if( Less_Parser::$options['sourceMap'] && $this->env->currentFileInfo ){ |
|
| 599 | + if (Less_Parser::$options['sourceMap'] && $this->env->currentFileInfo) { |
|
| 600 | 600 | $uri = $this->env->currentFileInfo['currentUri']; |
| 601 | 601 | Less_Parser::$contentsMap[$uri] = $this->input; |
| 602 | 602 | } |
@@ -608,44 +608,44 @@ discard block |
||
| 608 | 608 | * Free up some memory |
| 609 | 609 | * |
| 610 | 610 | */ |
| 611 | - public function UnsetInput(){ |
|
| 611 | + public function UnsetInput() { |
|
| 612 | 612 | unset($this->input, $this->pos, $this->input_len, $this->furthest); |
| 613 | 613 | $this->saveStack = array(); |
| 614 | 614 | } |
| 615 | 615 | |
| 616 | 616 | |
| 617 | - public function CacheFile( $file_path ){ |
|
| 617 | + public function CacheFile($file_path) { |
|
| 618 | 618 | |
| 619 | - if( $file_path && $this->CacheEnabled() ){ |
|
| 619 | + if ($file_path && $this->CacheEnabled()) { |
|
| 620 | 620 | |
| 621 | 621 | $env = get_object_vars($this->env); |
| 622 | 622 | unset($env['frames']); |
| 623 | 623 | |
| 624 | 624 | $parts = array(); |
| 625 | 625 | $parts[] = $file_path; |
| 626 | - $parts[] = filesize( $file_path ); |
|
| 627 | - $parts[] = filemtime( $file_path ); |
|
| 626 | + $parts[] = filesize($file_path); |
|
| 627 | + $parts[] = filemtime($file_path); |
|
| 628 | 628 | $parts[] = $env; |
| 629 | 629 | $parts[] = Less_Version::cache_version; |
| 630 | 630 | $parts[] = Less_Parser::$options['cache_method']; |
| 631 | - return Less_Cache::$cache_dir . Less_Cache::$prefix . base_convert( sha1(json_encode($parts) ), 16, 36) . '.lesscache'; |
|
| 631 | + return Less_Cache::$cache_dir.Less_Cache::$prefix.base_convert(sha1(json_encode($parts)), 16, 36).'.lesscache'; |
|
| 632 | 632 | } |
| 633 | 633 | } |
| 634 | 634 | |
| 635 | 635 | |
| 636 | - static function AddParsedFile($file){ |
|
| 636 | + static function AddParsedFile($file) { |
|
| 637 | 637 | self::$imports[] = $file; |
| 638 | 638 | } |
| 639 | 639 | |
| 640 | - static function AllParsedFiles(){ |
|
| 640 | + static function AllParsedFiles() { |
|
| 641 | 641 | return self::$imports; |
| 642 | 642 | } |
| 643 | 643 | |
| 644 | 644 | /** |
| 645 | 645 | * @param string $file |
| 646 | 646 | */ |
| 647 | - static function FileParsed($file){ |
|
| 648 | - return in_array($file,self::$imports); |
|
| 647 | + static function FileParsed($file) { |
|
| 648 | + return in_array($file, self::$imports); |
|
| 649 | 649 | } |
| 650 | 650 | |
| 651 | 651 | |
@@ -657,13 +657,13 @@ discard block |
||
| 657 | 657 | $this->pos = array_pop($this->saveStack); |
| 658 | 658 | } |
| 659 | 659 | |
| 660 | - private function forget(){ |
|
| 660 | + private function forget() { |
|
| 661 | 661 | array_pop($this->saveStack); |
| 662 | 662 | } |
| 663 | 663 | |
| 664 | 664 | |
| 665 | 665 | private function isWhitespace($offset = 0) { |
| 666 | - return preg_match('/\s/',$this->input[ $this->pos + $offset]); |
|
| 666 | + return preg_match('/\s/', $this->input[$this->pos+$offset]); |
|
| 667 | 667 | } |
| 668 | 668 | |
| 669 | 669 | /** |
@@ -672,7 +672,7 @@ discard block |
||
| 672 | 672 | * @param array $toks |
| 673 | 673 | * @return array |
| 674 | 674 | */ |
| 675 | - private function match($toks){ |
|
| 675 | + private function match($toks) { |
|
| 676 | 676 | |
| 677 | 677 | // The match is confirmed, add the match length to `this::pos`, |
| 678 | 678 | // and consume any extra white-space characters (' ' || '\n') |
@@ -680,27 +680,27 @@ discard block |
||
| 680 | 680 | // grammar is mostly white-space insensitive. |
| 681 | 681 | // |
| 682 | 682 | |
| 683 | - foreach($toks as $tok){ |
|
| 683 | + foreach ($toks as $tok) { |
|
| 684 | 684 | |
| 685 | 685 | $char = $tok[0]; |
| 686 | 686 | |
| 687 | - if( $char === '/' ){ |
|
| 687 | + if ($char==='/') { |
|
| 688 | 688 | $match = $this->MatchReg($tok); |
| 689 | 689 | |
| 690 | - if( $match ){ |
|
| 691 | - return count($match) === 1 ? $match[0] : $match; |
|
| 690 | + if ($match) { |
|
| 691 | + return count($match)===1 ? $match[0] : $match; |
|
| 692 | 692 | } |
| 693 | 693 | |
| 694 | - }elseif( $char === '#' ){ |
|
| 694 | + }elseif ($char==='#') { |
|
| 695 | 695 | $match = $this->MatchChar($tok[1]); |
| 696 | 696 | |
| 697 | - }else{ |
|
| 697 | + }else { |
|
| 698 | 698 | // Non-terminal, match using a function call |
| 699 | 699 | $match = $this->$tok(); |
| 700 | 700 | |
| 701 | 701 | } |
| 702 | 702 | |
| 703 | - if( $match ){ |
|
| 703 | + if ($match) { |
|
| 704 | 704 | return $match; |
| 705 | 705 | } |
| 706 | 706 | } |
@@ -711,12 +711,12 @@ discard block |
||
| 711 | 711 | * |
| 712 | 712 | * @return string |
| 713 | 713 | */ |
| 714 | - private function MatchFuncs($toks){ |
|
| 714 | + private function MatchFuncs($toks) { |
|
| 715 | 715 | |
| 716 | - if( $this->pos < $this->input_len ){ |
|
| 717 | - foreach($toks as $tok){ |
|
| 716 | + if ($this->pos<$this->input_len) { |
|
| 717 | + foreach ($toks as $tok) { |
|
| 718 | 718 | $match = $this->$tok(); |
| 719 | - if( $match ){ |
|
| 719 | + if ($match) { |
|
| 720 | 720 | return $match; |
| 721 | 721 | } |
| 722 | 722 | } |
@@ -725,17 +725,17 @@ discard block |
||
| 725 | 725 | } |
| 726 | 726 | |
| 727 | 727 | // Match a single character in the input, |
| 728 | - private function MatchChar($tok){ |
|
| 729 | - if( ($this->pos < $this->input_len) && ($this->input[$this->pos] === $tok) ){ |
|
| 728 | + private function MatchChar($tok) { |
|
| 729 | + if (($this->pos<$this->input_len) && ($this->input[$this->pos]===$tok)) { |
|
| 730 | 730 | $this->skipWhitespace(1); |
| 731 | 731 | return $tok; |
| 732 | 732 | } |
| 733 | 733 | } |
| 734 | 734 | |
| 735 | 735 | // Match a regexp from the current start point |
| 736 | - private function MatchReg($tok){ |
|
| 736 | + private function MatchReg($tok) { |
|
| 737 | 737 | |
| 738 | - if( preg_match($tok, $this->input, $match, 0, $this->pos) ){ |
|
| 738 | + if (preg_match($tok, $this->input, $match, 0, $this->pos)) { |
|
| 739 | 739 | $this->skipWhitespace(strlen($match[0])); |
| 740 | 740 | return $match; |
| 741 | 741 | } |
@@ -749,30 +749,30 @@ discard block |
||
| 749 | 749 | * @param string $tok |
| 750 | 750 | * @return integer |
| 751 | 751 | */ |
| 752 | - public function PeekReg($tok){ |
|
| 752 | + public function PeekReg($tok) { |
|
| 753 | 753 | return preg_match($tok, $this->input, $match, 0, $this->pos); |
| 754 | 754 | } |
| 755 | 755 | |
| 756 | 756 | /** |
| 757 | 757 | * @param string $tok |
| 758 | 758 | */ |
| 759 | - public function PeekChar($tok){ |
|
| 759 | + public function PeekChar($tok) { |
|
| 760 | 760 | //return ($this->input[$this->pos] === $tok ); |
| 761 | - return ($this->pos < $this->input_len) && ($this->input[$this->pos] === $tok ); |
|
| 761 | + return ($this->pos<$this->input_len) && ($this->input[$this->pos]===$tok); |
|
| 762 | 762 | } |
| 763 | 763 | |
| 764 | 764 | |
| 765 | 765 | /** |
| 766 | 766 | * @param integer $length |
| 767 | 767 | */ |
| 768 | - public function skipWhitespace($length){ |
|
| 768 | + public function skipWhitespace($length) { |
|
| 769 | 769 | |
| 770 | 770 | $this->pos += $length; |
| 771 | 771 | |
| 772 | - for(; $this->pos < $this->input_len; $this->pos++ ){ |
|
| 772 | + for (; $this->pos<$this->input_len; $this->pos++) { |
|
| 773 | 773 | $c = $this->input[$this->pos]; |
| 774 | 774 | |
| 775 | - if( ($c !== "\n") && ($c !== "\r") && ($c !== "\t") && ($c !== ' ') ){ |
|
| 775 | + if (($c!=="\n") && ($c!=="\r") && ($c!=="\t") && ($c!==' ')) { |
|
| 776 | 776 | break; |
| 777 | 777 | } |
| 778 | 778 | } |
@@ -784,10 +784,10 @@ discard block |
||
| 784 | 784 | * @param string|null $msg |
| 785 | 785 | */ |
| 786 | 786 | public function expect($tok, $msg = NULL) { |
| 787 | - $result = $this->match( array($tok) ); |
|
| 787 | + $result = $this->match(array($tok)); |
|
| 788 | 788 | if (!$result) { |
| 789 | - $this->Error( $msg ? "Expected '" . $tok . "' got '" . $this->input[$this->pos] . "'" : $msg ); |
|
| 790 | - } else { |
|
| 789 | + $this->Error($msg ? "Expected '".$tok."' got '".$this->input[$this->pos]."'" : $msg); |
|
| 790 | + }else { |
|
| 791 | 791 | return $result; |
| 792 | 792 | } |
| 793 | 793 | } |
@@ -795,11 +795,11 @@ discard block |
||
| 795 | 795 | /** |
| 796 | 796 | * @param string $tok |
| 797 | 797 | */ |
| 798 | - public function expectChar($tok, $msg = null ){ |
|
| 798 | + public function expectChar($tok, $msg = null) { |
|
| 799 | 799 | $result = $this->MatchChar($tok); |
| 800 | - if( !$result ){ |
|
| 801 | - $this->Error( $msg ? "Expected '" . $tok . "' got '" . $this->input[$this->pos] . "'" : $msg ); |
|
| 802 | - }else{ |
|
| 800 | + if (!$result) { |
|
| 801 | + $this->Error($msg ? "Expected '".$tok."' got '".$this->input[$this->pos]."'" : $msg); |
|
| 802 | + }else { |
|
| 803 | 803 | return $result; |
| 804 | 804 | } |
| 805 | 805 | } |
@@ -849,31 +849,31 @@ discard block |
||
| 849 | 849 | // Only at one point is the primary rule not called from the |
| 850 | 850 | // block rule: at the root level. |
| 851 | 851 | // |
| 852 | - private function parsePrimary(){ |
|
| 852 | + private function parsePrimary() { |
|
| 853 | 853 | $root = array(); |
| 854 | 854 | |
| 855 | - while( true ){ |
|
| 855 | + while (true) { |
|
| 856 | 856 | |
| 857 | - if( $this->pos >= $this->input_len ){ |
|
| 857 | + if ($this->pos>=$this->input_len) { |
|
| 858 | 858 | break; |
| 859 | 859 | } |
| 860 | 860 | |
| 861 | 861 | $node = $this->parseExtend(true); |
| 862 | - if( $node ){ |
|
| 863 | - $root = array_merge($root,$node); |
|
| 862 | + if ($node) { |
|
| 863 | + $root = array_merge($root, $node); |
|
| 864 | 864 | continue; |
| 865 | 865 | } |
| 866 | 866 | |
| 867 | 867 | //$node = $this->MatchFuncs( array( 'parseMixinDefinition', 'parseRule', 'parseRuleset', 'parseMixinCall', 'parseComment', 'parseDirective')); |
| 868 | - $node = $this->MatchFuncs( array( 'parseMixinDefinition', 'parseNameValue', 'parseRule', 'parseRuleset', 'parseMixinCall', 'parseComment', 'parseRulesetCall', 'parseDirective')); |
|
| 868 | + $node = $this->MatchFuncs(array('parseMixinDefinition', 'parseNameValue', 'parseRule', 'parseRuleset', 'parseMixinCall', 'parseComment', 'parseRulesetCall', 'parseDirective')); |
|
| 869 | 869 | |
| 870 | - if( $node ){ |
|
| 870 | + if ($node) { |
|
| 871 | 871 | $root[] = $node; |
| 872 | - }elseif( !$this->MatchReg('/\\G[\s\n;]+/') ){ |
|
| 872 | + }elseif (!$this->MatchReg('/\\G[\s\n;]+/')) { |
|
| 873 | 873 | break; |
| 874 | 874 | } |
| 875 | 875 | |
| 876 | - if( $this->PeekChar('}') ){ |
|
| 876 | + if ($this->PeekChar('}')) { |
|
| 877 | 877 | break; |
| 878 | 878 | } |
| 879 | 879 | } |
@@ -886,30 +886,30 @@ discard block |
||
| 886 | 886 | // We create a Comment node for CSS comments `/* */`, |
| 887 | 887 | // but keep the LeSS comments `//` silent, by just skipping |
| 888 | 888 | // over them. |
| 889 | - private function parseComment(){ |
|
| 889 | + private function parseComment() { |
|
| 890 | 890 | |
| 891 | - if( $this->input[$this->pos] !== '/' ){ |
|
| 891 | + if ($this->input[$this->pos]!=='/') { |
|
| 892 | 892 | return; |
| 893 | 893 | } |
| 894 | 894 | |
| 895 | - if( $this->input[$this->pos+1] === '/' ){ |
|
| 895 | + if ($this->input[$this->pos+1]==='/') { |
|
| 896 | 896 | $match = $this->MatchReg('/\\G\/\/.*/'); |
| 897 | - return $this->NewObj4('Less_Tree_Comment',array($match[0], true, $this->pos, $this->env->currentFileInfo)); |
|
| 897 | + return $this->NewObj4('Less_Tree_Comment', array($match[0], true, $this->pos, $this->env->currentFileInfo)); |
|
| 898 | 898 | } |
| 899 | 899 | |
| 900 | 900 | //$comment = $this->MatchReg('/\\G\/\*(?:[^*]|\*+[^\/*])*\*+\/\n?/'); |
| 901 | - $comment = $this->MatchReg('/\\G\/\*(?s).*?\*+\/\n?/');//not the same as less.js to prevent fatal errors |
|
| 902 | - if( $comment ){ |
|
| 903 | - return $this->NewObj4('Less_Tree_Comment',array($comment[0], false, $this->pos, $this->env->currentFileInfo)); |
|
| 901 | + $comment = $this->MatchReg('/\\G\/\*(?s).*?\*+\/\n?/'); //not the same as less.js to prevent fatal errors |
|
| 902 | + if ($comment) { |
|
| 903 | + return $this->NewObj4('Less_Tree_Comment', array($comment[0], false, $this->pos, $this->env->currentFileInfo)); |
|
| 904 | 904 | } |
| 905 | 905 | } |
| 906 | 906 | |
| 907 | - private function parseComments(){ |
|
| 907 | + private function parseComments() { |
|
| 908 | 908 | $comments = array(); |
| 909 | 909 | |
| 910 | - while( $this->pos < $this->input_len ){ |
|
| 910 | + while ($this->pos<$this->input_len) { |
|
| 911 | 911 | $comment = $this->parseComment(); |
| 912 | - if( !$comment ){ |
|
| 912 | + if (!$comment) { |
|
| 913 | 913 | break; |
| 914 | 914 | } |
| 915 | 915 | |
@@ -931,12 +931,12 @@ discard block |
||
| 931 | 931 | $e = false; |
| 932 | 932 | $index = $this->pos; |
| 933 | 933 | |
| 934 | - if( $this->input[$this->pos] === '~' ){ |
|
| 934 | + if ($this->input[$this->pos]==='~') { |
|
| 935 | 935 | $j++; |
| 936 | 936 | $e = true; // Escaped strings |
| 937 | 937 | } |
| 938 | 938 | |
| 939 | - if( $this->input[$j] != '"' && $this->input[$j] !== "'" ){ |
|
| 939 | + if ($this->input[$j]!='"' && $this->input[$j]!=="'") { |
|
| 940 | 940 | return; |
| 941 | 941 | } |
| 942 | 942 | |
@@ -948,9 +948,9 @@ discard block |
||
| 948 | 948 | //$str = $this->MatchReg('/\\G"((?:[^"\\\\\r\n]|\\\\.)*)"|\'((?:[^\'\\\\\r\n]|\\\\.)*)\'/'); |
| 949 | 949 | $str = $this->MatchReg('/\\G"((?:[^"\\\\\r\n]|\\\\.|\\\\\r\n|\\\\[\n\r\f])*)"|\'((?:[^\'\\\\\r\n]|\\\\.|\\\\\r\n|\\\\[\n\r\f])*)\'/'); |
| 950 | 950 | |
| 951 | - if( $str ){ |
|
| 952 | - $result = $str[0][0] == '"' ? $str[1] : $str[2]; |
|
| 953 | - return $this->NewObj5('Less_Tree_Quoted',array($str[0], $result, $e, $index, $this->env->currentFileInfo) ); |
|
| 951 | + if ($str) { |
|
| 952 | + $result = $str[0][0]=='"' ? $str[1] : $str[2]; |
|
| 953 | + return $this->NewObj5('Less_Tree_Quoted', array($str[0], $result, $e, $index, $this->env->currentFileInfo)); |
|
| 954 | 954 | } |
| 955 | 955 | return; |
| 956 | 956 | } |
@@ -961,31 +961,31 @@ discard block |
||
| 961 | 961 | // |
| 962 | 962 | // black border-collapse |
| 963 | 963 | // |
| 964 | - private function parseEntitiesKeyword(){ |
|
| 964 | + private function parseEntitiesKeyword() { |
|
| 965 | 965 | |
| 966 | 966 | //$k = $this->MatchReg('/\\G[_A-Za-z-][_A-Za-z0-9-]*/'); |
| 967 | 967 | $k = $this->MatchReg('/\\G%|\\G[_A-Za-z-][_A-Za-z0-9-]*/'); |
| 968 | - if( $k ){ |
|
| 968 | + if ($k) { |
|
| 969 | 969 | $k = $k[0]; |
| 970 | 970 | $color = $this->fromKeyword($k); |
| 971 | - if( $color ){ |
|
| 971 | + if ($color) { |
|
| 972 | 972 | return $color; |
| 973 | 973 | } |
| 974 | - return $this->NewObj1('Less_Tree_Keyword',$k); |
|
| 974 | + return $this->NewObj1('Less_Tree_Keyword', $k); |
|
| 975 | 975 | } |
| 976 | 976 | } |
| 977 | 977 | |
| 978 | 978 | // duplicate of Less_Tree_Color::FromKeyword |
| 979 | - private function FromKeyword( $keyword ){ |
|
| 979 | + private function FromKeyword($keyword) { |
|
| 980 | 980 | $keyword = strtolower($keyword); |
| 981 | 981 | |
| 982 | - if( Less_Colors::hasOwnProperty($keyword) ){ |
|
| 982 | + if (Less_Colors::hasOwnProperty($keyword)) { |
|
| 983 | 983 | // detect named color |
| 984 | - return $this->NewObj1('Less_Tree_Color',substr(Less_Colors::color($keyword), 1)); |
|
| 984 | + return $this->NewObj1('Less_Tree_Color', substr(Less_Colors::color($keyword), 1)); |
|
| 985 | 985 | } |
| 986 | 986 | |
| 987 | - if( $keyword === 'transparent' ){ |
|
| 988 | - return $this->NewObj3('Less_Tree_Color', array( array(0, 0, 0), 0, true)); |
|
| 987 | + if ($keyword==='transparent') { |
|
| 988 | + return $this->NewObj3('Less_Tree_Color', array(array(0, 0, 0), 0, true)); |
|
| 989 | 989 | } |
| 990 | 990 | } |
| 991 | 991 | |
@@ -999,24 +999,24 @@ discard block |
||
| 999 | 999 | // |
| 1000 | 1000 | // The arguments are parsed with the `entities.arguments` parser. |
| 1001 | 1001 | // |
| 1002 | - private function parseEntitiesCall(){ |
|
| 1002 | + private function parseEntitiesCall() { |
|
| 1003 | 1003 | $index = $this->pos; |
| 1004 | 1004 | |
| 1005 | - if( !preg_match('/\\G([\w-]+|%|progid:[\w\.]+)\(/', $this->input, $name,0,$this->pos) ){ |
|
| 1005 | + if (!preg_match('/\\G([\w-]+|%|progid:[\w\.]+)\(/', $this->input, $name, 0, $this->pos)) { |
|
| 1006 | 1006 | return; |
| 1007 | 1007 | } |
| 1008 | 1008 | $name = $name[1]; |
| 1009 | 1009 | $nameLC = strtolower($name); |
| 1010 | 1010 | |
| 1011 | - if ($nameLC === 'url') { |
|
| 1011 | + if ($nameLC==='url') { |
|
| 1012 | 1012 | return null; |
| 1013 | 1013 | } |
| 1014 | 1014 | |
| 1015 | 1015 | $this->pos += strlen($name); |
| 1016 | 1016 | |
| 1017 | - if( $nameLC === 'alpha' ){ |
|
| 1017 | + if ($nameLC==='alpha') { |
|
| 1018 | 1018 | $alpha_ret = $this->parseAlpha(); |
| 1019 | - if( $alpha_ret ){ |
|
| 1019 | + if ($alpha_ret) { |
|
| 1020 | 1020 | return $alpha_ret; |
| 1021 | 1021 | } |
| 1022 | 1022 | } |
@@ -1025,12 +1025,12 @@ discard block |
||
| 1025 | 1025 | |
| 1026 | 1026 | $args = $this->parseEntitiesArguments(); |
| 1027 | 1027 | |
| 1028 | - if( !$this->MatchChar(')') ){ |
|
| 1028 | + if (!$this->MatchChar(')')) { |
|
| 1029 | 1029 | return; |
| 1030 | 1030 | } |
| 1031 | 1031 | |
| 1032 | 1032 | if ($name) { |
| 1033 | - return $this->NewObj4('Less_Tree_Call',array($name, $args, $index, $this->env->currentFileInfo) ); |
|
| 1033 | + return $this->NewObj4('Less_Tree_Call', array($name, $args, $index, $this->env->currentFileInfo)); |
|
| 1034 | 1034 | } |
| 1035 | 1035 | } |
| 1036 | 1036 | |
@@ -1039,25 +1039,25 @@ discard block |
||
| 1039 | 1039 | * |
| 1040 | 1040 | * @return array |
| 1041 | 1041 | */ |
| 1042 | - private function parseEntitiesArguments(){ |
|
| 1042 | + private function parseEntitiesArguments() { |
|
| 1043 | 1043 | |
| 1044 | 1044 | $args = array(); |
| 1045 | - while( true ){ |
|
| 1046 | - $arg = $this->MatchFuncs( array('parseEntitiesAssignment','parseExpression') ); |
|
| 1047 | - if( !$arg ){ |
|
| 1045 | + while (true) { |
|
| 1046 | + $arg = $this->MatchFuncs(array('parseEntitiesAssignment', 'parseExpression')); |
|
| 1047 | + if (!$arg) { |
|
| 1048 | 1048 | break; |
| 1049 | 1049 | } |
| 1050 | 1050 | |
| 1051 | 1051 | $args[] = $arg; |
| 1052 | - if( !$this->MatchChar(',') ){ |
|
| 1052 | + if (!$this->MatchChar(',')) { |
|
| 1053 | 1053 | break; |
| 1054 | 1054 | } |
| 1055 | 1055 | } |
| 1056 | 1056 | return $args; |
| 1057 | 1057 | } |
| 1058 | 1058 | |
| 1059 | - private function parseEntitiesLiteral(){ |
|
| 1060 | - return $this->MatchFuncs( array('parseEntitiesDimension','parseEntitiesColor','parseEntitiesQuoted','parseUnicodeDescriptor') ); |
|
| 1059 | + private function parseEntitiesLiteral() { |
|
| 1060 | + return $this->MatchFuncs(array('parseEntitiesDimension', 'parseEntitiesColor', 'parseEntitiesQuoted', 'parseUnicodeDescriptor')); |
|
| 1061 | 1061 | } |
| 1062 | 1062 | |
| 1063 | 1063 | // Assignments are argument entities for calls. |
@@ -1068,17 +1068,17 @@ discard block |
||
| 1068 | 1068 | private function parseEntitiesAssignment() { |
| 1069 | 1069 | |
| 1070 | 1070 | $key = $this->MatchReg('/\\G\w+(?=\s?=)/'); |
| 1071 | - if( !$key ){ |
|
| 1071 | + if (!$key) { |
|
| 1072 | 1072 | return; |
| 1073 | 1073 | } |
| 1074 | 1074 | |
| 1075 | - if( !$this->MatchChar('=') ){ |
|
| 1075 | + if (!$this->MatchChar('=')) { |
|
| 1076 | 1076 | return; |
| 1077 | 1077 | } |
| 1078 | 1078 | |
| 1079 | 1079 | $value = $this->parseEntity(); |
| 1080 | - if( $value ){ |
|
| 1081 | - return $this->NewObj2('Less_Tree_Assignment',array($key[0], $value)); |
|
| 1080 | + if ($value) { |
|
| 1081 | + return $this->NewObj2('Less_Tree_Assignment', array($key[0], $value)); |
|
| 1082 | 1082 | } |
| 1083 | 1083 | } |
| 1084 | 1084 | |
@@ -1089,15 +1089,15 @@ discard block |
||
| 1089 | 1089 | // standard function calls. The difference is that the argument doesn't have |
| 1090 | 1090 | // to be enclosed within a string, so it can't be parsed as an Expression. |
| 1091 | 1091 | // |
| 1092 | - private function parseEntitiesUrl(){ |
|
| 1092 | + private function parseEntitiesUrl() { |
|
| 1093 | 1093 | |
| 1094 | 1094 | |
| 1095 | - if( $this->input[$this->pos] !== 'u' || !$this->matchReg('/\\Gurl\(/') ){ |
|
| 1095 | + if ($this->input[$this->pos]!=='u' || !$this->matchReg('/\\Gurl\(/')) { |
|
| 1096 | 1096 | return; |
| 1097 | 1097 | } |
| 1098 | 1098 | |
| 1099 | - $value = $this->match( array('parseEntitiesQuoted','parseEntitiesVariable','/\\Gdata\:.*?[^\)]+/','/\\G(?:(?:\\\\[\(\)\'"])|[^\(\)\'"])+/') ); |
|
| 1100 | - if( !$value ){ |
|
| 1099 | + $value = $this->match(array('parseEntitiesQuoted', 'parseEntitiesVariable', '/\\Gdata\:.*?[^\)]+/', '/\\G(?:(?:\\\\[\(\)\'"])|[^\(\)\'"])+/')); |
|
| 1100 | + if (!$value) { |
|
| 1101 | 1101 | $value = ''; |
| 1102 | 1102 | } |
| 1103 | 1103 | |
@@ -1105,11 +1105,11 @@ discard block |
||
| 1105 | 1105 | $this->expectChar(')'); |
| 1106 | 1106 | |
| 1107 | 1107 | |
| 1108 | - if( isset($value->value) || $value instanceof Less_Tree_Variable ){ |
|
| 1109 | - return $this->NewObj2('Less_Tree_Url',array($value, $this->env->currentFileInfo)); |
|
| 1108 | + if (isset($value->value) || $value instanceof Less_Tree_Variable) { |
|
| 1109 | + return $this->NewObj2('Less_Tree_Url', array($value, $this->env->currentFileInfo)); |
|
| 1110 | 1110 | } |
| 1111 | 1111 | |
| 1112 | - return $this->NewObj2('Less_Tree_Url', array( $this->NewObj1('Less_Tree_Anonymous',$value), $this->env->currentFileInfo) ); |
|
| 1112 | + return $this->NewObj2('Less_Tree_Url', array($this->NewObj1('Less_Tree_Anonymous', $value), $this->env->currentFileInfo)); |
|
| 1113 | 1113 | } |
| 1114 | 1114 | |
| 1115 | 1115 | |
@@ -1121,10 +1121,10 @@ discard block |
||
| 1121 | 1121 | // We use a different parser for variable definitions, |
| 1122 | 1122 | // see `parsers.variable`. |
| 1123 | 1123 | // |
| 1124 | - private function parseEntitiesVariable(){ |
|
| 1124 | + private function parseEntitiesVariable() { |
|
| 1125 | 1125 | $index = $this->pos; |
| 1126 | 1126 | if ($this->PeekChar('@') && ($name = $this->MatchReg('/\\G@@?[\w-]+/'))) { |
| 1127 | - return $this->NewObj3('Less_Tree_Variable', array( $name[0], $index, $this->env->currentFileInfo)); |
|
| 1127 | + return $this->NewObj3('Less_Tree_Variable', array($name[0], $index, $this->env->currentFileInfo)); |
|
| 1128 | 1128 | } |
| 1129 | 1129 | } |
| 1130 | 1130 | |
@@ -1133,8 +1133,8 @@ discard block |
||
| 1133 | 1133 | private function parseEntitiesVariableCurly() { |
| 1134 | 1134 | $index = $this->pos; |
| 1135 | 1135 | |
| 1136 | - if( $this->input_len > ($this->pos+1) && $this->input[$this->pos] === '@' && ($curly = $this->MatchReg('/\\G@\{([\w-]+)\}/')) ){ |
|
| 1137 | - return $this->NewObj3('Less_Tree_Variable',array('@'.$curly[1], $index, $this->env->currentFileInfo)); |
|
| 1136 | + if ($this->input_len>($this->pos+1) && $this->input[$this->pos]==='@' && ($curly = $this->MatchReg('/\\G@\{([\w-]+)\}/'))) { |
|
| 1137 | + return $this->NewObj3('Less_Tree_Variable', array('@'.$curly[1], $index, $this->env->currentFileInfo)); |
|
| 1138 | 1138 | } |
| 1139 | 1139 | } |
| 1140 | 1140 | |
@@ -1145,9 +1145,9 @@ discard block |
||
| 1145 | 1145 | // |
| 1146 | 1146 | // `rgb` and `hsl` colors are parsed through the `entities.call` parser. |
| 1147 | 1147 | // |
| 1148 | - private function parseEntitiesColor(){ |
|
| 1148 | + private function parseEntitiesColor() { |
|
| 1149 | 1149 | if ($this->PeekChar('#') && ($rgb = $this->MatchReg('/\\G#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})/'))) { |
| 1150 | - return $this->NewObj1('Less_Tree_Color',$rgb[1]); |
|
| 1150 | + return $this->NewObj1('Less_Tree_Color', $rgb[1]); |
|
| 1151 | 1151 | } |
| 1152 | 1152 | } |
| 1153 | 1153 | |
@@ -1156,22 +1156,22 @@ discard block |
||
| 1156 | 1156 | // |
| 1157 | 1157 | // 0.5em 95% |
| 1158 | 1158 | // |
| 1159 | - private function parseEntitiesDimension(){ |
|
| 1159 | + private function parseEntitiesDimension() { |
|
| 1160 | 1160 | |
| 1161 | 1161 | $c = @ord($this->input[$this->pos]); |
| 1162 | 1162 | |
| 1163 | 1163 | //Is the first char of the dimension 0-9, '.', '+' or '-' |
| 1164 | - if (($c > 57 || $c < 43) || $c === 47 || $c == 44){ |
|
| 1164 | + if (($c>57 || $c<43) || $c===47 || $c==44) { |
|
| 1165 | 1165 | return; |
| 1166 | 1166 | } |
| 1167 | 1167 | |
| 1168 | 1168 | $value = $this->MatchReg('/\\G([+-]?\d*\.?\d+)(%|[a-z]+)?/'); |
| 1169 | - if( $value ){ |
|
| 1169 | + if ($value) { |
|
| 1170 | 1170 | |
| 1171 | - if( isset($value[2]) ){ |
|
| 1172 | - return $this->NewObj2('Less_Tree_Dimension', array($value[1],$value[2])); |
|
| 1171 | + if (isset($value[2])) { |
|
| 1172 | + return $this->NewObj2('Less_Tree_Dimension', array($value[1], $value[2])); |
|
| 1173 | 1173 | } |
| 1174 | - return $this->NewObj1('Less_Tree_Dimension',$value[1]); |
|
| 1174 | + return $this->NewObj1('Less_Tree_Dimension', $value[1]); |
|
| 1175 | 1175 | } |
| 1176 | 1176 | } |
| 1177 | 1177 | |
@@ -1183,7 +1183,7 @@ discard block |
||
| 1183 | 1183 | // |
| 1184 | 1184 | function parseUnicodeDescriptor() { |
| 1185 | 1185 | $ud = $this->MatchReg('/\\G(U\+[0-9a-fA-F?]+)(\-[0-9a-fA-F?]+)?/'); |
| 1186 | - if( $ud ){ |
|
| 1186 | + if ($ud) { |
|
| 1187 | 1187 | return $this->NewObj1('Less_Tree_UnicodeDescriptor', $ud[0]); |
| 1188 | 1188 | } |
| 1189 | 1189 | } |
@@ -1194,21 +1194,21 @@ discard block |
||
| 1194 | 1194 | // |
| 1195 | 1195 | // `window.location.href` |
| 1196 | 1196 | // |
| 1197 | - private function parseEntitiesJavascript(){ |
|
| 1197 | + private function parseEntitiesJavascript() { |
|
| 1198 | 1198 | $e = false; |
| 1199 | 1199 | $j = $this->pos; |
| 1200 | - if( $this->input[$j] === '~' ){ |
|
| 1200 | + if ($this->input[$j]==='~') { |
|
| 1201 | 1201 | $j++; |
| 1202 | 1202 | $e = true; |
| 1203 | 1203 | } |
| 1204 | - if( $this->input[$j] !== '`' ){ |
|
| 1204 | + if ($this->input[$j]!=='`') { |
|
| 1205 | 1205 | return; |
| 1206 | 1206 | } |
| 1207 | - if( $e ){ |
|
| 1207 | + if ($e) { |
|
| 1208 | 1208 | $this->MatchChar('~'); |
| 1209 | 1209 | } |
| 1210 | 1210 | $str = $this->MatchReg('/\\G`([^`]*)`/'); |
| 1211 | - if( $str ){ |
|
| 1211 | + if ($str) { |
|
| 1212 | 1212 | return $this->NewObj3('Less_Tree_Javascript', array($str[1], $this->pos, $e)); |
| 1213 | 1213 | } |
| 1214 | 1214 | } |
@@ -1219,7 +1219,7 @@ discard block |
||
| 1219 | 1219 | // |
| 1220 | 1220 | // @fink: |
| 1221 | 1221 | // |
| 1222 | - private function parseVariable(){ |
|
| 1222 | + private function parseVariable() { |
|
| 1223 | 1223 | if ($this->PeekChar('@') && ($name = $this->MatchReg('/\\G(@[\w-]+)\s*:/'))) { |
| 1224 | 1224 | return $name[1]; |
| 1225 | 1225 | } |
@@ -1231,10 +1231,10 @@ discard block |
||
| 1231 | 1231 | // |
| 1232 | 1232 | // @fink(); |
| 1233 | 1233 | // |
| 1234 | - private function parseRulesetCall(){ |
|
| 1234 | + private function parseRulesetCall() { |
|
| 1235 | 1235 | |
| 1236 | - if( $this->input[$this->pos] === '@' && ($name = $this->MatchReg('/\\G(@[\w-]+)\s*\(\s*\)\s*;/')) ){ |
|
| 1237 | - return $this->NewObj1('Less_Tree_RulesetCall', $name[1] ); |
|
| 1236 | + if ($this->input[$this->pos]==='@' && ($name = $this->MatchReg('/\\G(@[\w-]+)\s*\(\s*\)\s*;/'))) { |
|
| 1237 | + return $this->NewObj1('Less_Tree_RulesetCall', $name[1]); |
|
| 1238 | 1238 | } |
| 1239 | 1239 | } |
| 1240 | 1240 | |
@@ -1242,36 +1242,36 @@ discard block |
||
| 1242 | 1242 | // |
| 1243 | 1243 | // extend syntax - used to extend selectors |
| 1244 | 1244 | // |
| 1245 | - function parseExtend($isRule = false){ |
|
| 1245 | + function parseExtend($isRule = false) { |
|
| 1246 | 1246 | |
| 1247 | 1247 | $index = $this->pos; |
| 1248 | 1248 | $extendList = array(); |
| 1249 | 1249 | |
| 1250 | 1250 | |
| 1251 | - if( !$this->MatchReg( $isRule ? '/\\G&:extend\(/' : '/\\G:extend\(/' ) ){ return; } |
|
| 1251 | + if (!$this->MatchReg($isRule ? '/\\G&:extend\(/' : '/\\G:extend\(/')) { return; } |
|
| 1252 | 1252 | |
| 1253 | - do{ |
|
| 1253 | + do { |
|
| 1254 | 1254 | $option = null; |
| 1255 | 1255 | $elements = array(); |
| 1256 | - while( true ){ |
|
| 1256 | + while (true) { |
|
| 1257 | 1257 | $option = $this->MatchReg('/\\G(all)(?=\s*(\)|,))/'); |
| 1258 | - if( $option ){ break; } |
|
| 1258 | + if ($option) { break; } |
|
| 1259 | 1259 | $e = $this->parseElement(); |
| 1260 | - if( !$e ){ break; } |
|
| 1260 | + if (!$e) { break; } |
|
| 1261 | 1261 | $elements[] = $e; |
| 1262 | 1262 | } |
| 1263 | 1263 | |
| 1264 | - if( $option ){ |
|
| 1264 | + if ($option) { |
|
| 1265 | 1265 | $option = $option[1]; |
| 1266 | 1266 | } |
| 1267 | 1267 | |
| 1268 | - $extendList[] = $this->NewObj3('Less_Tree_Extend', array( $this->NewObj1('Less_Tree_Selector',$elements), $option, $index )); |
|
| 1268 | + $extendList[] = $this->NewObj3('Less_Tree_Extend', array($this->NewObj1('Less_Tree_Selector', $elements), $option, $index)); |
|
| 1269 | 1269 | |
| 1270 | - }while( $this->MatchChar(",") ); |
|
| 1270 | + } while ($this->MatchChar(",")); |
|
| 1271 | 1271 | |
| 1272 | 1272 | $this->expect('/\\G\)/'); |
| 1273 | 1273 | |
| 1274 | - if( $isRule ){ |
|
| 1274 | + if ($isRule) { |
|
| 1275 | 1275 | $this->expect('/\\G;/'); |
| 1276 | 1276 | } |
| 1277 | 1277 | |
@@ -1290,10 +1290,10 @@ discard block |
||
| 1290 | 1290 | // namespaced, but we only support the child and descendant |
| 1291 | 1291 | // selector for now. |
| 1292 | 1292 | // |
| 1293 | - private function parseMixinCall(){ |
|
| 1293 | + private function parseMixinCall() { |
|
| 1294 | 1294 | |
| 1295 | 1295 | $char = $this->input[$this->pos]; |
| 1296 | - if( $char !== '.' && $char !== '#' ){ |
|
| 1296 | + if ($char!=='.' && $char!=='#') { |
|
| 1297 | 1297 | return; |
| 1298 | 1298 | } |
| 1299 | 1299 | |
@@ -1302,21 +1302,21 @@ discard block |
||
| 1302 | 1302 | |
| 1303 | 1303 | $elements = $this->parseMixinCallElements(); |
| 1304 | 1304 | |
| 1305 | - if( $elements ){ |
|
| 1305 | + if ($elements) { |
|
| 1306 | 1306 | |
| 1307 | - if( $this->MatchChar('(') ){ |
|
| 1307 | + if ($this->MatchChar('(')) { |
|
| 1308 | 1308 | $returned = $this->parseMixinArgs(true); |
| 1309 | 1309 | $args = $returned['args']; |
| 1310 | 1310 | $this->expectChar(')'); |
| 1311 | - }else{ |
|
| 1311 | + }else { |
|
| 1312 | 1312 | $args = array(); |
| 1313 | 1313 | } |
| 1314 | 1314 | |
| 1315 | 1315 | $important = $this->parseImportant(); |
| 1316 | 1316 | |
| 1317 | - if( $this->parseEnd() ){ |
|
| 1317 | + if ($this->parseEnd()) { |
|
| 1318 | 1318 | $this->forget(); |
| 1319 | - return $this->NewObj5('Less_Tree_Mixin_Call', array( $elements, $args, $index, $this->env->currentFileInfo, $important)); |
|
| 1319 | + return $this->NewObj5('Less_Tree_Mixin_Call', array($elements, $args, $index, $this->env->currentFileInfo, $important)); |
|
| 1320 | 1320 | } |
| 1321 | 1321 | } |
| 1322 | 1322 | |
@@ -1324,14 +1324,14 @@ discard block |
||
| 1324 | 1324 | } |
| 1325 | 1325 | |
| 1326 | 1326 | |
| 1327 | - private function parseMixinCallElements(){ |
|
| 1327 | + private function parseMixinCallElements() { |
|
| 1328 | 1328 | $elements = array(); |
| 1329 | 1329 | $c = null; |
| 1330 | 1330 | |
| 1331 | - while( true ){ |
|
| 1331 | + while (true) { |
|
| 1332 | 1332 | $elemIndex = $this->pos; |
| 1333 | 1333 | $e = $this->MatchReg('/\\G[#.](?:[\w-]|\\\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/'); |
| 1334 | - if( !$e ){ |
|
| 1334 | + if (!$e) { |
|
| 1335 | 1335 | break; |
| 1336 | 1336 | } |
| 1337 | 1337 | $elements[] = $this->NewObj4('Less_Tree_Element', array($c, $e[0], $elemIndex, $this->env->currentFileInfo)); |
@@ -1346,7 +1346,7 @@ discard block |
||
| 1346 | 1346 | /** |
| 1347 | 1347 | * @param boolean $isCall |
| 1348 | 1348 | */ |
| 1349 | - private function parseMixinArgs( $isCall ){ |
|
| 1349 | + private function parseMixinArgs($isCall) { |
|
| 1350 | 1350 | $expressions = array(); |
| 1351 | 1351 | $argsSemiColon = array(); |
| 1352 | 1352 | $isSemiColonSeperated = null; |
@@ -1357,54 +1357,54 @@ discard block |
||
| 1357 | 1357 | |
| 1358 | 1358 | $this->save(); |
| 1359 | 1359 | |
| 1360 | - while( true ){ |
|
| 1361 | - if( $isCall ){ |
|
| 1362 | - $arg = $this->MatchFuncs( array( 'parseDetachedRuleset','parseExpression' ) ); |
|
| 1363 | - } else { |
|
| 1360 | + while (true) { |
|
| 1361 | + if ($isCall) { |
|
| 1362 | + $arg = $this->MatchFuncs(array('parseDetachedRuleset', 'parseExpression')); |
|
| 1363 | + }else { |
|
| 1364 | 1364 | $this->parseComments(); |
| 1365 | - if( $this->input[ $this->pos ] === '.' && $this->MatchReg('/\\G\.{3}/') ){ |
|
| 1365 | + if ($this->input[$this->pos]==='.' && $this->MatchReg('/\\G\.{3}/')) { |
|
| 1366 | 1366 | $returner['variadic'] = true; |
| 1367 | - if( $this->MatchChar(";") && !$isSemiColonSeperated ){ |
|
| 1367 | + if ($this->MatchChar(";") && !$isSemiColonSeperated) { |
|
| 1368 | 1368 | $isSemiColonSeperated = true; |
| 1369 | 1369 | } |
| 1370 | 1370 | |
| 1371 | - if( $isSemiColonSeperated ){ |
|
| 1371 | + if ($isSemiColonSeperated) { |
|
| 1372 | 1372 | $argsSemiColon[] = array('variadic'=>true); |
| 1373 | - }else{ |
|
| 1373 | + }else { |
|
| 1374 | 1374 | $argsComma[] = array('variadic'=>true); |
| 1375 | 1375 | } |
| 1376 | 1376 | break; |
| 1377 | 1377 | } |
| 1378 | - $arg = $this->MatchFuncs( array('parseEntitiesVariable','parseEntitiesLiteral','parseEntitiesKeyword') ); |
|
| 1378 | + $arg = $this->MatchFuncs(array('parseEntitiesVariable', 'parseEntitiesLiteral', 'parseEntitiesKeyword')); |
|
| 1379 | 1379 | } |
| 1380 | 1380 | |
| 1381 | - if( !$arg ){ |
|
| 1381 | + if (!$arg) { |
|
| 1382 | 1382 | break; |
| 1383 | 1383 | } |
| 1384 | 1384 | |
| 1385 | 1385 | |
| 1386 | 1386 | $nameLoop = null; |
| 1387 | - if( $arg instanceof Less_Tree_Expression ){ |
|
| 1387 | + if ($arg instanceof Less_Tree_Expression) { |
|
| 1388 | 1388 | $arg->throwAwayComments(); |
| 1389 | 1389 | } |
| 1390 | 1390 | $value = $arg; |
| 1391 | 1391 | $val = null; |
| 1392 | 1392 | |
| 1393 | - if( $isCall ){ |
|
| 1393 | + if ($isCall) { |
|
| 1394 | 1394 | // Variable |
| 1395 | - if( property_exists($arg,'value') && count($arg->value) == 1 ){ |
|
| 1395 | + if (property_exists($arg, 'value') && count($arg->value)==1) { |
|
| 1396 | 1396 | $val = $arg->value[0]; |
| 1397 | 1397 | } |
| 1398 | - } else { |
|
| 1398 | + }else { |
|
| 1399 | 1399 | $val = $arg; |
| 1400 | 1400 | } |
| 1401 | 1401 | |
| 1402 | 1402 | |
| 1403 | - if( $val instanceof Less_Tree_Variable ){ |
|
| 1403 | + if ($val instanceof Less_Tree_Variable) { |
|
| 1404 | 1404 | |
| 1405 | - if( $this->MatchChar(':') ){ |
|
| 1406 | - if( $expressions ){ |
|
| 1407 | - if( $isSemiColonSeperated ){ |
|
| 1405 | + if ($this->MatchChar(':')) { |
|
| 1406 | + if ($expressions) { |
|
| 1407 | + if ($isSemiColonSeperated) { |
|
| 1408 | 1408 | $this->Error('Cannot mix ; and , as delimiter types'); |
| 1409 | 1409 | } |
| 1410 | 1410 | $expressionContainsNamed = true; |
@@ -1414,17 +1414,17 @@ discard block |
||
| 1414 | 1414 | // However if we do want to add it, there is nothing blocking it, just don't error |
| 1415 | 1415 | // and remove isCall dependency below |
| 1416 | 1416 | $value = null; |
| 1417 | - if( $isCall ){ |
|
| 1417 | + if ($isCall) { |
|
| 1418 | 1418 | $value = $this->parseDetachedRuleset(); |
| 1419 | 1419 | } |
| 1420 | - if( !$value ){ |
|
| 1420 | + if (!$value) { |
|
| 1421 | 1421 | $value = $this->parseExpression(); |
| 1422 | 1422 | } |
| 1423 | 1423 | |
| 1424 | - if( !$value ){ |
|
| 1425 | - if( $isCall ){ |
|
| 1424 | + if (!$value) { |
|
| 1425 | + if ($isCall) { |
|
| 1426 | 1426 | $this->Error('could not understand value for named argument'); |
| 1427 | - } else { |
|
| 1427 | + }else { |
|
| 1428 | 1428 | $this->restore(); |
| 1429 | 1429 | $returner['args'] = array(); |
| 1430 | 1430 | return $returner; |
@@ -1432,45 +1432,45 @@ discard block |
||
| 1432 | 1432 | } |
| 1433 | 1433 | |
| 1434 | 1434 | $nameLoop = ($name = $val->name); |
| 1435 | - }elseif( !$isCall && $this->MatchReg('/\\G\.{3}/') ){ |
|
| 1435 | + }elseif (!$isCall && $this->MatchReg('/\\G\.{3}/')) { |
|
| 1436 | 1436 | $returner['variadic'] = true; |
| 1437 | - if( $this->MatchChar(";") && !$isSemiColonSeperated ){ |
|
| 1437 | + if ($this->MatchChar(";") && !$isSemiColonSeperated) { |
|
| 1438 | 1438 | $isSemiColonSeperated = true; |
| 1439 | 1439 | } |
| 1440 | - if( $isSemiColonSeperated ){ |
|
| 1440 | + if ($isSemiColonSeperated) { |
|
| 1441 | 1441 | $argsSemiColon[] = array('name'=> $arg->name, 'variadic' => true); |
| 1442 | - }else{ |
|
| 1442 | + }else { |
|
| 1443 | 1443 | $argsComma[] = array('name'=> $arg->name, 'variadic' => true); |
| 1444 | 1444 | } |
| 1445 | 1445 | break; |
| 1446 | - }elseif( !$isCall ){ |
|
| 1446 | + }elseif (!$isCall) { |
|
| 1447 | 1447 | $name = $nameLoop = $val->name; |
| 1448 | 1448 | $value = null; |
| 1449 | 1449 | } |
| 1450 | 1450 | } |
| 1451 | 1451 | |
| 1452 | - if( $value ){ |
|
| 1452 | + if ($value) { |
|
| 1453 | 1453 | $expressions[] = $value; |
| 1454 | 1454 | } |
| 1455 | 1455 | |
| 1456 | - $argsComma[] = array('name'=>$nameLoop, 'value'=>$value ); |
|
| 1456 | + $argsComma[] = array('name'=>$nameLoop, 'value'=>$value); |
|
| 1457 | 1457 | |
| 1458 | - if( $this->MatchChar(',') ){ |
|
| 1458 | + if ($this->MatchChar(',')) { |
|
| 1459 | 1459 | continue; |
| 1460 | 1460 | } |
| 1461 | 1461 | |
| 1462 | - if( $this->MatchChar(';') || $isSemiColonSeperated ){ |
|
| 1462 | + if ($this->MatchChar(';') || $isSemiColonSeperated) { |
|
| 1463 | 1463 | |
| 1464 | - if( $expressionContainsNamed ){ |
|
| 1464 | + if ($expressionContainsNamed) { |
|
| 1465 | 1465 | $this->Error('Cannot mix ; and , as delimiter types'); |
| 1466 | 1466 | } |
| 1467 | 1467 | |
| 1468 | 1468 | $isSemiColonSeperated = true; |
| 1469 | 1469 | |
| 1470 | - if( count($expressions) > 1 ){ |
|
| 1470 | + if (count($expressions)>1) { |
|
| 1471 | 1471 | $value = $this->NewObj1('Less_Tree_Value', $expressions); |
| 1472 | 1472 | } |
| 1473 | - $argsSemiColon[] = array('name'=>$name, 'value'=>$value ); |
|
| 1473 | + $argsSemiColon[] = array('name'=>$name, 'value'=>$value); |
|
| 1474 | 1474 | |
| 1475 | 1475 | $name = null; |
| 1476 | 1476 | $expressions = array(); |
@@ -1504,21 +1504,21 @@ discard block |
||
| 1504 | 1504 | // Once we've got our params list, and a closing `)`, we parse |
| 1505 | 1505 | // the `{...}` block. |
| 1506 | 1506 | // |
| 1507 | - private function parseMixinDefinition(){ |
|
| 1507 | + private function parseMixinDefinition() { |
|
| 1508 | 1508 | $cond = null; |
| 1509 | 1509 | |
| 1510 | 1510 | $char = $this->input[$this->pos]; |
| 1511 | - if( ($char !== '.' && $char !== '#') || ($char === '{' && $this->PeekReg('/\\G[^{]*\}/')) ){ |
|
| 1511 | + if (($char!=='.' && $char!=='#') || ($char==='{' && $this->PeekReg('/\\G[^{]*\}/'))) { |
|
| 1512 | 1512 | return; |
| 1513 | 1513 | } |
| 1514 | 1514 | |
| 1515 | 1515 | $this->save(); |
| 1516 | 1516 | |
| 1517 | 1517 | $match = $this->MatchReg('/\\G([#.](?:[\w-]|\\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+)\s*\(/'); |
| 1518 | - if( $match ){ |
|
| 1518 | + if ($match) { |
|
| 1519 | 1519 | $name = $match[1]; |
| 1520 | 1520 | |
| 1521 | - $argInfo = $this->parseMixinArgs( false ); |
|
| 1521 | + $argInfo = $this->parseMixinArgs(false); |
|
| 1522 | 1522 | $params = $argInfo['args']; |
| 1523 | 1523 | $variadic = $argInfo['variadic']; |
| 1524 | 1524 | |
@@ -1528,7 +1528,7 @@ discard block |
||
| 1528 | 1528 | // also |
| 1529 | 1529 | // .mixincall(@a: {rule: set;}); |
| 1530 | 1530 | // so we have to be nice and restore |
| 1531 | - if( !$this->MatchChar(')') ){ |
|
| 1531 | + if (!$this->MatchChar(')')) { |
|
| 1532 | 1532 | $this->furthest = $this->pos; |
| 1533 | 1533 | $this->restore(); |
| 1534 | 1534 | return; |
@@ -1543,13 +1543,13 @@ discard block |
||
| 1543 | 1543 | |
| 1544 | 1544 | $ruleset = $this->parseBlock(); |
| 1545 | 1545 | |
| 1546 | - if( is_array($ruleset) ){ |
|
| 1546 | + if (is_array($ruleset)) { |
|
| 1547 | 1547 | $this->forget(); |
| 1548 | - return $this->NewObj5('Less_Tree_Mixin_Definition', array( $name, $params, $ruleset, $cond, $variadic)); |
|
| 1548 | + return $this->NewObj5('Less_Tree_Mixin_Definition', array($name, $params, $ruleset, $cond, $variadic)); |
|
| 1549 | 1549 | } |
| 1550 | 1550 | |
| 1551 | 1551 | $this->restore(); |
| 1552 | - }else{ |
|
| 1552 | + }else { |
|
| 1553 | 1553 | $this->forget(); |
| 1554 | 1554 | } |
| 1555 | 1555 | } |
@@ -1558,9 +1558,9 @@ discard block |
||
| 1558 | 1558 | // Entities are the smallest recognized token, |
| 1559 | 1559 | // and can be found inside a rule's value. |
| 1560 | 1560 | // |
| 1561 | - private function parseEntity(){ |
|
| 1561 | + private function parseEntity() { |
|
| 1562 | 1562 | |
| 1563 | - return $this->MatchFuncs( array('parseEntitiesLiteral','parseEntitiesVariable','parseEntitiesUrl','parseEntitiesCall','parseEntitiesKeyword','parseEntitiesJavascript','parseComment') ); |
|
| 1563 | + return $this->MatchFuncs(array('parseEntitiesLiteral', 'parseEntitiesVariable', 'parseEntitiesUrl', 'parseEntitiesCall', 'parseEntitiesKeyword', 'parseEntitiesJavascript', 'parseComment')); |
|
| 1564 | 1564 | } |
| 1565 | 1565 | |
| 1566 | 1566 | // |
@@ -1568,7 +1568,7 @@ discard block |
||
| 1568 | 1568 | // because the `block` rule will be expecting it, but we still need to make sure |
| 1569 | 1569 | // it's there, if ';' was omitted. |
| 1570 | 1570 | // |
| 1571 | - private function parseEnd(){ |
|
| 1571 | + private function parseEnd() { |
|
| 1572 | 1572 | return $this->MatchChar(';') || $this->PeekChar('}'); |
| 1573 | 1573 | } |
| 1574 | 1574 | |
@@ -1577,24 +1577,24 @@ discard block |
||
| 1577 | 1577 | // |
| 1578 | 1578 | // alpha(opacity=88) |
| 1579 | 1579 | // |
| 1580 | - private function parseAlpha(){ |
|
| 1580 | + private function parseAlpha() { |
|
| 1581 | 1581 | |
| 1582 | - if ( ! $this->MatchReg('/\\G\(opacity=/i')) { |
|
| 1582 | + if (!$this->MatchReg('/\\G\(opacity=/i')) { |
|
| 1583 | 1583 | return; |
| 1584 | 1584 | } |
| 1585 | 1585 | |
| 1586 | 1586 | $value = $this->MatchReg('/\\G[0-9]+/'); |
| 1587 | - if( $value ){ |
|
| 1587 | + if ($value) { |
|
| 1588 | 1588 | $value = $value[0]; |
| 1589 | - }else{ |
|
| 1589 | + }else { |
|
| 1590 | 1590 | $value = $this->parseEntitiesVariable(); |
| 1591 | - if( !$value ){ |
|
| 1591 | + if (!$value) { |
|
| 1592 | 1592 | return; |
| 1593 | 1593 | } |
| 1594 | 1594 | } |
| 1595 | 1595 | |
| 1596 | 1596 | $this->expectChar(')'); |
| 1597 | - return $this->NewObj1('Less_Tree_Alpha',$value); |
|
| 1597 | + return $this->NewObj1('Less_Tree_Alpha', $value); |
|
| 1598 | 1598 | } |
| 1599 | 1599 | |
| 1600 | 1600 | |
@@ -1610,29 +1610,29 @@ discard block |
||
| 1610 | 1610 | // they are made out of a `Combinator` (see combinator rule), |
| 1611 | 1611 | // and an element name, such as a tag a class, or `*`. |
| 1612 | 1612 | // |
| 1613 | - private function parseElement(){ |
|
| 1613 | + private function parseElement() { |
|
| 1614 | 1614 | $c = $this->parseCombinator(); |
| 1615 | 1615 | $index = $this->pos; |
| 1616 | 1616 | |
| 1617 | - $e = $this->match( array('/\\G(?:\d+\.\d+|\d+)%/', '/\\G(?:[.#]?|:*)(?:[\w-]|[^\x00-\x9f]|\\\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/', |
|
| 1618 | - '#*', '#&', 'parseAttribute', '/\\G\([^()@]+\)/', '/\\G[\.#](?=@)/', 'parseEntitiesVariableCurly') ); |
|
| 1617 | + $e = $this->match(array('/\\G(?:\d+\.\d+|\d+)%/', '/\\G(?:[.#]?|:*)(?:[\w-]|[^\x00-\x9f]|\\\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/', |
|
| 1618 | + '#*', '#&', 'parseAttribute', '/\\G\([^()@]+\)/', '/\\G[\.#](?=@)/', 'parseEntitiesVariableCurly')); |
|
| 1619 | 1619 | |
| 1620 | - if( is_null($e) ){ |
|
| 1620 | + if (is_null($e)) { |
|
| 1621 | 1621 | $this->save(); |
| 1622 | - if( $this->MatchChar('(') ){ |
|
| 1623 | - if( ($v = $this->parseSelector()) && $this->MatchChar(')') ){ |
|
| 1624 | - $e = $this->NewObj1('Less_Tree_Paren',$v); |
|
| 1622 | + if ($this->MatchChar('(')) { |
|
| 1623 | + if (($v = $this->parseSelector()) && $this->MatchChar(')')) { |
|
| 1624 | + $e = $this->NewObj1('Less_Tree_Paren', $v); |
|
| 1625 | 1625 | $this->forget(); |
| 1626 | - }else{ |
|
| 1626 | + }else { |
|
| 1627 | 1627 | $this->restore(); |
| 1628 | 1628 | } |
| 1629 | - }else{ |
|
| 1629 | + }else { |
|
| 1630 | 1630 | $this->forget(); |
| 1631 | 1631 | } |
| 1632 | 1632 | } |
| 1633 | 1633 | |
| 1634 | - if( !is_null($e) ){ |
|
| 1635 | - return $this->NewObj4('Less_Tree_Element',array( $c, $e, $index, $this->env->currentFileInfo)); |
|
| 1634 | + if (!is_null($e)) { |
|
| 1635 | + return $this->NewObj4('Less_Tree_Element', array($c, $e, $index, $this->env->currentFileInfo)); |
|
| 1636 | 1636 | } |
| 1637 | 1637 | } |
| 1638 | 1638 | |
@@ -1644,13 +1644,13 @@ discard block |
||
| 1644 | 1644 | // as it's an empty space. We have to check the previous character |
| 1645 | 1645 | // in the input, to see if it's a ` ` character. |
| 1646 | 1646 | // |
| 1647 | - private function parseCombinator(){ |
|
| 1648 | - if( $this->pos < $this->input_len ){ |
|
| 1647 | + private function parseCombinator() { |
|
| 1648 | + if ($this->pos<$this->input_len) { |
|
| 1649 | 1649 | $c = $this->input[$this->pos]; |
| 1650 | - if ($c === '>' || $c === '+' || $c === '~' || $c === '|' || $c === '^' ){ |
|
| 1650 | + if ($c==='>' || $c==='+' || $c==='~' || $c==='|' || $c==='^') { |
|
| 1651 | 1651 | |
| 1652 | 1652 | $this->pos++; |
| 1653 | - if( $this->input[$this->pos] === '^' ){ |
|
| 1653 | + if ($this->input[$this->pos]==='^') { |
|
| 1654 | 1654 | $c = '^^'; |
| 1655 | 1655 | $this->pos++; |
| 1656 | 1656 | } |
@@ -1660,7 +1660,7 @@ discard block |
||
| 1660 | 1660 | return $c; |
| 1661 | 1661 | } |
| 1662 | 1662 | |
| 1663 | - if( $this->pos > 0 && $this->isWhitespace(-1) ){ |
|
| 1663 | + if ($this->pos>0 && $this->isWhitespace(-1)) { |
|
| 1664 | 1664 | return ' '; |
| 1665 | 1665 | } |
| 1666 | 1666 | } |
@@ -1670,7 +1670,7 @@ discard block |
||
| 1670 | 1670 | // A CSS selector (see selector below) |
| 1671 | 1671 | // with less extensions e.g. the ability to extend and guard |
| 1672 | 1672 | // |
| 1673 | - private function parseLessSelector(){ |
|
| 1673 | + private function parseLessSelector() { |
|
| 1674 | 1674 | return $this->parseSelector(true); |
| 1675 | 1675 | } |
| 1676 | 1676 | |
@@ -1682,7 +1682,7 @@ discard block |
||
| 1682 | 1682 | // |
| 1683 | 1683 | // Selectors are made out of one or more Elements, see above. |
| 1684 | 1684 | // |
| 1685 | - private function parseSelector( $isLess = false ){ |
|
| 1685 | + private function parseSelector($isLess = false) { |
|
| 1686 | 1686 | $elements = array(); |
| 1687 | 1687 | $extendList = array(); |
| 1688 | 1688 | $condition = null; |
@@ -1692,127 +1692,127 @@ discard block |
||
| 1692 | 1692 | $c = null; |
| 1693 | 1693 | $index = $this->pos; |
| 1694 | 1694 | |
| 1695 | - while( ($isLess && ($extend = $this->parseExtend())) || ($isLess && ($when = $this->MatchReg('/\\Gwhen/') )) || ($e = $this->parseElement()) ){ |
|
| 1696 | - if( $when ){ |
|
| 1695 | + while (($isLess && ($extend = $this->parseExtend())) || ($isLess && ($when = $this->MatchReg('/\\Gwhen/'))) || ($e = $this->parseElement())) { |
|
| 1696 | + if ($when) { |
|
| 1697 | 1697 | $condition = $this->expect('parseConditions', 'expected condition'); |
| 1698 | - }elseif( $condition ){ |
|
| 1698 | + }elseif ($condition) { |
|
| 1699 | 1699 | //error("CSS guard can only be used at the end of selector"); |
| 1700 | - }elseif( $extend ){ |
|
| 1701 | - $extendList = array_merge($extendList,$extend); |
|
| 1702 | - }else{ |
|
| 1700 | + }elseif ($extend) { |
|
| 1701 | + $extendList = array_merge($extendList, $extend); |
|
| 1702 | + }else { |
|
| 1703 | 1703 | //if( count($extendList) ){ |
| 1704 | 1704 | //error("Extend can only be used at the end of selector"); |
| 1705 | 1705 | //} |
| 1706 | - if( $this->pos < $this->input_len ){ |
|
| 1707 | - $c = $this->input[ $this->pos ]; |
|
| 1706 | + if ($this->pos<$this->input_len) { |
|
| 1707 | + $c = $this->input[$this->pos]; |
|
| 1708 | 1708 | } |
| 1709 | 1709 | $elements[] = $e; |
| 1710 | 1710 | $e = null; |
| 1711 | 1711 | } |
| 1712 | 1712 | |
| 1713 | - if( $c === '{' || $c === '}' || $c === ';' || $c === ',' || $c === ')') { break; } |
|
| 1713 | + if ($c==='{' || $c==='}' || $c===';' || $c===',' || $c===')') { break; } |
|
| 1714 | 1714 | } |
| 1715 | 1715 | |
| 1716 | - if( $elements ){ |
|
| 1717 | - return $this->NewObj5('Less_Tree_Selector',array($elements, $extendList, $condition, $index, $this->env->currentFileInfo)); |
|
| 1716 | + if ($elements) { |
|
| 1717 | + return $this->NewObj5('Less_Tree_Selector', array($elements, $extendList, $condition, $index, $this->env->currentFileInfo)); |
|
| 1718 | 1718 | } |
| 1719 | - if( $extendList ) { |
|
| 1719 | + if ($extendList) { |
|
| 1720 | 1720 | $this->Error('Extend must be used to extend a selector, it cannot be used on its own'); |
| 1721 | 1721 | } |
| 1722 | 1722 | } |
| 1723 | 1723 | |
| 1724 | - private function parseTag(){ |
|
| 1725 | - return ( $tag = $this->MatchReg('/\\G[A-Za-z][A-Za-z-]*[0-9]?/') ) ? $tag : $this->MatchChar('*'); |
|
| 1724 | + private function parseTag() { |
|
| 1725 | + return ($tag = $this->MatchReg('/\\G[A-Za-z][A-Za-z-]*[0-9]?/')) ? $tag : $this->MatchChar('*'); |
|
| 1726 | 1726 | } |
| 1727 | 1727 | |
| 1728 | - private function parseAttribute(){ |
|
| 1728 | + private function parseAttribute() { |
|
| 1729 | 1729 | |
| 1730 | 1730 | $val = null; |
| 1731 | 1731 | |
| 1732 | - if( !$this->MatchChar('[') ){ |
|
| 1732 | + if (!$this->MatchChar('[')) { |
|
| 1733 | 1733 | return; |
| 1734 | 1734 | } |
| 1735 | 1735 | |
| 1736 | 1736 | $key = $this->parseEntitiesVariableCurly(); |
| 1737 | - if( !$key ){ |
|
| 1737 | + if (!$key) { |
|
| 1738 | 1738 | $key = $this->expect('/\\G(?:[_A-Za-z0-9-\*]*\|)?(?:[_A-Za-z0-9-]|\\\\.)+/'); |
| 1739 | 1739 | } |
| 1740 | 1740 | |
| 1741 | 1741 | $op = $this->MatchReg('/\\G[|~*$^]?=/'); |
| 1742 | - if( $op ){ |
|
| 1743 | - $val = $this->match( array('parseEntitiesQuoted','/\\G[0-9]+%/','/\\G[\w-]+/','parseEntitiesVariableCurly') ); |
|
| 1742 | + if ($op) { |
|
| 1743 | + $val = $this->match(array('parseEntitiesQuoted', '/\\G[0-9]+%/', '/\\G[\w-]+/', 'parseEntitiesVariableCurly')); |
|
| 1744 | 1744 | } |
| 1745 | 1745 | |
| 1746 | 1746 | $this->expectChar(']'); |
| 1747 | 1747 | |
| 1748 | - return $this->NewObj3('Less_Tree_Attribute',array( $key, $op[0], $val)); |
|
| 1748 | + return $this->NewObj3('Less_Tree_Attribute', array($key, $op[0], $val)); |
|
| 1749 | 1749 | } |
| 1750 | 1750 | |
| 1751 | 1751 | // |
| 1752 | 1752 | // The `block` rule is used by `ruleset` and `mixin.definition`. |
| 1753 | 1753 | // It's a wrapper around the `primary` rule, with added `{}`. |
| 1754 | 1754 | // |
| 1755 | - private function parseBlock(){ |
|
| 1756 | - if( $this->MatchChar('{') ){ |
|
| 1755 | + private function parseBlock() { |
|
| 1756 | + if ($this->MatchChar('{')) { |
|
| 1757 | 1757 | $content = $this->parsePrimary(); |
| 1758 | - if( $this->MatchChar('}') ){ |
|
| 1758 | + if ($this->MatchChar('}')) { |
|
| 1759 | 1759 | return $content; |
| 1760 | 1760 | } |
| 1761 | 1761 | } |
| 1762 | 1762 | } |
| 1763 | 1763 | |
| 1764 | - private function parseBlockRuleset(){ |
|
| 1764 | + private function parseBlockRuleset() { |
|
| 1765 | 1765 | $block = $this->parseBlock(); |
| 1766 | 1766 | |
| 1767 | - if( $block ){ |
|
| 1768 | - $block = $this->NewObj2('Less_Tree_Ruleset',array( null, $block)); |
|
| 1767 | + if ($block) { |
|
| 1768 | + $block = $this->NewObj2('Less_Tree_Ruleset', array(null, $block)); |
|
| 1769 | 1769 | } |
| 1770 | 1770 | |
| 1771 | 1771 | return $block; |
| 1772 | 1772 | } |
| 1773 | 1773 | |
| 1774 | - private function parseDetachedRuleset(){ |
|
| 1774 | + private function parseDetachedRuleset() { |
|
| 1775 | 1775 | $blockRuleset = $this->parseBlockRuleset(); |
| 1776 | - if( $blockRuleset ){ |
|
| 1777 | - return $this->NewObj1('Less_Tree_DetachedRuleset',$blockRuleset); |
|
| 1776 | + if ($blockRuleset) { |
|
| 1777 | + return $this->NewObj1('Less_Tree_DetachedRuleset', $blockRuleset); |
|
| 1778 | 1778 | } |
| 1779 | 1779 | } |
| 1780 | 1780 | |
| 1781 | 1781 | // |
| 1782 | 1782 | // div, .class, body > p {...} |
| 1783 | 1783 | // |
| 1784 | - private function parseRuleset(){ |
|
| 1784 | + private function parseRuleset() { |
|
| 1785 | 1785 | $selectors = array(); |
| 1786 | 1786 | |
| 1787 | 1787 | $this->save(); |
| 1788 | 1788 | |
| 1789 | - while( true ){ |
|
| 1789 | + while (true) { |
|
| 1790 | 1790 | $s = $this->parseLessSelector(); |
| 1791 | - if( !$s ){ |
|
| 1791 | + if (!$s) { |
|
| 1792 | 1792 | break; |
| 1793 | 1793 | } |
| 1794 | 1794 | $selectors[] = $s; |
| 1795 | 1795 | $this->parseComments(); |
| 1796 | 1796 | |
| 1797 | - if( $s->condition && count($selectors) > 1 ){ |
|
| 1797 | + if ($s->condition && count($selectors)>1) { |
|
| 1798 | 1798 | $this->Error('Guards are only currently allowed on a single selector.'); |
| 1799 | 1799 | } |
| 1800 | 1800 | |
| 1801 | - if( !$this->MatchChar(',') ){ |
|
| 1801 | + if (!$this->MatchChar(',')) { |
|
| 1802 | 1802 | break; |
| 1803 | 1803 | } |
| 1804 | - if( $s->condition ){ |
|
| 1804 | + if ($s->condition) { |
|
| 1805 | 1805 | $this->Error('Guards are only currently allowed on a single selector.'); |
| 1806 | 1806 | } |
| 1807 | 1807 | $this->parseComments(); |
| 1808 | 1808 | } |
| 1809 | 1809 | |
| 1810 | 1810 | |
| 1811 | - if( $selectors ){ |
|
| 1811 | + if ($selectors) { |
|
| 1812 | 1812 | $rules = $this->parseBlock(); |
| 1813 | - if( is_array($rules) ){ |
|
| 1813 | + if (is_array($rules)) { |
|
| 1814 | 1814 | $this->forget(); |
| 1815 | - return $this->NewObj2('Less_Tree_Ruleset',array( $selectors, $rules)); //Less_Environment::$strictImports |
|
| 1815 | + return $this->NewObj2('Less_Tree_Ruleset', array($selectors, $rules)); //Less_Environment::$strictImports |
|
| 1816 | 1816 | } |
| 1817 | 1817 | } |
| 1818 | 1818 | |
@@ -1826,7 +1826,7 @@ discard block |
||
| 1826 | 1826 | * ex: width:100px; |
| 1827 | 1827 | * |
| 1828 | 1828 | */ |
| 1829 | - private function parseNameValue(){ |
|
| 1829 | + private function parseNameValue() { |
|
| 1830 | 1830 | |
| 1831 | 1831 | $index = $this->pos; |
| 1832 | 1832 | $this->save(); |
@@ -1834,55 +1834,55 @@ discard block |
||
| 1834 | 1834 | |
| 1835 | 1835 | //$match = $this->MatchReg('/\\G([a-zA-Z\-]+)\s*:\s*((?:\'")?[a-zA-Z0-9\-% \.,!]+?(?:\'")?)\s*([;}])/'); |
| 1836 | 1836 | $match = $this->MatchReg('/\\G([a-zA-Z\-]+)\s*:\s*([\'"]?[#a-zA-Z0-9\-%\.,]+?[\'"]?) *(! *important)?\s*([;}])/'); |
| 1837 | - if( $match ){ |
|
| 1837 | + if ($match) { |
|
| 1838 | 1838 | |
| 1839 | - if( $match[4] == '}' ){ |
|
| 1840 | - $this->pos = $index + strlen($match[0])-1; |
|
| 1839 | + if ($match[4]=='}') { |
|
| 1840 | + $this->pos = $index+strlen($match[0])-1; |
|
| 1841 | 1841 | } |
| 1842 | 1842 | |
| 1843 | - if( $match[3] ){ |
|
| 1843 | + if ($match[3]) { |
|
| 1844 | 1844 | $match[2] .= ' !important'; |
| 1845 | 1845 | } |
| 1846 | 1846 | |
| 1847 | - return $this->NewObj4('Less_Tree_NameValue',array( $match[1], $match[2], $index, $this->env->currentFileInfo)); |
|
| 1847 | + return $this->NewObj4('Less_Tree_NameValue', array($match[1], $match[2], $index, $this->env->currentFileInfo)); |
|
| 1848 | 1848 | } |
| 1849 | 1849 | |
| 1850 | 1850 | $this->restore(); |
| 1851 | 1851 | } |
| 1852 | 1852 | |
| 1853 | 1853 | |
| 1854 | - private function parseRule( $tryAnonymous = null ){ |
|
| 1854 | + private function parseRule($tryAnonymous = null) { |
|
| 1855 | 1855 | |
| 1856 | 1856 | $merge = false; |
| 1857 | 1857 | $startOfRule = $this->pos; |
| 1858 | 1858 | |
| 1859 | 1859 | $c = $this->input[$this->pos]; |
| 1860 | - if( $c === '.' || $c === '#' || $c === '&' ){ |
|
| 1860 | + if ($c==='.' || $c==='#' || $c==='&') { |
|
| 1861 | 1861 | return; |
| 1862 | 1862 | } |
| 1863 | 1863 | |
| 1864 | 1864 | $this->save(); |
| 1865 | - $name = $this->MatchFuncs( array('parseVariable','parseRuleProperty')); |
|
| 1865 | + $name = $this->MatchFuncs(array('parseVariable', 'parseRuleProperty')); |
|
| 1866 | 1866 | |
| 1867 | - if( $name ){ |
|
| 1867 | + if ($name) { |
|
| 1868 | 1868 | |
| 1869 | 1869 | $isVariable = is_string($name); |
| 1870 | 1870 | |
| 1871 | 1871 | $value = null; |
| 1872 | - if( $isVariable ){ |
|
| 1872 | + if ($isVariable) { |
|
| 1873 | 1873 | $value = $this->parseDetachedRuleset(); |
| 1874 | 1874 | } |
| 1875 | 1875 | |
| 1876 | 1876 | $important = null; |
| 1877 | - if( !$value ){ |
|
| 1877 | + if (!$value) { |
|
| 1878 | 1878 | |
| 1879 | 1879 | // prefer to try to parse first if its a variable or we are compressing |
| 1880 | 1880 | // but always fallback on the other one |
| 1881 | 1881 | //if( !$tryAnonymous && is_string($name) && $name[0] === '@' ){ |
| 1882 | - if( !$tryAnonymous && (Less_Parser::$options['compress'] || $isVariable) ){ |
|
| 1883 | - $value = $this->MatchFuncs( array('parseValue','parseAnonymousValue')); |
|
| 1884 | - }else{ |
|
| 1885 | - $value = $this->MatchFuncs( array('parseAnonymousValue','parseValue')); |
|
| 1882 | + if (!$tryAnonymous && (Less_Parser::$options['compress'] || $isVariable)) { |
|
| 1883 | + $value = $this->MatchFuncs(array('parseValue', 'parseAnonymousValue')); |
|
| 1884 | + }else { |
|
| 1885 | + $value = $this->MatchFuncs(array('parseAnonymousValue', 'parseValue')); |
|
| 1886 | 1886 | } |
| 1887 | 1887 | |
| 1888 | 1888 | $important = $this->parseImportant(); |
@@ -1890,35 +1890,35 @@ discard block |
||
| 1890 | 1890 | // a name returned by this.ruleProperty() is always an array of the form: |
| 1891 | 1891 | // [string-1, ..., string-n, ""] or [string-1, ..., string-n, "+"] |
| 1892 | 1892 | // where each item is a tree.Keyword or tree.Variable |
| 1893 | - if( !$isVariable && is_array($name) ){ |
|
| 1893 | + if (!$isVariable && is_array($name)) { |
|
| 1894 | 1894 | $nm = array_pop($name); |
| 1895 | - if( $nm->value ){ |
|
| 1895 | + if ($nm->value) { |
|
| 1896 | 1896 | $merge = $nm->value; |
| 1897 | 1897 | } |
| 1898 | 1898 | } |
| 1899 | 1899 | } |
| 1900 | 1900 | |
| 1901 | 1901 | |
| 1902 | - if( $value && $this->parseEnd() ){ |
|
| 1902 | + if ($value && $this->parseEnd()) { |
|
| 1903 | 1903 | $this->forget(); |
| 1904 | - return $this->NewObj6('Less_Tree_Rule',array( $name, $value, $important, $merge, $startOfRule, $this->env->currentFileInfo)); |
|
| 1905 | - }else{ |
|
| 1904 | + return $this->NewObj6('Less_Tree_Rule', array($name, $value, $important, $merge, $startOfRule, $this->env->currentFileInfo)); |
|
| 1905 | + }else { |
|
| 1906 | 1906 | $this->furthest = $this->pos; |
| 1907 | 1907 | $this->restore(); |
| 1908 | - if( $value && !$tryAnonymous ){ |
|
| 1908 | + if ($value && !$tryAnonymous) { |
|
| 1909 | 1909 | return $this->parseRule(true); |
| 1910 | 1910 | } |
| 1911 | 1911 | } |
| 1912 | - }else{ |
|
| 1912 | + }else { |
|
| 1913 | 1913 | $this->forget(); |
| 1914 | 1914 | } |
| 1915 | 1915 | } |
| 1916 | 1916 | |
| 1917 | - function parseAnonymousValue(){ |
|
| 1917 | + function parseAnonymousValue() { |
|
| 1918 | 1918 | |
| 1919 | - if( preg_match('/\\G([^@+\/\'"*`(;{}-]*);/',$this->input, $match, 0, $this->pos) ){ |
|
| 1919 | + if (preg_match('/\\G([^@+\/\'"*`(;{}-]*);/', $this->input, $match, 0, $this->pos)) { |
|
| 1920 | 1920 | $this->pos += strlen($match[1]); |
| 1921 | - return $this->NewObj1('Less_Tree_Anonymous',$match[1]); |
|
| 1921 | + return $this->NewObj1('Less_Tree_Anonymous', $match[1]); |
|
| 1922 | 1922 | } |
| 1923 | 1923 | } |
| 1924 | 1924 | |
@@ -1932,25 +1932,25 @@ discard block |
||
| 1932 | 1932 | // file-system operation. The function used for importing is |
| 1933 | 1933 | // stored in `import`, which we pass to the Import constructor. |
| 1934 | 1934 | // |
| 1935 | - private function parseImport(){ |
|
| 1935 | + private function parseImport() { |
|
| 1936 | 1936 | |
| 1937 | 1937 | $this->save(); |
| 1938 | 1938 | |
| 1939 | 1939 | $dir = $this->MatchReg('/\\G@import?\s+/'); |
| 1940 | 1940 | |
| 1941 | - if( $dir ){ |
|
| 1941 | + if ($dir) { |
|
| 1942 | 1942 | $options = $this->parseImportOptions(); |
| 1943 | - $path = $this->MatchFuncs( array('parseEntitiesQuoted','parseEntitiesUrl')); |
|
| 1943 | + $path = $this->MatchFuncs(array('parseEntitiesQuoted', 'parseEntitiesUrl')); |
|
| 1944 | 1944 | |
| 1945 | - if( $path ){ |
|
| 1945 | + if ($path) { |
|
| 1946 | 1946 | $features = $this->parseMediaFeatures(); |
| 1947 | - if( $this->MatchChar(';') ){ |
|
| 1948 | - if( $features ){ |
|
| 1949 | - $features = $this->NewObj1('Less_Tree_Value',$features); |
|
| 1947 | + if ($this->MatchChar(';')) { |
|
| 1948 | + if ($features) { |
|
| 1949 | + $features = $this->NewObj1('Less_Tree_Value', $features); |
|
| 1950 | 1950 | } |
| 1951 | 1951 | |
| 1952 | 1952 | $this->forget(); |
| 1953 | - return $this->NewObj5('Less_Tree_Import',array( $path, $features, $options, $this->pos, $this->env->currentFileInfo)); |
|
| 1953 | + return $this->NewObj5('Less_Tree_Import', array($path, $features, $options, $this->pos, $this->env->currentFileInfo)); |
|
| 1954 | 1954 | } |
| 1955 | 1955 | } |
| 1956 | 1956 | } |
@@ -1958,19 +1958,19 @@ discard block |
||
| 1958 | 1958 | $this->restore(); |
| 1959 | 1959 | } |
| 1960 | 1960 | |
| 1961 | - private function parseImportOptions(){ |
|
| 1961 | + private function parseImportOptions() { |
|
| 1962 | 1962 | |
| 1963 | 1963 | $options = array(); |
| 1964 | 1964 | |
| 1965 | 1965 | // list of options, surrounded by parens |
| 1966 | - if( !$this->MatchChar('(') ){ |
|
| 1966 | + if (!$this->MatchChar('(')) { |
|
| 1967 | 1967 | return $options; |
| 1968 | 1968 | } |
| 1969 | - do{ |
|
| 1969 | + do { |
|
| 1970 | 1970 | $optionName = $this->parseImportOption(); |
| 1971 | - if( $optionName ){ |
|
| 1971 | + if ($optionName) { |
|
| 1972 | 1972 | $value = true; |
| 1973 | - switch( $optionName ){ |
|
| 1973 | + switch ($optionName) { |
|
| 1974 | 1974 | case "css": |
| 1975 | 1975 | $optionName = "less"; |
| 1976 | 1976 | $value = false; |
@@ -1981,16 +1981,16 @@ discard block |
||
| 1981 | 1981 | break; |
| 1982 | 1982 | } |
| 1983 | 1983 | $options[$optionName] = $value; |
| 1984 | - if( !$this->MatchChar(',') ){ break; } |
|
| 1984 | + if (!$this->MatchChar(',')) { break; } |
|
| 1985 | 1985 | } |
| 1986 | - }while( $optionName ); |
|
| 1986 | + } while ($optionName); |
|
| 1987 | 1987 | $this->expectChar(')'); |
| 1988 | 1988 | return $options; |
| 1989 | 1989 | } |
| 1990 | 1990 | |
| 1991 | - private function parseImportOption(){ |
|
| 1991 | + private function parseImportOption() { |
|
| 1992 | 1992 | $opt = $this->MatchReg('/\\G(less|css|multiple|once|inline|reference)/'); |
| 1993 | - if( $opt ){ |
|
| 1993 | + if ($opt) { |
|
| 1994 | 1994 | return $opt[1]; |
| 1995 | 1995 | } |
| 1996 | 1996 | } |
@@ -1998,43 +1998,43 @@ discard block |
||
| 1998 | 1998 | private function parseMediaFeature() { |
| 1999 | 1999 | $nodes = array(); |
| 2000 | 2000 | |
| 2001 | - do{ |
|
| 2002 | - $e = $this->MatchFuncs(array('parseEntitiesKeyword','parseEntitiesVariable')); |
|
| 2003 | - if( $e ){ |
|
| 2001 | + do { |
|
| 2002 | + $e = $this->MatchFuncs(array('parseEntitiesKeyword', 'parseEntitiesVariable')); |
|
| 2003 | + if ($e) { |
|
| 2004 | 2004 | $nodes[] = $e; |
| 2005 | 2005 | } elseif ($this->MatchChar('(')) { |
| 2006 | 2006 | $p = $this->parseProperty(); |
| 2007 | 2007 | $e = $this->parseValue(); |
| 2008 | 2008 | if ($this->MatchChar(')')) { |
| 2009 | 2009 | if ($p && $e) { |
| 2010 | - $r = $this->NewObj7('Less_Tree_Rule', array( $p, $e, null, null, $this->pos, $this->env->currentFileInfo, true)); |
|
| 2011 | - $nodes[] = $this->NewObj1('Less_Tree_Paren',$r); |
|
| 2010 | + $r = $this->NewObj7('Less_Tree_Rule', array($p, $e, null, null, $this->pos, $this->env->currentFileInfo, true)); |
|
| 2011 | + $nodes[] = $this->NewObj1('Less_Tree_Paren', $r); |
|
| 2012 | 2012 | } elseif ($e) { |
| 2013 | - $nodes[] = $this->NewObj1('Less_Tree_Paren',$e); |
|
| 2014 | - } else { |
|
| 2013 | + $nodes[] = $this->NewObj1('Less_Tree_Paren', $e); |
|
| 2014 | + }else { |
|
| 2015 | 2015 | return null; |
| 2016 | 2016 | } |
| 2017 | - } else |
|
| 2017 | + }else |
|
| 2018 | 2018 | return null; |
| 2019 | 2019 | } |
| 2020 | 2020 | } while ($e); |
| 2021 | 2021 | |
| 2022 | 2022 | if ($nodes) { |
| 2023 | - return $this->NewObj1('Less_Tree_Expression',$nodes); |
|
| 2023 | + return $this->NewObj1('Less_Tree_Expression', $nodes); |
|
| 2024 | 2024 | } |
| 2025 | 2025 | } |
| 2026 | 2026 | |
| 2027 | 2027 | private function parseMediaFeatures() { |
| 2028 | 2028 | $features = array(); |
| 2029 | 2029 | |
| 2030 | - do{ |
|
| 2030 | + do { |
|
| 2031 | 2031 | $e = $this->parseMediaFeature(); |
| 2032 | - if( $e ){ |
|
| 2032 | + if ($e) { |
|
| 2033 | 2033 | $features[] = $e; |
| 2034 | 2034 | if (!$this->MatchChar(',')) break; |
| 2035 | - }else{ |
|
| 2035 | + }else { |
|
| 2036 | 2036 | $e = $this->parseEntitiesVariable(); |
| 2037 | - if( $e ){ |
|
| 2037 | + if ($e) { |
|
| 2038 | 2038 | $features[] = $e; |
| 2039 | 2039 | if (!$this->MatchChar(',')) break; |
| 2040 | 2040 | } |
@@ -2045,12 +2045,12 @@ discard block |
||
| 2045 | 2045 | } |
| 2046 | 2046 | |
| 2047 | 2047 | private function parseMedia() { |
| 2048 | - if( $this->MatchReg('/\\G@media/') ){ |
|
| 2048 | + if ($this->MatchReg('/\\G@media/')) { |
|
| 2049 | 2049 | $features = $this->parseMediaFeatures(); |
| 2050 | 2050 | $rules = $this->parseBlock(); |
| 2051 | 2051 | |
| 2052 | - if( is_array($rules) ){ |
|
| 2053 | - return $this->NewObj4('Less_Tree_Media',array( $rules, $features, $this->pos, $this->env->currentFileInfo)); |
|
| 2052 | + if (is_array($rules)) { |
|
| 2053 | + return $this->NewObj4('Less_Tree_Media', array($rules, $features, $this->pos, $this->env->currentFileInfo)); |
|
| 2054 | 2054 | } |
| 2055 | 2055 | } |
| 2056 | 2056 | } |
@@ -2061,9 +2061,9 @@ discard block |
||
| 2061 | 2061 | // |
| 2062 | 2062 | // @charset "utf-8"; |
| 2063 | 2063 | // |
| 2064 | - private function parseDirective(){ |
|
| 2064 | + private function parseDirective() { |
|
| 2065 | 2065 | |
| 2066 | - if( !$this->PeekChar('@') ){ |
|
| 2066 | + if (!$this->PeekChar('@')) { |
|
| 2067 | 2067 | return; |
| 2068 | 2068 | } |
| 2069 | 2069 | |
@@ -2075,8 +2075,8 @@ discard block |
||
| 2075 | 2075 | $hasUnknown = false; |
| 2076 | 2076 | |
| 2077 | 2077 | |
| 2078 | - $value = $this->MatchFuncs(array('parseImport','parseMedia')); |
|
| 2079 | - if( $value ){ |
|
| 2078 | + $value = $this->MatchFuncs(array('parseImport', 'parseMedia')); |
|
| 2079 | + if ($value) { |
|
| 2080 | 2080 | return $value; |
| 2081 | 2081 | } |
| 2082 | 2082 | |
@@ -2084,18 +2084,18 @@ discard block |
||
| 2084 | 2084 | |
| 2085 | 2085 | $name = $this->MatchReg('/\\G@[a-z-]+/'); |
| 2086 | 2086 | |
| 2087 | - if( !$name ) return; |
|
| 2087 | + if (!$name) return; |
|
| 2088 | 2088 | $name = $name[0]; |
| 2089 | 2089 | |
| 2090 | 2090 | |
| 2091 | 2091 | $nonVendorSpecificName = $name; |
| 2092 | - $pos = strpos($name,'-', 2); |
|
| 2093 | - if( $name[1] == '-' && $pos > 0 ){ |
|
| 2094 | - $nonVendorSpecificName = "@" . substr($name, $pos + 1); |
|
| 2092 | + $pos = strpos($name, '-', 2); |
|
| 2093 | + if ($name[1]=='-' && $pos>0) { |
|
| 2094 | + $nonVendorSpecificName = "@".substr($name, $pos+1); |
|
| 2095 | 2095 | } |
| 2096 | 2096 | |
| 2097 | 2097 | |
| 2098 | - switch( $nonVendorSpecificName ){ |
|
| 2098 | + switch ($nonVendorSpecificName) { |
|
| 2099 | 2099 | /* |
| 2100 | 2100 | case "@font-face": |
| 2101 | 2101 | case "@viewport": |
@@ -2137,31 +2137,31 @@ discard block |
||
| 2137 | 2137 | break; |
| 2138 | 2138 | } |
| 2139 | 2139 | |
| 2140 | - if( $hasIdentifier ){ |
|
| 2140 | + if ($hasIdentifier) { |
|
| 2141 | 2141 | $value = $this->parseEntity(); |
| 2142 | - if( !$value ){ |
|
| 2143 | - $this->error("expected " . $name . " identifier"); |
|
| 2142 | + if (!$value) { |
|
| 2143 | + $this->error("expected ".$name." identifier"); |
|
| 2144 | 2144 | } |
| 2145 | - } else if( $hasExpression ){ |
|
| 2145 | + }else if ($hasExpression) { |
|
| 2146 | 2146 | $value = $this->parseExpression(); |
| 2147 | - if( !$value ){ |
|
| 2148 | - $this->error("expected " . $name. " expression"); |
|
| 2147 | + if (!$value) { |
|
| 2148 | + $this->error("expected ".$name." expression"); |
|
| 2149 | 2149 | } |
| 2150 | - } else if ($hasUnknown) { |
|
| 2150 | + }else if ($hasUnknown) { |
|
| 2151 | 2151 | |
| 2152 | 2152 | $value = $this->MatchReg('/\\G[^{;]+/'); |
| 2153 | - if( $value ){ |
|
| 2154 | - $value = $this->NewObj1('Less_Tree_Anonymous',trim($value[0])); |
|
| 2153 | + if ($value) { |
|
| 2154 | + $value = $this->NewObj1('Less_Tree_Anonymous', trim($value[0])); |
|
| 2155 | 2155 | } |
| 2156 | 2156 | } |
| 2157 | 2157 | |
| 2158 | - if( $hasBlock ){ |
|
| 2158 | + if ($hasBlock) { |
|
| 2159 | 2159 | $rules = $this->parseBlockRuleset(); |
| 2160 | 2160 | } |
| 2161 | 2161 | |
| 2162 | - if( $rules || (!$hasBlock && $value && $this->MatchChar(';'))) { |
|
| 2162 | + if ($rules || (!$hasBlock && $value && $this->MatchChar(';'))) { |
|
| 2163 | 2163 | $this->forget(); |
| 2164 | - return $this->NewObj5('Less_Tree_Directive',array($name, $value, $rules, $index, $this->env->currentFileInfo)); |
|
| 2164 | + return $this->NewObj5('Less_Tree_Directive', array($name, $value, $rules, $index, $this->env->currentFileInfo)); |
|
| 2165 | 2165 | } |
| 2166 | 2166 | |
| 2167 | 2167 | $this->restore(); |
@@ -2176,37 +2176,37 @@ discard block |
||
| 2176 | 2176 | // In a Rule, a Value represents everything after the `:`, |
| 2177 | 2177 | // and before the `;`. |
| 2178 | 2178 | // |
| 2179 | - private function parseValue(){ |
|
| 2179 | + private function parseValue() { |
|
| 2180 | 2180 | $expressions = array(); |
| 2181 | 2181 | |
| 2182 | - do{ |
|
| 2182 | + do { |
|
| 2183 | 2183 | $e = $this->parseExpression(); |
| 2184 | - if( $e ){ |
|
| 2184 | + if ($e) { |
|
| 2185 | 2185 | $expressions[] = $e; |
| 2186 | - if (! $this->MatchChar(',')) { |
|
| 2186 | + if (!$this->MatchChar(',')) { |
|
| 2187 | 2187 | break; |
| 2188 | 2188 | } |
| 2189 | 2189 | } |
| 2190 | - }while($e); |
|
| 2190 | + } while ($e); |
|
| 2191 | 2191 | |
| 2192 | - if( $expressions ){ |
|
| 2193 | - return $this->NewObj1('Less_Tree_Value',$expressions); |
|
| 2192 | + if ($expressions) { |
|
| 2193 | + return $this->NewObj1('Less_Tree_Value', $expressions); |
|
| 2194 | 2194 | } |
| 2195 | 2195 | } |
| 2196 | 2196 | |
| 2197 | - private function parseImportant (){ |
|
| 2198 | - if( $this->PeekChar('!') && $this->MatchReg('/\\G! *important/') ){ |
|
| 2197 | + private function parseImportant() { |
|
| 2198 | + if ($this->PeekChar('!') && $this->MatchReg('/\\G! *important/')) { |
|
| 2199 | 2199 | return ' !important'; |
| 2200 | 2200 | } |
| 2201 | 2201 | } |
| 2202 | 2202 | |
| 2203 | - private function parseSub (){ |
|
| 2203 | + private function parseSub() { |
|
| 2204 | 2204 | |
| 2205 | - if( $this->MatchChar('(') ){ |
|
| 2205 | + if ($this->MatchChar('(')) { |
|
| 2206 | 2206 | $a = $this->parseAddition(); |
| 2207 | - if( $a ){ |
|
| 2207 | + if ($a) { |
|
| 2208 | 2208 | $this->expectChar(')'); |
| 2209 | - return $this->NewObj2('Less_Tree_Expression',array( array($a), true) ); //instead of $e->parens = true so the value is cached |
|
| 2209 | + return $this->NewObj2('Less_Tree_Expression', array(array($a), true)); //instead of $e->parens = true so the value is cached |
|
| 2210 | 2210 | } |
| 2211 | 2211 | } |
| 2212 | 2212 | } |
@@ -2217,33 +2217,33 @@ discard block |
||
| 2217 | 2217 | * |
| 2218 | 2218 | * @return Less_Tree_Operation|null |
| 2219 | 2219 | */ |
| 2220 | - function parseMultiplication(){ |
|
| 2220 | + function parseMultiplication() { |
|
| 2221 | 2221 | |
| 2222 | 2222 | $return = $m = $this->parseOperand(); |
| 2223 | - if( $return ){ |
|
| 2224 | - while( true ){ |
|
| 2223 | + if ($return) { |
|
| 2224 | + while (true) { |
|
| 2225 | 2225 | |
| 2226 | 2226 | $isSpaced = $this->isWhitespace( -1 ); |
| 2227 | 2227 | |
| 2228 | - if( $this->PeekReg('/\\G\/[*\/]/') ){ |
|
| 2228 | + if ($this->PeekReg('/\\G\/[*\/]/')) { |
|
| 2229 | 2229 | break; |
| 2230 | 2230 | } |
| 2231 | 2231 | |
| 2232 | 2232 | $op = $this->MatchChar('/'); |
| 2233 | - if( !$op ){ |
|
| 2233 | + if (!$op) { |
|
| 2234 | 2234 | $op = $this->MatchChar('*'); |
| 2235 | - if( !$op ){ |
|
| 2235 | + if (!$op) { |
|
| 2236 | 2236 | break; |
| 2237 | 2237 | } |
| 2238 | 2238 | } |
| 2239 | 2239 | |
| 2240 | 2240 | $a = $this->parseOperand(); |
| 2241 | 2241 | |
| 2242 | - if(!$a) { break; } |
|
| 2242 | + if (!$a) { break; } |
|
| 2243 | 2243 | |
| 2244 | 2244 | $m->parensInOp = true; |
| 2245 | 2245 | $a->parensInOp = true; |
| 2246 | - $return = $this->NewObj3('Less_Tree_Operation',array( $op, array( $return, $a ), $isSpaced) ); |
|
| 2246 | + $return = $this->NewObj3('Less_Tree_Operation', array($op, array($return, $a), $isSpaced)); |
|
| 2247 | 2247 | } |
| 2248 | 2248 | } |
| 2249 | 2249 | return $return; |
@@ -2256,34 +2256,34 @@ discard block |
||
| 2256 | 2256 | * |
| 2257 | 2257 | * @return Less_Tree_Operation|null |
| 2258 | 2258 | */ |
| 2259 | - private function parseAddition (){ |
|
| 2259 | + private function parseAddition() { |
|
| 2260 | 2260 | |
| 2261 | 2261 | $return = $m = $this->parseMultiplication(); |
| 2262 | - if( $return ){ |
|
| 2263 | - while( true ){ |
|
| 2262 | + if ($return) { |
|
| 2263 | + while (true) { |
|
| 2264 | 2264 | |
| 2265 | 2265 | $isSpaced = $this->isWhitespace( -1 ); |
| 2266 | 2266 | |
| 2267 | 2267 | $op = $this->MatchReg('/\\G[-+]\s+/'); |
| 2268 | - if( $op ){ |
|
| 2268 | + if ($op) { |
|
| 2269 | 2269 | $op = $op[0]; |
| 2270 | - }else{ |
|
| 2271 | - if( !$isSpaced ){ |
|
| 2272 | - $op = $this->match(array('#+','#-')); |
|
| 2270 | + }else { |
|
| 2271 | + if (!$isSpaced) { |
|
| 2272 | + $op = $this->match(array('#+', '#-')); |
|
| 2273 | 2273 | } |
| 2274 | - if( !$op ){ |
|
| 2274 | + if (!$op) { |
|
| 2275 | 2275 | break; |
| 2276 | 2276 | } |
| 2277 | 2277 | } |
| 2278 | 2278 | |
| 2279 | 2279 | $a = $this->parseMultiplication(); |
| 2280 | - if( !$a ){ |
|
| 2280 | + if (!$a) { |
|
| 2281 | 2281 | break; |
| 2282 | 2282 | } |
| 2283 | 2283 | |
| 2284 | 2284 | $m->parensInOp = true; |
| 2285 | 2285 | $a->parensInOp = true; |
| 2286 | - $return = $this->NewObj3('Less_Tree_Operation',array($op, array($return, $a), $isSpaced)); |
|
| 2286 | + $return = $this->NewObj3('Less_Tree_Operation', array($op, array($return, $a), $isSpaced)); |
|
| 2287 | 2287 | } |
| 2288 | 2288 | } |
| 2289 | 2289 | |
@@ -2299,17 +2299,17 @@ discard block |
||
| 2299 | 2299 | private function parseConditions() { |
| 2300 | 2300 | $index = $this->pos; |
| 2301 | 2301 | $return = $a = $this->parseCondition(); |
| 2302 | - if( $a ){ |
|
| 2303 | - while( true ){ |
|
| 2304 | - if( !$this->PeekReg('/\\G,\s*(not\s*)?\(/') || !$this->MatchChar(',') ){ |
|
| 2302 | + if ($a) { |
|
| 2303 | + while (true) { |
|
| 2304 | + if (!$this->PeekReg('/\\G,\s*(not\s*)?\(/') || !$this->MatchChar(',')) { |
|
| 2305 | 2305 | break; |
| 2306 | 2306 | } |
| 2307 | 2307 | $b = $this->parseCondition(); |
| 2308 | - if( !$b ){ |
|
| 2308 | + if (!$b) { |
|
| 2309 | 2309 | break; |
| 2310 | 2310 | } |
| 2311 | 2311 | |
| 2312 | - $return = $this->NewObj4('Less_Tree_Condition',array('or', $return, $b, $index)); |
|
| 2312 | + $return = $this->NewObj4('Less_Tree_Condition', array('or', $return, $b, $index)); |
|
| 2313 | 2313 | } |
| 2314 | 2314 | return $return; |
| 2315 | 2315 | } |
@@ -2322,23 +2322,23 @@ discard block |
||
| 2322 | 2322 | |
| 2323 | 2323 | if ($this->MatchReg('/\\Gnot/')) $negate = true; |
| 2324 | 2324 | $this->expectChar('('); |
| 2325 | - $a = $this->MatchFuncs(array('parseAddition','parseEntitiesKeyword','parseEntitiesQuoted')); |
|
| 2325 | + $a = $this->MatchFuncs(array('parseAddition', 'parseEntitiesKeyword', 'parseEntitiesQuoted')); |
|
| 2326 | 2326 | |
| 2327 | - if( $a ){ |
|
| 2327 | + if ($a) { |
|
| 2328 | 2328 | $op = $this->MatchReg('/\\G(?:>=|<=|=<|[<=>])/'); |
| 2329 | - if( $op ){ |
|
| 2330 | - $b = $this->MatchFuncs(array('parseAddition','parseEntitiesKeyword','parseEntitiesQuoted')); |
|
| 2331 | - if( $b ){ |
|
| 2332 | - $c = $this->NewObj5('Less_Tree_Condition',array($op[0], $a, $b, $index, $negate)); |
|
| 2333 | - } else { |
|
| 2329 | + if ($op) { |
|
| 2330 | + $b = $this->MatchFuncs(array('parseAddition', 'parseEntitiesKeyword', 'parseEntitiesQuoted')); |
|
| 2331 | + if ($b) { |
|
| 2332 | + $c = $this->NewObj5('Less_Tree_Condition', array($op[0], $a, $b, $index, $negate)); |
|
| 2333 | + }else { |
|
| 2334 | 2334 | $this->Error('Unexpected expression'); |
| 2335 | 2335 | } |
| 2336 | - } else { |
|
| 2337 | - $k = $this->NewObj1('Less_Tree_Keyword','true'); |
|
| 2338 | - $c = $this->NewObj5('Less_Tree_Condition',array('=', $a, $k, $index, $negate)); |
|
| 2336 | + }else { |
|
| 2337 | + $k = $this->NewObj1('Less_Tree_Keyword', 'true'); |
|
| 2338 | + $c = $this->NewObj5('Less_Tree_Condition', array('=', $a, $k, $index, $negate)); |
|
| 2339 | 2339 | } |
| 2340 | 2340 | $this->expectChar(')'); |
| 2341 | - return $this->MatchReg('/\\Gand/') ? $this->NewObj3('Less_Tree_Condition',array('and', $c, $this->parseCondition())) : $c; |
|
| 2341 | + return $this->MatchReg('/\\Gand/') ? $this->NewObj3('Less_Tree_Condition', array('and', $c, $this->parseCondition())) : $c; |
|
| 2342 | 2342 | } |
| 2343 | 2343 | } |
| 2344 | 2344 | |
@@ -2347,23 +2347,23 @@ discard block |
||
| 2347 | 2347 | * such as a Color, or a Variable |
| 2348 | 2348 | * |
| 2349 | 2349 | */ |
| 2350 | - private function parseOperand (){ |
|
| 2350 | + private function parseOperand() { |
|
| 2351 | 2351 | |
| 2352 | 2352 | $negate = false; |
| 2353 | 2353 | $offset = $this->pos+1; |
| 2354 | - if( $offset >= $this->input_len ){ |
|
| 2354 | + if ($offset>=$this->input_len) { |
|
| 2355 | 2355 | return; |
| 2356 | 2356 | } |
| 2357 | 2357 | $char = $this->input[$offset]; |
| 2358 | - if( $char === '@' || $char === '(' ){ |
|
| 2358 | + if ($char==='@' || $char==='(') { |
|
| 2359 | 2359 | $negate = $this->MatchChar('-'); |
| 2360 | 2360 | } |
| 2361 | 2361 | |
| 2362 | - $o = $this->MatchFuncs(array('parseSub','parseEntitiesDimension','parseEntitiesColor','parseEntitiesVariable','parseEntitiesCall')); |
|
| 2362 | + $o = $this->MatchFuncs(array('parseSub', 'parseEntitiesDimension', 'parseEntitiesColor', 'parseEntitiesVariable', 'parseEntitiesCall')); |
|
| 2363 | 2363 | |
| 2364 | - if( $negate ){ |
|
| 2364 | + if ($negate) { |
|
| 2365 | 2365 | $o->parensInOp = true; |
| 2366 | - $o = $this->NewObj1('Less_Tree_Negative',$o); |
|
| 2366 | + $o = $this->NewObj1('Less_Tree_Negative', $o); |
|
| 2367 | 2367 | } |
| 2368 | 2368 | |
| 2369 | 2369 | return $o; |
@@ -2379,25 +2379,25 @@ discard block |
||
| 2379 | 2379 | * |
| 2380 | 2380 | * @return Less_Tree_Expression|null |
| 2381 | 2381 | */ |
| 2382 | - private function parseExpression (){ |
|
| 2382 | + private function parseExpression() { |
|
| 2383 | 2383 | $entities = array(); |
| 2384 | 2384 | |
| 2385 | - do{ |
|
| 2386 | - $e = $this->MatchFuncs(array('parseAddition','parseEntity')); |
|
| 2387 | - if( $e ){ |
|
| 2385 | + do { |
|
| 2386 | + $e = $this->MatchFuncs(array('parseAddition', 'parseEntity')); |
|
| 2387 | + if ($e) { |
|
| 2388 | 2388 | $entities[] = $e; |
| 2389 | 2389 | // operations do not allow keyword "/" dimension (e.g. small/20px) so we support that here |
| 2390 | - if( !$this->PeekReg('/\\G\/[\/*]/') ){ |
|
| 2390 | + if (!$this->PeekReg('/\\G\/[\/*]/')) { |
|
| 2391 | 2391 | $delim = $this->MatchChar('/'); |
| 2392 | - if( $delim ){ |
|
| 2393 | - $entities[] = $this->NewObj1('Less_Tree_Anonymous',$delim); |
|
| 2392 | + if ($delim) { |
|
| 2393 | + $entities[] = $this->NewObj1('Less_Tree_Anonymous', $delim); |
|
| 2394 | 2394 | } |
| 2395 | 2395 | } |
| 2396 | 2396 | } |
| 2397 | - }while($e); |
|
| 2397 | + } while ($e); |
|
| 2398 | 2398 | |
| 2399 | - if( $entities ){ |
|
| 2400 | - return $this->NewObj1('Less_Tree_Expression',$entities); |
|
| 2399 | + if ($entities) { |
|
| 2400 | + return $this->NewObj1('Less_Tree_Expression', $entities); |
|
| 2401 | 2401 | } |
| 2402 | 2402 | } |
| 2403 | 2403 | |
@@ -2408,9 +2408,9 @@ discard block |
||
| 2408 | 2408 | * |
| 2409 | 2409 | * @return string |
| 2410 | 2410 | */ |
| 2411 | - private function parseProperty (){ |
|
| 2411 | + private function parseProperty() { |
|
| 2412 | 2412 | $name = $this->MatchReg('/\\G(\*?-?[_a-zA-Z0-9-]+)\s*:/'); |
| 2413 | - if( $name ){ |
|
| 2413 | + if ($name) { |
|
| 2414 | 2414 | return $name[1]; |
| 2415 | 2415 | } |
| 2416 | 2416 | } |
@@ -2422,30 +2422,30 @@ discard block |
||
| 2422 | 2422 | * |
| 2423 | 2423 | * @return string |
| 2424 | 2424 | */ |
| 2425 | - private function parseRuleProperty(){ |
|
| 2425 | + private function parseRuleProperty() { |
|
| 2426 | 2426 | $offset = $this->pos; |
| 2427 | 2427 | $name = array(); |
| 2428 | 2428 | $index = array(); |
| 2429 | 2429 | $length = 0; |
| 2430 | 2430 | |
| 2431 | 2431 | |
| 2432 | - $this->rulePropertyMatch('/\\G(\*?)/', $offset, $length, $index, $name ); |
|
| 2433 | - while( $this->rulePropertyMatch('/\\G((?:[\w-]+)|(?:@\{[\w-]+\}))/', $offset, $length, $index, $name )); // ! |
|
| 2432 | + $this->rulePropertyMatch('/\\G(\*?)/', $offset, $length, $index, $name); |
|
| 2433 | + while ($this->rulePropertyMatch('/\\G((?:[\w-]+)|(?:@\{[\w-]+\}))/', $offset, $length, $index, $name)); // ! |
|
| 2434 | 2434 | |
| 2435 | - if( (count($name) > 1) && $this->rulePropertyMatch('/\\G\s*((?:\+_|\+)?)\s*:/', $offset, $length, $index, $name) ){ |
|
| 2435 | + if ((count($name)>1) && $this->rulePropertyMatch('/\\G\s*((?:\+_|\+)?)\s*:/', $offset, $length, $index, $name)) { |
|
| 2436 | 2436 | // at last, we have the complete match now. move forward, |
| 2437 | 2437 | // convert name particles to tree objects and return: |
| 2438 | 2438 | $this->skipWhitespace($length); |
| 2439 | 2439 | |
| 2440 | - if( $name[0] === '' ){ |
|
| 2440 | + if ($name[0]==='') { |
|
| 2441 | 2441 | array_shift($name); |
| 2442 | 2442 | array_shift($index); |
| 2443 | 2443 | } |
| 2444 | - foreach($name as $k => $s ){ |
|
| 2445 | - if( !$s || $s[0] !== '@' ){ |
|
| 2446 | - $name[$k] = $this->NewObj1('Less_Tree_Keyword',$s); |
|
| 2447 | - }else{ |
|
| 2448 | - $name[$k] = $this->NewObj3('Less_Tree_Variable',array('@' . substr($s,2,-1), $index[$k], $this->env->currentFileInfo)); |
|
| 2444 | + foreach ($name as $k => $s) { |
|
| 2445 | + if (!$s || $s[0]!=='@') { |
|
| 2446 | + $name[$k] = $this->NewObj1('Less_Tree_Keyword', $s); |
|
| 2447 | + }else { |
|
| 2448 | + $name[$k] = $this->NewObj3('Less_Tree_Variable', array('@'.substr($s, 2, -1), $index[$k], $this->env->currentFileInfo)); |
|
| 2449 | 2449 | } |
| 2450 | 2450 | } |
| 2451 | 2451 | return $name; |
@@ -2454,10 +2454,10 @@ discard block |
||
| 2454 | 2454 | |
| 2455 | 2455 | } |
| 2456 | 2456 | |
| 2457 | - private function rulePropertyMatch( $re, &$offset, &$length, &$index, &$name ){ |
|
| 2457 | + private function rulePropertyMatch($re, &$offset, &$length, &$index, &$name) { |
|
| 2458 | 2458 | preg_match($re, $this->input, $a, 0, $offset); |
| 2459 | - if( $a ){ |
|
| 2460 | - $index[] = $this->pos + $length; |
|
| 2459 | + if ($a) { |
|
| 2460 | + $index[] = $this->pos+$length; |
|
| 2461 | 2461 | $length += strlen($a[0]); |
| 2462 | 2462 | $offset += strlen($a[0]); |
| 2463 | 2463 | $name[] = $a[1]; |
@@ -2465,11 +2465,11 @@ discard block |
||
| 2465 | 2465 | } |
| 2466 | 2466 | } |
| 2467 | 2467 | |
| 2468 | - public static function serializeVars( $vars ){ |
|
| 2468 | + public static function serializeVars($vars) { |
|
| 2469 | 2469 | $s = ''; |
| 2470 | 2470 | |
| 2471 | - foreach($vars as $name => $value){ |
|
| 2472 | - $s .= (($name[0] === '@') ? '' : '@') . $name .': '. $value . ((substr($value,-1) === ';') ? '' : ';'); |
|
| 2471 | + foreach ($vars as $name => $value) { |
|
| 2472 | + $s .= (($name[0]==='@') ? '' : '@').$name.': '.$value.((substr($value, -1)===';') ? '' : ';'); |
|
| 2473 | 2473 | } |
| 2474 | 2474 | |
| 2475 | 2475 | return $s; |
@@ -2481,8 +2481,8 @@ discard block |
||
| 2481 | 2481 | * |
| 2482 | 2482 | * @param string $b |
| 2483 | 2483 | */ |
| 2484 | - public static function is_method($a,$b){ |
|
| 2485 | - return is_object($a) && method_exists($a,$b); |
|
| 2484 | + public static function is_method($a, $b) { |
|
| 2485 | + return is_object($a) && method_exists($a, $b); |
|
| 2486 | 2486 | } |
| 2487 | 2487 | |
| 2488 | 2488 | |
@@ -2491,17 +2491,17 @@ discard block |
||
| 2491 | 2491 | * eg: 1.499999 to 1 instead of 2 |
| 2492 | 2492 | * |
| 2493 | 2493 | */ |
| 2494 | - public static function round($i, $precision = 0){ |
|
| 2494 | + public static function round($i, $precision = 0) { |
|
| 2495 | 2495 | |
| 2496 | - $precision = pow(10,$precision); |
|
| 2497 | - $i = $i*$precision; |
|
| 2496 | + $precision = pow(10, $precision); |
|
| 2497 | + $i = $i * $precision; |
|
| 2498 | 2498 | |
| 2499 | 2499 | $ceil = ceil($i); |
| 2500 | 2500 | $floor = floor($i); |
| 2501 | - if( ($ceil - $i) <= ($i - $floor) ){ |
|
| 2502 | - return $ceil/$precision; |
|
| 2503 | - }else{ |
|
| 2504 | - return $floor/$precision; |
|
| 2501 | + if (($ceil-$i)<=($i-$floor)) { |
|
| 2502 | + return $ceil / $precision; |
|
| 2503 | + }else { |
|
| 2504 | + return $floor / $precision; |
|
| 2505 | 2505 | } |
| 2506 | 2506 | } |
| 2507 | 2507 | |
@@ -2511,77 +2511,77 @@ discard block |
||
| 2511 | 2511 | * |
| 2512 | 2512 | * @return mixed |
| 2513 | 2513 | */ |
| 2514 | - public function NewObj0($class){ |
|
| 2514 | + public function NewObj0($class) { |
|
| 2515 | 2515 | $obj = new $class(); |
| 2516 | - if( $this->CacheEnabled() ){ |
|
| 2516 | + if ($this->CacheEnabled()) { |
|
| 2517 | 2517 | $obj->cache_string = ' new '.$class.'()'; |
| 2518 | 2518 | } |
| 2519 | 2519 | return $obj; |
| 2520 | 2520 | } |
| 2521 | 2521 | |
| 2522 | - public function NewObj1($class, $arg){ |
|
| 2523 | - $obj = new $class( $arg ); |
|
| 2524 | - if( $this->CacheEnabled() ){ |
|
| 2522 | + public function NewObj1($class, $arg) { |
|
| 2523 | + $obj = new $class($arg); |
|
| 2524 | + if ($this->CacheEnabled()) { |
|
| 2525 | 2525 | $obj->cache_string = ' new '.$class.'('.Less_Parser::ArgString($arg).')'; |
| 2526 | 2526 | } |
| 2527 | 2527 | return $obj; |
| 2528 | 2528 | } |
| 2529 | 2529 | |
| 2530 | - public function NewObj2($class, $args){ |
|
| 2531 | - $obj = new $class( $args[0], $args[1] ); |
|
| 2532 | - if( $this->CacheEnabled() ){ |
|
| 2533 | - $this->ObjCache( $obj, $class, $args); |
|
| 2530 | + public function NewObj2($class, $args) { |
|
| 2531 | + $obj = new $class($args[0], $args[1]); |
|
| 2532 | + if ($this->CacheEnabled()) { |
|
| 2533 | + $this->ObjCache($obj, $class, $args); |
|
| 2534 | 2534 | } |
| 2535 | 2535 | return $obj; |
| 2536 | 2536 | } |
| 2537 | 2537 | |
| 2538 | - public function NewObj3($class, $args){ |
|
| 2539 | - $obj = new $class( $args[0], $args[1], $args[2] ); |
|
| 2540 | - if( $this->CacheEnabled() ){ |
|
| 2541 | - $this->ObjCache( $obj, $class, $args); |
|
| 2538 | + public function NewObj3($class, $args) { |
|
| 2539 | + $obj = new $class($args[0], $args[1], $args[2]); |
|
| 2540 | + if ($this->CacheEnabled()) { |
|
| 2541 | + $this->ObjCache($obj, $class, $args); |
|
| 2542 | 2542 | } |
| 2543 | 2543 | return $obj; |
| 2544 | 2544 | } |
| 2545 | 2545 | |
| 2546 | - public function NewObj4($class, $args){ |
|
| 2547 | - $obj = new $class( $args[0], $args[1], $args[2], $args[3] ); |
|
| 2548 | - if( $this->CacheEnabled() ){ |
|
| 2549 | - $this->ObjCache( $obj, $class, $args); |
|
| 2546 | + public function NewObj4($class, $args) { |
|
| 2547 | + $obj = new $class($args[0], $args[1], $args[2], $args[3]); |
|
| 2548 | + if ($this->CacheEnabled()) { |
|
| 2549 | + $this->ObjCache($obj, $class, $args); |
|
| 2550 | 2550 | } |
| 2551 | 2551 | return $obj; |
| 2552 | 2552 | } |
| 2553 | 2553 | |
| 2554 | - public function NewObj5($class, $args){ |
|
| 2555 | - $obj = new $class( $args[0], $args[1], $args[2], $args[3], $args[4] ); |
|
| 2556 | - if( $this->CacheEnabled() ){ |
|
| 2557 | - $this->ObjCache( $obj, $class, $args); |
|
| 2554 | + public function NewObj5($class, $args) { |
|
| 2555 | + $obj = new $class($args[0], $args[1], $args[2], $args[3], $args[4]); |
|
| 2556 | + if ($this->CacheEnabled()) { |
|
| 2557 | + $this->ObjCache($obj, $class, $args); |
|
| 2558 | 2558 | } |
| 2559 | 2559 | return $obj; |
| 2560 | 2560 | } |
| 2561 | 2561 | |
| 2562 | - public function NewObj6($class, $args){ |
|
| 2563 | - $obj = new $class( $args[0], $args[1], $args[2], $args[3], $args[4], $args[5] ); |
|
| 2564 | - if( $this->CacheEnabled() ){ |
|
| 2565 | - $this->ObjCache( $obj, $class, $args); |
|
| 2562 | + public function NewObj6($class, $args) { |
|
| 2563 | + $obj = new $class($args[0], $args[1], $args[2], $args[3], $args[4], $args[5]); |
|
| 2564 | + if ($this->CacheEnabled()) { |
|
| 2565 | + $this->ObjCache($obj, $class, $args); |
|
| 2566 | 2566 | } |
| 2567 | 2567 | return $obj; |
| 2568 | 2568 | } |
| 2569 | 2569 | |
| 2570 | - public function NewObj7($class, $args){ |
|
| 2571 | - $obj = new $class( $args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6] ); |
|
| 2572 | - if( $this->CacheEnabled() ){ |
|
| 2573 | - $this->ObjCache( $obj, $class, $args); |
|
| 2570 | + public function NewObj7($class, $args) { |
|
| 2571 | + $obj = new $class($args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6]); |
|
| 2572 | + if ($this->CacheEnabled()) { |
|
| 2573 | + $this->ObjCache($obj, $class, $args); |
|
| 2574 | 2574 | } |
| 2575 | 2575 | return $obj; |
| 2576 | 2576 | } |
| 2577 | 2577 | |
| 2578 | 2578 | //caching |
| 2579 | - public function ObjCache($obj, $class, $args=array()){ |
|
| 2580 | - $obj->cache_string = ' new '.$class.'('. self::ArgCache($args).')'; |
|
| 2579 | + public function ObjCache($obj, $class, $args = array()) { |
|
| 2580 | + $obj->cache_string = ' new '.$class.'('.self::ArgCache($args).')'; |
|
| 2581 | 2581 | } |
| 2582 | 2582 | |
| 2583 | - public function ArgCache($args){ |
|
| 2584 | - return implode(',',array_map( array('Less_Parser','ArgString'),$args)); |
|
| 2583 | + public function ArgCache($args) { |
|
| 2584 | + return implode(',', array_map(array('Less_Parser', 'ArgString'), $args)); |
|
| 2585 | 2585 | } |
| 2586 | 2586 | |
| 2587 | 2587 | |
@@ -2590,36 +2590,36 @@ discard block |
||
| 2590 | 2590 | * |
| 2591 | 2591 | * @return string |
| 2592 | 2592 | */ |
| 2593 | - public static function ArgString($arg){ |
|
| 2593 | + public static function ArgString($arg) { |
|
| 2594 | 2594 | |
| 2595 | 2595 | $type = gettype($arg); |
| 2596 | 2596 | |
| 2597 | - if( $type === 'object'){ |
|
| 2597 | + if ($type==='object') { |
|
| 2598 | 2598 | $string = $arg->cache_string; |
| 2599 | 2599 | unset($arg->cache_string); |
| 2600 | 2600 | return $string; |
| 2601 | 2601 | |
| 2602 | - }elseif( $type === 'array' ){ |
|
| 2602 | + }elseif ($type==='array') { |
|
| 2603 | 2603 | $string = ' Array('; |
| 2604 | - foreach($arg as $k => $a){ |
|
| 2605 | - $string .= var_export($k,true).' => '.self::ArgString($a).','; |
|
| 2604 | + foreach ($arg as $k => $a) { |
|
| 2605 | + $string .= var_export($k, true).' => '.self::ArgString($a).','; |
|
| 2606 | 2606 | } |
| 2607 | - return $string . ')'; |
|
| 2607 | + return $string.')'; |
|
| 2608 | 2608 | } |
| 2609 | 2609 | |
| 2610 | - return var_export($arg,true); |
|
| 2610 | + return var_export($arg, true); |
|
| 2611 | 2611 | } |
| 2612 | 2612 | |
| 2613 | - public function Error($msg){ |
|
| 2613 | + public function Error($msg) { |
|
| 2614 | 2614 | throw new Less_Exception_Parser($msg, null, $this->furthest, $this->env->currentFileInfo); |
| 2615 | 2615 | } |
| 2616 | 2616 | |
| 2617 | - public static function WinPath($path){ |
|
| 2617 | + public static function WinPath($path) { |
|
| 2618 | 2618 | return str_replace('\\', '/', $path); |
| 2619 | 2619 | } |
| 2620 | 2620 | |
| 2621 | - public function CacheEnabled(){ |
|
| 2622 | - return (Less_Parser::$options['cache_method'] && (Less_Cache::$cache_dir || (Less_Parser::$options['cache_method'] == 'callback'))); |
|
| 2621 | + public function CacheEnabled() { |
|
| 2622 | + return (Less_Parser::$options['cache_method'] && (Less_Cache::$cache_dir || (Less_Parser::$options['cache_method']=='callback'))); |
|
| 2623 | 2623 | } |
| 2624 | 2624 | |
| 2625 | 2625 | } |
@@ -2804,7 +2804,7 @@ discard block |
||
| 2804 | 2804 | * @package Less |
| 2805 | 2805 | * @subpackage environment |
| 2806 | 2806 | */ |
| 2807 | -class Less_Environment{ |
|
| 2807 | +class Less_Environment { |
|
| 2808 | 2808 | |
| 2809 | 2809 | //public $paths = array(); // option - unmodified - paths to search for imports on |
| 2810 | 2810 | //public static $files = array(); // list of files that have been imported, used for import-once |
@@ -2814,9 +2814,9 @@ discard block |
||
| 2814 | 2814 | //public $processImports; // option - whether to process imports. if false then imports will not be imported |
| 2815 | 2815 | //public $javascriptEnabled; // option - whether JavaScript is enabled. if undefined, defaults to true |
| 2816 | 2816 | //public $useFileCache; // browser only - whether to use the per file session cache |
| 2817 | - public $currentFileInfo; // information about the current file - for error reporting and importing and making urls relative etc. |
|
| 2817 | + public $currentFileInfo; // information about the current file - for error reporting and importing and making urls relative etc. |
|
| 2818 | 2818 | |
| 2819 | - public $importMultiple = false; // whether we are currently importing multiple copies |
|
| 2819 | + public $importMultiple = false; // whether we are currently importing multiple copies |
|
| 2820 | 2820 | |
| 2821 | 2821 | |
| 2822 | 2822 | /** |
@@ -2850,14 +2850,14 @@ discard block |
||
| 2850 | 2850 | public $functions = array(); |
| 2851 | 2851 | |
| 2852 | 2852 | |
| 2853 | - public function Init(){ |
|
| 2853 | + public function Init() { |
|
| 2854 | 2854 | |
| 2855 | 2855 | self::$parensStack = 0; |
| 2856 | 2856 | self::$tabLevel = 0; |
| 2857 | 2857 | self::$lastRule = false; |
| 2858 | 2858 | self::$mixin_stack = 0; |
| 2859 | 2859 | |
| 2860 | - if( Less_Parser::$options['compress'] ){ |
|
| 2860 | + if (Less_Parser::$options['compress']) { |
|
| 2861 | 2861 | |
| 2862 | 2862 | Less_Environment::$_outputMap = array( |
| 2863 | 2863 | ',' => ',', |
@@ -2873,7 +2873,7 @@ discard block |
||
| 2873 | 2873 | '^^' => '^^' |
| 2874 | 2874 | ); |
| 2875 | 2875 | |
| 2876 | - }else{ |
|
| 2876 | + }else { |
|
| 2877 | 2877 | |
| 2878 | 2878 | Less_Environment::$_outputMap = array( |
| 2879 | 2879 | ',' => ', ', |
@@ -2893,19 +2893,19 @@ discard block |
||
| 2893 | 2893 | } |
| 2894 | 2894 | |
| 2895 | 2895 | |
| 2896 | - public function copyEvalEnv($frames = array() ){ |
|
| 2896 | + public function copyEvalEnv($frames = array()) { |
|
| 2897 | 2897 | $new_env = new Less_Environment(); |
| 2898 | 2898 | $new_env->frames = $frames; |
| 2899 | 2899 | return $new_env; |
| 2900 | 2900 | } |
| 2901 | 2901 | |
| 2902 | 2902 | |
| 2903 | - public static function isMathOn(){ |
|
| 2903 | + public static function isMathOn() { |
|
| 2904 | 2904 | return !Less_Parser::$options['strictMath'] || Less_Environment::$parensStack; |
| 2905 | 2905 | } |
| 2906 | 2906 | |
| 2907 | - public static function isPathRelative($path){ |
|
| 2908 | - return !preg_match('/^(?:[a-z-]+:|\/)/',$path); |
|
| 2907 | + public static function isPathRelative($path) { |
|
| 2908 | + return !preg_match('/^(?:[a-z-]+:|\/)/', $path); |
|
| 2909 | 2909 | } |
| 2910 | 2910 | |
| 2911 | 2911 | |
@@ -2916,26 +2916,26 @@ discard block |
||
| 2916 | 2916 | * @return string Canonicalized path |
| 2917 | 2917 | * |
| 2918 | 2918 | */ |
| 2919 | - public static function normalizePath($path){ |
|
| 2919 | + public static function normalizePath($path) { |
|
| 2920 | 2920 | |
| 2921 | - $segments = explode('/',$path); |
|
| 2921 | + $segments = explode('/', $path); |
|
| 2922 | 2922 | $segments = array_reverse($segments); |
| 2923 | 2923 | |
| 2924 | 2924 | $path = array(); |
| 2925 | 2925 | $path_len = 0; |
| 2926 | 2926 | |
| 2927 | - while( $segments ){ |
|
| 2927 | + while ($segments) { |
|
| 2928 | 2928 | $segment = array_pop($segments); |
| 2929 | - switch( $segment ) { |
|
| 2929 | + switch ($segment) { |
|
| 2930 | 2930 | |
| 2931 | 2931 | case '.': |
| 2932 | 2932 | break; |
| 2933 | 2933 | |
| 2934 | 2934 | case '..': |
| 2935 | - if( !$path_len || ( $path[$path_len-1] === '..') ){ |
|
| 2935 | + if (!$path_len || ($path[$path_len-1]==='..')) { |
|
| 2936 | 2936 | $path[] = $segment; |
| 2937 | 2937 | $path_len++; |
| 2938 | - }else{ |
|
| 2938 | + }else { |
|
| 2939 | 2939 | array_pop($path); |
| 2940 | 2940 | $path_len--; |
| 2941 | 2941 | } |
@@ -2948,15 +2948,15 @@ discard block |
||
| 2948 | 2948 | } |
| 2949 | 2949 | } |
| 2950 | 2950 | |
| 2951 | - return implode('/',$path); |
|
| 2951 | + return implode('/', $path); |
|
| 2952 | 2952 | } |
| 2953 | 2953 | |
| 2954 | 2954 | |
| 2955 | - public function unshiftFrame($frame){ |
|
| 2955 | + public function unshiftFrame($frame) { |
|
| 2956 | 2956 | array_unshift($this->frames, $frame); |
| 2957 | 2957 | } |
| 2958 | 2958 | |
| 2959 | - public function shiftFrame(){ |
|
| 2959 | + public function shiftFrame() { |
|
| 2960 | 2960 | return array_shift($this->frames); |
| 2961 | 2961 | } |
| 2962 | 2962 | |
@@ -2970,12 +2970,12 @@ discard block |
||
| 2970 | 2970 | * @subpackage function |
| 2971 | 2971 | * @see http://lesscss.org/functions/ |
| 2972 | 2972 | */ |
| 2973 | -class Less_Functions{ |
|
| 2973 | +class Less_Functions { |
|
| 2974 | 2974 | |
| 2975 | 2975 | public $env; |
| 2976 | 2976 | public $currentFileInfo; |
| 2977 | 2977 | |
| 2978 | - function __construct($env, $currentFileInfo = null ){ |
|
| 2978 | + function __construct($env, $currentFileInfo = null) { |
|
| 2979 | 2979 | $this->env = $env; |
| 2980 | 2980 | $this->currentFileInfo = $currentFileInfo; |
| 2981 | 2981 | } |
@@ -2983,95 +2983,95 @@ discard block |
||
| 2983 | 2983 | /** |
| 2984 | 2984 | * @param string $op |
| 2985 | 2985 | */ |
| 2986 | - public static function operate( $op, $a, $b ){ |
|
| 2986 | + public static function operate($op, $a, $b) { |
|
| 2987 | 2987 | switch ($op) { |
| 2988 | - case '+': return $a + $b; |
|
| 2989 | - case '-': return $a - $b; |
|
| 2988 | + case '+': return $a+$b; |
|
| 2989 | + case '-': return $a-$b; |
|
| 2990 | 2990 | case '*': return $a * $b; |
| 2991 | 2991 | case '/': return $a / $b; |
| 2992 | 2992 | } |
| 2993 | 2993 | } |
| 2994 | 2994 | |
| 2995 | - public static function clamp($val, $max = 1){ |
|
| 2996 | - return min( max($val, 0), $max); |
|
| 2995 | + public static function clamp($val, $max = 1) { |
|
| 2996 | + return min(max($val, 0), $max); |
|
| 2997 | 2997 | } |
| 2998 | 2998 | |
| 2999 | - public static function fround( $value ){ |
|
| 2999 | + public static function fround($value) { |
|
| 3000 | 3000 | |
| 3001 | - if( $value === 0 ){ |
|
| 3001 | + if ($value===0) { |
|
| 3002 | 3002 | return $value; |
| 3003 | 3003 | } |
| 3004 | 3004 | |
| 3005 | - if( Less_Parser::$options['numPrecision'] ){ |
|
| 3005 | + if (Less_Parser::$options['numPrecision']) { |
|
| 3006 | 3006 | $p = pow(10, Less_Parser::$options['numPrecision']); |
| 3007 | - return round( $value * $p) / $p; |
|
| 3007 | + return round($value * $p) / $p; |
|
| 3008 | 3008 | } |
| 3009 | 3009 | return $value; |
| 3010 | 3010 | } |
| 3011 | 3011 | |
| 3012 | - public static function number($n){ |
|
| 3012 | + public static function number($n) { |
|
| 3013 | 3013 | |
| 3014 | 3014 | if ($n instanceof Less_Tree_Dimension) { |
| 3015 | - return floatval( $n->unit->is('%') ? $n->value / 100 : $n->value); |
|
| 3016 | - } else if (is_numeric($n)) { |
|
| 3015 | + return floatval($n->unit->is('%') ? $n->value / 100 : $n->value); |
|
| 3016 | + }else if (is_numeric($n)) { |
|
| 3017 | 3017 | return $n; |
| 3018 | - } else { |
|
| 3018 | + }else { |
|
| 3019 | 3019 | throw new Less_Exception_Compiler("color functions take numbers as parameters"); |
| 3020 | 3020 | } |
| 3021 | 3021 | } |
| 3022 | 3022 | |
| 3023 | - public static function scaled($n, $size = 255 ){ |
|
| 3024 | - if( $n instanceof Less_Tree_Dimension && $n->unit->is('%') ){ |
|
| 3023 | + public static function scaled($n, $size = 255) { |
|
| 3024 | + if ($n instanceof Less_Tree_Dimension && $n->unit->is('%')) { |
|
| 3025 | 3025 | return (float)$n->value * $size / 100; |
| 3026 | - } else { |
|
| 3026 | + }else { |
|
| 3027 | 3027 | return Less_Functions::number($n); |
| 3028 | 3028 | } |
| 3029 | 3029 | } |
| 3030 | 3030 | |
| 3031 | - public function rgb ($r = null, $g = null, $b = null){ |
|
| 3031 | + public function rgb($r = null, $g = null, $b = null) { |
|
| 3032 | 3032 | if (is_null($r) || is_null($g) || is_null($b)) { |
| 3033 | 3033 | throw new Less_Exception_Compiler("rgb expects three parameters"); |
| 3034 | 3034 | } |
| 3035 | 3035 | return $this->rgba($r, $g, $b, 1.0); |
| 3036 | 3036 | } |
| 3037 | 3037 | |
| 3038 | - public function rgba($r = null, $g = null, $b = null, $a = null){ |
|
| 3038 | + public function rgba($r = null, $g = null, $b = null, $a = null) { |
|
| 3039 | 3039 | $rgb = array($r, $g, $b); |
| 3040 | - $rgb = array_map(array('Less_Functions','scaled'),$rgb); |
|
| 3040 | + $rgb = array_map(array('Less_Functions', 'scaled'), $rgb); |
|
| 3041 | 3041 | |
| 3042 | 3042 | $a = self::number($a); |
| 3043 | 3043 | return new Less_Tree_Color($rgb, $a); |
| 3044 | 3044 | } |
| 3045 | 3045 | |
| 3046 | - public function hsl($h, $s, $l){ |
|
| 3046 | + public function hsl($h, $s, $l) { |
|
| 3047 | 3047 | return $this->hsla($h, $s, $l, 1.0); |
| 3048 | 3048 | } |
| 3049 | 3049 | |
| 3050 | - public function hsla($h, $s, $l, $a){ |
|
| 3050 | + public function hsla($h, $s, $l, $a) { |
|
| 3051 | 3051 | |
| 3052 | 3052 | $h = fmod(self::number($h), 360) / 360; // Classic % operator will change float to int |
| 3053 | 3053 | $s = self::clamp(self::number($s)); |
| 3054 | 3054 | $l = self::clamp(self::number($l)); |
| 3055 | 3055 | $a = self::clamp(self::number($a)); |
| 3056 | 3056 | |
| 3057 | - $m2 = $l <= 0.5 ? $l * ($s + 1) : $l + $s - $l * $s; |
|
| 3057 | + $m2 = $l<=0.5 ? $l * ($s+1) : $l+$s-$l * $s; |
|
| 3058 | 3058 | |
| 3059 | - $m1 = $l * 2 - $m2; |
|
| 3059 | + $m1 = $l * 2-$m2; |
|
| 3060 | 3060 | |
| 3061 | - return $this->rgba( self::hsla_hue($h + 1/3, $m1, $m2) * 255, |
|
| 3061 | + return $this->rgba(self::hsla_hue($h+1 / 3, $m1, $m2) * 255, |
|
| 3062 | 3062 | self::hsla_hue($h, $m1, $m2) * 255, |
| 3063 | - self::hsla_hue($h - 1/3, $m1, $m2) * 255, |
|
| 3063 | + self::hsla_hue($h-1 / 3, $m1, $m2) * 255, |
|
| 3064 | 3064 | $a); |
| 3065 | 3065 | } |
| 3066 | 3066 | |
| 3067 | 3067 | /** |
| 3068 | 3068 | * @param double $h |
| 3069 | 3069 | */ |
| 3070 | - public function hsla_hue($h, $m1, $m2){ |
|
| 3071 | - $h = $h < 0 ? $h + 1 : ($h > 1 ? $h - 1 : $h); |
|
| 3072 | - if ($h * 6 < 1) return $m1 + ($m2 - $m1) * $h * 6; |
|
| 3073 | - else if ($h * 2 < 1) return $m2; |
|
| 3074 | - else if ($h * 3 < 2) return $m1 + ($m2 - $m1) * (2/3 - $h) * 6; |
|
| 3070 | + public function hsla_hue($h, $m1, $m2) { |
|
| 3071 | + $h = $h<0 ? $h+1 : ($h>1 ? $h-1 : $h); |
|
| 3072 | + if ($h * 6<1) return $m1+($m2-$m1) * $h * 6; |
|
| 3073 | + else if ($h * 2<1) return $m2; |
|
| 3074 | + else if ($h * 3<2) return $m1+($m2-$m1) * (2 / 3-$h) * 6; |
|
| 3075 | 3075 | else return $m1; |
| 3076 | 3076 | } |
| 3077 | 3077 | |
@@ -3083,18 +3083,18 @@ discard block |
||
| 3083 | 3083 | * @param double $a |
| 3084 | 3084 | */ |
| 3085 | 3085 | public function hsva($h, $s, $v, $a) { |
| 3086 | - $h = ((Less_Functions::number($h) % 360) / 360 ) * 360; |
|
| 3086 | + $h = ((Less_Functions::number($h) % 360) / 360) * 360; |
|
| 3087 | 3087 | $s = Less_Functions::number($s); |
| 3088 | 3088 | $v = Less_Functions::number($v); |
| 3089 | 3089 | $a = Less_Functions::number($a); |
| 3090 | 3090 | |
| 3091 | 3091 | $i = floor(($h / 60) % 6); |
| 3092 | - $f = ($h / 60) - $i; |
|
| 3092 | + $f = ($h / 60)-$i; |
|
| 3093 | 3093 | |
| 3094 | - $vs = array( $v, |
|
| 3095 | - $v * (1 - $s), |
|
| 3096 | - $v * (1 - $f * $s), |
|
| 3097 | - $v * (1 - (1 - $f) * $s)); |
|
| 3094 | + $vs = array($v, |
|
| 3095 | + $v * (1-$s), |
|
| 3096 | + $v * (1-$f * $s), |
|
| 3097 | + $v * (1-(1-$f) * $s)); |
|
| 3098 | 3098 | |
| 3099 | 3099 | $perm = array(array(0, 3, 1), |
| 3100 | 3100 | array(2, 0, 1), |
@@ -3109,105 +3109,105 @@ discard block |
||
| 3109 | 3109 | $a); |
| 3110 | 3110 | } |
| 3111 | 3111 | |
| 3112 | - public function hue($color = null){ |
|
| 3112 | + public function hue($color = null) { |
|
| 3113 | 3113 | if (!$color instanceof Less_Tree_Color) { |
| 3114 | - throw new Less_Exception_Compiler('The first argument to hue must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3114 | + throw new Less_Exception_Compiler('The first argument to hue must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3115 | 3115 | } |
| 3116 | 3116 | |
| 3117 | 3117 | $c = $color->toHSL(); |
| 3118 | 3118 | return new Less_Tree_Dimension(Less_Parser::round($c['h'])); |
| 3119 | 3119 | } |
| 3120 | 3120 | |
| 3121 | - public function saturation($color = null){ |
|
| 3121 | + public function saturation($color = null) { |
|
| 3122 | 3122 | if (!$color instanceof Less_Tree_Color) { |
| 3123 | - throw new Less_Exception_Compiler('The first argument to saturation must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3123 | + throw new Less_Exception_Compiler('The first argument to saturation must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3124 | 3124 | } |
| 3125 | 3125 | |
| 3126 | 3126 | $c = $color->toHSL(); |
| 3127 | 3127 | return new Less_Tree_Dimension(Less_Parser::round($c['s'] * 100), '%'); |
| 3128 | 3128 | } |
| 3129 | 3129 | |
| 3130 | - public function lightness($color = null){ |
|
| 3130 | + public function lightness($color = null) { |
|
| 3131 | 3131 | if (!$color instanceof Less_Tree_Color) { |
| 3132 | - throw new Less_Exception_Compiler('The first argument to lightness must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3132 | + throw new Less_Exception_Compiler('The first argument to lightness must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3133 | 3133 | } |
| 3134 | 3134 | |
| 3135 | 3135 | $c = $color->toHSL(); |
| 3136 | 3136 | return new Less_Tree_Dimension(Less_Parser::round($c['l'] * 100), '%'); |
| 3137 | 3137 | } |
| 3138 | 3138 | |
| 3139 | - public function hsvhue( $color = null ){ |
|
| 3139 | + public function hsvhue($color = null) { |
|
| 3140 | 3140 | if (!$color instanceof Less_Tree_Color) { |
| 3141 | - throw new Less_Exception_Compiler('The first argument to hsvhue must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3141 | + throw new Less_Exception_Compiler('The first argument to hsvhue must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3142 | 3142 | } |
| 3143 | 3143 | |
| 3144 | 3144 | $hsv = $color->toHSV(); |
| 3145 | - return new Less_Tree_Dimension( Less_Parser::round($hsv['h']) ); |
|
| 3145 | + return new Less_Tree_Dimension(Less_Parser::round($hsv['h'])); |
|
| 3146 | 3146 | } |
| 3147 | 3147 | |
| 3148 | 3148 | |
| 3149 | - public function hsvsaturation( $color = null ){ |
|
| 3149 | + public function hsvsaturation($color = null) { |
|
| 3150 | 3150 | if (!$color instanceof Less_Tree_Color) { |
| 3151 | - throw new Less_Exception_Compiler('The first argument to hsvsaturation must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3151 | + throw new Less_Exception_Compiler('The first argument to hsvsaturation must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3152 | 3152 | } |
| 3153 | 3153 | |
| 3154 | 3154 | $hsv = $color->toHSV(); |
| 3155 | - return new Less_Tree_Dimension( Less_Parser::round($hsv['s'] * 100), '%' ); |
|
| 3155 | + return new Less_Tree_Dimension(Less_Parser::round($hsv['s'] * 100), '%'); |
|
| 3156 | 3156 | } |
| 3157 | 3157 | |
| 3158 | - public function hsvvalue( $color = null ){ |
|
| 3158 | + public function hsvvalue($color = null) { |
|
| 3159 | 3159 | if (!$color instanceof Less_Tree_Color) { |
| 3160 | - throw new Less_Exception_Compiler('The first argument to hsvvalue must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3160 | + throw new Less_Exception_Compiler('The first argument to hsvvalue must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3161 | 3161 | } |
| 3162 | 3162 | |
| 3163 | 3163 | $hsv = $color->toHSV(); |
| 3164 | - return new Less_Tree_Dimension( Less_Parser::round($hsv['v'] * 100), '%' ); |
|
| 3164 | + return new Less_Tree_Dimension(Less_Parser::round($hsv['v'] * 100), '%'); |
|
| 3165 | 3165 | } |
| 3166 | 3166 | |
| 3167 | 3167 | public function red($color = null) { |
| 3168 | 3168 | if (!$color instanceof Less_Tree_Color) { |
| 3169 | - throw new Less_Exception_Compiler('The first argument to red must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3169 | + throw new Less_Exception_Compiler('The first argument to red must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3170 | 3170 | } |
| 3171 | 3171 | |
| 3172 | - return new Less_Tree_Dimension( $color->rgb[0] ); |
|
| 3172 | + return new Less_Tree_Dimension($color->rgb[0]); |
|
| 3173 | 3173 | } |
| 3174 | 3174 | |
| 3175 | 3175 | public function green($color = null) { |
| 3176 | 3176 | if (!$color instanceof Less_Tree_Color) { |
| 3177 | - throw new Less_Exception_Compiler('The first argument to green must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3177 | + throw new Less_Exception_Compiler('The first argument to green must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3178 | 3178 | } |
| 3179 | 3179 | |
| 3180 | - return new Less_Tree_Dimension( $color->rgb[1] ); |
|
| 3180 | + return new Less_Tree_Dimension($color->rgb[1]); |
|
| 3181 | 3181 | } |
| 3182 | 3182 | |
| 3183 | 3183 | public function blue($color = null) { |
| 3184 | 3184 | if (!$color instanceof Less_Tree_Color) { |
| 3185 | - throw new Less_Exception_Compiler('The first argument to blue must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3185 | + throw new Less_Exception_Compiler('The first argument to blue must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3186 | 3186 | } |
| 3187 | 3187 | |
| 3188 | - return new Less_Tree_Dimension( $color->rgb[2] ); |
|
| 3188 | + return new Less_Tree_Dimension($color->rgb[2]); |
|
| 3189 | 3189 | } |
| 3190 | 3190 | |
| 3191 | - public function alpha($color = null){ |
|
| 3191 | + public function alpha($color = null) { |
|
| 3192 | 3192 | if (!$color instanceof Less_Tree_Color) { |
| 3193 | - throw new Less_Exception_Compiler('The first argument to alpha must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3193 | + throw new Less_Exception_Compiler('The first argument to alpha must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3194 | 3194 | } |
| 3195 | 3195 | |
| 3196 | 3196 | $c = $color->toHSL(); |
| 3197 | 3197 | return new Less_Tree_Dimension($c['a']); |
| 3198 | 3198 | } |
| 3199 | 3199 | |
| 3200 | - public function luma ($color = null) { |
|
| 3200 | + public function luma($color = null) { |
|
| 3201 | 3201 | if (!$color instanceof Less_Tree_Color) { |
| 3202 | - throw new Less_Exception_Compiler('The first argument to luma must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3202 | + throw new Less_Exception_Compiler('The first argument to luma must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3203 | 3203 | } |
| 3204 | 3204 | |
| 3205 | - return new Less_Tree_Dimension(Less_Parser::round( $color->luma() * $color->alpha * 100), '%'); |
|
| 3205 | + return new Less_Tree_Dimension(Less_Parser::round($color->luma() * $color->alpha * 100), '%'); |
|
| 3206 | 3206 | } |
| 3207 | 3207 | |
| 3208 | - public function luminance( $color = null ){ |
|
| 3208 | + public function luminance($color = null) { |
|
| 3209 | 3209 | if (!$color instanceof Less_Tree_Color) { |
| 3210 | - throw new Less_Exception_Compiler('The first argument to luminance must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3210 | + throw new Less_Exception_Compiler('The first argument to luminance must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3211 | 3211 | } |
| 3212 | 3212 | |
| 3213 | 3213 | $luminance = |
@@ -3215,10 +3215,10 @@ discard block |
||
| 3215 | 3215 | + (0.7152 * $color->rgb[1] / 255) |
| 3216 | 3216 | + (0.0722 * $color->rgb[2] / 255); |
| 3217 | 3217 | |
| 3218 | - return new Less_Tree_Dimension(Less_Parser::round( $luminance * $color->alpha * 100), '%'); |
|
| 3218 | + return new Less_Tree_Dimension(Less_Parser::round($luminance * $color->alpha * 100), '%'); |
|
| 3219 | 3219 | } |
| 3220 | 3220 | |
| 3221 | - public function saturate($color = null, $amount = null){ |
|
| 3221 | + public function saturate($color = null, $amount = null) { |
|
| 3222 | 3222 | // filter: saturate(3.2); |
| 3223 | 3223 | // should be kept as is, so check for color |
| 3224 | 3224 | if ($color instanceof Less_Tree_Dimension) { |
@@ -3226,10 +3226,10 @@ discard block |
||
| 3226 | 3226 | } |
| 3227 | 3227 | |
| 3228 | 3228 | if (!$color instanceof Less_Tree_Color) { |
| 3229 | - throw new Less_Exception_Compiler('The first argument to saturate must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3229 | + throw new Less_Exception_Compiler('The first argument to saturate must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3230 | 3230 | } |
| 3231 | 3231 | if (!$amount instanceof Less_Tree_Dimension) { |
| 3232 | - throw new Less_Exception_Compiler('The second argument to saturate must be a percentage' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3232 | + throw new Less_Exception_Compiler('The second argument to saturate must be a percentage'.($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3233 | 3233 | } |
| 3234 | 3234 | |
| 3235 | 3235 | $hsl = $color->toHSL(); |
@@ -3243,12 +3243,12 @@ discard block |
||
| 3243 | 3243 | /** |
| 3244 | 3244 | * @param Less_Tree_Dimension $amount |
| 3245 | 3245 | */ |
| 3246 | - public function desaturate($color = null, $amount = null){ |
|
| 3246 | + public function desaturate($color = null, $amount = null) { |
|
| 3247 | 3247 | if (!$color instanceof Less_Tree_Color) { |
| 3248 | - throw new Less_Exception_Compiler('The first argument to desaturate must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3248 | + throw new Less_Exception_Compiler('The first argument to desaturate must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3249 | 3249 | } |
| 3250 | 3250 | if (!$amount instanceof Less_Tree_Dimension) { |
| 3251 | - throw new Less_Exception_Compiler('The second argument to desaturate must be a percentage' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3251 | + throw new Less_Exception_Compiler('The second argument to desaturate must be a percentage'.($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3252 | 3252 | } |
| 3253 | 3253 | |
| 3254 | 3254 | $hsl = $color->toHSL(); |
@@ -3261,12 +3261,12 @@ discard block |
||
| 3261 | 3261 | |
| 3262 | 3262 | |
| 3263 | 3263 | |
| 3264 | - public function lighten($color = null, $amount=null){ |
|
| 3264 | + public function lighten($color = null, $amount = null) { |
|
| 3265 | 3265 | if (!$color instanceof Less_Tree_Color) { |
| 3266 | - throw new Less_Exception_Compiler('The first argument to lighten must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3266 | + throw new Less_Exception_Compiler('The first argument to lighten must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3267 | 3267 | } |
| 3268 | 3268 | if (!$amount instanceof Less_Tree_Dimension) { |
| 3269 | - throw new Less_Exception_Compiler('The second argument to lighten must be a percentage' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3269 | + throw new Less_Exception_Compiler('The second argument to lighten must be a percentage'.($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3270 | 3270 | } |
| 3271 | 3271 | |
| 3272 | 3272 | $hsl = $color->toHSL(); |
@@ -3277,12 +3277,12 @@ discard block |
||
| 3277 | 3277 | return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']); |
| 3278 | 3278 | } |
| 3279 | 3279 | |
| 3280 | - public function darken($color = null, $amount = null){ |
|
| 3280 | + public function darken($color = null, $amount = null) { |
|
| 3281 | 3281 | if (!$color instanceof Less_Tree_Color) { |
| 3282 | - throw new Less_Exception_Compiler('The first argument to darken must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3282 | + throw new Less_Exception_Compiler('The first argument to darken must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3283 | 3283 | } |
| 3284 | 3284 | if (!$amount instanceof Less_Tree_Dimension) { |
| 3285 | - throw new Less_Exception_Compiler('The second argument to darken must be a percentage' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3285 | + throw new Less_Exception_Compiler('The second argument to darken must be a percentage'.($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3286 | 3286 | } |
| 3287 | 3287 | |
| 3288 | 3288 | $hsl = $color->toHSL(); |
@@ -3292,12 +3292,12 @@ discard block |
||
| 3292 | 3292 | return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']); |
| 3293 | 3293 | } |
| 3294 | 3294 | |
| 3295 | - public function fadein($color = null, $amount = null){ |
|
| 3295 | + public function fadein($color = null, $amount = null) { |
|
| 3296 | 3296 | if (!$color instanceof Less_Tree_Color) { |
| 3297 | - throw new Less_Exception_Compiler('The first argument to fadein must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3297 | + throw new Less_Exception_Compiler('The first argument to fadein must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3298 | 3298 | } |
| 3299 | 3299 | if (!$amount instanceof Less_Tree_Dimension) { |
| 3300 | - throw new Less_Exception_Compiler('The second argument to fadein must be a percentage' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3300 | + throw new Less_Exception_Compiler('The second argument to fadein must be a percentage'.($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3301 | 3301 | } |
| 3302 | 3302 | |
| 3303 | 3303 | $hsl = $color->toHSL(); |
@@ -3306,12 +3306,12 @@ discard block |
||
| 3306 | 3306 | return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']); |
| 3307 | 3307 | } |
| 3308 | 3308 | |
| 3309 | - public function fadeout($color = null, $amount = null){ |
|
| 3309 | + public function fadeout($color = null, $amount = null) { |
|
| 3310 | 3310 | if (!$color instanceof Less_Tree_Color) { |
| 3311 | - throw new Less_Exception_Compiler('The first argument to fadeout must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3311 | + throw new Less_Exception_Compiler('The first argument to fadeout must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3312 | 3312 | } |
| 3313 | 3313 | if (!$amount instanceof Less_Tree_Dimension) { |
| 3314 | - throw new Less_Exception_Compiler('The second argument to fadeout must be a percentage' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3314 | + throw new Less_Exception_Compiler('The second argument to fadeout must be a percentage'.($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3315 | 3315 | } |
| 3316 | 3316 | |
| 3317 | 3317 | $hsl = $color->toHSL(); |
@@ -3320,12 +3320,12 @@ discard block |
||
| 3320 | 3320 | return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']); |
| 3321 | 3321 | } |
| 3322 | 3322 | |
| 3323 | - public function fade($color = null, $amount = null){ |
|
| 3323 | + public function fade($color = null, $amount = null) { |
|
| 3324 | 3324 | if (!$color instanceof Less_Tree_Color) { |
| 3325 | - throw new Less_Exception_Compiler('The first argument to fade must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3325 | + throw new Less_Exception_Compiler('The first argument to fade must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3326 | 3326 | } |
| 3327 | 3327 | if (!$amount instanceof Less_Tree_Dimension) { |
| 3328 | - throw new Less_Exception_Compiler('The second argument to fade must be a percentage' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3328 | + throw new Less_Exception_Compiler('The second argument to fade must be a percentage'.($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3329 | 3329 | } |
| 3330 | 3330 | |
| 3331 | 3331 | $hsl = $color->toHSL(); |
@@ -3337,18 +3337,18 @@ discard block |
||
| 3337 | 3337 | |
| 3338 | 3338 | |
| 3339 | 3339 | |
| 3340 | - public function spin($color = null, $amount = null){ |
|
| 3340 | + public function spin($color = null, $amount = null) { |
|
| 3341 | 3341 | if (!$color instanceof Less_Tree_Color) { |
| 3342 | - throw new Less_Exception_Compiler('The first argument to spin must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3342 | + throw new Less_Exception_Compiler('The first argument to spin must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3343 | 3343 | } |
| 3344 | 3344 | if (!$amount instanceof Less_Tree_Dimension) { |
| 3345 | - throw new Less_Exception_Compiler('The second argument to spin must be a number' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3345 | + throw new Less_Exception_Compiler('The second argument to spin must be a number'.($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3346 | 3346 | } |
| 3347 | 3347 | |
| 3348 | 3348 | $hsl = $color->toHSL(); |
| 3349 | - $hue = fmod($hsl['h'] + $amount->value, 360); |
|
| 3349 | + $hue = fmod($hsl['h']+$amount->value, 360); |
|
| 3350 | 3350 | |
| 3351 | - $hsl['h'] = $hue < 0 ? 360 + $hue : $hue; |
|
| 3351 | + $hsl['h'] = $hue<0 ? 360+$hue : $hue; |
|
| 3352 | 3352 | |
| 3353 | 3353 | return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']); |
| 3354 | 3354 | } |
@@ -3361,92 +3361,92 @@ discard block |
||
| 3361 | 3361 | /** |
| 3362 | 3362 | * @param Less_Tree_Color $color1 |
| 3363 | 3363 | */ |
| 3364 | - public function mix($color1 = null, $color2 = null, $weight = null){ |
|
| 3364 | + public function mix($color1 = null, $color2 = null, $weight = null) { |
|
| 3365 | 3365 | if (!$color1 instanceof Less_Tree_Color) { |
| 3366 | - throw new Less_Exception_Compiler('The first argument to mix must be a color' . ($color1 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3366 | + throw new Less_Exception_Compiler('The first argument to mix must be a color'.($color1 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3367 | 3367 | } |
| 3368 | 3368 | if (!$color2 instanceof Less_Tree_Color) { |
| 3369 | - throw new Less_Exception_Compiler('The second argument to mix must be a color' . ($color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3369 | + throw new Less_Exception_Compiler('The second argument to mix must be a color'.($color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3370 | 3370 | } |
| 3371 | 3371 | if (!$weight) { |
| 3372 | 3372 | $weight = new Less_Tree_Dimension('50', '%'); |
| 3373 | 3373 | } |
| 3374 | 3374 | if (!$weight instanceof Less_Tree_Dimension) { |
| 3375 | - throw new Less_Exception_Compiler('The third argument to contrast must be a percentage' . ($weight instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3375 | + throw new Less_Exception_Compiler('The third argument to contrast must be a percentage'.($weight instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3376 | 3376 | } |
| 3377 | 3377 | |
| 3378 | 3378 | $p = $weight->value / 100.0; |
| 3379 | - $w = $p * 2 - 1; |
|
| 3379 | + $w = $p * 2-1; |
|
| 3380 | 3380 | $hsl1 = $color1->toHSL(); |
| 3381 | 3381 | $hsl2 = $color2->toHSL(); |
| 3382 | - $a = $hsl1['a'] - $hsl2['a']; |
|
| 3382 | + $a = $hsl1['a']-$hsl2['a']; |
|
| 3383 | 3383 | |
| 3384 | - $w1 = (((($w * $a) == -1) ? $w : ($w + $a) / (1 + $w * $a)) + 1) / 2; |
|
| 3385 | - $w2 = 1 - $w1; |
|
| 3384 | + $w1 = (((($w * $a)==-1) ? $w : ($w+$a) / (1+$w * $a))+1) / 2; |
|
| 3385 | + $w2 = 1-$w1; |
|
| 3386 | 3386 | |
| 3387 | - $rgb = array($color1->rgb[0] * $w1 + $color2->rgb[0] * $w2, |
|
| 3388 | - $color1->rgb[1] * $w1 + $color2->rgb[1] * $w2, |
|
| 3389 | - $color1->rgb[2] * $w1 + $color2->rgb[2] * $w2); |
|
| 3387 | + $rgb = array($color1->rgb[0] * $w1+$color2->rgb[0] * $w2, |
|
| 3388 | + $color1->rgb[1] * $w1+$color2->rgb[1] * $w2, |
|
| 3389 | + $color1->rgb[2] * $w1+$color2->rgb[2] * $w2); |
|
| 3390 | 3390 | |
| 3391 | - $alpha = $color1->alpha * $p + $color2->alpha * (1 - $p); |
|
| 3391 | + $alpha = $color1->alpha * $p+$color2->alpha * (1-$p); |
|
| 3392 | 3392 | |
| 3393 | 3393 | return new Less_Tree_Color($rgb, $alpha); |
| 3394 | 3394 | } |
| 3395 | 3395 | |
| 3396 | - public function greyscale($color){ |
|
| 3397 | - return $this->desaturate($color, new Less_Tree_Dimension(100,'%')); |
|
| 3396 | + public function greyscale($color) { |
|
| 3397 | + return $this->desaturate($color, new Less_Tree_Dimension(100, '%')); |
|
| 3398 | 3398 | } |
| 3399 | 3399 | |
| 3400 | 3400 | |
| 3401 | - public function contrast( $color, $dark = null, $light = null, $threshold = null){ |
|
| 3401 | + public function contrast($color, $dark = null, $light = null, $threshold = null) { |
|
| 3402 | 3402 | // filter: contrast(3.2); |
| 3403 | 3403 | // should be kept as is, so check for color |
| 3404 | 3404 | if (!$color instanceof Less_Tree_Color) { |
| 3405 | 3405 | return null; |
| 3406 | 3406 | } |
| 3407 | - if( !$light ){ |
|
| 3407 | + if (!$light) { |
|
| 3408 | 3408 | $light = $this->rgba(255, 255, 255, 1.0); |
| 3409 | 3409 | } |
| 3410 | - if( !$dark ){ |
|
| 3410 | + if (!$dark) { |
|
| 3411 | 3411 | $dark = $this->rgba(0, 0, 0, 1.0); |
| 3412 | 3412 | } |
| 3413 | 3413 | |
| 3414 | 3414 | if (!$dark instanceof Less_Tree_Color) { |
| 3415 | - throw new Less_Exception_Compiler('The second argument to contrast must be a color' . ($dark instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3415 | + throw new Less_Exception_Compiler('The second argument to contrast must be a color'.($dark instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3416 | 3416 | } |
| 3417 | 3417 | if (!$light instanceof Less_Tree_Color) { |
| 3418 | - throw new Less_Exception_Compiler('The third argument to contrast must be a color' . ($light instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3418 | + throw new Less_Exception_Compiler('The third argument to contrast must be a color'.($light instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3419 | 3419 | } |
| 3420 | 3420 | |
| 3421 | 3421 | //Figure out which is actually light and dark! |
| 3422 | - if( $dark->luma() > $light->luma() ){ |
|
| 3422 | + if ($dark->luma()>$light->luma()) { |
|
| 3423 | 3423 | $t = $light; |
| 3424 | 3424 | $light = $dark; |
| 3425 | 3425 | $dark = $t; |
| 3426 | 3426 | } |
| 3427 | - if( !$threshold ){ |
|
| 3427 | + if (!$threshold) { |
|
| 3428 | 3428 | $threshold = 0.43; |
| 3429 | - } else { |
|
| 3429 | + }else { |
|
| 3430 | 3430 | $threshold = Less_Functions::number($threshold); |
| 3431 | 3431 | } |
| 3432 | 3432 | |
| 3433 | - if( $color->luma() < $threshold ){ |
|
| 3433 | + if ($color->luma()<$threshold) { |
|
| 3434 | 3434 | return $light; |
| 3435 | - } else { |
|
| 3435 | + }else { |
|
| 3436 | 3436 | return $dark; |
| 3437 | 3437 | } |
| 3438 | 3438 | } |
| 3439 | 3439 | |
| 3440 | - public function e ($str){ |
|
| 3441 | - if( is_string($str) ){ |
|
| 3440 | + public function e($str) { |
|
| 3441 | + if (is_string($str)) { |
|
| 3442 | 3442 | return new Less_Tree_Anonymous($str); |
| 3443 | 3443 | } |
| 3444 | 3444 | return new Less_Tree_Anonymous($str instanceof Less_Tree_JavaScript ? $str->expression : $str->value); |
| 3445 | 3445 | } |
| 3446 | 3446 | |
| 3447 | - public function escape ($str){ |
|
| 3447 | + public function escape($str) { |
|
| 3448 | 3448 | |
| 3449 | - $revert = array('%21'=>'!', '%2A'=>'*', '%27'=>"'",'%3F'=>'?','%26'=>'&','%2C'=>',','%2F'=>'/','%40'=>'@','%2B'=>'+','%24'=>'$'); |
|
| 3449 | + $revert = array('%21'=>'!', '%2A'=>'*', '%27'=>"'", '%3F'=>'?', '%26'=>'&', '%2C'=>',', '%2F'=>'/', '%40'=>'@', '%2B'=>'+', '%24'=>'$'); |
|
| 3450 | 3450 | |
| 3451 | 3451 | return new Less_Tree_Anonymous(strtr(rawurlencode($str->value), $revert)); |
| 3452 | 3452 | } |
@@ -3456,29 +3456,29 @@ discard block |
||
| 3456 | 3456 | * todo: This function will need some additional work to make it work the same as less.js |
| 3457 | 3457 | * |
| 3458 | 3458 | */ |
| 3459 | - public function replace( $string, $pattern, $replacement, $flags = null ){ |
|
| 3459 | + public function replace($string, $pattern, $replacement, $flags = null) { |
|
| 3460 | 3460 | $result = $string->value; |
| 3461 | 3461 | |
| 3462 | - $expr = '/'.str_replace('/','\\/',$pattern->value).'/'; |
|
| 3463 | - if( $flags && $flags->value){ |
|
| 3462 | + $expr = '/'.str_replace('/', '\\/', $pattern->value).'/'; |
|
| 3463 | + if ($flags && $flags->value) { |
|
| 3464 | 3464 | $expr .= self::replace_flags($flags->value); |
| 3465 | 3465 | } |
| 3466 | 3466 | |
| 3467 | - $result = preg_replace($expr,$replacement->value,$result); |
|
| 3467 | + $result = preg_replace($expr, $replacement->value, $result); |
|
| 3468 | 3468 | |
| 3469 | 3469 | |
| 3470 | - if( property_exists($string,'quote') ){ |
|
| 3471 | - return new Less_Tree_Quoted( $string->quote, $result, $string->escaped); |
|
| 3470 | + if (property_exists($string, 'quote')) { |
|
| 3471 | + return new Less_Tree_Quoted($string->quote, $result, $string->escaped); |
|
| 3472 | 3472 | } |
| 3473 | - return new Less_Tree_Quoted( '', $result ); |
|
| 3473 | + return new Less_Tree_Quoted('', $result); |
|
| 3474 | 3474 | } |
| 3475 | 3475 | |
| 3476 | - public static function replace_flags($flags){ |
|
| 3477 | - $flags = str_split($flags,1); |
|
| 3476 | + public static function replace_flags($flags) { |
|
| 3477 | + $flags = str_split($flags, 1); |
|
| 3478 | 3478 | $new_flags = ''; |
| 3479 | 3479 | |
| 3480 | - foreach($flags as $flag){ |
|
| 3481 | - switch($flag){ |
|
| 3480 | + foreach ($flags as $flag) { |
|
| 3481 | + switch ($flag) { |
|
| 3482 | 3482 | case 'e': |
| 3483 | 3483 | case 'g': |
| 3484 | 3484 | break; |
@@ -3492,91 +3492,91 @@ discard block |
||
| 3492 | 3492 | return $new_flags; |
| 3493 | 3493 | } |
| 3494 | 3494 | |
| 3495 | - public function _percent(){ |
|
| 3495 | + public function _percent() { |
|
| 3496 | 3496 | $string = func_get_arg(0); |
| 3497 | 3497 | |
| 3498 | 3498 | $args = func_get_args(); |
| 3499 | 3499 | array_shift($args); |
| 3500 | 3500 | $result = $string->value; |
| 3501 | 3501 | |
| 3502 | - foreach($args as $arg){ |
|
| 3503 | - if( preg_match('/%[sda]/i',$result, $token) ){ |
|
| 3502 | + foreach ($args as $arg) { |
|
| 3503 | + if (preg_match('/%[sda]/i', $result, $token)) { |
|
| 3504 | 3504 | $token = $token[0]; |
| 3505 | 3505 | $value = stristr($token, 's') ? $arg->value : $arg->toCSS(); |
| 3506 | 3506 | $value = preg_match('/[A-Z]$/', $token) ? urlencode($value) : $value; |
| 3507 | - $result = preg_replace('/%[sda]/i',$value, $result, 1); |
|
| 3507 | + $result = preg_replace('/%[sda]/i', $value, $result, 1); |
|
| 3508 | 3508 | } |
| 3509 | 3509 | } |
| 3510 | 3510 | $result = str_replace('%%', '%', $result); |
| 3511 | 3511 | |
| 3512 | - return new Less_Tree_Quoted( $string->quote , $result, $string->escaped); |
|
| 3512 | + return new Less_Tree_Quoted($string->quote, $result, $string->escaped); |
|
| 3513 | 3513 | } |
| 3514 | 3514 | |
| 3515 | - public function unit( $val, $unit = null) { |
|
| 3516 | - if( !($val instanceof Less_Tree_Dimension) ){ |
|
| 3517 | - throw new Less_Exception_Compiler('The first argument to unit must be a number' . ($val instanceof Less_Tree_Operation ? '. Have you forgotten parenthesis?' : '.') ); |
|
| 3515 | + public function unit($val, $unit = null) { |
|
| 3516 | + if (!($val instanceof Less_Tree_Dimension)) { |
|
| 3517 | + throw new Less_Exception_Compiler('The first argument to unit must be a number'.($val instanceof Less_Tree_Operation ? '. Have you forgotten parenthesis?' : '.')); |
|
| 3518 | 3518 | } |
| 3519 | 3519 | |
| 3520 | - if( $unit ){ |
|
| 3521 | - if( $unit instanceof Less_Tree_Keyword ){ |
|
| 3520 | + if ($unit) { |
|
| 3521 | + if ($unit instanceof Less_Tree_Keyword) { |
|
| 3522 | 3522 | $unit = $unit->value; |
| 3523 | - } else { |
|
| 3523 | + }else { |
|
| 3524 | 3524 | $unit = $unit->toCSS(); |
| 3525 | 3525 | } |
| 3526 | - } else { |
|
| 3526 | + }else { |
|
| 3527 | 3527 | $unit = ""; |
| 3528 | 3528 | } |
| 3529 | - return new Less_Tree_Dimension($val->value, $unit ); |
|
| 3529 | + return new Less_Tree_Dimension($val->value, $unit); |
|
| 3530 | 3530 | } |
| 3531 | 3531 | |
| 3532 | - public function convert($val, $unit){ |
|
| 3532 | + public function convert($val, $unit) { |
|
| 3533 | 3533 | return $val->convertTo($unit->value); |
| 3534 | 3534 | } |
| 3535 | 3535 | |
| 3536 | 3536 | public function round($n, $f = false) { |
| 3537 | 3537 | |
| 3538 | 3538 | $fraction = 0; |
| 3539 | - if( $f !== false ){ |
|
| 3539 | + if ($f!==false) { |
|
| 3540 | 3540 | $fraction = $f->value; |
| 3541 | 3541 | } |
| 3542 | 3542 | |
| 3543 | - return $this->_math('Less_Parser::round',null, $n, $fraction); |
|
| 3543 | + return $this->_math('Less_Parser::round', null, $n, $fraction); |
|
| 3544 | 3544 | } |
| 3545 | 3545 | |
| 3546 | - public function pi(){ |
|
| 3546 | + public function pi() { |
|
| 3547 | 3547 | return new Less_Tree_Dimension(M_PI); |
| 3548 | 3548 | } |
| 3549 | 3549 | |
| 3550 | 3550 | public function mod($a, $b) { |
| 3551 | - return new Less_Tree_Dimension( $a->value % $b->value, $a->unit); |
|
| 3551 | + return new Less_Tree_Dimension($a->value % $b->value, $a->unit); |
|
| 3552 | 3552 | } |
| 3553 | 3553 | |
| 3554 | 3554 | |
| 3555 | 3555 | |
| 3556 | 3556 | public function pow($x, $y) { |
| 3557 | - if( is_numeric($x) && is_numeric($y) ){ |
|
| 3557 | + if (is_numeric($x) && is_numeric($y)) { |
|
| 3558 | 3558 | $x = new Less_Tree_Dimension($x); |
| 3559 | 3559 | $y = new Less_Tree_Dimension($y); |
| 3560 | - }elseif( !($x instanceof Less_Tree_Dimension) || !($y instanceof Less_Tree_Dimension) ){ |
|
| 3560 | + }elseif (!($x instanceof Less_Tree_Dimension) || !($y instanceof Less_Tree_Dimension)) { |
|
| 3561 | 3561 | throw new Less_Exception_Compiler('Arguments must be numbers'); |
| 3562 | 3562 | } |
| 3563 | 3563 | |
| 3564 | - return new Less_Tree_Dimension( pow($x->value, $y->value), $x->unit ); |
|
| 3564 | + return new Less_Tree_Dimension(pow($x->value, $y->value), $x->unit); |
|
| 3565 | 3565 | } |
| 3566 | 3566 | |
| 3567 | 3567 | // var mathFunctions = [{name:"ce ... |
| 3568 | - public function ceil( $n ){ return $this->_math('ceil', null, $n); } |
|
| 3569 | - public function floor( $n ){ return $this->_math('floor', null, $n); } |
|
| 3570 | - public function sqrt( $n ){ return $this->_math('sqrt', null, $n); } |
|
| 3571 | - public function abs( $n ){ return $this->_math('abs', null, $n); } |
|
| 3568 | + public function ceil($n) { return $this->_math('ceil', null, $n); } |
|
| 3569 | + public function floor($n) { return $this->_math('floor', null, $n); } |
|
| 3570 | + public function sqrt($n) { return $this->_math('sqrt', null, $n); } |
|
| 3571 | + public function abs($n) { return $this->_math('abs', null, $n); } |
|
| 3572 | 3572 | |
| 3573 | - public function tan( $n ){ return $this->_math('tan', '', $n); } |
|
| 3574 | - public function sin( $n ){ return $this->_math('sin', '', $n); } |
|
| 3575 | - public function cos( $n ){ return $this->_math('cos', '', $n); } |
|
| 3573 | + public function tan($n) { return $this->_math('tan', '', $n); } |
|
| 3574 | + public function sin($n) { return $this->_math('sin', '', $n); } |
|
| 3575 | + public function cos($n) { return $this->_math('cos', '', $n); } |
|
| 3576 | 3576 | |
| 3577 | - public function atan( $n ){ return $this->_math('atan', 'rad', $n); } |
|
| 3578 | - public function asin( $n ){ return $this->_math('asin', 'rad', $n); } |
|
| 3579 | - public function acos( $n ){ return $this->_math('acos', 'rad', $n); } |
|
| 3577 | + public function atan($n) { return $this->_math('atan', 'rad', $n); } |
|
| 3578 | + public function asin($n) { return $this->_math('asin', 'rad', $n); } |
|
| 3579 | + public function acos($n) { return $this->_math('acos', 'rad', $n); } |
|
| 3580 | 3580 | |
| 3581 | 3581 | private function _math() { |
| 3582 | 3582 | $args = func_get_args(); |
@@ -3585,16 +3585,16 @@ discard block |
||
| 3585 | 3585 | |
| 3586 | 3586 | if ($args[0] instanceof Less_Tree_Dimension) { |
| 3587 | 3587 | |
| 3588 | - if( $unit === null ){ |
|
| 3588 | + if ($unit===null) { |
|
| 3589 | 3589 | $unit = $args[0]->unit; |
| 3590 | - }else{ |
|
| 3590 | + }else { |
|
| 3591 | 3591 | $args[0] = $args[0]->unify(); |
| 3592 | 3592 | } |
| 3593 | 3593 | $args[0] = (float)$args[0]->value; |
| 3594 | - return new Less_Tree_Dimension( call_user_func_array($fn, $args), $unit); |
|
| 3595 | - } else if (is_numeric($args[0])) { |
|
| 3596 | - return call_user_func_array($fn,$args); |
|
| 3597 | - } else { |
|
| 3594 | + return new Less_Tree_Dimension(call_user_func_array($fn, $args), $unit); |
|
| 3595 | + }else if (is_numeric($args[0])) { |
|
| 3596 | + return call_user_func_array($fn, $args); |
|
| 3597 | + }else { |
|
| 3598 | 3598 | throw new Less_Exception_Compiler("math functions take numbers as parameters"); |
| 3599 | 3599 | } |
| 3600 | 3600 | } |
@@ -3602,12 +3602,12 @@ discard block |
||
| 3602 | 3602 | /** |
| 3603 | 3603 | * @param boolean $isMin |
| 3604 | 3604 | */ |
| 3605 | - private function _minmax( $isMin, $args ){ |
|
| 3605 | + private function _minmax($isMin, $args) { |
|
| 3606 | 3606 | |
| 3607 | 3607 | $arg_count = count($args); |
| 3608 | 3608 | |
| 3609 | - if( $arg_count < 1 ){ |
|
| 3610 | - throw new Less_Exception_Compiler( 'one or more arguments required'); |
|
| 3609 | + if ($arg_count<1) { |
|
| 3610 | + throw new Less_Exception_Compiler('one or more arguments required'); |
|
| 3611 | 3611 | } |
| 3612 | 3612 | |
| 3613 | 3613 | $j = null; |
@@ -3615,49 +3615,49 @@ discard block |
||
| 3615 | 3615 | $unitStatic = null; |
| 3616 | 3616 | |
| 3617 | 3617 | |
| 3618 | - $order = array(); // elems only contains original argument values. |
|
| 3619 | - $values = array(); // key is the unit.toString() for unified tree.Dimension values, |
|
| 3618 | + $order = array(); // elems only contains original argument values. |
|
| 3619 | + $values = array(); // key is the unit.toString() for unified tree.Dimension values, |
|
| 3620 | 3620 | // value is the index into the order array. |
| 3621 | 3621 | |
| 3622 | 3622 | |
| 3623 | - for( $i = 0; $i < $arg_count; $i++ ){ |
|
| 3623 | + for ($i = 0; $i<$arg_count; $i++) { |
|
| 3624 | 3624 | $current = $args[$i]; |
| 3625 | - if( !($current instanceof Less_Tree_Dimension) ){ |
|
| 3626 | - if( is_array($args[$i]->value) ){ |
|
| 3625 | + if (!($current instanceof Less_Tree_Dimension)) { |
|
| 3626 | + if (is_array($args[$i]->value)) { |
|
| 3627 | 3627 | $args[] = $args[$i]->value; |
| 3628 | 3628 | } |
| 3629 | 3629 | continue; |
| 3630 | 3630 | } |
| 3631 | 3631 | |
| 3632 | - if( $current->unit->toString() === '' && !$unitClone ){ |
|
| 3632 | + if ($current->unit->toString()==='' && !$unitClone) { |
|
| 3633 | 3633 | $temp = new Less_Tree_Dimension($current->value, $unitClone); |
| 3634 | 3634 | $currentUnified = $temp->unify(); |
| 3635 | - }else{ |
|
| 3635 | + }else { |
|
| 3636 | 3636 | $currentUnified = $current->unify(); |
| 3637 | 3637 | } |
| 3638 | 3638 | |
| 3639 | - if( $currentUnified->unit->toString() === "" && !$unitStatic ){ |
|
| 3639 | + if ($currentUnified->unit->toString()==="" && !$unitStatic) { |
|
| 3640 | 3640 | $unit = $unitStatic; |
| 3641 | - }else{ |
|
| 3641 | + }else { |
|
| 3642 | 3642 | $unit = $currentUnified->unit->toString(); |
| 3643 | 3643 | } |
| 3644 | 3644 | |
| 3645 | - if( $unit !== '' && !$unitStatic || $unit !== '' && $order[0]->unify()->unit->toString() === "" ){ |
|
| 3645 | + if ($unit!=='' && !$unitStatic || $unit!=='' && $order[0]->unify()->unit->toString()==="") { |
|
| 3646 | 3646 | $unitStatic = $unit; |
| 3647 | 3647 | } |
| 3648 | 3648 | |
| 3649 | - if( $unit != '' && !$unitClone ){ |
|
| 3649 | + if ($unit!='' && !$unitClone) { |
|
| 3650 | 3650 | $unitClone = $current->unit->toString(); |
| 3651 | 3651 | } |
| 3652 | 3652 | |
| 3653 | - if( isset($values['']) && $unit !== '' && $unit === $unitStatic ){ |
|
| 3653 | + if (isset($values['']) && $unit!=='' && $unit===$unitStatic) { |
|
| 3654 | 3654 | $j = $values['']; |
| 3655 | - }elseif( isset($values[$unit]) ){ |
|
| 3655 | + }elseif (isset($values[$unit])) { |
|
| 3656 | 3656 | $j = $values[$unit]; |
| 3657 | - }else{ |
|
| 3657 | + }else { |
|
| 3658 | 3658 | |
| 3659 | - if( $unitStatic && $unit !== $unitStatic ){ |
|
| 3660 | - throw new Less_Exception_Compiler( 'incompatible types'); |
|
| 3659 | + if ($unitStatic && $unit!==$unitStatic) { |
|
| 3660 | + throw new Less_Exception_Compiler('incompatible types'); |
|
| 3661 | 3661 | } |
| 3662 | 3662 | $values[$unit] = count($order); |
| 3663 | 3663 | $order[] = $current; |
@@ -3665,44 +3665,44 @@ discard block |
||
| 3665 | 3665 | } |
| 3666 | 3666 | |
| 3667 | 3667 | |
| 3668 | - if( $order[$j]->unit->toString() === "" && $unitClone ){ |
|
| 3669 | - $temp = new Less_Tree_Dimension( $order[$j]->value, $unitClone); |
|
| 3668 | + if ($order[$j]->unit->toString()==="" && $unitClone) { |
|
| 3669 | + $temp = new Less_Tree_Dimension($order[$j]->value, $unitClone); |
|
| 3670 | 3670 | $referenceUnified = $temp->unify(); |
| 3671 | - }else{ |
|
| 3671 | + }else { |
|
| 3672 | 3672 | $referenceUnified = $order[$j]->unify(); |
| 3673 | 3673 | } |
| 3674 | - if( ($isMin && $currentUnified->value < $referenceUnified->value) || (!$isMin && $currentUnified->value > $referenceUnified->value) ){ |
|
| 3674 | + if (($isMin && $currentUnified->value<$referenceUnified->value) || (!$isMin && $currentUnified->value>$referenceUnified->value)) { |
|
| 3675 | 3675 | $order[$j] = $current; |
| 3676 | 3676 | } |
| 3677 | 3677 | } |
| 3678 | 3678 | |
| 3679 | - if( count($order) == 1 ){ |
|
| 3679 | + if (count($order)==1) { |
|
| 3680 | 3680 | return $order[0]; |
| 3681 | 3681 | } |
| 3682 | 3682 | $args = array(); |
| 3683 | - foreach($order as $a){ |
|
| 3683 | + foreach ($order as $a) { |
|
| 3684 | 3684 | $args[] = $a->toCSS($this->env); |
| 3685 | 3685 | } |
| 3686 | - return new Less_Tree_Anonymous( ($isMin?'min(':'max(') . implode(Less_Environment::$_outputMap[','],$args).')'); |
|
| 3686 | + return new Less_Tree_Anonymous(($isMin ? 'min(' : 'max(').implode(Less_Environment::$_outputMap[','], $args).')'); |
|
| 3687 | 3687 | } |
| 3688 | 3688 | |
| 3689 | - public function min(){ |
|
| 3689 | + public function min() { |
|
| 3690 | 3690 | $args = func_get_args(); |
| 3691 | - return $this->_minmax( true, $args ); |
|
| 3691 | + return $this->_minmax(true, $args); |
|
| 3692 | 3692 | } |
| 3693 | 3693 | |
| 3694 | - public function max(){ |
|
| 3694 | + public function max() { |
|
| 3695 | 3695 | $args = func_get_args(); |
| 3696 | - return $this->_minmax( false, $args ); |
|
| 3696 | + return $this->_minmax(false, $args); |
|
| 3697 | 3697 | } |
| 3698 | 3698 | |
| 3699 | - public function getunit($n){ |
|
| 3699 | + public function getunit($n) { |
|
| 3700 | 3700 | return new Less_Tree_Anonymous($n->unit); |
| 3701 | 3701 | } |
| 3702 | 3702 | |
| 3703 | 3703 | public function argb($color) { |
| 3704 | 3704 | if (!$color instanceof Less_Tree_Color) { |
| 3705 | - throw new Less_Exception_Compiler('The first argument to argb must be a color' . ($dark instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3705 | + throw new Less_Exception_Compiler('The first argument to argb must be a color'.($dark instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3706 | 3706 | } |
| 3707 | 3707 | |
| 3708 | 3708 | return new Less_Tree_Anonymous($color->toARGB()); |
@@ -3714,17 +3714,17 @@ discard block |
||
| 3714 | 3714 | |
| 3715 | 3715 | public function color($n) { |
| 3716 | 3716 | |
| 3717 | - if( $n instanceof Less_Tree_Quoted ){ |
|
| 3717 | + if ($n instanceof Less_Tree_Quoted) { |
|
| 3718 | 3718 | $colorCandidate = $n->value; |
| 3719 | 3719 | $returnColor = Less_Tree_Color::fromKeyword($colorCandidate); |
| 3720 | - if( $returnColor ){ |
|
| 3720 | + if ($returnColor) { |
|
| 3721 | 3721 | return $returnColor; |
| 3722 | 3722 | } |
| 3723 | - if( preg_match('/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})/',$colorCandidate) ){ |
|
| 3723 | + if (preg_match('/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})/', $colorCandidate)) { |
|
| 3724 | 3724 | return new Less_Tree_Color(substr($colorCandidate, 1)); |
| 3725 | 3725 | } |
| 3726 | 3726 | throw new Less_Exception_Compiler("argument must be a color keyword or 3/6 digit hex e.g. #FFF"); |
| 3727 | - } else { |
|
| 3727 | + }else { |
|
| 3728 | 3728 | throw new Less_Exception_Compiler("argument must be a string"); |
| 3729 | 3729 | } |
| 3730 | 3730 | } |
@@ -3765,8 +3765,8 @@ discard block |
||
| 3765 | 3765 | /** |
| 3766 | 3766 | * @param string $unit |
| 3767 | 3767 | */ |
| 3768 | - public function isunit( $n, $unit ){ |
|
| 3769 | - return ($n instanceof Less_Tree_Dimension) && $n->unit->is( ( property_exists($unit,'value') ? $unit->value : $unit) ) ? new Less_Tree_Keyword('true') : new Less_Tree_Keyword('false'); |
|
| 3768 | + public function isunit($n, $unit) { |
|
| 3769 | + return ($n instanceof Less_Tree_Dimension) && $n->unit->is((property_exists($unit, 'value') ? $unit->value : $unit)) ? new Less_Tree_Keyword('true') : new Less_Tree_Keyword('false'); |
|
| 3770 | 3770 | } |
| 3771 | 3771 | |
| 3772 | 3772 | /** |
@@ -3777,64 +3777,64 @@ discard block |
||
| 3777 | 3777 | } |
| 3778 | 3778 | |
| 3779 | 3779 | public function tint($color, $amount) { |
| 3780 | - return $this->mix( $this->rgb(255,255,255), $color, $amount); |
|
| 3780 | + return $this->mix($this->rgb(255, 255, 255), $color, $amount); |
|
| 3781 | 3781 | } |
| 3782 | 3782 | |
| 3783 | 3783 | public function shade($color, $amount) { |
| 3784 | 3784 | return $this->mix($this->rgb(0, 0, 0), $color, $amount); |
| 3785 | 3785 | } |
| 3786 | 3786 | |
| 3787 | - public function extract($values, $index ){ |
|
| 3788 | - $index = (int)$index->value - 1; // (1-based index) |
|
| 3787 | + public function extract($values, $index) { |
|
| 3788 | + $index = (int)$index->value-1; // (1-based index) |
|
| 3789 | 3789 | // handle non-array values as an array of length 1 |
| 3790 | 3790 | // return 'undefined' if index is invalid |
| 3791 | - if( property_exists($values,'value') && is_array($values->value) ){ |
|
| 3792 | - if( isset($values->value[$index]) ){ |
|
| 3791 | + if (property_exists($values, 'value') && is_array($values->value)) { |
|
| 3792 | + if (isset($values->value[$index])) { |
|
| 3793 | 3793 | return $values->value[$index]; |
| 3794 | 3794 | } |
| 3795 | 3795 | return null; |
| 3796 | 3796 | |
| 3797 | - }elseif( (int)$index === 0 ){ |
|
| 3797 | + }elseif ((int)$index===0) { |
|
| 3798 | 3798 | return $values; |
| 3799 | 3799 | } |
| 3800 | 3800 | |
| 3801 | 3801 | return null; |
| 3802 | 3802 | } |
| 3803 | 3803 | |
| 3804 | - public function length($values){ |
|
| 3805 | - $n = (property_exists($values,'value') && is_array($values->value)) ? count($values->value) : 1; |
|
| 3804 | + public function length($values) { |
|
| 3805 | + $n = (property_exists($values, 'value') && is_array($values->value)) ? count($values->value) : 1; |
|
| 3806 | 3806 | return new Less_Tree_Dimension($n); |
| 3807 | 3807 | } |
| 3808 | 3808 | |
| 3809 | - public function datauri($mimetypeNode, $filePathNode = null ) { |
|
| 3809 | + public function datauri($mimetypeNode, $filePathNode = null) { |
|
| 3810 | 3810 | |
| 3811 | - $filePath = ( $filePathNode ? $filePathNode->value : null ); |
|
| 3811 | + $filePath = ($filePathNode ? $filePathNode->value : null); |
|
| 3812 | 3812 | $mimetype = $mimetypeNode->value; |
| 3813 | 3813 | |
| 3814 | 3814 | $args = 2; |
| 3815 | - if( !$filePath ){ |
|
| 3815 | + if (!$filePath) { |
|
| 3816 | 3816 | $filePath = $mimetype; |
| 3817 | 3817 | $args = 1; |
| 3818 | 3818 | } |
| 3819 | 3819 | |
| 3820 | - $filePath = str_replace('\\','/',$filePath); |
|
| 3821 | - if( Less_Environment::isPathRelative($filePath) ){ |
|
| 3820 | + $filePath = str_replace('\\', '/', $filePath); |
|
| 3821 | + if (Less_Environment::isPathRelative($filePath)) { |
|
| 3822 | 3822 | |
| 3823 | - if( Less_Parser::$options['relativeUrls'] ){ |
|
| 3823 | + if (Less_Parser::$options['relativeUrls']) { |
|
| 3824 | 3824 | $temp = $this->currentFileInfo['currentDirectory']; |
| 3825 | - } else { |
|
| 3825 | + }else { |
|
| 3826 | 3826 | $temp = $this->currentFileInfo['entryPath']; |
| 3827 | 3827 | } |
| 3828 | 3828 | |
| 3829 | - if( !empty($temp) ){ |
|
| 3830 | - $filePath = Less_Environment::normalizePath(rtrim($temp,'/').'/'.$filePath); |
|
| 3829 | + if (!empty($temp)) { |
|
| 3830 | + $filePath = Less_Environment::normalizePath(rtrim($temp, '/').'/'.$filePath); |
|
| 3831 | 3831 | } |
| 3832 | 3832 | |
| 3833 | 3833 | } |
| 3834 | 3834 | |
| 3835 | 3835 | |
| 3836 | 3836 | // detect the mimetype if not given |
| 3837 | - if( $args < 2 ){ |
|
| 3837 | + if ($args<2) { |
|
| 3838 | 3838 | |
| 3839 | 3839 | /* incomplete |
| 3840 | 3840 | $mime = require('mime'); |
@@ -3849,17 +3849,17 @@ discard block |
||
| 3849 | 3849 | $mimetype = Less_Mime::lookup($filePath); |
| 3850 | 3850 | |
| 3851 | 3851 | $charset = Less_Mime::charsets_lookup($mimetype); |
| 3852 | - $useBase64 = !in_array($charset,array('US-ASCII', 'UTF-8')); |
|
| 3853 | - if( $useBase64 ){ $mimetype .= ';base64'; } |
|
| 3852 | + $useBase64 = !in_array($charset, array('US-ASCII', 'UTF-8')); |
|
| 3853 | + if ($useBase64) { $mimetype .= ';base64'; } |
|
| 3854 | 3854 | |
| 3855 | - }else{ |
|
| 3856 | - $useBase64 = preg_match('/;base64$/',$mimetype); |
|
| 3855 | + }else { |
|
| 3856 | + $useBase64 = preg_match('/;base64$/', $mimetype); |
|
| 3857 | 3857 | } |
| 3858 | 3858 | |
| 3859 | 3859 | |
| 3860 | - if( file_exists($filePath) ){ |
|
| 3860 | + if (file_exists($filePath)) { |
|
| 3861 | 3861 | $buf = @file_get_contents($filePath); |
| 3862 | - }else{ |
|
| 3862 | + }else { |
|
| 3863 | 3863 | $buf = false; |
| 3864 | 3864 | } |
| 3865 | 3865 | |
@@ -3867,38 +3867,38 @@ discard block |
||
| 3867 | 3867 | // IE8 cannot handle a data-uri larger than 32KB. If this is exceeded |
| 3868 | 3868 | // and the --ieCompat flag is enabled, return a normal url() instead. |
| 3869 | 3869 | $DATA_URI_MAX_KB = 32; |
| 3870 | - $fileSizeInKB = round( strlen($buf) / 1024 ); |
|
| 3871 | - if( $fileSizeInKB >= $DATA_URI_MAX_KB ){ |
|
| 3872 | - $url = new Less_Tree_Url( ($filePathNode ? $filePathNode : $mimetypeNode), $this->currentFileInfo); |
|
| 3870 | + $fileSizeInKB = round(strlen($buf) / 1024); |
|
| 3871 | + if ($fileSizeInKB>=$DATA_URI_MAX_KB) { |
|
| 3872 | + $url = new Less_Tree_Url(($filePathNode ? $filePathNode : $mimetypeNode), $this->currentFileInfo); |
|
| 3873 | 3873 | return $url->compile($this); |
| 3874 | 3874 | } |
| 3875 | 3875 | |
| 3876 | - if( $buf ){ |
|
| 3876 | + if ($buf) { |
|
| 3877 | 3877 | $buf = $useBase64 ? base64_encode($buf) : rawurlencode($buf); |
| 3878 | - $filePath = '"data:' . $mimetype . ',' . $buf . '"'; |
|
| 3878 | + $filePath = '"data:'.$mimetype.','.$buf.'"'; |
|
| 3879 | 3879 | } |
| 3880 | 3880 | |
| 3881 | - return new Less_Tree_Url( new Less_Tree_Anonymous($filePath) ); |
|
| 3881 | + return new Less_Tree_Url(new Less_Tree_Anonymous($filePath)); |
|
| 3882 | 3882 | } |
| 3883 | 3883 | |
| 3884 | 3884 | //svg-gradient |
| 3885 | - public function svggradient( $direction ){ |
|
| 3885 | + public function svggradient($direction) { |
|
| 3886 | 3886 | |
| 3887 | 3887 | $throw_message = 'svg-gradient expects direction, start_color [start_position], [color position,]..., end_color [end_position]'; |
| 3888 | 3888 | $arguments = func_get_args(); |
| 3889 | 3889 | |
| 3890 | - if( count($arguments) < 3 ){ |
|
| 3891 | - throw new Less_Exception_Compiler( $throw_message ); |
|
| 3890 | + if (count($arguments)<3) { |
|
| 3891 | + throw new Less_Exception_Compiler($throw_message); |
|
| 3892 | 3892 | } |
| 3893 | 3893 | |
| 3894 | - $stops = array_slice($arguments,1); |
|
| 3894 | + $stops = array_slice($arguments, 1); |
|
| 3895 | 3895 | $gradientType = 'linear'; |
| 3896 | 3896 | $rectangleDimension = 'x="0" y="0" width="1" height="1"'; |
| 3897 | 3897 | $useBase64 = true; |
| 3898 | 3898 | $directionValue = $direction->toCSS(); |
| 3899 | 3899 | |
| 3900 | 3900 | |
| 3901 | - switch( $directionValue ){ |
|
| 3901 | + switch ($directionValue) { |
|
| 3902 | 3902 | case "to bottom": |
| 3903 | 3903 | $gradientDirectionSvg = 'x1="0%" y1="0%" x2="0%" y2="100%"'; |
| 3904 | 3904 | break; |
@@ -3918,46 +3918,46 @@ discard block |
||
| 3918 | 3918 | $rectangleDimension = 'x="-50" y="-50" width="101" height="101"'; |
| 3919 | 3919 | break; |
| 3920 | 3920 | default: |
| 3921 | - throw new Less_Exception_Compiler( "svg-gradient direction must be 'to bottom', 'to right', 'to bottom right', 'to top right' or 'ellipse at center'" ); |
|
| 3921 | + throw new Less_Exception_Compiler("svg-gradient direction must be 'to bottom', 'to right', 'to bottom right', 'to top right' or 'ellipse at center'"); |
|
| 3922 | 3922 | } |
| 3923 | 3923 | |
| 3924 | - $returner = '<?xml version="1.0" ?>' . |
|
| 3925 | - '<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="100%" height="100%" viewBox="0 0 1 1" preserveAspectRatio="none">' . |
|
| 3926 | - '<' . $gradientType . 'Gradient id="gradient" gradientUnits="userSpaceOnUse" ' . $gradientDirectionSvg . '>'; |
|
| 3924 | + $returner = '<?xml version="1.0" ?>'. |
|
| 3925 | + '<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="100%" height="100%" viewBox="0 0 1 1" preserveAspectRatio="none">'. |
|
| 3926 | + '<'.$gradientType.'Gradient id="gradient" gradientUnits="userSpaceOnUse" '.$gradientDirectionSvg.'>'; |
|
| 3927 | 3927 | |
| 3928 | - for( $i = 0; $i < count($stops); $i++ ){ |
|
| 3929 | - if( is_object($stops[$i]) && property_exists($stops[$i],'value') ){ |
|
| 3928 | + for ($i = 0; $i<count($stops); $i++) { |
|
| 3929 | + if (is_object($stops[$i]) && property_exists($stops[$i], 'value')) { |
|
| 3930 | 3930 | $color = $stops[$i]->value[0]; |
| 3931 | 3931 | $position = $stops[$i]->value[1]; |
| 3932 | - }else{ |
|
| 3932 | + }else { |
|
| 3933 | 3933 | $color = $stops[$i]; |
| 3934 | 3934 | $position = null; |
| 3935 | 3935 | } |
| 3936 | 3936 | |
| 3937 | - if( !($color instanceof Less_Tree_Color) || (!(($i === 0 || $i+1 === count($stops)) && $position === null) && !($position instanceof Less_Tree_Dimension)) ){ |
|
| 3938 | - throw new Less_Exception_Compiler( $throw_message ); |
|
| 3937 | + if (!($color instanceof Less_Tree_Color) || (!(($i===0 || $i+1===count($stops)) && $position===null) && !($position instanceof Less_Tree_Dimension))) { |
|
| 3938 | + throw new Less_Exception_Compiler($throw_message); |
|
| 3939 | 3939 | } |
| 3940 | - if( $position ){ |
|
| 3940 | + if ($position) { |
|
| 3941 | 3941 | $positionValue = $position->toCSS(); |
| 3942 | - }elseif( $i === 0 ){ |
|
| 3942 | + }elseif ($i===0) { |
|
| 3943 | 3943 | $positionValue = '0%'; |
| 3944 | - }else{ |
|
| 3944 | + }else { |
|
| 3945 | 3945 | $positionValue = '100%'; |
| 3946 | 3946 | } |
| 3947 | 3947 | $alpha = $color->alpha; |
| 3948 | - $returner .= '<stop offset="' . $positionValue . '" stop-color="' . $color->toRGB() . '"' . ($alpha < 1 ? ' stop-opacity="' . $alpha . '"' : '') . '/>'; |
|
| 3948 | + $returner .= '<stop offset="'.$positionValue.'" stop-color="'.$color->toRGB().'"'.($alpha<1 ? ' stop-opacity="'.$alpha.'"' : '').'/>'; |
|
| 3949 | 3949 | } |
| 3950 | 3950 | |
| 3951 | - $returner .= '</' . $gradientType . 'Gradient><rect ' . $rectangleDimension . ' fill="url(#gradient)" /></svg>'; |
|
| 3951 | + $returner .= '</'.$gradientType.'Gradient><rect '.$rectangleDimension.' fill="url(#gradient)" /></svg>'; |
|
| 3952 | 3952 | |
| 3953 | 3953 | |
| 3954 | - if( $useBase64 ){ |
|
| 3954 | + if ($useBase64) { |
|
| 3955 | 3955 | $returner = "'data:image/svg+xml;base64,".base64_encode($returner)."'"; |
| 3956 | - }else{ |
|
| 3956 | + }else { |
|
| 3957 | 3957 | $returner = "'data:image/svg+xml,".$returner."'"; |
| 3958 | 3958 | } |
| 3959 | 3959 | |
| 3960 | - return new Less_Tree_URL( new Less_Tree_Anonymous( $returner ) ); |
|
| 3960 | + return new Less_Tree_URL(new Less_Tree_Anonymous($returner)); |
|
| 3961 | 3961 | } |
| 3962 | 3962 | |
| 3963 | 3963 | |
@@ -3967,7 +3967,7 @@ discard block |
||
| 3967 | 3967 | * @param string $string The string to encode |
| 3968 | 3968 | * @return string The encoded string |
| 3969 | 3969 | */ |
| 3970 | - public static function encodeURIComponent($string){ |
|
| 3970 | + public static function encodeURIComponent($string) { |
|
| 3971 | 3971 | $revert = array('%21' => '!', '%2A' => '*', '%27' => "'", '%28' => '(', '%29' => ')'); |
| 3972 | 3972 | return strtr(rawurlencode($string), $revert); |
| 3973 | 3973 | } |
@@ -3976,18 +3976,18 @@ discard block |
||
| 3976 | 3976 | // Color Blending |
| 3977 | 3977 | // ref: http://www.w3.org/TR/compositing-1 |
| 3978 | 3978 | |
| 3979 | - public function colorBlend( $mode, $color1, $color2 ){ |
|
| 3980 | - $ab = $color1->alpha; // backdrop |
|
| 3981 | - $as = $color2->alpha; // source |
|
| 3982 | - $r = array(); // result |
|
| 3979 | + public function colorBlend($mode, $color1, $color2) { |
|
| 3980 | + $ab = $color1->alpha; // backdrop |
|
| 3981 | + $as = $color2->alpha; // source |
|
| 3982 | + $r = array(); // result |
|
| 3983 | 3983 | |
| 3984 | - $ar = $as + $ab * (1 - $as); |
|
| 3985 | - for( $i = 0; $i < 3; $i++ ){ |
|
| 3984 | + $ar = $as+$ab * (1-$as); |
|
| 3985 | + for ($i = 0; $i<3; $i++) { |
|
| 3986 | 3986 | $cb = $color1->rgb[$i] / 255; |
| 3987 | 3987 | $cs = $color2->rgb[$i] / 255; |
| 3988 | - $cr = call_user_func( $mode, $cb, $cs ); |
|
| 3989 | - if( $ar ){ |
|
| 3990 | - $cr = ($as * $cs + $ab * ($cb - $as * ($cb + $cs - $cr))) / $ar; |
|
| 3988 | + $cr = call_user_func($mode, $cb, $cs); |
|
| 3989 | + if ($ar) { |
|
| 3990 | + $cr = ($as * $cs+$ab * ($cb-$as * ($cb+$cs-$cr))) / $ar; |
|
| 3991 | 3991 | } |
| 3992 | 3992 | $r[$i] = $cr * 255; |
| 3993 | 3993 | } |
@@ -3995,150 +3995,150 @@ discard block |
||
| 3995 | 3995 | return new Less_Tree_Color($r, $ar); |
| 3996 | 3996 | } |
| 3997 | 3997 | |
| 3998 | - public function multiply($color1 = null, $color2 = null ){ |
|
| 3998 | + public function multiply($color1 = null, $color2 = null) { |
|
| 3999 | 3999 | if (!$color1 instanceof Less_Tree_Color) { |
| 4000 | - throw new Less_Exception_Compiler('The first argument to multiply must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 4000 | + throw new Less_Exception_Compiler('The first argument to multiply must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 4001 | 4001 | } |
| 4002 | 4002 | if (!$color2 instanceof Less_Tree_Color) { |
| 4003 | - throw new Less_Exception_Compiler('The second argument to multiply must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 4003 | + throw new Less_Exception_Compiler('The second argument to multiply must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 4004 | 4004 | } |
| 4005 | 4005 | |
| 4006 | - return $this->colorBlend( array($this,'colorBlendMultiply'), $color1, $color2 ); |
|
| 4006 | + return $this->colorBlend(array($this, 'colorBlendMultiply'), $color1, $color2); |
|
| 4007 | 4007 | } |
| 4008 | 4008 | |
| 4009 | - private function colorBlendMultiply($cb, $cs){ |
|
| 4009 | + private function colorBlendMultiply($cb, $cs) { |
|
| 4010 | 4010 | return $cb * $cs; |
| 4011 | 4011 | } |
| 4012 | 4012 | |
| 4013 | - public function screen($color1 = null, $color2 = null ){ |
|
| 4013 | + public function screen($color1 = null, $color2 = null) { |
|
| 4014 | 4014 | if (!$color1 instanceof Less_Tree_Color) { |
| 4015 | - throw new Less_Exception_Compiler('The first argument to screen must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 4015 | + throw new Less_Exception_Compiler('The first argument to screen must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 4016 | 4016 | } |
| 4017 | 4017 | if (!$color2 instanceof Less_Tree_Color) { |
| 4018 | - throw new Less_Exception_Compiler('The second argument to screen must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 4018 | + throw new Less_Exception_Compiler('The second argument to screen must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 4019 | 4019 | } |
| 4020 | 4020 | |
| 4021 | - return $this->colorBlend( array($this,'colorBlendScreen'), $color1, $color2 ); |
|
| 4021 | + return $this->colorBlend(array($this, 'colorBlendScreen'), $color1, $color2); |
|
| 4022 | 4022 | } |
| 4023 | 4023 | |
| 4024 | - private function colorBlendScreen( $cb, $cs){ |
|
| 4025 | - return $cb + $cs - $cb * $cs; |
|
| 4024 | + private function colorBlendScreen($cb, $cs) { |
|
| 4025 | + return $cb+$cs-$cb * $cs; |
|
| 4026 | 4026 | } |
| 4027 | 4027 | |
| 4028 | - public function overlay($color1 = null, $color2 = null){ |
|
| 4028 | + public function overlay($color1 = null, $color2 = null) { |
|
| 4029 | 4029 | if (!$color1 instanceof Less_Tree_Color) { |
| 4030 | - throw new Less_Exception_Compiler('The first argument to overlay must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 4030 | + throw new Less_Exception_Compiler('The first argument to overlay must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 4031 | 4031 | } |
| 4032 | 4032 | if (!$color2 instanceof Less_Tree_Color) { |
| 4033 | - throw new Less_Exception_Compiler('The second argument to overlay must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 4033 | + throw new Less_Exception_Compiler('The second argument to overlay must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 4034 | 4034 | } |
| 4035 | 4035 | |
| 4036 | - return $this->colorBlend( array($this,'colorBlendOverlay'), $color1, $color2 ); |
|
| 4036 | + return $this->colorBlend(array($this, 'colorBlendOverlay'), $color1, $color2); |
|
| 4037 | 4037 | } |
| 4038 | 4038 | |
| 4039 | - private function colorBlendOverlay($cb, $cs ){ |
|
| 4039 | + private function colorBlendOverlay($cb, $cs) { |
|
| 4040 | 4040 | $cb *= 2; |
| 4041 | - return ($cb <= 1) |
|
| 4041 | + return ($cb<=1) |
|
| 4042 | 4042 | ? $this->colorBlendMultiply($cb, $cs) |
| 4043 | - : $this->colorBlendScreen($cb - 1, $cs); |
|
| 4043 | + : $this->colorBlendScreen($cb-1, $cs); |
|
| 4044 | 4044 | } |
| 4045 | 4045 | |
| 4046 | - public function softlight($color1 = null, $color2 = null){ |
|
| 4046 | + public function softlight($color1 = null, $color2 = null) { |
|
| 4047 | 4047 | if (!$color1 instanceof Less_Tree_Color) { |
| 4048 | - throw new Less_Exception_Compiler('The first argument to softlight must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 4048 | + throw new Less_Exception_Compiler('The first argument to softlight must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 4049 | 4049 | } |
| 4050 | 4050 | if (!$color2 instanceof Less_Tree_Color) { |
| 4051 | - throw new Less_Exception_Compiler('The second argument to softlight must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 4051 | + throw new Less_Exception_Compiler('The second argument to softlight must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 4052 | 4052 | } |
| 4053 | 4053 | |
| 4054 | - return $this->colorBlend( array($this,'colorBlendSoftlight'), $color1, $color2 ); |
|
| 4054 | + return $this->colorBlend(array($this, 'colorBlendSoftlight'), $color1, $color2); |
|
| 4055 | 4055 | } |
| 4056 | 4056 | |
| 4057 | - private function colorBlendSoftlight($cb, $cs ){ |
|
| 4057 | + private function colorBlendSoftlight($cb, $cs) { |
|
| 4058 | 4058 | $d = 1; |
| 4059 | 4059 | $e = $cb; |
| 4060 | - if( $cs > 0.5 ){ |
|
| 4060 | + if ($cs>0.5) { |
|
| 4061 | 4061 | $e = 1; |
| 4062 | - $d = ($cb > 0.25) ? sqrt($cb) |
|
| 4063 | - : ((16 * $cb - 12) * $cb + 4) * $cb; |
|
| 4062 | + $d = ($cb>0.25) ? sqrt($cb) |
|
| 4063 | + : ((16 * $cb-12) * $cb+4) * $cb; |
|
| 4064 | 4064 | } |
| 4065 | - return $cb - (1 - 2 * $cs) * $e * ($d - $cb); |
|
| 4065 | + return $cb-(1-2 * $cs) * $e * ($d-$cb); |
|
| 4066 | 4066 | } |
| 4067 | 4067 | |
| 4068 | - public function hardlight($color1 = null, $color2 = null){ |
|
| 4068 | + public function hardlight($color1 = null, $color2 = null) { |
|
| 4069 | 4069 | if (!$color1 instanceof Less_Tree_Color) { |
| 4070 | - throw new Less_Exception_Compiler('The first argument to hardlight must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 4070 | + throw new Less_Exception_Compiler('The first argument to hardlight must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 4071 | 4071 | } |
| 4072 | 4072 | if (!$color2 instanceof Less_Tree_Color) { |
| 4073 | - throw new Less_Exception_Compiler('The second argument to hardlight must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 4073 | + throw new Less_Exception_Compiler('The second argument to hardlight must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 4074 | 4074 | } |
| 4075 | 4075 | |
| 4076 | - return $this->colorBlend( array($this,'colorBlendHardlight'), $color1, $color2 ); |
|
| 4076 | + return $this->colorBlend(array($this, 'colorBlendHardlight'), $color1, $color2); |
|
| 4077 | 4077 | } |
| 4078 | 4078 | |
| 4079 | - private function colorBlendHardlight( $cb, $cs ){ |
|
| 4079 | + private function colorBlendHardlight($cb, $cs) { |
|
| 4080 | 4080 | return $this->colorBlendOverlay($cs, $cb); |
| 4081 | 4081 | } |
| 4082 | 4082 | |
| 4083 | 4083 | public function difference($color1 = null, $color2 = null) { |
| 4084 | 4084 | if (!$color1 instanceof Less_Tree_Color) { |
| 4085 | - throw new Less_Exception_Compiler('The first argument to difference must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 4085 | + throw new Less_Exception_Compiler('The first argument to difference must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 4086 | 4086 | } |
| 4087 | 4087 | if (!$color2 instanceof Less_Tree_Color) { |
| 4088 | - throw new Less_Exception_Compiler('The second argument to difference must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 4088 | + throw new Less_Exception_Compiler('The second argument to difference must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 4089 | 4089 | } |
| 4090 | 4090 | |
| 4091 | - return $this->colorBlend( array($this,'colorBlendDifference'), $color1, $color2 ); |
|
| 4091 | + return $this->colorBlend(array($this, 'colorBlendDifference'), $color1, $color2); |
|
| 4092 | 4092 | } |
| 4093 | 4093 | |
| 4094 | - private function colorBlendDifference( $cb, $cs ){ |
|
| 4095 | - return abs($cb - $cs); |
|
| 4094 | + private function colorBlendDifference($cb, $cs) { |
|
| 4095 | + return abs($cb-$cs); |
|
| 4096 | 4096 | } |
| 4097 | 4097 | |
| 4098 | - public function exclusion( $color1 = null, $color2 = null ){ |
|
| 4098 | + public function exclusion($color1 = null, $color2 = null) { |
|
| 4099 | 4099 | if (!$color1 instanceof Less_Tree_Color) { |
| 4100 | - throw new Less_Exception_Compiler('The first argument to exclusion must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 4100 | + throw new Less_Exception_Compiler('The first argument to exclusion must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 4101 | 4101 | } |
| 4102 | 4102 | if (!$color2 instanceof Less_Tree_Color) { |
| 4103 | - throw new Less_Exception_Compiler('The second argument to exclusion must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 4103 | + throw new Less_Exception_Compiler('The second argument to exclusion must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 4104 | 4104 | } |
| 4105 | 4105 | |
| 4106 | - return $this->colorBlend( array($this,'colorBlendExclusion'), $color1, $color2 ); |
|
| 4106 | + return $this->colorBlend(array($this, 'colorBlendExclusion'), $color1, $color2); |
|
| 4107 | 4107 | } |
| 4108 | 4108 | |
| 4109 | - private function colorBlendExclusion( $cb, $cs ){ |
|
| 4110 | - return $cb + $cs - 2 * $cb * $cs; |
|
| 4109 | + private function colorBlendExclusion($cb, $cs) { |
|
| 4110 | + return $cb+$cs-2 * $cb * $cs; |
|
| 4111 | 4111 | } |
| 4112 | 4112 | |
| 4113 | - public function average($color1 = null, $color2 = null){ |
|
| 4113 | + public function average($color1 = null, $color2 = null) { |
|
| 4114 | 4114 | if (!$color1 instanceof Less_Tree_Color) { |
| 4115 | - throw new Less_Exception_Compiler('The first argument to average must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 4115 | + throw new Less_Exception_Compiler('The first argument to average must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 4116 | 4116 | } |
| 4117 | 4117 | if (!$color2 instanceof Less_Tree_Color) { |
| 4118 | - throw new Less_Exception_Compiler('The second argument to average must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 4118 | + throw new Less_Exception_Compiler('The second argument to average must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 4119 | 4119 | } |
| 4120 | 4120 | |
| 4121 | - return $this->colorBlend( array($this,'colorBlendAverage'), $color1, $color2 ); |
|
| 4121 | + return $this->colorBlend(array($this, 'colorBlendAverage'), $color1, $color2); |
|
| 4122 | 4122 | } |
| 4123 | 4123 | |
| 4124 | 4124 | // non-w3c functions: |
| 4125 | - public function colorBlendAverage($cb, $cs ){ |
|
| 4126 | - return ($cb + $cs) / 2; |
|
| 4125 | + public function colorBlendAverage($cb, $cs) { |
|
| 4126 | + return ($cb+$cs) / 2; |
|
| 4127 | 4127 | } |
| 4128 | 4128 | |
| 4129 | - public function negation($color1 = null, $color2 = null ){ |
|
| 4129 | + public function negation($color1 = null, $color2 = null) { |
|
| 4130 | 4130 | if (!$color1 instanceof Less_Tree_Color) { |
| 4131 | - throw new Less_Exception_Compiler('The first argument to negation must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 4131 | + throw new Less_Exception_Compiler('The first argument to negation must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 4132 | 4132 | } |
| 4133 | 4133 | if (!$color2 instanceof Less_Tree_Color) { |
| 4134 | - throw new Less_Exception_Compiler('The second argument to negation must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 4134 | + throw new Less_Exception_Compiler('The second argument to negation must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 4135 | 4135 | } |
| 4136 | 4136 | |
| 4137 | - return $this->colorBlend( array($this,'colorBlendNegation'), $color1, $color2 ); |
|
| 4137 | + return $this->colorBlend(array($this, 'colorBlendNegation'), $color1, $color2); |
|
| 4138 | 4138 | } |
| 4139 | 4139 | |
| 4140 | - public function colorBlendNegation($cb, $cs){ |
|
| 4141 | - return 1 - abs($cb + $cs - 1); |
|
| 4140 | + public function colorBlendNegation($cb, $cs) { |
|
| 4141 | + return 1-abs($cb+$cs-1); |
|
| 4142 | 4142 | } |
| 4143 | 4143 | |
| 4144 | 4144 | // ~ End of Color Blending |
@@ -4152,7 +4152,7 @@ discard block |
||
| 4152 | 4152 | * @package Less |
| 4153 | 4153 | * @subpackage node |
| 4154 | 4154 | */ |
| 4155 | -class Less_Mime{ |
|
| 4155 | +class Less_Mime { |
|
| 4156 | 4156 | |
| 4157 | 4157 | // this map is intentionally incomplete |
| 4158 | 4158 | // if you want more, install 'mime' dep |
@@ -4170,19 +4170,19 @@ discard block |
||
| 4170 | 4170 | '.svg' => 'image/svg+xml', |
| 4171 | 4171 | ); |
| 4172 | 4172 | |
| 4173 | - public static function lookup( $filepath ){ |
|
| 4174 | - $parts = explode('.',$filepath); |
|
| 4173 | + public static function lookup($filepath) { |
|
| 4174 | + $parts = explode('.', $filepath); |
|
| 4175 | 4175 | $ext = '.'.strtolower(array_pop($parts)); |
| 4176 | 4176 | |
| 4177 | - if( !isset(self::$_types[$ext]) ){ |
|
| 4177 | + if (!isset(self::$_types[$ext])) { |
|
| 4178 | 4178 | return null; |
| 4179 | 4179 | } |
| 4180 | 4180 | return self::$_types[$ext]; |
| 4181 | 4181 | } |
| 4182 | 4182 | |
| 4183 | - public static function charsets_lookup( $type = null ){ |
|
| 4183 | + public static function charsets_lookup($type = null) { |
|
| 4184 | 4184 | // assumes all text types are UTF-8 |
| 4185 | - return $type && preg_match('/^text\//',$type) ? 'UTF-8' : ''; |
|
| 4185 | + return $type && preg_match('/^text\//', $type) ? 'UTF-8' : ''; |
|
| 4186 | 4186 | } |
| 4187 | 4187 | } |
| 4188 | 4188 | |
@@ -4193,11 +4193,11 @@ discard block |
||
| 4193 | 4193 | * @package Less |
| 4194 | 4194 | * @subpackage tree |
| 4195 | 4195 | */ |
| 4196 | -class Less_Tree{ |
|
| 4196 | +class Less_Tree { |
|
| 4197 | 4197 | |
| 4198 | 4198 | public $cache_string; |
| 4199 | 4199 | |
| 4200 | - public function toCSS(){ |
|
| 4200 | + public function toCSS() { |
|
| 4201 | 4201 | $output = new Less_Output(); |
| 4202 | 4202 | $this->genCSS($output); |
| 4203 | 4203 | return $output->toString(); |
@@ -4210,51 +4210,51 @@ discard block |
||
| 4210 | 4210 | * @param Less_Output $output The output |
| 4211 | 4211 | * @return void |
| 4212 | 4212 | */ |
| 4213 | - public function genCSS($output){} |
|
| 4213 | + public function genCSS($output) {} |
|
| 4214 | 4214 | |
| 4215 | 4215 | |
| 4216 | 4216 | /** |
| 4217 | 4217 | * @param Less_Tree_Ruleset[] $rules |
| 4218 | 4218 | */ |
| 4219 | - public static function outputRuleset( $output, $rules ){ |
|
| 4219 | + public static function outputRuleset($output, $rules) { |
|
| 4220 | 4220 | |
| 4221 | 4221 | $ruleCnt = count($rules); |
| 4222 | 4222 | Less_Environment::$tabLevel++; |
| 4223 | 4223 | |
| 4224 | 4224 | |
| 4225 | 4225 | // Compressed |
| 4226 | - if( Less_Parser::$options['compress'] ){ |
|
| 4226 | + if (Less_Parser::$options['compress']) { |
|
| 4227 | 4227 | $output->add('{'); |
| 4228 | - for( $i = 0; $i < $ruleCnt; $i++ ){ |
|
| 4229 | - $rules[$i]->genCSS( $output ); |
|
| 4228 | + for ($i = 0; $i<$ruleCnt; $i++) { |
|
| 4229 | + $rules[$i]->genCSS($output); |
|
| 4230 | 4230 | } |
| 4231 | 4231 | |
| 4232 | - $output->add( '}' ); |
|
| 4232 | + $output->add('}'); |
|
| 4233 | 4233 | Less_Environment::$tabLevel--; |
| 4234 | 4234 | return; |
| 4235 | 4235 | } |
| 4236 | 4236 | |
| 4237 | 4237 | |
| 4238 | 4238 | // Non-compressed |
| 4239 | - $tabSetStr = "\n".str_repeat( ' ' , Less_Environment::$tabLevel-1 ); |
|
| 4239 | + $tabSetStr = "\n".str_repeat(' ', Less_Environment::$tabLevel-1); |
|
| 4240 | 4240 | $tabRuleStr = $tabSetStr.' '; |
| 4241 | 4241 | |
| 4242 | - $output->add( " {" ); |
|
| 4243 | - for($i = 0; $i < $ruleCnt; $i++ ){ |
|
| 4244 | - $output->add( $tabRuleStr ); |
|
| 4245 | - $rules[$i]->genCSS( $output ); |
|
| 4242 | + $output->add(" {"); |
|
| 4243 | + for ($i = 0; $i<$ruleCnt; $i++) { |
|
| 4244 | + $output->add($tabRuleStr); |
|
| 4245 | + $rules[$i]->genCSS($output); |
|
| 4246 | 4246 | } |
| 4247 | 4247 | Less_Environment::$tabLevel--; |
| 4248 | - $output->add( $tabSetStr.'}' ); |
|
| 4248 | + $output->add($tabSetStr.'}'); |
|
| 4249 | 4249 | |
| 4250 | 4250 | } |
| 4251 | 4251 | |
| 4252 | - public function accept($visitor){} |
|
| 4252 | + public function accept($visitor) {} |
|
| 4253 | 4253 | |
| 4254 | 4254 | |
| 4255 | - public static function ReferencedArray($rules){ |
|
| 4256 | - foreach($rules as $rule){ |
|
| 4257 | - if( method_exists($rule, 'markReferenced') ){ |
|
| 4255 | + public static function ReferencedArray($rules) { |
|
| 4256 | + foreach ($rules as $rule) { |
|
| 4257 | + if (method_exists($rule, 'markReferenced')) { |
|
| 4258 | 4258 | $rule->markReferenced(); |
| 4259 | 4259 | } |
| 4260 | 4260 | } |
@@ -4264,11 +4264,11 @@ discard block |
||
| 4264 | 4264 | /** |
| 4265 | 4265 | * Requires php 5.3+ |
| 4266 | 4266 | */ |
| 4267 | - public static function __set_state($args){ |
|
| 4267 | + public static function __set_state($args) { |
|
| 4268 | 4268 | |
| 4269 | 4269 | $class = get_called_class(); |
| 4270 | - $obj = new $class(null,null,null,null); |
|
| 4271 | - foreach($args as $key => $val){ |
|
| 4270 | + $obj = new $class(null, null, null, null); |
|
| 4271 | + foreach ($args as $key => $val) { |
|
| 4272 | 4272 | $obj->$key = $val; |
| 4273 | 4273 | } |
| 4274 | 4274 | return $obj; |
@@ -4282,7 +4282,7 @@ discard block |
||
| 4282 | 4282 | * @package Less |
| 4283 | 4283 | * @subpackage output |
| 4284 | 4284 | */ |
| 4285 | -class Less_Output{ |
|
| 4285 | +class Less_Output { |
|
| 4286 | 4286 | |
| 4287 | 4287 | /** |
| 4288 | 4288 | * Output holder |
@@ -4299,7 +4299,7 @@ discard block |
||
| 4299 | 4299 | * @param integer $index The index |
| 4300 | 4300 | * @param mixed $mapLines |
| 4301 | 4301 | */ |
| 4302 | - public function add($chunk, $fileInfo = null, $index = 0, $mapLines = null){ |
|
| 4302 | + public function add($chunk, $fileInfo = null, $index = 0, $mapLines = null) { |
|
| 4303 | 4303 | $this->strs[] = $chunk; |
| 4304 | 4304 | } |
| 4305 | 4305 | |
@@ -4308,8 +4308,8 @@ discard block |
||
| 4308 | 4308 | * |
| 4309 | 4309 | * @return boolean |
| 4310 | 4310 | */ |
| 4311 | - public function isEmpty(){ |
|
| 4312 | - return count($this->strs) === 0; |
|
| 4311 | + public function isEmpty() { |
|
| 4312 | + return count($this->strs)===0; |
|
| 4313 | 4313 | } |
| 4314 | 4314 | |
| 4315 | 4315 | |
@@ -4318,8 +4318,8 @@ discard block |
||
| 4318 | 4318 | * |
| 4319 | 4319 | * @return string |
| 4320 | 4320 | */ |
| 4321 | - public function toString(){ |
|
| 4322 | - return implode('',$this->strs); |
|
| 4321 | + public function toString() { |
|
| 4322 | + return implode('', $this->strs); |
|
| 4323 | 4323 | } |
| 4324 | 4324 | |
| 4325 | 4325 | } |
@@ -4330,43 +4330,43 @@ discard block |
||
| 4330 | 4330 | * @package Less |
| 4331 | 4331 | * @subpackage visitor |
| 4332 | 4332 | */ |
| 4333 | -class Less_Visitor{ |
|
| 4333 | +class Less_Visitor { |
|
| 4334 | 4334 | |
| 4335 | 4335 | protected $methods = array(); |
| 4336 | 4336 | protected $_visitFnCache = array(); |
| 4337 | 4337 | |
| 4338 | - public function __construct(){ |
|
| 4338 | + public function __construct() { |
|
| 4339 | 4339 | $this->_visitFnCache = get_class_methods(get_class($this)); |
| 4340 | 4340 | $this->_visitFnCache = array_flip($this->_visitFnCache); |
| 4341 | 4341 | } |
| 4342 | 4342 | |
| 4343 | - public function visitObj( $node ){ |
|
| 4343 | + public function visitObj($node) { |
|
| 4344 | 4344 | |
| 4345 | 4345 | $funcName = 'visit'.$node->type; |
| 4346 | - if( isset($this->_visitFnCache[$funcName]) ){ |
|
| 4346 | + if (isset($this->_visitFnCache[$funcName])) { |
|
| 4347 | 4347 | |
| 4348 | 4348 | $visitDeeper = true; |
| 4349 | - $this->$funcName( $node, $visitDeeper ); |
|
| 4349 | + $this->$funcName($node, $visitDeeper); |
|
| 4350 | 4350 | |
| 4351 | - if( $visitDeeper ){ |
|
| 4351 | + if ($visitDeeper) { |
|
| 4352 | 4352 | $node->accept($this); |
| 4353 | 4353 | } |
| 4354 | 4354 | |
| 4355 | - $funcName = $funcName . "Out"; |
|
| 4356 | - if( isset($this->_visitFnCache[$funcName]) ){ |
|
| 4357 | - $this->$funcName( $node ); |
|
| 4355 | + $funcName = $funcName."Out"; |
|
| 4356 | + if (isset($this->_visitFnCache[$funcName])) { |
|
| 4357 | + $this->$funcName($node); |
|
| 4358 | 4358 | } |
| 4359 | 4359 | |
| 4360 | - }else{ |
|
| 4360 | + }else { |
|
| 4361 | 4361 | $node->accept($this); |
| 4362 | 4362 | } |
| 4363 | 4363 | |
| 4364 | 4364 | return $node; |
| 4365 | 4365 | } |
| 4366 | 4366 | |
| 4367 | - public function visitArray( $nodes ){ |
|
| 4367 | + public function visitArray($nodes) { |
|
| 4368 | 4368 | |
| 4369 | - array_map( array($this,'visitObj'), $nodes); |
|
| 4369 | + array_map(array($this, 'visitObj'), $nodes); |
|
| 4370 | 4370 | return $nodes; |
| 4371 | 4371 | } |
| 4372 | 4372 | } |
@@ -4379,43 +4379,43 @@ discard block |
||
| 4379 | 4379 | * @package Less |
| 4380 | 4380 | * @subpackage visitor |
| 4381 | 4381 | */ |
| 4382 | -class Less_VisitorReplacing extends Less_Visitor{ |
|
| 4382 | +class Less_VisitorReplacing extends Less_Visitor { |
|
| 4383 | 4383 | |
| 4384 | - public function visitObj( $node ){ |
|
| 4384 | + public function visitObj($node) { |
|
| 4385 | 4385 | |
| 4386 | 4386 | $funcName = 'visit'.$node->type; |
| 4387 | - if( isset($this->_visitFnCache[$funcName]) ){ |
|
| 4387 | + if (isset($this->_visitFnCache[$funcName])) { |
|
| 4388 | 4388 | |
| 4389 | 4389 | $visitDeeper = true; |
| 4390 | - $node = $this->$funcName( $node, $visitDeeper ); |
|
| 4390 | + $node = $this->$funcName($node, $visitDeeper); |
|
| 4391 | 4391 | |
| 4392 | - if( $node ){ |
|
| 4393 | - if( $visitDeeper && is_object($node) ){ |
|
| 4392 | + if ($node) { |
|
| 4393 | + if ($visitDeeper && is_object($node)) { |
|
| 4394 | 4394 | $node->accept($this); |
| 4395 | 4395 | } |
| 4396 | 4396 | |
| 4397 | - $funcName = $funcName . "Out"; |
|
| 4398 | - if( isset($this->_visitFnCache[$funcName]) ){ |
|
| 4399 | - $this->$funcName( $node ); |
|
| 4397 | + $funcName = $funcName."Out"; |
|
| 4398 | + if (isset($this->_visitFnCache[$funcName])) { |
|
| 4399 | + $this->$funcName($node); |
|
| 4400 | 4400 | } |
| 4401 | 4401 | } |
| 4402 | 4402 | |
| 4403 | - }else{ |
|
| 4403 | + }else { |
|
| 4404 | 4404 | $node->accept($this); |
| 4405 | 4405 | } |
| 4406 | 4406 | |
| 4407 | 4407 | return $node; |
| 4408 | 4408 | } |
| 4409 | 4409 | |
| 4410 | - public function visitArray( $nodes ){ |
|
| 4410 | + public function visitArray($nodes) { |
|
| 4411 | 4411 | |
| 4412 | 4412 | $newNodes = array(); |
| 4413 | - foreach($nodes as $node){ |
|
| 4413 | + foreach ($nodes as $node) { |
|
| 4414 | 4414 | $evald = $this->visitObj($node); |
| 4415 | - if( $evald ){ |
|
| 4416 | - if( is_array($evald) ){ |
|
| 4417 | - self::flatten($evald,$newNodes); |
|
| 4418 | - }else{ |
|
| 4415 | + if ($evald) { |
|
| 4416 | + if (is_array($evald)) { |
|
| 4417 | + self::flatten($evald, $newNodes); |
|
| 4418 | + }else { |
|
| 4419 | 4419 | $newNodes[] = $evald; |
| 4420 | 4420 | } |
| 4421 | 4421 | } |
@@ -4423,18 +4423,18 @@ discard block |
||
| 4423 | 4423 | return $newNodes; |
| 4424 | 4424 | } |
| 4425 | 4425 | |
| 4426 | - public function flatten( $arr, &$out ){ |
|
| 4426 | + public function flatten($arr, &$out) { |
|
| 4427 | 4427 | |
| 4428 | - foreach($arr as $item){ |
|
| 4429 | - if( !is_array($item) ){ |
|
| 4428 | + foreach ($arr as $item) { |
|
| 4429 | + if (!is_array($item)) { |
|
| 4430 | 4430 | $out[] = $item; |
| 4431 | 4431 | continue; |
| 4432 | 4432 | } |
| 4433 | 4433 | |
| 4434 | - foreach($item as $nestedItem){ |
|
| 4435 | - if( is_array($nestedItem) ){ |
|
| 4436 | - self::flatten( $nestedItem, $out); |
|
| 4437 | - }else{ |
|
| 4434 | + foreach ($item as $nestedItem) { |
|
| 4435 | + if (is_array($nestedItem)) { |
|
| 4436 | + self::flatten($nestedItem, $out); |
|
| 4437 | + }else { |
|
| 4438 | 4438 | $out[] = $nestedItem; |
| 4439 | 4439 | } |
| 4440 | 4440 | } |
@@ -4481,8 +4481,8 @@ discard block |
||
| 4481 | 4481 | * @param array|object $options |
| 4482 | 4482 | * |
| 4483 | 4483 | */ |
| 4484 | - public function setOptions($options){ |
|
| 4485 | - $options = array_intersect_key($options,$this->defaultOptions); |
|
| 4484 | + public function setOptions($options) { |
|
| 4485 | + $options = array_intersect_key($options, $this->defaultOptions); |
|
| 4486 | 4486 | $this->options = array_merge($this->defaultOptions, $this->options, $options); |
| 4487 | 4487 | } |
| 4488 | 4488 | |
@@ -4496,8 +4496,8 @@ discard block |
||
| 4496 | 4496 | * @param mixed $default Default value if confiuration of $name is not present |
| 4497 | 4497 | * @return mixed |
| 4498 | 4498 | */ |
| 4499 | - public function getOption($name, $default = null){ |
|
| 4500 | - if(isset($this->options[$name])){ |
|
| 4499 | + public function getOption($name, $default = null) { |
|
| 4500 | + if (isset($this->options[$name])) { |
|
| 4501 | 4501 | return $this->options[$name]; |
| 4502 | 4502 | } |
| 4503 | 4503 | return $default; |
@@ -4510,7 +4510,7 @@ discard block |
||
| 4510 | 4510 | * @param string $name |
| 4511 | 4511 | * @param mixed $value |
| 4512 | 4512 | */ |
| 4513 | - public function setOption($name, $value){ |
|
| 4513 | + public function setOption($name, $value) { |
|
| 4514 | 4514 | $this->options[$name] = $value; |
| 4515 | 4515 | } |
| 4516 | 4516 | |
@@ -4522,11 +4522,11 @@ discard block |
||
| 4522 | 4522 | * @package Less |
| 4523 | 4523 | * @subpackage tree |
| 4524 | 4524 | */ |
| 4525 | -class Less_Tree_Alpha extends Less_Tree{ |
|
| 4525 | +class Less_Tree_Alpha extends Less_Tree { |
|
| 4526 | 4526 | public $value; |
| 4527 | 4527 | public $type = 'Alpha'; |
| 4528 | 4528 | |
| 4529 | - public function __construct($val){ |
|
| 4529 | + public function __construct($val) { |
|
| 4530 | 4530 | $this->value = $val; |
| 4531 | 4531 | } |
| 4532 | 4532 | |
@@ -4534,9 +4534,9 @@ discard block |
||
| 4534 | 4534 | // $this->value = $visitor->visit( $this->value ); |
| 4535 | 4535 | //} |
| 4536 | 4536 | |
| 4537 | - public function compile($env){ |
|
| 4537 | + public function compile($env) { |
|
| 4538 | 4538 | |
| 4539 | - if( is_object($this->value) ){ |
|
| 4539 | + if (is_object($this->value)) { |
|
| 4540 | 4540 | $this->value = $this->value->compile($env); |
| 4541 | 4541 | } |
| 4542 | 4542 | |
@@ -4546,21 +4546,21 @@ discard block |
||
| 4546 | 4546 | /** |
| 4547 | 4547 | * @see Less_Tree::genCSS |
| 4548 | 4548 | */ |
| 4549 | - public function genCSS( $output ){ |
|
| 4549 | + public function genCSS($output) { |
|
| 4550 | 4550 | |
| 4551 | - $output->add( "alpha(opacity=" ); |
|
| 4551 | + $output->add("alpha(opacity="); |
|
| 4552 | 4552 | |
| 4553 | - if( is_string($this->value) ){ |
|
| 4554 | - $output->add( $this->value ); |
|
| 4555 | - }else{ |
|
| 4556 | - $this->value->genCSS( $output); |
|
| 4553 | + if (is_string($this->value)) { |
|
| 4554 | + $output->add($this->value); |
|
| 4555 | + }else { |
|
| 4556 | + $this->value->genCSS($output); |
|
| 4557 | 4557 | } |
| 4558 | 4558 | |
| 4559 | - $output->add( ')' ); |
|
| 4559 | + $output->add(')'); |
|
| 4560 | 4560 | } |
| 4561 | 4561 | |
| 4562 | - public function toCSS(){ |
|
| 4563 | - return "alpha(opacity=" . (is_string($this->value) ? $this->value : $this->value->toCSS()) . ")"; |
|
| 4562 | + public function toCSS() { |
|
| 4563 | + return "alpha(opacity=".(is_string($this->value) ? $this->value : $this->value->toCSS()).")"; |
|
| 4564 | 4564 | } |
| 4565 | 4565 | |
| 4566 | 4566 | |
@@ -4572,7 +4572,7 @@ discard block |
||
| 4572 | 4572 | * @package Less |
| 4573 | 4573 | * @subpackage tree |
| 4574 | 4574 | */ |
| 4575 | -class Less_Tree_Anonymous extends Less_Tree{ |
|
| 4575 | +class Less_Tree_Anonymous extends Less_Tree { |
|
| 4576 | 4576 | public $value; |
| 4577 | 4577 | public $quote; |
| 4578 | 4578 | public $index; |
@@ -4584,40 +4584,40 @@ discard block |
||
| 4584 | 4584 | * @param integer $index |
| 4585 | 4585 | * @param boolean $mapLines |
| 4586 | 4586 | */ |
| 4587 | - public function __construct($value, $index = null, $currentFileInfo = null, $mapLines = null ){ |
|
| 4587 | + public function __construct($value, $index = null, $currentFileInfo = null, $mapLines = null) { |
|
| 4588 | 4588 | $this->value = $value; |
| 4589 | 4589 | $this->index = $index; |
| 4590 | 4590 | $this->mapLines = $mapLines; |
| 4591 | 4591 | $this->currentFileInfo = $currentFileInfo; |
| 4592 | 4592 | } |
| 4593 | 4593 | |
| 4594 | - public function compile(){ |
|
| 4594 | + public function compile() { |
|
| 4595 | 4595 | return new Less_Tree_Anonymous($this->value, $this->index, $this->currentFileInfo, $this->mapLines); |
| 4596 | 4596 | } |
| 4597 | 4597 | |
| 4598 | - public function compare($x){ |
|
| 4599 | - if( !is_object($x) ){ |
|
| 4598 | + public function compare($x) { |
|
| 4599 | + if (!is_object($x)) { |
|
| 4600 | 4600 | return -1; |
| 4601 | 4601 | } |
| 4602 | 4602 | |
| 4603 | 4603 | $left = $this->toCSS(); |
| 4604 | 4604 | $right = $x->toCSS(); |
| 4605 | 4605 | |
| 4606 | - if( $left === $right ){ |
|
| 4606 | + if ($left===$right) { |
|
| 4607 | 4607 | return 0; |
| 4608 | 4608 | } |
| 4609 | 4609 | |
| 4610 | - return $left < $right ? -1 : 1; |
|
| 4610 | + return $left<$right ? -1 : 1; |
|
| 4611 | 4611 | } |
| 4612 | 4612 | |
| 4613 | 4613 | /** |
| 4614 | 4614 | * @see Less_Tree::genCSS |
| 4615 | 4615 | */ |
| 4616 | - public function genCSS( $output ){ |
|
| 4617 | - $output->add( $this->value, $this->currentFileInfo, $this->index, $this->mapLines ); |
|
| 4616 | + public function genCSS($output) { |
|
| 4617 | + $output->add($this->value, $this->currentFileInfo, $this->index, $this->mapLines); |
|
| 4618 | 4618 | } |
| 4619 | 4619 | |
| 4620 | - public function toCSS(){ |
|
| 4620 | + public function toCSS() { |
|
| 4621 | 4621 | return $this->value; |
| 4622 | 4622 | } |
| 4623 | 4623 | |
@@ -4630,7 +4630,7 @@ discard block |
||
| 4630 | 4630 | * @package Less |
| 4631 | 4631 | * @subpackage tree |
| 4632 | 4632 | */ |
| 4633 | -class Less_Tree_Assignment extends Less_Tree{ |
|
| 4633 | +class Less_Tree_Assignment extends Less_Tree { |
|
| 4634 | 4634 | |
| 4635 | 4635 | public $key; |
| 4636 | 4636 | public $value; |
@@ -4641,24 +4641,24 @@ discard block |
||
| 4641 | 4641 | $this->value = $val; |
| 4642 | 4642 | } |
| 4643 | 4643 | |
| 4644 | - public function accept( $visitor ){ |
|
| 4645 | - $this->value = $visitor->visitObj( $this->value ); |
|
| 4644 | + public function accept($visitor) { |
|
| 4645 | + $this->value = $visitor->visitObj($this->value); |
|
| 4646 | 4646 | } |
| 4647 | 4647 | |
| 4648 | 4648 | public function compile($env) { |
| 4649 | - return new Less_Tree_Assignment( $this->key, $this->value->compile($env)); |
|
| 4649 | + return new Less_Tree_Assignment($this->key, $this->value->compile($env)); |
|
| 4650 | 4650 | } |
| 4651 | 4651 | |
| 4652 | 4652 | /** |
| 4653 | 4653 | * @see Less_Tree::genCSS |
| 4654 | 4654 | */ |
| 4655 | - public function genCSS( $output ){ |
|
| 4656 | - $output->add( $this->key . '=' ); |
|
| 4657 | - $this->value->genCSS( $output ); |
|
| 4655 | + public function genCSS($output) { |
|
| 4656 | + $output->add($this->key.'='); |
|
| 4657 | + $this->value->genCSS($output); |
|
| 4658 | 4658 | } |
| 4659 | 4659 | |
| 4660 | - public function toCss(){ |
|
| 4661 | - return $this->key . '=' . $this->value->toCSS(); |
|
| 4660 | + public function toCss() { |
|
| 4661 | + return $this->key.'='.$this->value->toCSS(); |
|
| 4662 | 4662 | } |
| 4663 | 4663 | } |
| 4664 | 4664 | |
@@ -4669,30 +4669,30 @@ discard block |
||
| 4669 | 4669 | * @package Less |
| 4670 | 4670 | * @subpackage tree |
| 4671 | 4671 | */ |
| 4672 | -class Less_Tree_Attribute extends Less_Tree{ |
|
| 4672 | +class Less_Tree_Attribute extends Less_Tree { |
|
| 4673 | 4673 | |
| 4674 | 4674 | public $key; |
| 4675 | 4675 | public $op; |
| 4676 | 4676 | public $value; |
| 4677 | 4677 | public $type = 'Attribute'; |
| 4678 | 4678 | |
| 4679 | - public function __construct($key, $op, $value){ |
|
| 4679 | + public function __construct($key, $op, $value) { |
|
| 4680 | 4680 | $this->key = $key; |
| 4681 | 4681 | $this->op = $op; |
| 4682 | 4682 | $this->value = $value; |
| 4683 | 4683 | } |
| 4684 | 4684 | |
| 4685 | - public function compile($env){ |
|
| 4685 | + public function compile($env) { |
|
| 4686 | 4686 | |
| 4687 | 4687 | $key_obj = is_object($this->key); |
| 4688 | 4688 | $val_obj = is_object($this->value); |
| 4689 | 4689 | |
| 4690 | - if( !$key_obj && !$val_obj ){ |
|
| 4690 | + if (!$key_obj && !$val_obj) { |
|
| 4691 | 4691 | return $this; |
| 4692 | 4692 | } |
| 4693 | 4693 | |
| 4694 | 4694 | return new Less_Tree_Attribute( |
| 4695 | - $key_obj ? $this->key->compile($env) : $this->key , |
|
| 4695 | + $key_obj ? $this->key->compile($env) : $this->key, |
|
| 4696 | 4696 | $this->op, |
| 4697 | 4697 | $val_obj ? $this->value->compile($env) : $this->value); |
| 4698 | 4698 | } |
@@ -4700,19 +4700,19 @@ discard block |
||
| 4700 | 4700 | /** |
| 4701 | 4701 | * @see Less_Tree::genCSS |
| 4702 | 4702 | */ |
| 4703 | - public function genCSS( $output ){ |
|
| 4704 | - $output->add( $this->toCSS() ); |
|
| 4703 | + public function genCSS($output) { |
|
| 4704 | + $output->add($this->toCSS()); |
|
| 4705 | 4705 | } |
| 4706 | 4706 | |
| 4707 | - public function toCSS(){ |
|
| 4707 | + public function toCSS() { |
|
| 4708 | 4708 | $value = $this->key; |
| 4709 | 4709 | |
| 4710 | - if( $this->op ){ |
|
| 4710 | + if ($this->op) { |
|
| 4711 | 4711 | $value .= $this->op; |
| 4712 | 4712 | $value .= (is_object($this->value) ? $this->value->toCSS() : $this->value); |
| 4713 | 4713 | } |
| 4714 | 4714 | |
| 4715 | - return '[' . $value . ']'; |
|
| 4715 | + return '['.$value.']'; |
|
| 4716 | 4716 | } |
| 4717 | 4717 | } |
| 4718 | 4718 | |
@@ -4723,7 +4723,7 @@ discard block |
||
| 4723 | 4723 | * @package Less |
| 4724 | 4724 | * @subpackage tree |
| 4725 | 4725 | */ |
| 4726 | -class Less_Tree_Call extends Less_Tree{ |
|
| 4726 | +class Less_Tree_Call extends Less_Tree { |
|
| 4727 | 4727 | public $value; |
| 4728 | 4728 | |
| 4729 | 4729 | protected $name; |
@@ -4732,15 +4732,15 @@ discard block |
||
| 4732 | 4732 | protected $currentFileInfo; |
| 4733 | 4733 | public $type = 'Call'; |
| 4734 | 4734 | |
| 4735 | - public function __construct($name, $args, $index, $currentFileInfo = null ){ |
|
| 4735 | + public function __construct($name, $args, $index, $currentFileInfo = null) { |
|
| 4736 | 4736 | $this->name = $name; |
| 4737 | 4737 | $this->args = $args; |
| 4738 | 4738 | $this->index = $index; |
| 4739 | 4739 | $this->currentFileInfo = $currentFileInfo; |
| 4740 | 4740 | } |
| 4741 | 4741 | |
| 4742 | - public function accept( $visitor ){ |
|
| 4743 | - $this->args = $visitor->visitArray( $this->args ); |
|
| 4742 | + public function accept($visitor) { |
|
| 4743 | + $this->args = $visitor->visitArray($this->args); |
|
| 4744 | 4744 | } |
| 4745 | 4745 | |
| 4746 | 4746 | // |
@@ -4755,14 +4755,14 @@ discard block |
||
| 4755 | 4755 | // we try to pass a variable to a function, like: `saturate(@color)`. |
| 4756 | 4756 | // The function should receive the value, not the variable. |
| 4757 | 4757 | // |
| 4758 | - public function compile($env=null){ |
|
| 4758 | + public function compile($env = null) { |
|
| 4759 | 4759 | $args = array(); |
| 4760 | - foreach($this->args as $a){ |
|
| 4760 | + foreach ($this->args as $a) { |
|
| 4761 | 4761 | $args[] = $a->compile($env); |
| 4762 | 4762 | } |
| 4763 | 4763 | |
| 4764 | 4764 | $nameLC = strtolower($this->name); |
| 4765 | - switch($nameLC){ |
|
| 4765 | + switch ($nameLC) { |
|
| 4766 | 4766 | case '%': |
| 4767 | 4767 | $nameLC = '_percent'; |
| 4768 | 4768 | break; |
@@ -4781,52 +4781,52 @@ discard block |
||
| 4781 | 4781 | } |
| 4782 | 4782 | |
| 4783 | 4783 | $result = null; |
| 4784 | - if( $nameLC === 'default' ){ |
|
| 4784 | + if ($nameLC==='default') { |
|
| 4785 | 4785 | $result = Less_Tree_DefaultFunc::compile(); |
| 4786 | 4786 | |
| 4787 | - }else{ |
|
| 4787 | + }else { |
|
| 4788 | 4788 | |
| 4789 | - if( method_exists('Less_Functions',$nameLC) ){ // 1. |
|
| 4789 | + if (method_exists('Less_Functions', $nameLC)) { // 1. |
|
| 4790 | 4790 | try { |
| 4791 | 4791 | |
| 4792 | 4792 | $func = new Less_Functions($env, $this->currentFileInfo); |
| 4793 | - $result = call_user_func_array( array($func,$nameLC),$args); |
|
| 4793 | + $result = call_user_func_array(array($func, $nameLC), $args); |
|
| 4794 | 4794 | |
| 4795 | 4795 | } catch (Exception $e) { |
| 4796 | - throw new Less_Exception_Compiler('error evaluating function `' . $this->name . '` '.$e->getMessage().' index: '. $this->index); |
|
| 4796 | + throw new Less_Exception_Compiler('error evaluating function `'.$this->name.'` '.$e->getMessage().' index: '.$this->index); |
|
| 4797 | 4797 | } |
| 4798 | - } elseif( isset( $env->functions[$nameLC] ) && is_callable( $env->functions[$nameLC] ) ) { |
|
| 4798 | + } elseif (isset($env->functions[$nameLC]) && is_callable($env->functions[$nameLC])) { |
|
| 4799 | 4799 | try { |
| 4800 | - $result = call_user_func_array( $env->functions[$nameLC], $args ); |
|
| 4800 | + $result = call_user_func_array($env->functions[$nameLC], $args); |
|
| 4801 | 4801 | } catch (Exception $e) { |
| 4802 | - throw new Less_Exception_Compiler('error evaluating function `' . $this->name . '` '.$e->getMessage().' index: '. $this->index); |
|
| 4802 | + throw new Less_Exception_Compiler('error evaluating function `'.$this->name.'` '.$e->getMessage().' index: '.$this->index); |
|
| 4803 | 4803 | } |
| 4804 | 4804 | } |
| 4805 | 4805 | } |
| 4806 | 4806 | |
| 4807 | - if( $result !== null ){ |
|
| 4807 | + if ($result!==null) { |
|
| 4808 | 4808 | return $result; |
| 4809 | 4809 | } |
| 4810 | 4810 | |
| 4811 | 4811 | |
| 4812 | - return new Less_Tree_Call( $this->name, $args, $this->index, $this->currentFileInfo ); |
|
| 4812 | + return new Less_Tree_Call($this->name, $args, $this->index, $this->currentFileInfo); |
|
| 4813 | 4813 | } |
| 4814 | 4814 | |
| 4815 | 4815 | /** |
| 4816 | 4816 | * @see Less_Tree::genCSS |
| 4817 | 4817 | */ |
| 4818 | - public function genCSS( $output ){ |
|
| 4818 | + public function genCSS($output) { |
|
| 4819 | 4819 | |
| 4820 | - $output->add( $this->name . '(', $this->currentFileInfo, $this->index ); |
|
| 4820 | + $output->add($this->name.'(', $this->currentFileInfo, $this->index); |
|
| 4821 | 4821 | $args_len = count($this->args); |
| 4822 | - for($i = 0; $i < $args_len; $i++ ){ |
|
| 4823 | - $this->args[$i]->genCSS( $output ); |
|
| 4824 | - if( $i + 1 < $args_len ){ |
|
| 4825 | - $output->add( ', ' ); |
|
| 4822 | + for ($i = 0; $i<$args_len; $i++) { |
|
| 4823 | + $this->args[$i]->genCSS($output); |
|
| 4824 | + if ($i+1<$args_len) { |
|
| 4825 | + $output->add(', '); |
|
| 4826 | 4826 | } |
| 4827 | 4827 | } |
| 4828 | 4828 | |
| 4829 | - $output->add( ')' ); |
|
| 4829 | + $output->add(')'); |
|
| 4830 | 4830 | } |
| 4831 | 4831 | |
| 4832 | 4832 | |
@@ -4843,15 +4843,15 @@ discard block |
||
| 4843 | 4843 | * @package Less |
| 4844 | 4844 | * @subpackage tree |
| 4845 | 4845 | */ |
| 4846 | -class Less_Tree_Color extends Less_Tree{ |
|
| 4846 | +class Less_Tree_Color extends Less_Tree { |
|
| 4847 | 4847 | public $rgb; |
| 4848 | 4848 | public $alpha; |
| 4849 | 4849 | public $isTransparentKeyword; |
| 4850 | 4850 | public $type = 'Color'; |
| 4851 | 4851 | |
| 4852 | - public function __construct($rgb, $a = 1, $isTransparentKeyword = null ){ |
|
| 4852 | + public function __construct($rgb, $a = 1, $isTransparentKeyword = null) { |
|
| 4853 | 4853 | |
| 4854 | - if( $isTransparentKeyword ){ |
|
| 4854 | + if ($isTransparentKeyword) { |
|
| 4855 | 4855 | $this->rgb = $rgb; |
| 4856 | 4856 | $this->alpha = $a; |
| 4857 | 4857 | $this->isTransparentKeyword = true; |
@@ -4859,46 +4859,46 @@ discard block |
||
| 4859 | 4859 | } |
| 4860 | 4860 | |
| 4861 | 4861 | $this->rgb = array(); |
| 4862 | - if( is_array($rgb) ){ |
|
| 4862 | + if (is_array($rgb)) { |
|
| 4863 | 4863 | $this->rgb = $rgb; |
| 4864 | - }else if( strlen($rgb) == 6 ){ |
|
| 4865 | - foreach(str_split($rgb, 2) as $c){ |
|
| 4864 | + }else if (strlen($rgb)==6) { |
|
| 4865 | + foreach (str_split($rgb, 2) as $c) { |
|
| 4866 | 4866 | $this->rgb[] = hexdec($c); |
| 4867 | 4867 | } |
| 4868 | - }else{ |
|
| 4869 | - foreach(str_split($rgb, 1) as $c){ |
|
| 4868 | + }else { |
|
| 4869 | + foreach (str_split($rgb, 1) as $c) { |
|
| 4870 | 4870 | $this->rgb[] = hexdec($c.$c); |
| 4871 | 4871 | } |
| 4872 | 4872 | } |
| 4873 | 4873 | $this->alpha = is_numeric($a) ? $a : 1; |
| 4874 | 4874 | } |
| 4875 | 4875 | |
| 4876 | - public function compile(){ |
|
| 4876 | + public function compile() { |
|
| 4877 | 4877 | return $this; |
| 4878 | 4878 | } |
| 4879 | 4879 | |
| 4880 | - public function luma(){ |
|
| 4880 | + public function luma() { |
|
| 4881 | 4881 | $r = $this->rgb[0] / 255; |
| 4882 | 4882 | $g = $this->rgb[1] / 255; |
| 4883 | 4883 | $b = $this->rgb[2] / 255; |
| 4884 | 4884 | |
| 4885 | - $r = ($r <= 0.03928) ? $r / 12.92 : pow((($r + 0.055) / 1.055), 2.4); |
|
| 4886 | - $g = ($g <= 0.03928) ? $g / 12.92 : pow((($g + 0.055) / 1.055), 2.4); |
|
| 4887 | - $b = ($b <= 0.03928) ? $b / 12.92 : pow((($b + 0.055) / 1.055), 2.4); |
|
| 4885 | + $r = ($r<=0.03928) ? $r / 12.92 : pow((($r+0.055) / 1.055), 2.4); |
|
| 4886 | + $g = ($g<=0.03928) ? $g / 12.92 : pow((($g+0.055) / 1.055), 2.4); |
|
| 4887 | + $b = ($b<=0.03928) ? $b / 12.92 : pow((($b+0.055) / 1.055), 2.4); |
|
| 4888 | 4888 | |
| 4889 | - return 0.2126 * $r + 0.7152 * $g + 0.0722 * $b; |
|
| 4889 | + return 0.2126 * $r+0.7152 * $g+0.0722 * $b; |
|
| 4890 | 4890 | } |
| 4891 | 4891 | |
| 4892 | 4892 | /** |
| 4893 | 4893 | * @see Less_Tree::genCSS |
| 4894 | 4894 | */ |
| 4895 | - public function genCSS( $output ){ |
|
| 4896 | - $output->add( $this->toCSS() ); |
|
| 4895 | + public function genCSS($output) { |
|
| 4896 | + $output->add($this->toCSS()); |
|
| 4897 | 4897 | } |
| 4898 | 4898 | |
| 4899 | - public function toCSS( $doNotCompress = false ){ |
|
| 4899 | + public function toCSS($doNotCompress = false) { |
|
| 4900 | 4900 | $compress = Less_Parser::$options['compress'] && !$doNotCompress; |
| 4901 | - $alpha = Less_Functions::fround( $this->alpha ); |
|
| 4901 | + $alpha = Less_Functions::fround($this->alpha); |
|
| 4902 | 4902 | |
| 4903 | 4903 | |
| 4904 | 4904 | // |
@@ -4907,28 +4907,28 @@ discard block |
||
| 4907 | 4907 | // which has better compatibility with older browsers. |
| 4908 | 4908 | // Values are capped between `0` and `255`, rounded and zero-padded. |
| 4909 | 4909 | // |
| 4910 | - if( $alpha < 1 ){ |
|
| 4911 | - if( ( $alpha === 0 || $alpha === 0.0 ) && isset($this->isTransparentKeyword) && $this->isTransparentKeyword ){ |
|
| 4910 | + if ($alpha<1) { |
|
| 4911 | + if (($alpha===0 || $alpha===0.0) && isset($this->isTransparentKeyword) && $this->isTransparentKeyword) { |
|
| 4912 | 4912 | return 'transparent'; |
| 4913 | 4913 | } |
| 4914 | 4914 | |
| 4915 | 4915 | $values = array(); |
| 4916 | - foreach($this->rgb as $c){ |
|
| 4917 | - $values[] = Less_Functions::clamp( round($c), 255); |
|
| 4916 | + foreach ($this->rgb as $c) { |
|
| 4917 | + $values[] = Less_Functions::clamp(round($c), 255); |
|
| 4918 | 4918 | } |
| 4919 | 4919 | $values[] = $alpha; |
| 4920 | 4920 | |
| 4921 | 4921 | $glue = ($compress ? ',' : ', '); |
| 4922 | - return "rgba(" . implode($glue, $values) . ")"; |
|
| 4923 | - }else{ |
|
| 4922 | + return "rgba(".implode($glue, $values).")"; |
|
| 4923 | + }else { |
|
| 4924 | 4924 | |
| 4925 | 4925 | $color = $this->toRGB(); |
| 4926 | 4926 | |
| 4927 | - if( $compress ){ |
|
| 4927 | + if ($compress) { |
|
| 4928 | 4928 | |
| 4929 | 4929 | // Convert color to short format |
| 4930 | - if( $color[1] === $color[2] && $color[3] === $color[4] && $color[5] === $color[6]) { |
|
| 4931 | - $color = '#'.$color[1] . $color[3] . $color[5]; |
|
| 4930 | + if ($color[1]===$color[2] && $color[3]===$color[4] && $color[5]===$color[6]) { |
|
| 4931 | + $color = '#'.$color[1].$color[3].$color[5]; |
|
| 4932 | 4932 | } |
| 4933 | 4933 | } |
| 4934 | 4934 | |
@@ -4946,20 +4946,20 @@ discard block |
||
| 4946 | 4946 | /** |
| 4947 | 4947 | * @param string $op |
| 4948 | 4948 | */ |
| 4949 | - public function operate( $op, $other) { |
|
| 4949 | + public function operate($op, $other) { |
|
| 4950 | 4950 | $rgb = array(); |
| 4951 | - $alpha = $this->alpha * (1 - $other->alpha) + $other->alpha; |
|
| 4952 | - for ($c = 0; $c < 3; $c++) { |
|
| 4953 | - $rgb[$c] = Less_Functions::operate( $op, $this->rgb[$c], $other->rgb[$c]); |
|
| 4951 | + $alpha = $this->alpha * (1-$other->alpha)+$other->alpha; |
|
| 4952 | + for ($c = 0; $c<3; $c++) { |
|
| 4953 | + $rgb[$c] = Less_Functions::operate($op, $this->rgb[$c], $other->rgb[$c]); |
|
| 4954 | 4954 | } |
| 4955 | 4955 | return new Less_Tree_Color($rgb, $alpha); |
| 4956 | 4956 | } |
| 4957 | 4957 | |
| 4958 | - public function toRGB(){ |
|
| 4958 | + public function toRGB() { |
|
| 4959 | 4959 | return $this->toHex($this->rgb); |
| 4960 | 4960 | } |
| 4961 | 4961 | |
| 4962 | - public function toHSL(){ |
|
| 4962 | + public function toHSL() { |
|
| 4963 | 4963 | $r = $this->rgb[0] / 255; |
| 4964 | 4964 | $g = $this->rgb[1] / 255; |
| 4965 | 4965 | $b = $this->rgb[2] / 255; |
@@ -4967,21 +4967,21 @@ discard block |
||
| 4967 | 4967 | |
| 4968 | 4968 | $max = max($r, $g, $b); |
| 4969 | 4969 | $min = min($r, $g, $b); |
| 4970 | - $l = ($max + $min) / 2; |
|
| 4971 | - $d = $max - $min; |
|
| 4970 | + $l = ($max+$min) / 2; |
|
| 4971 | + $d = $max-$min; |
|
| 4972 | 4972 | |
| 4973 | 4973 | $h = $s = 0; |
| 4974 | - if( $max !== $min ){ |
|
| 4975 | - $s = $l > 0.5 ? $d / (2 - $max - $min) : $d / ($max + $min); |
|
| 4974 | + if ($max!==$min) { |
|
| 4975 | + $s = $l>0.5 ? $d / (2-$max-$min) : $d / ($max+$min); |
|
| 4976 | 4976 | |
| 4977 | 4977 | switch ($max) { |
| 4978 | - case $r: $h = ($g - $b) / $d + ($g < $b ? 6 : 0); break; |
|
| 4979 | - case $g: $h = ($b - $r) / $d + 2; break; |
|
| 4980 | - case $b: $h = ($r - $g) / $d + 4; break; |
|
| 4978 | + case $r: $h = ($g-$b) / $d+($g<$b ? 6 : 0); break; |
|
| 4979 | + case $g: $h = ($b-$r) / $d+2; break; |
|
| 4980 | + case $b: $h = ($r-$g) / $d+4; break; |
|
| 4981 | 4981 | } |
| 4982 | 4982 | $h /= 6; |
| 4983 | 4983 | } |
| 4984 | - return array('h' => $h * 360, 's' => $s, 'l' => $l, 'a' => $a ); |
|
| 4984 | + return array('h' => $h * 360, 's' => $s, 'l' => $l, 'a' => $a); |
|
| 4985 | 4985 | } |
| 4986 | 4986 | |
| 4987 | 4987 | //Adapted from http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript |
@@ -4996,49 +4996,49 @@ discard block |
||
| 4996 | 4996 | |
| 4997 | 4997 | $v = $max; |
| 4998 | 4998 | |
| 4999 | - $d = $max - $min; |
|
| 5000 | - if ($max === 0) { |
|
| 4999 | + $d = $max-$min; |
|
| 5000 | + if ($max===0) { |
|
| 5001 | 5001 | $s = 0; |
| 5002 | - } else { |
|
| 5002 | + }else { |
|
| 5003 | 5003 | $s = $d / $max; |
| 5004 | 5004 | } |
| 5005 | 5005 | |
| 5006 | 5006 | $h = 0; |
| 5007 | - if( $max !== $min ){ |
|
| 5008 | - switch($max){ |
|
| 5009 | - case $r: $h = ($g - $b) / $d + ($g < $b ? 6 : 0); break; |
|
| 5010 | - case $g: $h = ($b - $r) / $d + 2; break; |
|
| 5011 | - case $b: $h = ($r - $g) / $d + 4; break; |
|
| 5007 | + if ($max!==$min) { |
|
| 5008 | + switch ($max) { |
|
| 5009 | + case $r: $h = ($g-$b) / $d+($g<$b ? 6 : 0); break; |
|
| 5010 | + case $g: $h = ($b-$r) / $d+2; break; |
|
| 5011 | + case $b: $h = ($r-$g) / $d+4; break; |
|
| 5012 | 5012 | } |
| 5013 | 5013 | $h /= 6; |
| 5014 | 5014 | } |
| 5015 | - return array('h'=> $h * 360, 's'=> $s, 'v'=> $v, 'a' => $a ); |
|
| 5015 | + return array('h'=> $h * 360, 's'=> $s, 'v'=> $v, 'a' => $a); |
|
| 5016 | 5016 | } |
| 5017 | 5017 | |
| 5018 | - public function toARGB(){ |
|
| 5019 | - $argb = array_merge( (array) Less_Parser::round($this->alpha * 255), $this->rgb); |
|
| 5020 | - return $this->toHex( $argb ); |
|
| 5018 | + public function toARGB() { |
|
| 5019 | + $argb = array_merge((array)Less_Parser::round($this->alpha * 255), $this->rgb); |
|
| 5020 | + return $this->toHex($argb); |
|
| 5021 | 5021 | } |
| 5022 | 5022 | |
| 5023 | - public function compare($x){ |
|
| 5023 | + public function compare($x) { |
|
| 5024 | 5024 | |
| 5025 | - if( !property_exists( $x, 'rgb' ) ){ |
|
| 5025 | + if (!property_exists($x, 'rgb')) { |
|
| 5026 | 5026 | return -1; |
| 5027 | 5027 | } |
| 5028 | 5028 | |
| 5029 | 5029 | |
| 5030 | - return ($x->rgb[0] === $this->rgb[0] && |
|
| 5031 | - $x->rgb[1] === $this->rgb[1] && |
|
| 5032 | - $x->rgb[2] === $this->rgb[2] && |
|
| 5033 | - $x->alpha === $this->alpha) ? 0 : -1; |
|
| 5030 | + return ($x->rgb[0]===$this->rgb[0] && |
|
| 5031 | + $x->rgb[1]===$this->rgb[1] && |
|
| 5032 | + $x->rgb[2]===$this->rgb[2] && |
|
| 5033 | + $x->alpha===$this->alpha) ? 0 : -1; |
|
| 5034 | 5034 | } |
| 5035 | 5035 | |
| 5036 | - public function toHex( $v ){ |
|
| 5036 | + public function toHex($v) { |
|
| 5037 | 5037 | |
| 5038 | 5038 | $ret = '#'; |
| 5039 | - foreach($v as $c){ |
|
| 5040 | - $c = Less_Functions::clamp( Less_Parser::round($c), 255); |
|
| 5041 | - if( $c < 16 ){ |
|
| 5039 | + foreach ($v as $c) { |
|
| 5040 | + $c = Less_Functions::clamp(Less_Parser::round($c), 255); |
|
| 5041 | + if ($c<16) { |
|
| 5042 | 5042 | $ret .= '0'; |
| 5043 | 5043 | } |
| 5044 | 5044 | $ret .= dechex($c); |
@@ -5051,16 +5051,16 @@ discard block |
||
| 5051 | 5051 | /** |
| 5052 | 5052 | * @param string $keyword |
| 5053 | 5053 | */ |
| 5054 | - public static function fromKeyword( $keyword ){ |
|
| 5054 | + public static function fromKeyword($keyword) { |
|
| 5055 | 5055 | $keyword = strtolower($keyword); |
| 5056 | 5056 | |
| 5057 | - if( Less_Colors::hasOwnProperty($keyword) ){ |
|
| 5057 | + if (Less_Colors::hasOwnProperty($keyword)) { |
|
| 5058 | 5058 | // detect named color |
| 5059 | 5059 | return new Less_Tree_Color(substr(Less_Colors::color($keyword), 1)); |
| 5060 | 5060 | } |
| 5061 | 5061 | |
| 5062 | - if( $keyword === 'transparent' ){ |
|
| 5063 | - return new Less_Tree_Color( array(0, 0, 0), 0, true); |
|
| 5062 | + if ($keyword==='transparent') { |
|
| 5063 | + return new Less_Tree_Color(array(0, 0, 0), 0, true); |
|
| 5064 | 5064 | } |
| 5065 | 5065 | } |
| 5066 | 5066 | |
@@ -5073,7 +5073,7 @@ discard block |
||
| 5073 | 5073 | * @package Less |
| 5074 | 5074 | * @subpackage tree |
| 5075 | 5075 | */ |
| 5076 | -class Less_Tree_Comment extends Less_Tree{ |
|
| 5076 | +class Less_Tree_Comment extends Less_Tree { |
|
| 5077 | 5077 | |
| 5078 | 5078 | public $value; |
| 5079 | 5079 | public $silent; |
@@ -5081,37 +5081,37 @@ discard block |
||
| 5081 | 5081 | public $currentFileInfo; |
| 5082 | 5082 | public $type = 'Comment'; |
| 5083 | 5083 | |
| 5084 | - public function __construct($value, $silent, $index = null, $currentFileInfo = null ){ |
|
| 5084 | + public function __construct($value, $silent, $index = null, $currentFileInfo = null) { |
|
| 5085 | 5085 | $this->value = $value; |
| 5086 | - $this->silent = !! $silent; |
|
| 5086 | + $this->silent = !!$silent; |
|
| 5087 | 5087 | $this->currentFileInfo = $currentFileInfo; |
| 5088 | 5088 | } |
| 5089 | 5089 | |
| 5090 | 5090 | /** |
| 5091 | 5091 | * @see Less_Tree::genCSS |
| 5092 | 5092 | */ |
| 5093 | - public function genCSS( $output ){ |
|
| 5093 | + public function genCSS($output) { |
|
| 5094 | 5094 | //if( $this->debugInfo ){ |
| 5095 | 5095 | //$output->add( tree.debugInfo($env, $this), $this->currentFileInfo, $this->index); |
| 5096 | 5096 | //} |
| 5097 | - $output->add( trim($this->value) );//TODO shouldn't need to trim, we shouldn't grab the \n |
|
| 5097 | + $output->add(trim($this->value)); //TODO shouldn't need to trim, we shouldn't grab the \n |
|
| 5098 | 5098 | } |
| 5099 | 5099 | |
| 5100 | - public function toCSS(){ |
|
| 5100 | + public function toCSS() { |
|
| 5101 | 5101 | return Less_Parser::$options['compress'] ? '' : $this->value; |
| 5102 | 5102 | } |
| 5103 | 5103 | |
| 5104 | - public function isSilent(){ |
|
| 5105 | - $isReference = ($this->currentFileInfo && isset($this->currentFileInfo['reference']) && (!isset($this->isReferenced) || !$this->isReferenced) ); |
|
| 5104 | + public function isSilent() { |
|
| 5105 | + $isReference = ($this->currentFileInfo && isset($this->currentFileInfo['reference']) && (!isset($this->isReferenced) || !$this->isReferenced)); |
|
| 5106 | 5106 | $isCompressed = Less_Parser::$options['compress'] && !preg_match('/^\/\*!/', $this->value); |
| 5107 | 5107 | return $this->silent || $isReference || $isCompressed; |
| 5108 | 5108 | } |
| 5109 | 5109 | |
| 5110 | - public function compile(){ |
|
| 5110 | + public function compile() { |
|
| 5111 | 5111 | return $this; |
| 5112 | 5112 | } |
| 5113 | 5113 | |
| 5114 | - public function markReferenced(){ |
|
| 5114 | + public function markReferenced() { |
|
| 5115 | 5115 | $this->isReferenced = true; |
| 5116 | 5116 | } |
| 5117 | 5117 | |
@@ -5124,7 +5124,7 @@ discard block |
||
| 5124 | 5124 | * @package Less |
| 5125 | 5125 | * @subpackage tree |
| 5126 | 5126 | */ |
| 5127 | -class Less_Tree_Condition extends Less_Tree{ |
|
| 5127 | +class Less_Tree_Condition extends Less_Tree { |
|
| 5128 | 5128 | |
| 5129 | 5129 | public $op; |
| 5130 | 5130 | public $lvalue; |
@@ -5141,16 +5141,16 @@ discard block |
||
| 5141 | 5141 | $this->negate = $negate; |
| 5142 | 5142 | } |
| 5143 | 5143 | |
| 5144 | - public function accept($visitor){ |
|
| 5145 | - $this->lvalue = $visitor->visitObj( $this->lvalue ); |
|
| 5146 | - $this->rvalue = $visitor->visitObj( $this->rvalue ); |
|
| 5144 | + public function accept($visitor) { |
|
| 5145 | + $this->lvalue = $visitor->visitObj($this->lvalue); |
|
| 5146 | + $this->rvalue = $visitor->visitObj($this->rvalue); |
|
| 5147 | 5147 | } |
| 5148 | 5148 | |
| 5149 | 5149 | public function compile($env) { |
| 5150 | 5150 | $a = $this->lvalue->compile($env); |
| 5151 | 5151 | $b = $this->rvalue->compile($env); |
| 5152 | 5152 | |
| 5153 | - switch( $this->op ){ |
|
| 5153 | + switch ($this->op) { |
|
| 5154 | 5154 | case 'and': |
| 5155 | 5155 | $result = $a && $b; |
| 5156 | 5156 | break; |
@@ -5160,25 +5160,25 @@ discard block |
||
| 5160 | 5160 | break; |
| 5161 | 5161 | |
| 5162 | 5162 | default: |
| 5163 | - if( Less_Parser::is_method($a, 'compare') ){ |
|
| 5163 | + if (Less_Parser::is_method($a, 'compare')) { |
|
| 5164 | 5164 | $result = $a->compare($b); |
| 5165 | - }elseif( Less_Parser::is_method($b, 'compare') ){ |
|
| 5165 | + }elseif (Less_Parser::is_method($b, 'compare')) { |
|
| 5166 | 5166 | $result = $b->compare($a); |
| 5167 | - }else{ |
|
| 5167 | + }else { |
|
| 5168 | 5168 | throw new Less_Exception_Compiler('Unable to perform comparison', null, $this->index); |
| 5169 | 5169 | } |
| 5170 | 5170 | |
| 5171 | 5171 | switch ($result) { |
| 5172 | 5172 | case -1: |
| 5173 | - $result = $this->op === '<' || $this->op === '=<' || $this->op === '<='; |
|
| 5173 | + $result = $this->op==='<' || $this->op==='=<' || $this->op==='<='; |
|
| 5174 | 5174 | break; |
| 5175 | 5175 | |
| 5176 | 5176 | case 0: |
| 5177 | - $result = $this->op === '=' || $this->op === '>=' || $this->op === '=<' || $this->op === '<='; |
|
| 5177 | + $result = $this->op==='=' || $this->op==='>=' || $this->op==='=<' || $this->op==='<='; |
|
| 5178 | 5178 | break; |
| 5179 | 5179 | |
| 5180 | 5180 | case 1: |
| 5181 | - $result = $this->op === '>' || $this->op === '>='; |
|
| 5181 | + $result = $this->op==='>' || $this->op==='>='; |
|
| 5182 | 5182 | break; |
| 5183 | 5183 | } |
| 5184 | 5184 | break; |
@@ -5196,29 +5196,29 @@ discard block |
||
| 5196 | 5196 | * @package Less |
| 5197 | 5197 | * @subpackage tree |
| 5198 | 5198 | */ |
| 5199 | -class Less_Tree_DefaultFunc{ |
|
| 5199 | +class Less_Tree_DefaultFunc { |
|
| 5200 | 5200 | |
| 5201 | 5201 | static $error_; |
| 5202 | 5202 | static $value_; |
| 5203 | 5203 | |
| 5204 | - public static function compile(){ |
|
| 5205 | - if( self::$error_ ){ |
|
| 5204 | + public static function compile() { |
|
| 5205 | + if (self::$error_) { |
|
| 5206 | 5206 | throw new Exception(self::$error_); |
| 5207 | 5207 | } |
| 5208 | - if( self::$value_ !== null ){ |
|
| 5208 | + if (self::$value_!==null) { |
|
| 5209 | 5209 | return self::$value_ ? new Less_Tree_Keyword('true') : new Less_Tree_Keyword('false'); |
| 5210 | 5210 | } |
| 5211 | 5211 | } |
| 5212 | 5212 | |
| 5213 | - public static function value( $v ){ |
|
| 5213 | + public static function value($v) { |
|
| 5214 | 5214 | self::$value_ = $v; |
| 5215 | 5215 | } |
| 5216 | 5216 | |
| 5217 | - public static function error( $e ){ |
|
| 5217 | + public static function error($e) { |
|
| 5218 | 5218 | self::$error_ = $e; |
| 5219 | 5219 | } |
| 5220 | 5220 | |
| 5221 | - public static function reset(){ |
|
| 5221 | + public static function reset() { |
|
| 5222 | 5222 | self::$value_ = self::$error_ = null; |
| 5223 | 5223 | } |
| 5224 | 5224 | } |
@@ -5229,13 +5229,13 @@ discard block |
||
| 5229 | 5229 | * @package Less |
| 5230 | 5230 | * @subpackage tree |
| 5231 | 5231 | */ |
| 5232 | -class Less_Tree_DetachedRuleset extends Less_Tree{ |
|
| 5232 | +class Less_Tree_DetachedRuleset extends Less_Tree { |
|
| 5233 | 5233 | |
| 5234 | 5234 | public $ruleset; |
| 5235 | 5235 | public $frames; |
| 5236 | 5236 | public $type = 'DetachedRuleset'; |
| 5237 | 5237 | |
| 5238 | - public function __construct( $ruleset, $frames = null ){ |
|
| 5238 | + public function __construct($ruleset, $frames = null) { |
|
| 5239 | 5239 | $this->ruleset = $ruleset; |
| 5240 | 5240 | $this->frames = $frames; |
| 5241 | 5241 | } |
@@ -5244,20 +5244,20 @@ discard block |
||
| 5244 | 5244 | $this->ruleset = $visitor->visitObj($this->ruleset); |
| 5245 | 5245 | } |
| 5246 | 5246 | |
| 5247 | - public function compile($env){ |
|
| 5248 | - if( $this->frames ){ |
|
| 5247 | + public function compile($env) { |
|
| 5248 | + if ($this->frames) { |
|
| 5249 | 5249 | $frames = $this->frames; |
| 5250 | - }else{ |
|
| 5250 | + }else { |
|
| 5251 | 5251 | $frames = $env->frames; |
| 5252 | 5252 | } |
| 5253 | 5253 | return new Less_Tree_DetachedRuleset($this->ruleset, $frames); |
| 5254 | 5254 | } |
| 5255 | 5255 | |
| 5256 | 5256 | public function callEval($env) { |
| 5257 | - if( $this->frames ){ |
|
| 5258 | - return $this->ruleset->compile( $env->copyEvalEnv( array_merge($this->frames,$env->frames) ) ); |
|
| 5257 | + if ($this->frames) { |
|
| 5258 | + return $this->ruleset->compile($env->copyEvalEnv(array_merge($this->frames, $env->frames))); |
|
| 5259 | 5259 | } |
| 5260 | - return $this->ruleset->compile( $env ); |
|
| 5260 | + return $this->ruleset->compile($env); |
|
| 5261 | 5261 | } |
| 5262 | 5262 | } |
| 5263 | 5263 | |
@@ -5269,29 +5269,29 @@ discard block |
||
| 5269 | 5269 | * @package Less |
| 5270 | 5270 | * @subpackage tree |
| 5271 | 5271 | */ |
| 5272 | -class Less_Tree_Dimension extends Less_Tree{ |
|
| 5272 | +class Less_Tree_Dimension extends Less_Tree { |
|
| 5273 | 5273 | |
| 5274 | 5274 | public $value; |
| 5275 | 5275 | public $unit; |
| 5276 | 5276 | public $type = 'Dimension'; |
| 5277 | 5277 | |
| 5278 | - public function __construct($value, $unit = null){ |
|
| 5278 | + public function __construct($value, $unit = null) { |
|
| 5279 | 5279 | $this->value = floatval($value); |
| 5280 | 5280 | |
| 5281 | - if( $unit && ($unit instanceof Less_Tree_Unit) ){ |
|
| 5281 | + if ($unit && ($unit instanceof Less_Tree_Unit)) { |
|
| 5282 | 5282 | $this->unit = $unit; |
| 5283 | - }elseif( $unit ){ |
|
| 5284 | - $this->unit = new Less_Tree_Unit( array($unit) ); |
|
| 5285 | - }else{ |
|
| 5283 | + }elseif ($unit) { |
|
| 5284 | + $this->unit = new Less_Tree_Unit(array($unit)); |
|
| 5285 | + }else { |
|
| 5286 | 5286 | $this->unit = new Less_Tree_Unit( ); |
| 5287 | 5287 | } |
| 5288 | 5288 | } |
| 5289 | 5289 | |
| 5290 | - public function accept( $visitor ){ |
|
| 5291 | - $this->unit = $visitor->visitObj( $this->unit ); |
|
| 5290 | + public function accept($visitor) { |
|
| 5291 | + $this->unit = $visitor->visitObj($this->unit); |
|
| 5292 | 5292 | } |
| 5293 | 5293 | |
| 5294 | - public function compile(){ |
|
| 5294 | + public function compile() { |
|
| 5295 | 5295 | return $this; |
| 5296 | 5296 | } |
| 5297 | 5297 | |
@@ -5302,39 +5302,39 @@ discard block |
||
| 5302 | 5302 | /** |
| 5303 | 5303 | * @see Less_Tree::genCSS |
| 5304 | 5304 | */ |
| 5305 | - public function genCSS( $output ){ |
|
| 5305 | + public function genCSS($output) { |
|
| 5306 | 5306 | |
| 5307 | - if( Less_Parser::$options['strictUnits'] && !$this->unit->isSingular() ){ |
|
| 5307 | + if (Less_Parser::$options['strictUnits'] && !$this->unit->isSingular()) { |
|
| 5308 | 5308 | throw new Less_Exception_Compiler("Multiple units in dimension. Correct the units or use the unit function. Bad unit: ".$this->unit->toString()); |
| 5309 | 5309 | } |
| 5310 | 5310 | |
| 5311 | - $value = Less_Functions::fround( $this->value ); |
|
| 5311 | + $value = Less_Functions::fround($this->value); |
|
| 5312 | 5312 | $strValue = (string)$value; |
| 5313 | 5313 | |
| 5314 | - if( $value !== 0 && $value < 0.000001 && $value > -0.000001 ){ |
|
| 5314 | + if ($value!==0 && $value<0.000001 && $value>-0.000001) { |
|
| 5315 | 5315 | // would be output 1e-6 etc. |
| 5316 | - $strValue = number_format($strValue,10); |
|
| 5317 | - $strValue = preg_replace('/\.?0+$/','', $strValue); |
|
| 5316 | + $strValue = number_format($strValue, 10); |
|
| 5317 | + $strValue = preg_replace('/\.?0+$/', '', $strValue); |
|
| 5318 | 5318 | } |
| 5319 | 5319 | |
| 5320 | - if( Less_Parser::$options['compress'] ){ |
|
| 5320 | + if (Less_Parser::$options['compress']) { |
|
| 5321 | 5321 | // Zero values doesn't need a unit |
| 5322 | - if( $value === 0 && $this->unit->isLength() ){ |
|
| 5323 | - $output->add( $strValue ); |
|
| 5322 | + if ($value===0 && $this->unit->isLength()) { |
|
| 5323 | + $output->add($strValue); |
|
| 5324 | 5324 | return $strValue; |
| 5325 | 5325 | } |
| 5326 | 5326 | |
| 5327 | 5327 | // Float values doesn't need a leading zero |
| 5328 | - if( $value > 0 && $value < 1 && $strValue[0] === '0' ){ |
|
| 5329 | - $strValue = substr($strValue,1); |
|
| 5328 | + if ($value>0 && $value<1 && $strValue[0]==='0') { |
|
| 5329 | + $strValue = substr($strValue, 1); |
|
| 5330 | 5330 | } |
| 5331 | 5331 | } |
| 5332 | 5332 | |
| 5333 | - $output->add( $strValue ); |
|
| 5334 | - $this->unit->genCSS( $output ); |
|
| 5333 | + $output->add($strValue); |
|
| 5334 | + $this->unit->genCSS($output); |
|
| 5335 | 5335 | } |
| 5336 | 5336 | |
| 5337 | - public function __toString(){ |
|
| 5337 | + public function __toString() { |
|
| 5338 | 5338 | return $this->toCSS(); |
| 5339 | 5339 | } |
| 5340 | 5340 | |
@@ -5345,97 +5345,97 @@ discard block |
||
| 5345 | 5345 | /** |
| 5346 | 5346 | * @param string $op |
| 5347 | 5347 | */ |
| 5348 | - public function operate( $op, $other){ |
|
| 5348 | + public function operate($op, $other) { |
|
| 5349 | 5349 | |
| 5350 | - $value = Less_Functions::operate( $op, $this->value, $other->value); |
|
| 5350 | + $value = Less_Functions::operate($op, $this->value, $other->value); |
|
| 5351 | 5351 | $unit = clone $this->unit; |
| 5352 | 5352 | |
| 5353 | - if( $op === '+' || $op === '-' ){ |
|
| 5353 | + if ($op==='+' || $op==='-') { |
|
| 5354 | 5354 | |
| 5355 | - if( !$unit->numerator && !$unit->denominator ){ |
|
| 5355 | + if (!$unit->numerator && !$unit->denominator) { |
|
| 5356 | 5356 | $unit->numerator = $other->unit->numerator; |
| 5357 | 5357 | $unit->denominator = $other->unit->denominator; |
| 5358 | - }elseif( !$other->unit->numerator && !$other->unit->denominator ){ |
|
| 5358 | + }elseif (!$other->unit->numerator && !$other->unit->denominator) { |
|
| 5359 | 5359 | // do nothing |
| 5360 | - }else{ |
|
| 5361 | - $other = $other->convertTo( $this->unit->usedUnits()); |
|
| 5360 | + }else { |
|
| 5361 | + $other = $other->convertTo($this->unit->usedUnits()); |
|
| 5362 | 5362 | |
| 5363 | - if( Less_Parser::$options['strictUnits'] && $other->unit->toString() !== $unit->toCSS() ){ |
|
| 5364 | - throw new Less_Exception_Compiler("Incompatible units. Change the units or use the unit function. Bad units: '".$unit->toString() . "' and ".$other->unit->toString()+"'."); |
|
| 5363 | + if (Less_Parser::$options['strictUnits'] && $other->unit->toString()!==$unit->toCSS()) { |
|
| 5364 | + throw new Less_Exception_Compiler("Incompatible units. Change the units or use the unit function. Bad units: '".$unit->toString()."' and ".$other->unit->toString()+"'."); |
|
| 5365 | 5365 | } |
| 5366 | 5366 | |
| 5367 | - $value = Less_Functions::operate( $op, $this->value, $other->value); |
|
| 5367 | + $value = Less_Functions::operate($op, $this->value, $other->value); |
|
| 5368 | 5368 | } |
| 5369 | - }elseif( $op === '*' ){ |
|
| 5369 | + }elseif ($op==='*') { |
|
| 5370 | 5370 | $unit->numerator = array_merge($unit->numerator, $other->unit->numerator); |
| 5371 | 5371 | $unit->denominator = array_merge($unit->denominator, $other->unit->denominator); |
| 5372 | 5372 | sort($unit->numerator); |
| 5373 | 5373 | sort($unit->denominator); |
| 5374 | 5374 | $unit->cancel(); |
| 5375 | - }elseif( $op === '/' ){ |
|
| 5375 | + }elseif ($op==='/') { |
|
| 5376 | 5376 | $unit->numerator = array_merge($unit->numerator, $other->unit->denominator); |
| 5377 | 5377 | $unit->denominator = array_merge($unit->denominator, $other->unit->numerator); |
| 5378 | 5378 | sort($unit->numerator); |
| 5379 | 5379 | sort($unit->denominator); |
| 5380 | 5380 | $unit->cancel(); |
| 5381 | 5381 | } |
| 5382 | - return new Less_Tree_Dimension( $value, $unit); |
|
| 5382 | + return new Less_Tree_Dimension($value, $unit); |
|
| 5383 | 5383 | } |
| 5384 | 5384 | |
| 5385 | 5385 | public function compare($other) { |
| 5386 | 5386 | if ($other instanceof Less_Tree_Dimension) { |
| 5387 | 5387 | |
| 5388 | - if( $this->unit->isEmpty() || $other->unit->isEmpty() ){ |
|
| 5388 | + if ($this->unit->isEmpty() || $other->unit->isEmpty()) { |
|
| 5389 | 5389 | $a = $this; |
| 5390 | 5390 | $b = $other; |
| 5391 | - } else { |
|
| 5391 | + }else { |
|
| 5392 | 5392 | $a = $this->unify(); |
| 5393 | 5393 | $b = $other->unify(); |
| 5394 | - if( $a->unit->compare($b->unit) !== 0 ){ |
|
| 5394 | + if ($a->unit->compare($b->unit)!==0) { |
|
| 5395 | 5395 | return -1; |
| 5396 | 5396 | } |
| 5397 | 5397 | } |
| 5398 | 5398 | $aValue = $a->value; |
| 5399 | 5399 | $bValue = $b->value; |
| 5400 | 5400 | |
| 5401 | - if ($bValue > $aValue) { |
|
| 5401 | + if ($bValue>$aValue) { |
|
| 5402 | 5402 | return -1; |
| 5403 | - } elseif ($bValue < $aValue) { |
|
| 5403 | + } elseif ($bValue<$aValue) { |
|
| 5404 | 5404 | return 1; |
| 5405 | - } else { |
|
| 5405 | + }else { |
|
| 5406 | 5406 | return 0; |
| 5407 | 5407 | } |
| 5408 | - } else { |
|
| 5408 | + }else { |
|
| 5409 | 5409 | return -1; |
| 5410 | 5410 | } |
| 5411 | 5411 | } |
| 5412 | 5412 | |
| 5413 | 5413 | public function unify() { |
| 5414 | - return $this->convertTo(array('length'=> 'px', 'duration'=> 's', 'angle' => 'rad' )); |
|
| 5414 | + return $this->convertTo(array('length'=> 'px', 'duration'=> 's', 'angle' => 'rad')); |
|
| 5415 | 5415 | } |
| 5416 | 5416 | |
| 5417 | 5417 | public function convertTo($conversions) { |
| 5418 | 5418 | $value = $this->value; |
| 5419 | 5419 | $unit = clone $this->unit; |
| 5420 | 5420 | |
| 5421 | - if( is_string($conversions) ){ |
|
| 5421 | + if (is_string($conversions)) { |
|
| 5422 | 5422 | $derivedConversions = array(); |
| 5423 | - foreach( Less_Tree_UnitConversions::$groups as $i ){ |
|
| 5424 | - if( isset(Less_Tree_UnitConversions::${$i}[$conversions]) ){ |
|
| 5425 | - $derivedConversions = array( $i => $conversions); |
|
| 5423 | + foreach (Less_Tree_UnitConversions::$groups as $i) { |
|
| 5424 | + if (isset(Less_Tree_UnitConversions::${$i}[$conversions])) { |
|
| 5425 | + $derivedConversions = array($i => $conversions); |
|
| 5426 | 5426 | } |
| 5427 | 5427 | } |
| 5428 | 5428 | $conversions = $derivedConversions; |
| 5429 | 5429 | } |
| 5430 | 5430 | |
| 5431 | 5431 | |
| 5432 | - foreach($conversions as $groupName => $targetUnit){ |
|
| 5432 | + foreach ($conversions as $groupName => $targetUnit) { |
|
| 5433 | 5433 | $group = Less_Tree_UnitConversions::${$groupName}; |
| 5434 | 5434 | |
| 5435 | 5435 | //numerator |
| 5436 | - foreach($unit->numerator as $i => $atomicUnit){ |
|
| 5436 | + foreach ($unit->numerator as $i => $atomicUnit) { |
|
| 5437 | 5437 | $atomicUnit = $unit->numerator[$i]; |
| 5438 | - if( !isset($group[$atomicUnit]) ){ |
|
| 5438 | + if (!isset($group[$atomicUnit])) { |
|
| 5439 | 5439 | continue; |
| 5440 | 5440 | } |
| 5441 | 5441 | |
@@ -5445,9 +5445,9 @@ discard block |
||
| 5445 | 5445 | } |
| 5446 | 5446 | |
| 5447 | 5447 | //denominator |
| 5448 | - foreach($unit->denominator as $i => $atomicUnit){ |
|
| 5448 | + foreach ($unit->denominator as $i => $atomicUnit) { |
|
| 5449 | 5449 | $atomicUnit = $unit->denominator[$i]; |
| 5450 | - if( !isset($group[$atomicUnit]) ){ |
|
| 5450 | + if (!isset($group[$atomicUnit])) { |
|
| 5451 | 5451 | continue; |
| 5452 | 5452 | } |
| 5453 | 5453 | |
@@ -5459,7 +5459,7 @@ discard block |
||
| 5459 | 5459 | |
| 5460 | 5460 | $unit->cancel(); |
| 5461 | 5461 | |
| 5462 | - return new Less_Tree_Dimension( $value, $unit); |
|
| 5462 | + return new Less_Tree_Dimension($value, $unit); |
|
| 5463 | 5463 | } |
| 5464 | 5464 | } |
| 5465 | 5465 | |
@@ -5470,7 +5470,7 @@ discard block |
||
| 5470 | 5470 | * @package Less |
| 5471 | 5471 | * @subpackage tree |
| 5472 | 5472 | */ |
| 5473 | -class Less_Tree_Directive extends Less_Tree{ |
|
| 5473 | +class Less_Tree_Directive extends Less_Tree { |
|
| 5474 | 5474 | |
| 5475 | 5475 | public $name; |
| 5476 | 5476 | public $value; |
@@ -5481,10 +5481,10 @@ discard block |
||
| 5481 | 5481 | public $debugInfo; |
| 5482 | 5482 | public $type = 'Directive'; |
| 5483 | 5483 | |
| 5484 | - public function __construct($name, $value = null, $rules, $index = null, $currentFileInfo = null, $debugInfo = null ){ |
|
| 5484 | + public function __construct($name, $value = null, $rules, $index = null, $currentFileInfo = null, $debugInfo = null) { |
|
| 5485 | 5485 | $this->name = $name; |
| 5486 | 5486 | $this->value = $value; |
| 5487 | - if( $rules ){ |
|
| 5487 | + if ($rules) { |
|
| 5488 | 5488 | $this->rules = $rules; |
| 5489 | 5489 | $this->rules->allowImports = true; |
| 5490 | 5490 | } |
@@ -5495,12 +5495,12 @@ discard block |
||
| 5495 | 5495 | } |
| 5496 | 5496 | |
| 5497 | 5497 | |
| 5498 | - public function accept( $visitor ){ |
|
| 5499 | - if( $this->rules ){ |
|
| 5500 | - $this->rules = $visitor->visitObj( $this->rules ); |
|
| 5498 | + public function accept($visitor) { |
|
| 5499 | + if ($this->rules) { |
|
| 5500 | + $this->rules = $visitor->visitObj($this->rules); |
|
| 5501 | 5501 | } |
| 5502 | - if( $this->value ){ |
|
| 5503 | - $this->value = $visitor->visitObj( $this->value ); |
|
| 5502 | + if ($this->value) { |
|
| 5503 | + $this->value = $visitor->visitObj($this->value); |
|
| 5504 | 5504 | } |
| 5505 | 5505 | } |
| 5506 | 5506 | |
@@ -5508,55 +5508,55 @@ discard block |
||
| 5508 | 5508 | /** |
| 5509 | 5509 | * @see Less_Tree::genCSS |
| 5510 | 5510 | */ |
| 5511 | - public function genCSS( $output ){ |
|
| 5511 | + public function genCSS($output) { |
|
| 5512 | 5512 | $value = $this->value; |
| 5513 | 5513 | $rules = $this->rules; |
| 5514 | - $output->add( $this->name, $this->currentFileInfo, $this->index ); |
|
| 5515 | - if( $this->value ){ |
|
| 5514 | + $output->add($this->name, $this->currentFileInfo, $this->index); |
|
| 5515 | + if ($this->value) { |
|
| 5516 | 5516 | $output->add(' '); |
| 5517 | 5517 | $this->value->genCSS($output); |
| 5518 | 5518 | } |
| 5519 | - if( $this->rules ){ |
|
| 5520 | - Less_Tree::outputRuleset( $output, array($this->rules)); |
|
| 5521 | - } else { |
|
| 5519 | + if ($this->rules) { |
|
| 5520 | + Less_Tree::outputRuleset($output, array($this->rules)); |
|
| 5521 | + }else { |
|
| 5522 | 5522 | $output->add(';'); |
| 5523 | 5523 | } |
| 5524 | 5524 | } |
| 5525 | 5525 | |
| 5526 | - public function compile($env){ |
|
| 5526 | + public function compile($env) { |
|
| 5527 | 5527 | |
| 5528 | 5528 | $value = $this->value; |
| 5529 | 5529 | $rules = $this->rules; |
| 5530 | - if( $value ){ |
|
| 5530 | + if ($value) { |
|
| 5531 | 5531 | $value = $value->compile($env); |
| 5532 | 5532 | } |
| 5533 | 5533 | |
| 5534 | - if( $rules ){ |
|
| 5534 | + if ($rules) { |
|
| 5535 | 5535 | $rules = $rules->compile($env); |
| 5536 | 5536 | $rules->root = true; |
| 5537 | 5537 | } |
| 5538 | 5538 | |
| 5539 | - return new Less_Tree_Directive( $this->name, $value, $rules, $this->index, $this->currentFileInfo, $this->debugInfo ); |
|
| 5539 | + return new Less_Tree_Directive($this->name, $value, $rules, $this->index, $this->currentFileInfo, $this->debugInfo); |
|
| 5540 | 5540 | } |
| 5541 | 5541 | |
| 5542 | 5542 | |
| 5543 | - public function variable($name){ |
|
| 5544 | - if( $this->rules ){ |
|
| 5543 | + public function variable($name) { |
|
| 5544 | + if ($this->rules) { |
|
| 5545 | 5545 | return $this->rules->variable($name); |
| 5546 | 5546 | } |
| 5547 | 5547 | } |
| 5548 | 5548 | |
| 5549 | - public function find($selector){ |
|
| 5550 | - if( $this->rules ){ |
|
| 5549 | + public function find($selector) { |
|
| 5550 | + if ($this->rules) { |
|
| 5551 | 5551 | return $this->rules->find($selector, $this); |
| 5552 | 5552 | } |
| 5553 | 5553 | } |
| 5554 | 5554 | |
| 5555 | 5555 | //rulesets: function () { if (this.rules) return tree.Ruleset.prototype.rulesets.apply(this.rules); }, |
| 5556 | 5556 | |
| 5557 | - public function markReferenced(){ |
|
| 5557 | + public function markReferenced() { |
|
| 5558 | 5558 | $this->isReferenced = true; |
| 5559 | - if( $this->rules ){ |
|
| 5559 | + if ($this->rules) { |
|
| 5560 | 5560 | Less_Tree::ReferencedArray($this->rules->rules); |
| 5561 | 5561 | } |
| 5562 | 5562 | } |
@@ -5570,7 +5570,7 @@ discard block |
||
| 5570 | 5570 | * @package Less |
| 5571 | 5571 | * @subpackage tree |
| 5572 | 5572 | */ |
| 5573 | -class Less_Tree_Element extends Less_Tree{ |
|
| 5573 | +class Less_Tree_Element extends Less_Tree { |
|
| 5574 | 5574 | |
| 5575 | 5575 | public $combinator = ''; |
| 5576 | 5576 | public $value = ''; |
@@ -5580,12 +5580,12 @@ discard block |
||
| 5580 | 5580 | |
| 5581 | 5581 | public $value_is_object = false; |
| 5582 | 5582 | |
| 5583 | - public function __construct($combinator, $value, $index = null, $currentFileInfo = null ){ |
|
| 5583 | + public function __construct($combinator, $value, $index = null, $currentFileInfo = null) { |
|
| 5584 | 5584 | |
| 5585 | 5585 | $this->value = $value; |
| 5586 | 5586 | $this->value_is_object = is_object($value); |
| 5587 | 5587 | |
| 5588 | - if( $combinator ){ |
|
| 5588 | + if ($combinator) { |
|
| 5589 | 5589 | $this->combinator = $combinator; |
| 5590 | 5590 | } |
| 5591 | 5591 | |
@@ -5593,19 +5593,19 @@ discard block |
||
| 5593 | 5593 | $this->currentFileInfo = $currentFileInfo; |
| 5594 | 5594 | } |
| 5595 | 5595 | |
| 5596 | - public function accept( $visitor ){ |
|
| 5597 | - if( $this->value_is_object ){ //object or string |
|
| 5598 | - $this->value = $visitor->visitObj( $this->value ); |
|
| 5596 | + public function accept($visitor) { |
|
| 5597 | + if ($this->value_is_object) { //object or string |
|
| 5598 | + $this->value = $visitor->visitObj($this->value); |
|
| 5599 | 5599 | } |
| 5600 | 5600 | } |
| 5601 | 5601 | |
| 5602 | - public function compile($env){ |
|
| 5602 | + public function compile($env) { |
|
| 5603 | 5603 | |
| 5604 | - if( Less_Environment::$mixin_stack ){ |
|
| 5605 | - return new Less_Tree_Element($this->combinator, ($this->value_is_object ? $this->value->compile($env) : $this->value), $this->index, $this->currentFileInfo ); |
|
| 5604 | + if (Less_Environment::$mixin_stack) { |
|
| 5605 | + return new Less_Tree_Element($this->combinator, ($this->value_is_object ? $this->value->compile($env) : $this->value), $this->index, $this->currentFileInfo); |
|
| 5606 | 5606 | } |
| 5607 | 5607 | |
| 5608 | - if( $this->value_is_object ){ |
|
| 5608 | + if ($this->value_is_object) { |
|
| 5609 | 5609 | $this->value = $this->value->compile($env); |
| 5610 | 5610 | } |
| 5611 | 5611 | |
@@ -5615,25 +5615,25 @@ discard block |
||
| 5615 | 5615 | /** |
| 5616 | 5616 | * @see Less_Tree::genCSS |
| 5617 | 5617 | */ |
| 5618 | - public function genCSS( $output ){ |
|
| 5619 | - $output->add( $this->toCSS(), $this->currentFileInfo, $this->index ); |
|
| 5618 | + public function genCSS($output) { |
|
| 5619 | + $output->add($this->toCSS(), $this->currentFileInfo, $this->index); |
|
| 5620 | 5620 | } |
| 5621 | 5621 | |
| 5622 | - public function toCSS(){ |
|
| 5622 | + public function toCSS() { |
|
| 5623 | 5623 | |
| 5624 | - if( $this->value_is_object ){ |
|
| 5624 | + if ($this->value_is_object) { |
|
| 5625 | 5625 | $value = $this->value->toCSS(); |
| 5626 | - }else{ |
|
| 5626 | + }else { |
|
| 5627 | 5627 | $value = $this->value; |
| 5628 | 5628 | } |
| 5629 | 5629 | |
| 5630 | 5630 | |
| 5631 | - if( $value === '' && $this->combinator && $this->combinator === '&' ){ |
|
| 5631 | + if ($value==='' && $this->combinator && $this->combinator==='&') { |
|
| 5632 | 5632 | return ''; |
| 5633 | 5633 | } |
| 5634 | 5634 | |
| 5635 | 5635 | |
| 5636 | - return Less_Environment::$_outputMap[$this->combinator] . $value; |
|
| 5636 | + return Less_Environment::$_outputMap[$this->combinator].$value; |
|
| 5637 | 5637 | } |
| 5638 | 5638 | |
| 5639 | 5639 | } |
@@ -5645,61 +5645,61 @@ discard block |
||
| 5645 | 5645 | * @package Less |
| 5646 | 5646 | * @subpackage tree |
| 5647 | 5647 | */ |
| 5648 | -class Less_Tree_Expression extends Less_Tree{ |
|
| 5648 | +class Less_Tree_Expression extends Less_Tree { |
|
| 5649 | 5649 | |
| 5650 | 5650 | public $value = array(); |
| 5651 | 5651 | public $parens = false; |
| 5652 | 5652 | public $parensInOp = false; |
| 5653 | 5653 | public $type = 'Expression'; |
| 5654 | 5654 | |
| 5655 | - public function __construct( $value, $parens = null ){ |
|
| 5655 | + public function __construct($value, $parens = null) { |
|
| 5656 | 5656 | $this->value = $value; |
| 5657 | 5657 | $this->parens = $parens; |
| 5658 | 5658 | } |
| 5659 | 5659 | |
| 5660 | - public function accept( $visitor ){ |
|
| 5661 | - $this->value = $visitor->visitArray( $this->value ); |
|
| 5660 | + public function accept($visitor) { |
|
| 5661 | + $this->value = $visitor->visitArray($this->value); |
|
| 5662 | 5662 | } |
| 5663 | 5663 | |
| 5664 | 5664 | public function compile($env) { |
| 5665 | 5665 | |
| 5666 | 5666 | $doubleParen = false; |
| 5667 | 5667 | |
| 5668 | - if( $this->parens && !$this->parensInOp ){ |
|
| 5668 | + if ($this->parens && !$this->parensInOp) { |
|
| 5669 | 5669 | Less_Environment::$parensStack++; |
| 5670 | 5670 | } |
| 5671 | 5671 | |
| 5672 | 5672 | $returnValue = null; |
| 5673 | - if( $this->value ){ |
|
| 5673 | + if ($this->value) { |
|
| 5674 | 5674 | |
| 5675 | 5675 | $count = count($this->value); |
| 5676 | 5676 | |
| 5677 | - if( $count > 1 ){ |
|
| 5677 | + if ($count>1) { |
|
| 5678 | 5678 | |
| 5679 | 5679 | $ret = array(); |
| 5680 | - foreach($this->value as $e){ |
|
| 5680 | + foreach ($this->value as $e) { |
|
| 5681 | 5681 | $ret[] = $e->compile($env); |
| 5682 | 5682 | } |
| 5683 | 5683 | $returnValue = new Less_Tree_Expression($ret); |
| 5684 | 5684 | |
| 5685 | - }else{ |
|
| 5685 | + }else { |
|
| 5686 | 5686 | |
| 5687 | - if( ($this->value[0] instanceof Less_Tree_Expression) && $this->value[0]->parens && !$this->value[0]->parensInOp ){ |
|
| 5687 | + if (($this->value[0] instanceof Less_Tree_Expression) && $this->value[0]->parens && !$this->value[0]->parensInOp) { |
|
| 5688 | 5688 | $doubleParen = true; |
| 5689 | 5689 | } |
| 5690 | 5690 | |
| 5691 | 5691 | $returnValue = $this->value[0]->compile($env); |
| 5692 | 5692 | } |
| 5693 | 5693 | |
| 5694 | - } else { |
|
| 5694 | + }else { |
|
| 5695 | 5695 | $returnValue = $this; |
| 5696 | 5696 | } |
| 5697 | 5697 | |
| 5698 | - if( $this->parens ){ |
|
| 5699 | - if( !$this->parensInOp ){ |
|
| 5698 | + if ($this->parens) { |
|
| 5699 | + if (!$this->parensInOp) { |
|
| 5700 | 5700 | Less_Environment::$parensStack--; |
| 5701 | 5701 | |
| 5702 | - }elseif( !Less_Environment::isMathOn() && !$doubleParen ){ |
|
| 5702 | + }elseif (!Less_Environment::isMathOn() && !$doubleParen) { |
|
| 5703 | 5703 | $returnValue = new Less_Tree_Paren($returnValue); |
| 5704 | 5704 | |
| 5705 | 5705 | } |
@@ -5710,22 +5710,22 @@ discard block |
||
| 5710 | 5710 | /** |
| 5711 | 5711 | * @see Less_Tree::genCSS |
| 5712 | 5712 | */ |
| 5713 | - public function genCSS( $output ){ |
|
| 5713 | + public function genCSS($output) { |
|
| 5714 | 5714 | $val_len = count($this->value); |
| 5715 | - for( $i = 0; $i < $val_len; $i++ ){ |
|
| 5716 | - $this->value[$i]->genCSS( $output ); |
|
| 5717 | - if( $i + 1 < $val_len ){ |
|
| 5718 | - $output->add( ' ' ); |
|
| 5715 | + for ($i = 0; $i<$val_len; $i++) { |
|
| 5716 | + $this->value[$i]->genCSS($output); |
|
| 5717 | + if ($i+1<$val_len) { |
|
| 5718 | + $output->add(' '); |
|
| 5719 | 5719 | } |
| 5720 | 5720 | } |
| 5721 | 5721 | } |
| 5722 | 5722 | |
| 5723 | 5723 | public function throwAwayComments() { |
| 5724 | 5724 | |
| 5725 | - if( is_array($this->value) ){ |
|
| 5725 | + if (is_array($this->value)) { |
|
| 5726 | 5726 | $new_value = array(); |
| 5727 | - foreach($this->value as $v){ |
|
| 5728 | - if( $v instanceof Less_Tree_Comment ){ |
|
| 5727 | + foreach ($this->value as $v) { |
|
| 5728 | + if ($v instanceof Less_Tree_Comment) { |
|
| 5729 | 5729 | continue; |
| 5730 | 5730 | } |
| 5731 | 5731 | $new_value[] = $v; |
@@ -5742,7 +5742,7 @@ discard block |
||
| 5742 | 5742 | * @package Less |
| 5743 | 5743 | * @subpackage tree |
| 5744 | 5744 | */ |
| 5745 | -class Less_Tree_Extend extends Less_Tree{ |
|
| 5745 | +class Less_Tree_Extend extends Less_Tree { |
|
| 5746 | 5746 | |
| 5747 | 5747 | public $selector; |
| 5748 | 5748 | public $option; |
@@ -5761,13 +5761,13 @@ discard block |
||
| 5761 | 5761 | /** |
| 5762 | 5762 | * @param integer $index |
| 5763 | 5763 | */ |
| 5764 | - public function __construct($selector, $option, $index){ |
|
| 5764 | + public function __construct($selector, $option, $index) { |
|
| 5765 | 5765 | static $i = 0; |
| 5766 | 5766 | $this->selector = $selector; |
| 5767 | 5767 | $this->option = $option; |
| 5768 | 5768 | $this->index = $index; |
| 5769 | 5769 | |
| 5770 | - switch($option){ |
|
| 5770 | + switch ($option) { |
|
| 5771 | 5771 | case "all": |
| 5772 | 5772 | $this->allowBefore = true; |
| 5773 | 5773 | $this->allowAfter = true; |
@@ -5782,29 +5782,29 @@ discard block |
||
| 5782 | 5782 | $this->parent_ids = array($this->object_id); |
| 5783 | 5783 | } |
| 5784 | 5784 | |
| 5785 | - public function accept( $visitor ){ |
|
| 5786 | - $this->selector = $visitor->visitObj( $this->selector ); |
|
| 5785 | + public function accept($visitor) { |
|
| 5786 | + $this->selector = $visitor->visitObj($this->selector); |
|
| 5787 | 5787 | } |
| 5788 | 5788 | |
| 5789 | - public function compile( $env ){ |
|
| 5789 | + public function compile($env) { |
|
| 5790 | 5790 | Less_Parser::$has_extends = true; |
| 5791 | 5791 | $this->selector = $this->selector->compile($env); |
| 5792 | 5792 | return $this; |
| 5793 | 5793 | //return new Less_Tree_Extend( $this->selector->compile($env), $this->option, $this->index); |
| 5794 | 5794 | } |
| 5795 | 5795 | |
| 5796 | - public function findSelfSelectors( $selectors ){ |
|
| 5796 | + public function findSelfSelectors($selectors) { |
|
| 5797 | 5797 | $selfElements = array(); |
| 5798 | 5798 | |
| 5799 | 5799 | |
| 5800 | - for( $i = 0, $selectors_len = count($selectors); $i < $selectors_len; $i++ ){ |
|
| 5800 | + for ($i = 0, $selectors_len = count($selectors); $i<$selectors_len; $i++) { |
|
| 5801 | 5801 | $selectorElements = $selectors[$i]->elements; |
| 5802 | 5802 | // duplicate the logic in genCSS function inside the selector node. |
| 5803 | 5803 | // future TODO - move both logics into the selector joiner visitor |
| 5804 | - if( $i && $selectorElements && $selectorElements[0]->combinator === "") { |
|
| 5804 | + if ($i && $selectorElements && $selectorElements[0]->combinator==="") { |
|
| 5805 | 5805 | $selectorElements[0]->combinator = ' '; |
| 5806 | 5806 | } |
| 5807 | - $selfElements = array_merge( $selfElements, $selectors[$i]->elements ); |
|
| 5807 | + $selfElements = array_merge($selfElements, $selectors[$i]->elements); |
|
| 5808 | 5808 | } |
| 5809 | 5809 | |
| 5810 | 5810 | $this->selfSelectors = array(new Less_Tree_Selector($selfElements)); |
@@ -5827,7 +5827,7 @@ discard block |
||
| 5827 | 5827 | * @package Less |
| 5828 | 5828 | * @subpackage tree |
| 5829 | 5829 | */ |
| 5830 | -class Less_Tree_Import extends Less_Tree{ |
|
| 5830 | +class Less_Tree_Import extends Less_Tree { |
|
| 5831 | 5831 | |
| 5832 | 5832 | public $options; |
| 5833 | 5833 | public $index; |
@@ -5839,21 +5839,21 @@ discard block |
||
| 5839 | 5839 | public $root; |
| 5840 | 5840 | public $type = 'Import'; |
| 5841 | 5841 | |
| 5842 | - public function __construct($path, $features, $options, $index, $currentFileInfo = null ){ |
|
| 5842 | + public function __construct($path, $features, $options, $index, $currentFileInfo = null) { |
|
| 5843 | 5843 | $this->options = $options; |
| 5844 | 5844 | $this->index = $index; |
| 5845 | 5845 | $this->path = $path; |
| 5846 | 5846 | $this->features = $features; |
| 5847 | 5847 | $this->currentFileInfo = $currentFileInfo; |
| 5848 | 5848 | |
| 5849 | - if( is_array($options) ){ |
|
| 5849 | + if (is_array($options)) { |
|
| 5850 | 5850 | $this->options += array('inline'=>false); |
| 5851 | 5851 | |
| 5852 | - if( isset($this->options['less']) || $this->options['inline'] ){ |
|
| 5852 | + if (isset($this->options['less']) || $this->options['inline']) { |
|
| 5853 | 5853 | $this->css = !isset($this->options['less']) || !$this->options['less'] || $this->options['inline']; |
| 5854 | - } else { |
|
| 5854 | + }else { |
|
| 5855 | 5855 | $pathValue = $this->getPath(); |
| 5856 | - if( $pathValue && preg_match('/css([\?;].*)?$/',$pathValue) ){ |
|
| 5856 | + if ($pathValue && preg_match('/css([\?;].*)?$/', $pathValue)) { |
|
| 5857 | 5857 | $this->css = true; |
| 5858 | 5858 | } |
| 5859 | 5859 | } |
@@ -5870,14 +5870,14 @@ discard block |
||
| 5870 | 5870 | // ruleset. |
| 5871 | 5871 | // |
| 5872 | 5872 | |
| 5873 | - public function accept($visitor){ |
|
| 5873 | + public function accept($visitor) { |
|
| 5874 | 5874 | |
| 5875 | - if( $this->features ){ |
|
| 5875 | + if ($this->features) { |
|
| 5876 | 5876 | $this->features = $visitor->visitObj($this->features); |
| 5877 | 5877 | } |
| 5878 | 5878 | $this->path = $visitor->visitObj($this->path); |
| 5879 | 5879 | |
| 5880 | - if( !$this->options['inline'] && $this->root ){ |
|
| 5880 | + if (!$this->options['inline'] && $this->root) { |
|
| 5881 | 5881 | $this->root = $visitor->visit($this->root); |
| 5882 | 5882 | } |
| 5883 | 5883 | } |
@@ -5885,26 +5885,26 @@ discard block |
||
| 5885 | 5885 | /** |
| 5886 | 5886 | * @see Less_Tree::genCSS |
| 5887 | 5887 | */ |
| 5888 | - public function genCSS( $output ){ |
|
| 5889 | - if( $this->css ){ |
|
| 5888 | + public function genCSS($output) { |
|
| 5889 | + if ($this->css) { |
|
| 5890 | 5890 | |
| 5891 | - $output->add( '@import ', $this->currentFileInfo, $this->index ); |
|
| 5891 | + $output->add('@import ', $this->currentFileInfo, $this->index); |
|
| 5892 | 5892 | |
| 5893 | - $this->path->genCSS( $output ); |
|
| 5894 | - if( $this->features ){ |
|
| 5895 | - $output->add( ' ' ); |
|
| 5896 | - $this->features->genCSS( $output ); |
|
| 5893 | + $this->path->genCSS($output); |
|
| 5894 | + if ($this->features) { |
|
| 5895 | + $output->add(' '); |
|
| 5896 | + $this->features->genCSS($output); |
|
| 5897 | 5897 | } |
| 5898 | - $output->add( ';' ); |
|
| 5898 | + $output->add(';'); |
|
| 5899 | 5899 | } |
| 5900 | 5900 | } |
| 5901 | 5901 | |
| 5902 | - public function toCSS(){ |
|
| 5903 | - $features = $this->features ? ' ' . $this->features->toCSS() : ''; |
|
| 5902 | + public function toCSS() { |
|
| 5903 | + $features = $this->features ? ' '.$this->features->toCSS() : ''; |
|
| 5904 | 5904 | |
| 5905 | 5905 | if ($this->css) { |
| 5906 | - return "@import " . $this->path->toCSS() . $features . ";\n"; |
|
| 5907 | - } else { |
|
| 5906 | + return "@import ".$this->path->toCSS().$features.";\n"; |
|
| 5907 | + }else { |
|
| 5908 | 5908 | return ""; |
| 5909 | 5909 | } |
| 5910 | 5910 | } |
@@ -5912,37 +5912,37 @@ discard block |
||
| 5912 | 5912 | /** |
| 5913 | 5913 | * @return string |
| 5914 | 5914 | */ |
| 5915 | - public function getPath(){ |
|
| 5915 | + public function getPath() { |
|
| 5916 | 5916 | if ($this->path instanceof Less_Tree_Quoted) { |
| 5917 | 5917 | $path = $this->path->value; |
| 5918 | - $path = ( isset($this->css) || preg_match('/(\.[a-z]*$)|([\?;].*)$/',$path)) ? $path : $path . '.less'; |
|
| 5919 | - } else if ($this->path instanceof Less_Tree_URL) { |
|
| 5918 | + $path = (isset($this->css) || preg_match('/(\.[a-z]*$)|([\?;].*)$/', $path)) ? $path : $path.'.less'; |
|
| 5919 | + }else if ($this->path instanceof Less_Tree_URL) { |
|
| 5920 | 5920 | $path = $this->path->value->value; |
| 5921 | - }else{ |
|
| 5921 | + }else { |
|
| 5922 | 5922 | return null; |
| 5923 | 5923 | } |
| 5924 | 5924 | |
| 5925 | 5925 | //remove query string and fragment |
| 5926 | - return preg_replace('/[\?#][^\?]*$/','',$path); |
|
| 5926 | + return preg_replace('/[\?#][^\?]*$/', '', $path); |
|
| 5927 | 5927 | } |
| 5928 | 5928 | |
| 5929 | - public function compileForImport( $env ){ |
|
| 5930 | - return new Less_Tree_Import( $this->path->compile($env), $this->features, $this->options, $this->index, $this->currentFileInfo); |
|
| 5929 | + public function compileForImport($env) { |
|
| 5930 | + return new Less_Tree_Import($this->path->compile($env), $this->features, $this->options, $this->index, $this->currentFileInfo); |
|
| 5931 | 5931 | } |
| 5932 | 5932 | |
| 5933 | 5933 | public function compilePath($env) { |
| 5934 | 5934 | $path = $this->path->compile($env); |
| 5935 | 5935 | $rootpath = ''; |
| 5936 | - if( $this->currentFileInfo && $this->currentFileInfo['rootpath'] ){ |
|
| 5936 | + if ($this->currentFileInfo && $this->currentFileInfo['rootpath']) { |
|
| 5937 | 5937 | $rootpath = $this->currentFileInfo['rootpath']; |
| 5938 | 5938 | } |
| 5939 | 5939 | |
| 5940 | 5940 | |
| 5941 | - if( !($path instanceof Less_Tree_URL) ){ |
|
| 5942 | - if( $rootpath ){ |
|
| 5941 | + if (!($path instanceof Less_Tree_URL)) { |
|
| 5942 | + if ($rootpath) { |
|
| 5943 | 5943 | $pathValue = $path->value; |
| 5944 | 5944 | // Add the base path if the import is relative |
| 5945 | - if( $pathValue && Less_Environment::isPathRelative($pathValue) ){ |
|
| 5945 | + if ($pathValue && Less_Environment::isPathRelative($pathValue)) { |
|
| 5946 | 5946 | $path->value = $this->currentFileInfo['uri_root'].$pathValue; |
| 5947 | 5947 | } |
| 5948 | 5948 | } |
@@ -5954,55 +5954,55 @@ discard block |
||
| 5954 | 5954 | return $path; |
| 5955 | 5955 | } |
| 5956 | 5956 | |
| 5957 | - public function compile( $env ){ |
|
| 5957 | + public function compile($env) { |
|
| 5958 | 5958 | |
| 5959 | 5959 | $evald = $this->compileForImport($env); |
| 5960 | 5960 | |
| 5961 | 5961 | //get path & uri |
| 5962 | 5962 | $path_and_uri = null; |
| 5963 | - if( is_callable(Less_Parser::$options['import_callback']) ){ |
|
| 5964 | - $path_and_uri = call_user_func(Less_Parser::$options['import_callback'],$evald); |
|
| 5963 | + if (is_callable(Less_Parser::$options['import_callback'])) { |
|
| 5964 | + $path_and_uri = call_user_func(Less_Parser::$options['import_callback'], $evald); |
|
| 5965 | 5965 | } |
| 5966 | 5966 | |
| 5967 | - if( !$path_and_uri ){ |
|
| 5967 | + if (!$path_and_uri) { |
|
| 5968 | 5968 | $path_and_uri = $evald->PathAndUri(); |
| 5969 | 5969 | } |
| 5970 | 5970 | |
| 5971 | - if( $path_and_uri ){ |
|
| 5971 | + if ($path_and_uri) { |
|
| 5972 | 5972 | list($full_path, $uri) = $path_and_uri; |
| 5973 | - }else{ |
|
| 5973 | + }else { |
|
| 5974 | 5974 | $full_path = $uri = $evald->getPath(); |
| 5975 | 5975 | } |
| 5976 | 5976 | |
| 5977 | 5977 | |
| 5978 | 5978 | //import once |
| 5979 | - if( $evald->skip( $full_path, $env) ){ |
|
| 5979 | + if ($evald->skip($full_path, $env)) { |
|
| 5980 | 5980 | return array(); |
| 5981 | 5981 | } |
| 5982 | 5982 | |
| 5983 | - if( $this->options['inline'] ){ |
|
| 5983 | + if ($this->options['inline']) { |
|
| 5984 | 5984 | //todo needs to reference css file not import |
| 5985 | 5985 | //$contents = new Less_Tree_Anonymous($this->root, 0, array('filename'=>$this->importedFilename), true ); |
| 5986 | 5986 | |
| 5987 | 5987 | Less_Parser::AddParsedFile($full_path); |
| 5988 | - $contents = new Less_Tree_Anonymous( file_get_contents($full_path), 0, array(), true ); |
|
| 5988 | + $contents = new Less_Tree_Anonymous(file_get_contents($full_path), 0, array(), true); |
|
| 5989 | 5989 | |
| 5990 | - if( $this->features ){ |
|
| 5991 | - return new Less_Tree_Media( array($contents), $this->features->value ); |
|
| 5990 | + if ($this->features) { |
|
| 5991 | + return new Less_Tree_Media(array($contents), $this->features->value); |
|
| 5992 | 5992 | } |
| 5993 | 5993 | |
| 5994 | - return array( $contents ); |
|
| 5994 | + return array($contents); |
|
| 5995 | 5995 | } |
| 5996 | 5996 | |
| 5997 | 5997 | |
| 5998 | 5998 | // css ? |
| 5999 | - if( $evald->css ){ |
|
| 6000 | - $features = ( $evald->features ? $evald->features->compile($env) : null ); |
|
| 6001 | - return new Less_Tree_Import( $this->compilePath( $env), $features, $this->options, $this->index); |
|
| 5999 | + if ($evald->css) { |
|
| 6000 | + $features = ($evald->features ? $evald->features->compile($env) : null); |
|
| 6001 | + return new Less_Tree_Import($this->compilePath($env), $features, $this->options, $this->index); |
|
| 6002 | 6002 | } |
| 6003 | 6003 | |
| 6004 | 6004 | |
| 6005 | - return $this->ParseImport( $full_path, $uri, $env ); |
|
| 6005 | + return $this->ParseImport($full_path, $uri, $env); |
|
| 6006 | 6006 | } |
| 6007 | 6007 | |
| 6008 | 6008 | |
@@ -6011,57 +6011,57 @@ discard block |
||
| 6011 | 6011 | * |
| 6012 | 6012 | * @param Less_Tree_Import $evald |
| 6013 | 6013 | */ |
| 6014 | - public function PathAndUri(){ |
|
| 6014 | + public function PathAndUri() { |
|
| 6015 | 6015 | |
| 6016 | 6016 | $evald_path = $this->getPath(); |
| 6017 | 6017 | |
| 6018 | - if( $evald_path ){ |
|
| 6018 | + if ($evald_path) { |
|
| 6019 | 6019 | |
| 6020 | 6020 | $import_dirs = array(); |
| 6021 | 6021 | |
| 6022 | - if( Less_Environment::isPathRelative($evald_path) ){ |
|
| 6022 | + if (Less_Environment::isPathRelative($evald_path)) { |
|
| 6023 | 6023 | //if the path is relative, the file should be in the current directory |
| 6024 | - $import_dirs[ $this->currentFileInfo['currentDirectory'] ] = $this->currentFileInfo['uri_root']; |
|
| 6024 | + $import_dirs[$this->currentFileInfo['currentDirectory']] = $this->currentFileInfo['uri_root']; |
|
| 6025 | 6025 | |
| 6026 | - }else{ |
|
| 6026 | + }else { |
|
| 6027 | 6027 | //otherwise, the file should be relative to the server root |
| 6028 | - $import_dirs[ $this->currentFileInfo['entryPath'] ] = $this->currentFileInfo['entryUri']; |
|
| 6028 | + $import_dirs[$this->currentFileInfo['entryPath']] = $this->currentFileInfo['entryUri']; |
|
| 6029 | 6029 | |
| 6030 | 6030 | //if the user supplied entryPath isn't the actual root |
| 6031 | - $import_dirs[ $_SERVER['DOCUMENT_ROOT'] ] = ''; |
|
| 6031 | + $import_dirs[$_SERVER['DOCUMENT_ROOT']] = ''; |
|
| 6032 | 6032 | |
| 6033 | 6033 | } |
| 6034 | 6034 | |
| 6035 | 6035 | // always look in user supplied import directories |
| 6036 | - $import_dirs = array_merge( $import_dirs, Less_Parser::$options['import_dirs'] ); |
|
| 6036 | + $import_dirs = array_merge($import_dirs, Less_Parser::$options['import_dirs']); |
|
| 6037 | 6037 | |
| 6038 | 6038 | |
| 6039 | - foreach( $import_dirs as $rootpath => $rooturi){ |
|
| 6040 | - if( is_callable($rooturi) ){ |
|
| 6039 | + foreach ($import_dirs as $rootpath => $rooturi) { |
|
| 6040 | + if (is_callable($rooturi)) { |
|
| 6041 | 6041 | list($path, $uri) = call_user_func($rooturi, $evald_path); |
| 6042 | - if( is_string($path) ){ |
|
| 6042 | + if (is_string($path)) { |
|
| 6043 | 6043 | $full_path = $path; |
| 6044 | - return array( $full_path, $uri ); |
|
| 6044 | + return array($full_path, $uri); |
|
| 6045 | 6045 | } |
| 6046 | - }elseif( !empty($rootpath) ){ |
|
| 6046 | + }elseif (!empty($rootpath)) { |
|
| 6047 | 6047 | |
| 6048 | 6048 | |
| 6049 | - if( $rooturi ){ |
|
| 6050 | - if( strpos($evald_path,$rooturi) === 0 ){ |
|
| 6051 | - $evald_path = substr( $evald_path, strlen($rooturi) ); |
|
| 6049 | + if ($rooturi) { |
|
| 6050 | + if (strpos($evald_path, $rooturi)===0) { |
|
| 6051 | + $evald_path = substr($evald_path, strlen($rooturi)); |
|
| 6052 | 6052 | } |
| 6053 | 6053 | } |
| 6054 | 6054 | |
| 6055 | - $path = rtrim($rootpath,'/\\').'/'.ltrim($evald_path,'/\\'); |
|
| 6055 | + $path = rtrim($rootpath, '/\\').'/'.ltrim($evald_path, '/\\'); |
|
| 6056 | 6056 | |
| 6057 | - if( file_exists($path) ){ |
|
| 6057 | + if (file_exists($path)) { |
|
| 6058 | 6058 | $full_path = Less_Environment::normalizePath($path); |
| 6059 | 6059 | $uri = Less_Environment::normalizePath(dirname($rooturi.$evald_path)); |
| 6060 | - return array( $full_path, $uri ); |
|
| 6061 | - } elseif( file_exists($path.'.less') ){ |
|
| 6060 | + return array($full_path, $uri); |
|
| 6061 | + } elseif (file_exists($path.'.less')) { |
|
| 6062 | 6062 | $full_path = Less_Environment::normalizePath($path.'.less'); |
| 6063 | 6063 | $uri = Less_Environment::normalizePath(dirname($rooturi.$evald_path.'.less')); |
| 6064 | - return array( $full_path, $uri ); |
|
| 6064 | + return array($full_path, $uri); |
|
| 6065 | 6065 | } |
| 6066 | 6066 | } |
| 6067 | 6067 | } |
@@ -6074,14 +6074,14 @@ discard block |
||
| 6074 | 6074 | * |
| 6075 | 6075 | * @return Less_Tree_Media|array |
| 6076 | 6076 | */ |
| 6077 | - public function ParseImport( $full_path, $uri, $env ){ |
|
| 6077 | + public function ParseImport($full_path, $uri, $env) { |
|
| 6078 | 6078 | |
| 6079 | 6079 | $import_env = clone $env; |
| 6080 | - if( (isset($this->options['reference']) && $this->options['reference']) || isset($this->currentFileInfo['reference']) ){ |
|
| 6080 | + if ((isset($this->options['reference']) && $this->options['reference']) || isset($this->currentFileInfo['reference'])) { |
|
| 6081 | 6081 | $import_env->currentFileInfo['reference'] = true; |
| 6082 | 6082 | } |
| 6083 | 6083 | |
| 6084 | - if( (isset($this->options['multiple']) && $this->options['multiple']) ){ |
|
| 6084 | + if ((isset($this->options['multiple']) && $this->options['multiple'])) { |
|
| 6085 | 6085 | $import_env->importMultiple = true; |
| 6086 | 6086 | } |
| 6087 | 6087 | |
@@ -6089,7 +6089,7 @@ discard block |
||
| 6089 | 6089 | $root = $parser->parseFile($full_path, $uri, true); |
| 6090 | 6090 | |
| 6091 | 6091 | |
| 6092 | - $ruleset = new Less_Tree_Ruleset(array(), $root->rules ); |
|
| 6092 | + $ruleset = new Less_Tree_Ruleset(array(), $root->rules); |
|
| 6093 | 6093 | $ruleset->evalImports($import_env); |
| 6094 | 6094 | |
| 6095 | 6095 | return $this->features ? new Less_Tree_Media($ruleset->rules, $this->features->value) : $ruleset->rules; |
@@ -6101,13 +6101,13 @@ discard block |
||
| 6101 | 6101 | * |
| 6102 | 6102 | * @return boolean|null |
| 6103 | 6103 | */ |
| 6104 | - private function Skip($path, $env){ |
|
| 6104 | + private function Skip($path, $env) { |
|
| 6105 | 6105 | |
| 6106 | 6106 | $path = Less_Parser::winPath(realpath($path)); |
| 6107 | 6107 | |
| 6108 | - if( $path && Less_Parser::FileParsed($path) ){ |
|
| 6108 | + if ($path && Less_Parser::FileParsed($path)) { |
|
| 6109 | 6109 | |
| 6110 | - if( isset($this->currentFileInfo['reference']) ){ |
|
| 6110 | + if (isset($this->currentFileInfo['reference'])) { |
|
| 6111 | 6111 | return true; |
| 6112 | 6112 | } |
| 6113 | 6113 | |
@@ -6125,7 +6125,7 @@ discard block |
||
| 6125 | 6125 | * @package Less |
| 6126 | 6126 | * @subpackage tree |
| 6127 | 6127 | */ |
| 6128 | -class Less_Tree_Javascript extends Less_Tree{ |
|
| 6128 | +class Less_Tree_Javascript extends Less_Tree { |
|
| 6129 | 6129 | |
| 6130 | 6130 | public $type = 'Javascript'; |
| 6131 | 6131 | public $escaped; |
@@ -6136,13 +6136,13 @@ discard block |
||
| 6136 | 6136 | * @param boolean $index |
| 6137 | 6137 | * @param boolean $escaped |
| 6138 | 6138 | */ |
| 6139 | - public function __construct($string, $index, $escaped){ |
|
| 6139 | + public function __construct($string, $index, $escaped) { |
|
| 6140 | 6140 | $this->escaped = $escaped; |
| 6141 | 6141 | $this->expression = $string; |
| 6142 | 6142 | $this->index = $index; |
| 6143 | 6143 | } |
| 6144 | 6144 | |
| 6145 | - public function compile(){ |
|
| 6145 | + public function compile() { |
|
| 6146 | 6146 | return new Less_Tree_Anonymous('/* Sorry, can not do JavaScript evaluation in PHP... :( */'); |
| 6147 | 6147 | } |
| 6148 | 6148 | |
@@ -6155,7 +6155,7 @@ discard block |
||
| 6155 | 6155 | * @package Less |
| 6156 | 6156 | * @subpackage tree |
| 6157 | 6157 | */ |
| 6158 | -class Less_Tree_Keyword extends Less_Tree{ |
|
| 6158 | +class Less_Tree_Keyword extends Less_Tree { |
|
| 6159 | 6159 | |
| 6160 | 6160 | public $value; |
| 6161 | 6161 | public $type = 'Keyword'; |
@@ -6163,30 +6163,30 @@ discard block |
||
| 6163 | 6163 | /** |
| 6164 | 6164 | * @param string $value |
| 6165 | 6165 | */ |
| 6166 | - public function __construct($value){ |
|
| 6166 | + public function __construct($value) { |
|
| 6167 | 6167 | $this->value = $value; |
| 6168 | 6168 | } |
| 6169 | 6169 | |
| 6170 | - public function compile(){ |
|
| 6170 | + public function compile() { |
|
| 6171 | 6171 | return $this; |
| 6172 | 6172 | } |
| 6173 | 6173 | |
| 6174 | 6174 | /** |
| 6175 | 6175 | * @see Less_Tree::genCSS |
| 6176 | 6176 | */ |
| 6177 | - public function genCSS( $output ){ |
|
| 6177 | + public function genCSS($output) { |
|
| 6178 | 6178 | |
| 6179 | - if( $this->value === '%') { |
|
| 6179 | + if ($this->value==='%') { |
|
| 6180 | 6180 | throw new Less_Exception_Compiler("Invalid % without number"); |
| 6181 | 6181 | } |
| 6182 | 6182 | |
| 6183 | - $output->add( $this->value ); |
|
| 6183 | + $output->add($this->value); |
|
| 6184 | 6184 | } |
| 6185 | 6185 | |
| 6186 | 6186 | public function compare($other) { |
| 6187 | 6187 | if ($other instanceof Less_Tree_Keyword) { |
| 6188 | - return $other->value === $this->value ? 0 : 1; |
|
| 6189 | - } else { |
|
| 6188 | + return $other->value===$this->value ? 0 : 1; |
|
| 6189 | + }else { |
|
| 6190 | 6190 | return -1; |
| 6191 | 6191 | } |
| 6192 | 6192 | } |
@@ -6199,7 +6199,7 @@ discard block |
||
| 6199 | 6199 | * @package Less |
| 6200 | 6200 | * @subpackage tree |
| 6201 | 6201 | */ |
| 6202 | -class Less_Tree_Media extends Less_Tree{ |
|
| 6202 | +class Less_Tree_Media extends Less_Tree { |
|
| 6203 | 6203 | |
| 6204 | 6204 | public $features; |
| 6205 | 6205 | public $rules; |
@@ -6208,7 +6208,7 @@ discard block |
||
| 6208 | 6208 | public $isReferenced; |
| 6209 | 6209 | public $type = 'Media'; |
| 6210 | 6210 | |
| 6211 | - public function __construct($value = array(), $features = array(), $index = null, $currentFileInfo = null ){ |
|
| 6211 | + public function __construct($value = array(), $features = array(), $index = null, $currentFileInfo = null) { |
|
| 6212 | 6212 | |
| 6213 | 6213 | $this->index = $index; |
| 6214 | 6214 | $this->currentFileInfo = $currentFileInfo; |
@@ -6221,7 +6221,7 @@ discard block |
||
| 6221 | 6221 | $this->rules[0]->allowImports = true; |
| 6222 | 6222 | } |
| 6223 | 6223 | |
| 6224 | - public function accept( $visitor ){ |
|
| 6224 | + public function accept($visitor) { |
|
| 6225 | 6225 | $this->features = $visitor->visitObj($this->features); |
| 6226 | 6226 | $this->rules = $visitor->visitArray($this->rules); |
| 6227 | 6227 | } |
@@ -6229,27 +6229,27 @@ discard block |
||
| 6229 | 6229 | /** |
| 6230 | 6230 | * @see Less_Tree::genCSS |
| 6231 | 6231 | */ |
| 6232 | - public function genCSS( $output ){ |
|
| 6232 | + public function genCSS($output) { |
|
| 6233 | 6233 | |
| 6234 | - $output->add( '@media ', $this->currentFileInfo, $this->index ); |
|
| 6235 | - $this->features->genCSS( $output ); |
|
| 6236 | - Less_Tree::outputRuleset( $output, $this->rules); |
|
| 6234 | + $output->add('@media ', $this->currentFileInfo, $this->index); |
|
| 6235 | + $this->features->genCSS($output); |
|
| 6236 | + Less_Tree::outputRuleset($output, $this->rules); |
|
| 6237 | 6237 | |
| 6238 | 6238 | } |
| 6239 | 6239 | |
| 6240 | 6240 | public function compile($env) { |
| 6241 | 6241 | |
| 6242 | - $media = new Less_Tree_Media(array(), array(), $this->index, $this->currentFileInfo ); |
|
| 6242 | + $media = new Less_Tree_Media(array(), array(), $this->index, $this->currentFileInfo); |
|
| 6243 | 6243 | |
| 6244 | 6244 | $strictMathBypass = false; |
| 6245 | - if( Less_Parser::$options['strictMath'] === false) { |
|
| 6245 | + if (Less_Parser::$options['strictMath']===false) { |
|
| 6246 | 6246 | $strictMathBypass = true; |
| 6247 | 6247 | Less_Parser::$options['strictMath'] = true; |
| 6248 | 6248 | } |
| 6249 | 6249 | |
| 6250 | 6250 | $media->features = $this->features->compile($env); |
| 6251 | 6251 | |
| 6252 | - if( $strictMathBypass ){ |
|
| 6252 | + if ($strictMathBypass) { |
|
| 6253 | 6253 | Less_Parser::$options['strictMath'] = false; |
| 6254 | 6254 | } |
| 6255 | 6255 | |
@@ -6273,14 +6273,14 @@ discard block |
||
| 6273 | 6273 | return $this->rules[0]->find($selector, $this); |
| 6274 | 6274 | } |
| 6275 | 6275 | |
| 6276 | - public function emptySelectors(){ |
|
| 6277 | - $el = new Less_Tree_Element('','&', $this->index, $this->currentFileInfo ); |
|
| 6278 | - $sels = array( new Less_Tree_Selector(array($el), array(), null, $this->index, $this->currentFileInfo) ); |
|
| 6276 | + public function emptySelectors() { |
|
| 6277 | + $el = new Less_Tree_Element('', '&', $this->index, $this->currentFileInfo); |
|
| 6278 | + $sels = array(new Less_Tree_Selector(array($el), array(), null, $this->index, $this->currentFileInfo)); |
|
| 6279 | 6279 | $sels[0]->mediaEmpty = true; |
| 6280 | 6280 | return $sels; |
| 6281 | 6281 | } |
| 6282 | 6282 | |
| 6283 | - public function markReferenced(){ |
|
| 6283 | + public function markReferenced() { |
|
| 6284 | 6284 | $this->rules[0]->markReferenced(); |
| 6285 | 6285 | $this->isReferenced = true; |
| 6286 | 6286 | Less_Tree::ReferencedArray($this->rules[0]->rules); |
@@ -6290,7 +6290,7 @@ discard block |
||
| 6290 | 6290 | public function compileTop($env) { |
| 6291 | 6291 | $result = $this; |
| 6292 | 6292 | |
| 6293 | - if (count($env->mediaBlocks) > 1) { |
|
| 6293 | + if (count($env->mediaBlocks)>1) { |
|
| 6294 | 6294 | $selectors = $this->emptySelectors(); |
| 6295 | 6295 | $result = new Less_Tree_Ruleset($selectors, $env->mediaBlocks); |
| 6296 | 6296 | $result->multiMedia = true; |
@@ -6321,13 +6321,13 @@ discard block |
||
| 6321 | 6321 | |
| 6322 | 6322 | $permuted = $this->permute($path); |
| 6323 | 6323 | $expressions = array(); |
| 6324 | - foreach($permuted as $path){ |
|
| 6324 | + foreach ($permuted as $path) { |
|
| 6325 | 6325 | |
| 6326 | - for( $i=0, $len=count($path); $i < $len; $i++){ |
|
| 6326 | + for ($i = 0, $len = count($path); $i<$len; $i++) { |
|
| 6327 | 6327 | $path[$i] = Less_Parser::is_method($path[$i], 'toCSS') ? $path[$i] : new Less_Tree_Anonymous($path[$i]); |
| 6328 | 6328 | } |
| 6329 | 6329 | |
| 6330 | - for( $i = count($path) - 1; $i > 0; $i-- ){ |
|
| 6330 | + for ($i = count($path)-1; $i>0; $i--) { |
|
| 6331 | 6331 | array_splice($path, $i, 0, array(new Less_Tree_Anonymous('and'))); |
| 6332 | 6332 | } |
| 6333 | 6333 | |
@@ -6345,7 +6345,7 @@ discard block |
||
| 6345 | 6345 | if (!$arr) |
| 6346 | 6346 | return array(); |
| 6347 | 6347 | |
| 6348 | - if (count($arr) == 1) |
|
| 6348 | + if (count($arr)==1) |
|
| 6349 | 6349 | return $arr[0]; |
| 6350 | 6350 | |
| 6351 | 6351 | $result = array(); |
@@ -6364,9 +6364,9 @@ discard block |
||
| 6364 | 6364 | |
| 6365 | 6365 | public function bubbleSelectors($selectors) { |
| 6366 | 6366 | |
| 6367 | - if( !$selectors) return; |
|
| 6367 | + if (!$selectors) return; |
|
| 6368 | 6368 | |
| 6369 | - $this->rules = array(new Less_Tree_Ruleset( $selectors, array($this->rules[0]))); |
|
| 6369 | + $this->rules = array(new Less_Tree_Ruleset($selectors, array($this->rules[0]))); |
|
| 6370 | 6370 | } |
| 6371 | 6371 | |
| 6372 | 6372 | } |
@@ -6382,7 +6382,7 @@ discard block |
||
| 6382 | 6382 | * @package Less |
| 6383 | 6383 | * @subpackage tree |
| 6384 | 6384 | */ |
| 6385 | -class Less_Tree_NameValue extends Less_Tree{ |
|
| 6385 | +class Less_Tree_NameValue extends Less_Tree { |
|
| 6386 | 6386 | |
| 6387 | 6387 | public $name; |
| 6388 | 6388 | public $value; |
@@ -6390,14 +6390,14 @@ discard block |
||
| 6390 | 6390 | public $currentFileInfo; |
| 6391 | 6391 | public $type = 'NameValue'; |
| 6392 | 6392 | |
| 6393 | - public function __construct($name, $value = null, $index = null, $currentFileInfo = null ){ |
|
| 6393 | + public function __construct($name, $value = null, $index = null, $currentFileInfo = null) { |
|
| 6394 | 6394 | $this->name = $name; |
| 6395 | 6395 | $this->value = $value; |
| 6396 | 6396 | $this->index = $index; |
| 6397 | 6397 | $this->currentFileInfo = $currentFileInfo; |
| 6398 | 6398 | } |
| 6399 | 6399 | |
| 6400 | - public function genCSS( $output ){ |
|
| 6400 | + public function genCSS($output) { |
|
| 6401 | 6401 | |
| 6402 | 6402 | $output->add( |
| 6403 | 6403 | $this->name |
@@ -6407,7 +6407,7 @@ discard block |
||
| 6407 | 6407 | , $this->currentFileInfo, $this->index); |
| 6408 | 6408 | } |
| 6409 | 6409 | |
| 6410 | - public function compile ($env){ |
|
| 6410 | + public function compile($env) { |
|
| 6411 | 6411 | return $this; |
| 6412 | 6412 | } |
| 6413 | 6413 | } |
@@ -6419,12 +6419,12 @@ discard block |
||
| 6419 | 6419 | * @package Less |
| 6420 | 6420 | * @subpackage tree |
| 6421 | 6421 | */ |
| 6422 | -class Less_Tree_Negative extends Less_Tree{ |
|
| 6422 | +class Less_Tree_Negative extends Less_Tree { |
|
| 6423 | 6423 | |
| 6424 | 6424 | public $value; |
| 6425 | 6425 | public $type = 'Negative'; |
| 6426 | 6426 | |
| 6427 | - public function __construct($node){ |
|
| 6427 | + public function __construct($node) { |
|
| 6428 | 6428 | $this->value = $node; |
| 6429 | 6429 | } |
| 6430 | 6430 | |
@@ -6435,17 +6435,17 @@ discard block |
||
| 6435 | 6435 | /** |
| 6436 | 6436 | * @see Less_Tree::genCSS |
| 6437 | 6437 | */ |
| 6438 | - public function genCSS( $output ){ |
|
| 6439 | - $output->add( '-' ); |
|
| 6440 | - $this->value->genCSS( $output ); |
|
| 6438 | + public function genCSS($output) { |
|
| 6439 | + $output->add('-'); |
|
| 6440 | + $this->value->genCSS($output); |
|
| 6441 | 6441 | } |
| 6442 | 6442 | |
| 6443 | 6443 | public function compile($env) { |
| 6444 | - if( Less_Environment::isMathOn() ){ |
|
| 6445 | - $ret = new Less_Tree_Operation('*', array( new Less_Tree_Dimension(-1), $this->value ) ); |
|
| 6444 | + if (Less_Environment::isMathOn()) { |
|
| 6445 | + $ret = new Less_Tree_Operation('*', array(new Less_Tree_Dimension(-1), $this->value)); |
|
| 6446 | 6446 | return $ret->compile($env); |
| 6447 | 6447 | } |
| 6448 | - return new Less_Tree_Negative( $this->value->compile($env) ); |
|
| 6448 | + return new Less_Tree_Negative($this->value->compile($env)); |
|
| 6449 | 6449 | } |
| 6450 | 6450 | } |
| 6451 | 6451 | |
@@ -6455,7 +6455,7 @@ discard block |
||
| 6455 | 6455 | * @package Less |
| 6456 | 6456 | * @subpackage tree |
| 6457 | 6457 | */ |
| 6458 | -class Less_Tree_Operation extends Less_Tree{ |
|
| 6458 | +class Less_Tree_Operation extends Less_Tree { |
|
| 6459 | 6459 | |
| 6460 | 6460 | public $op; |
| 6461 | 6461 | public $operands; |
@@ -6465,7 +6465,7 @@ discard block |
||
| 6465 | 6465 | /** |
| 6466 | 6466 | * @param string $op |
| 6467 | 6467 | */ |
| 6468 | - public function __construct($op, $operands, $isSpaced = false){ |
|
| 6468 | + public function __construct($op, $operands, $isSpaced = false) { |
|
| 6469 | 6469 | $this->op = trim($op); |
| 6470 | 6470 | $this->operands = $operands; |
| 6471 | 6471 | $this->isSpaced = $isSpaced; |
@@ -6475,45 +6475,45 @@ discard block |
||
| 6475 | 6475 | $this->operands = $visitor->visitArray($this->operands); |
| 6476 | 6476 | } |
| 6477 | 6477 | |
| 6478 | - public function compile($env){ |
|
| 6478 | + public function compile($env) { |
|
| 6479 | 6479 | $a = $this->operands[0]->compile($env); |
| 6480 | 6480 | $b = $this->operands[1]->compile($env); |
| 6481 | 6481 | |
| 6482 | 6482 | |
| 6483 | - if( Less_Environment::isMathOn() ){ |
|
| 6483 | + if (Less_Environment::isMathOn()) { |
|
| 6484 | 6484 | |
| 6485 | - if( $a instanceof Less_Tree_Dimension && $b instanceof Less_Tree_Color ){ |
|
| 6485 | + if ($a instanceof Less_Tree_Dimension && $b instanceof Less_Tree_Color) { |
|
| 6486 | 6486 | $a = $a->toColor(); |
| 6487 | 6487 | |
| 6488 | - }elseif( $b instanceof Less_Tree_Dimension && $a instanceof Less_Tree_Color ){ |
|
| 6488 | + }elseif ($b instanceof Less_Tree_Dimension && $a instanceof Less_Tree_Color) { |
|
| 6489 | 6489 | $b = $b->toColor(); |
| 6490 | 6490 | |
| 6491 | 6491 | } |
| 6492 | 6492 | |
| 6493 | - if( !method_exists($a,'operate') ){ |
|
| 6493 | + if (!method_exists($a, 'operate')) { |
|
| 6494 | 6494 | throw new Less_Exception_Compiler("Operation on an invalid type"); |
| 6495 | 6495 | } |
| 6496 | 6496 | |
| 6497 | - return $a->operate( $this->op, $b); |
|
| 6497 | + return $a->operate($this->op, $b); |
|
| 6498 | 6498 | } |
| 6499 | 6499 | |
| 6500 | - return new Less_Tree_Operation($this->op, array($a, $b), $this->isSpaced ); |
|
| 6500 | + return new Less_Tree_Operation($this->op, array($a, $b), $this->isSpaced); |
|
| 6501 | 6501 | } |
| 6502 | 6502 | |
| 6503 | 6503 | |
| 6504 | 6504 | /** |
| 6505 | 6505 | * @see Less_Tree::genCSS |
| 6506 | 6506 | */ |
| 6507 | - public function genCSS( $output ){ |
|
| 6508 | - $this->operands[0]->genCSS( $output ); |
|
| 6509 | - if( $this->isSpaced ){ |
|
| 6510 | - $output->add( " " ); |
|
| 6507 | + public function genCSS($output) { |
|
| 6508 | + $this->operands[0]->genCSS($output); |
|
| 6509 | + if ($this->isSpaced) { |
|
| 6510 | + $output->add(" "); |
|
| 6511 | 6511 | } |
| 6512 | - $output->add( $this->op ); |
|
| 6513 | - if( $this->isSpaced ){ |
|
| 6514 | - $output->add( ' ' ); |
|
| 6512 | + $output->add($this->op); |
|
| 6513 | + if ($this->isSpaced) { |
|
| 6514 | + $output->add(' '); |
|
| 6515 | 6515 | } |
| 6516 | - $this->operands[1]->genCSS( $output ); |
|
| 6516 | + $this->operands[1]->genCSS($output); |
|
| 6517 | 6517 | } |
| 6518 | 6518 | |
| 6519 | 6519 | } |
@@ -6525,7 +6525,7 @@ discard block |
||
| 6525 | 6525 | * @package Less |
| 6526 | 6526 | * @subpackage tree |
| 6527 | 6527 | */ |
| 6528 | -class Less_Tree_Paren extends Less_Tree{ |
|
| 6528 | +class Less_Tree_Paren extends Less_Tree { |
|
| 6529 | 6529 | |
| 6530 | 6530 | public $value; |
| 6531 | 6531 | public $type = 'Paren'; |
@@ -6534,17 +6534,17 @@ discard block |
||
| 6534 | 6534 | $this->value = $value; |
| 6535 | 6535 | } |
| 6536 | 6536 | |
| 6537 | - public function accept($visitor){ |
|
| 6537 | + public function accept($visitor) { |
|
| 6538 | 6538 | $this->value = $visitor->visitObj($this->value); |
| 6539 | 6539 | } |
| 6540 | 6540 | |
| 6541 | 6541 | /** |
| 6542 | 6542 | * @see Less_Tree::genCSS |
| 6543 | 6543 | */ |
| 6544 | - public function genCSS( $output ){ |
|
| 6545 | - $output->add( '(' ); |
|
| 6546 | - $this->value->genCSS( $output ); |
|
| 6547 | - $output->add( ')' ); |
|
| 6544 | + public function genCSS($output) { |
|
| 6545 | + $output->add('('); |
|
| 6546 | + $this->value->genCSS($output); |
|
| 6547 | + $output->add(')'); |
|
| 6548 | 6548 | } |
| 6549 | 6549 | |
| 6550 | 6550 | public function compile($env) { |
@@ -6560,7 +6560,7 @@ discard block |
||
| 6560 | 6560 | * @package Less |
| 6561 | 6561 | * @subpackage tree |
| 6562 | 6562 | */ |
| 6563 | -class Less_Tree_Quoted extends Less_Tree{ |
|
| 6563 | +class Less_Tree_Quoted extends Less_Tree { |
|
| 6564 | 6564 | public $escaped; |
| 6565 | 6565 | public $value; |
| 6566 | 6566 | public $quote; |
@@ -6571,10 +6571,10 @@ discard block |
||
| 6571 | 6571 | /** |
| 6572 | 6572 | * @param string $str |
| 6573 | 6573 | */ |
| 6574 | - public function __construct($str, $content = '', $escaped = false, $index = false, $currentFileInfo = null ){ |
|
| 6574 | + public function __construct($str, $content = '', $escaped = false, $index = false, $currentFileInfo = null) { |
|
| 6575 | 6575 | $this->escaped = $escaped; |
| 6576 | 6576 | $this->value = $content; |
| 6577 | - if( $str ){ |
|
| 6577 | + if ($str) { |
|
| 6578 | 6578 | $this->quote = $str[0]; |
| 6579 | 6579 | } |
| 6580 | 6580 | $this->index = $index; |
@@ -6584,53 +6584,53 @@ discard block |
||
| 6584 | 6584 | /** |
| 6585 | 6585 | * @see Less_Tree::genCSS |
| 6586 | 6586 | */ |
| 6587 | - public function genCSS( $output ){ |
|
| 6588 | - if( !$this->escaped ){ |
|
| 6589 | - $output->add( $this->quote, $this->currentFileInfo, $this->index ); |
|
| 6587 | + public function genCSS($output) { |
|
| 6588 | + if (!$this->escaped) { |
|
| 6589 | + $output->add($this->quote, $this->currentFileInfo, $this->index); |
|
| 6590 | 6590 | } |
| 6591 | - $output->add( $this->value ); |
|
| 6592 | - if( !$this->escaped ){ |
|
| 6593 | - $output->add( $this->quote ); |
|
| 6591 | + $output->add($this->value); |
|
| 6592 | + if (!$this->escaped) { |
|
| 6593 | + $output->add($this->quote); |
|
| 6594 | 6594 | } |
| 6595 | 6595 | } |
| 6596 | 6596 | |
| 6597 | - public function compile($env){ |
|
| 6597 | + public function compile($env) { |
|
| 6598 | 6598 | |
| 6599 | 6599 | $value = $this->value; |
| 6600 | - if( preg_match_all('/`([^`]+)`/', $this->value, $matches) ){ |
|
| 6601 | - foreach($matches as $i => $match){ |
|
| 6600 | + if (preg_match_all('/`([^`]+)`/', $this->value, $matches)) { |
|
| 6601 | + foreach ($matches as $i => $match) { |
|
| 6602 | 6602 | $js = new Less_Tree_JavaScript($matches[1], $this->index, true); |
| 6603 | 6603 | $js = $js->compile()->value; |
| 6604 | 6604 | $value = str_replace($matches[0][$i], $js, $value); |
| 6605 | 6605 | } |
| 6606 | 6606 | } |
| 6607 | 6607 | |
| 6608 | - if( preg_match_all('/@\{([\w-]+)\}/',$value,$matches) ){ |
|
| 6609 | - foreach($matches[1] as $i => $match){ |
|
| 6610 | - $v = new Less_Tree_Variable('@' . $match, $this->index, $this->currentFileInfo ); |
|
| 6608 | + if (preg_match_all('/@\{([\w-]+)\}/', $value, $matches)) { |
|
| 6609 | + foreach ($matches[1] as $i => $match) { |
|
| 6610 | + $v = new Less_Tree_Variable('@'.$match, $this->index, $this->currentFileInfo); |
|
| 6611 | 6611 | $v = $v->compile($env); |
| 6612 | 6612 | $v = ($v instanceof Less_Tree_Quoted) ? $v->value : $v->toCSS(); |
| 6613 | 6613 | $value = str_replace($matches[0][$i], $v, $value); |
| 6614 | 6614 | } |
| 6615 | 6615 | } |
| 6616 | 6616 | |
| 6617 | - return new Less_Tree_Quoted($this->quote . $value . $this->quote, $value, $this->escaped, $this->index, $this->currentFileInfo); |
|
| 6617 | + return new Less_Tree_Quoted($this->quote.$value.$this->quote, $value, $this->escaped, $this->index, $this->currentFileInfo); |
|
| 6618 | 6618 | } |
| 6619 | 6619 | |
| 6620 | 6620 | public function compare($x) { |
| 6621 | 6621 | |
| 6622 | - if( !Less_Parser::is_method($x, 'toCSS') ){ |
|
| 6622 | + if (!Less_Parser::is_method($x, 'toCSS')) { |
|
| 6623 | 6623 | return -1; |
| 6624 | 6624 | } |
| 6625 | 6625 | |
| 6626 | 6626 | $left = $this->toCSS(); |
| 6627 | 6627 | $right = $x->toCSS(); |
| 6628 | 6628 | |
| 6629 | - if ($left === $right) { |
|
| 6629 | + if ($left===$right) { |
|
| 6630 | 6630 | return 0; |
| 6631 | 6631 | } |
| 6632 | 6632 | |
| 6633 | - return $left < $right ? -1 : 1; |
|
| 6633 | + return $left<$right ? -1 : 1; |
|
| 6634 | 6634 | } |
| 6635 | 6635 | } |
| 6636 | 6636 | |
@@ -6641,7 +6641,7 @@ discard block |
||
| 6641 | 6641 | * @package Less |
| 6642 | 6642 | * @subpackage tree |
| 6643 | 6643 | */ |
| 6644 | -class Less_Tree_Rule extends Less_Tree{ |
|
| 6644 | +class Less_Tree_Rule extends Less_Tree { |
|
| 6645 | 6645 | |
| 6646 | 6646 | public $name; |
| 6647 | 6647 | public $value; |
@@ -6656,73 +6656,73 @@ discard block |
||
| 6656 | 6656 | /** |
| 6657 | 6657 | * @param string $important |
| 6658 | 6658 | */ |
| 6659 | - public function __construct($name, $value = null, $important = null, $merge = null, $index = null, $currentFileInfo = null, $inline = false){ |
|
| 6659 | + public function __construct($name, $value = null, $important = null, $merge = null, $index = null, $currentFileInfo = null, $inline = false) { |
|
| 6660 | 6660 | $this->name = $name; |
| 6661 | 6661 | $this->value = ($value instanceof Less_Tree_Value || $value instanceof Less_Tree_Ruleset) ? $value : new Less_Tree_Value(array($value)); |
| 6662 | - $this->important = $important ? ' ' . trim($important) : ''; |
|
| 6662 | + $this->important = $important ? ' '.trim($important) : ''; |
|
| 6663 | 6663 | $this->merge = $merge; |
| 6664 | 6664 | $this->index = $index; |
| 6665 | 6665 | $this->currentFileInfo = $currentFileInfo; |
| 6666 | 6666 | $this->inline = $inline; |
| 6667 | - $this->variable = ( is_string($name) && $name[0] === '@'); |
|
| 6667 | + $this->variable = (is_string($name) && $name[0]==='@'); |
|
| 6668 | 6668 | } |
| 6669 | 6669 | |
| 6670 | 6670 | public function accept($visitor) { |
| 6671 | - $this->value = $visitor->visitObj( $this->value ); |
|
| 6671 | + $this->value = $visitor->visitObj($this->value); |
|
| 6672 | 6672 | } |
| 6673 | 6673 | |
| 6674 | 6674 | /** |
| 6675 | 6675 | * @see Less_Tree::genCSS |
| 6676 | 6676 | */ |
| 6677 | - public function genCSS( $output ){ |
|
| 6677 | + public function genCSS($output) { |
|
| 6678 | 6678 | |
| 6679 | - $output->add( $this->name . Less_Environment::$_outputMap[': '], $this->currentFileInfo, $this->index); |
|
| 6680 | - try{ |
|
| 6681 | - $this->value->genCSS( $output); |
|
| 6679 | + $output->add($this->name.Less_Environment::$_outputMap[': '], $this->currentFileInfo, $this->index); |
|
| 6680 | + try { |
|
| 6681 | + $this->value->genCSS($output); |
|
| 6682 | 6682 | |
| 6683 | - }catch( Less_Exception_Parser $e ){ |
|
| 6683 | + } catch (Less_Exception_Parser $e) { |
|
| 6684 | 6684 | $e->index = $this->index; |
| 6685 | 6685 | $e->currentFile = $this->currentFileInfo; |
| 6686 | 6686 | throw $e; |
| 6687 | 6687 | } |
| 6688 | - $output->add( $this->important . (($this->inline || (Less_Environment::$lastRule && Less_Parser::$options['compress'])) ? "" : ";"), $this->currentFileInfo, $this->index); |
|
| 6688 | + $output->add($this->important.(($this->inline || (Less_Environment::$lastRule && Less_Parser::$options['compress'])) ? "" : ";"), $this->currentFileInfo, $this->index); |
|
| 6689 | 6689 | } |
| 6690 | 6690 | |
| 6691 | - public function compile ($env){ |
|
| 6691 | + public function compile($env) { |
|
| 6692 | 6692 | |
| 6693 | 6693 | $name = $this->name; |
| 6694 | - if( is_array($name) ){ |
|
| 6694 | + if (is_array($name)) { |
|
| 6695 | 6695 | // expand 'primitive' name directly to get |
| 6696 | 6696 | // things faster (~10% for benchmark.less): |
| 6697 | - if( count($name) === 1 && $name[0] instanceof Less_Tree_Keyword ){ |
|
| 6697 | + if (count($name)===1 && $name[0] instanceof Less_Tree_Keyword) { |
|
| 6698 | 6698 | $name = $name[0]->value; |
| 6699 | - }else{ |
|
| 6700 | - $name = $this->CompileName($env,$name); |
|
| 6699 | + }else { |
|
| 6700 | + $name = $this->CompileName($env, $name); |
|
| 6701 | 6701 | } |
| 6702 | 6702 | } |
| 6703 | 6703 | |
| 6704 | 6704 | $strictMathBypass = Less_Parser::$options['strictMath']; |
| 6705 | - if( $name === "font" && !Less_Parser::$options['strictMath'] ){ |
|
| 6705 | + if ($name==="font" && !Less_Parser::$options['strictMath']) { |
|
| 6706 | 6706 | Less_Parser::$options['strictMath'] = true; |
| 6707 | 6707 | } |
| 6708 | 6708 | |
| 6709 | 6709 | try { |
| 6710 | 6710 | $evaldValue = $this->value->compile($env); |
| 6711 | 6711 | |
| 6712 | - if( !$this->variable && $evaldValue->type === "DetachedRuleset") { |
|
| 6712 | + if (!$this->variable && $evaldValue->type==="DetachedRuleset") { |
|
| 6713 | 6713 | throw new Less_Exception_Compiler("Rulesets cannot be evaluated on a property.", null, $this->index, $this->currentFileInfo); |
| 6714 | 6714 | } |
| 6715 | 6715 | |
| 6716 | - if( Less_Environment::$mixin_stack ){ |
|
| 6716 | + if (Less_Environment::$mixin_stack) { |
|
| 6717 | 6717 | $return = new Less_Tree_Rule($name, $evaldValue, $this->important, $this->merge, $this->index, $this->currentFileInfo, $this->inline); |
| 6718 | - }else{ |
|
| 6718 | + }else { |
|
| 6719 | 6719 | $this->name = $name; |
| 6720 | 6720 | $this->value = $evaldValue; |
| 6721 | 6721 | $return = $this; |
| 6722 | 6722 | } |
| 6723 | 6723 | |
| 6724 | - }catch( Less_Exception_Parser $e ){ |
|
| 6725 | - if( !is_numeric($e->index) ){ |
|
| 6724 | + } catch (Less_Exception_Parser $e) { |
|
| 6725 | + if (!is_numeric($e->index)) { |
|
| 6726 | 6726 | $e->index = $this->index; |
| 6727 | 6727 | $e->currentFile = $this->currentFileInfo; |
| 6728 | 6728 | } |
@@ -6735,15 +6735,15 @@ discard block |
||
| 6735 | 6735 | } |
| 6736 | 6736 | |
| 6737 | 6737 | |
| 6738 | - public function CompileName( $env, $name ){ |
|
| 6738 | + public function CompileName($env, $name) { |
|
| 6739 | 6739 | $output = new Less_Output(); |
| 6740 | - foreach($name as $n){ |
|
| 6740 | + foreach ($name as $n) { |
|
| 6741 | 6741 | $n->compile($env)->genCSS($output); |
| 6742 | 6742 | } |
| 6743 | 6743 | return $output->toString(); |
| 6744 | 6744 | } |
| 6745 | 6745 | |
| 6746 | - public function makeImportant(){ |
|
| 6746 | + public function makeImportant() { |
|
| 6747 | 6747 | return new Less_Tree_Rule($this->name, $this->value, '!important', $this->merge, $this->index, $this->currentFileInfo, $this->inline); |
| 6748 | 6748 | } |
| 6749 | 6749 | |
@@ -6756,7 +6756,7 @@ discard block |
||
| 6756 | 6756 | * @package Less |
| 6757 | 6757 | * @subpackage tree |
| 6758 | 6758 | */ |
| 6759 | -class Less_Tree_Ruleset extends Less_Tree{ |
|
| 6759 | +class Less_Tree_Ruleset extends Less_Tree { |
|
| 6760 | 6760 | |
| 6761 | 6761 | protected $lookups; |
| 6762 | 6762 | public $_variables; |
@@ -6779,20 +6779,20 @@ discard block |
||
| 6779 | 6779 | |
| 6780 | 6780 | public $first_oelements; |
| 6781 | 6781 | |
| 6782 | - public function SetRulesetIndex(){ |
|
| 6782 | + public function SetRulesetIndex() { |
|
| 6783 | 6783 | $this->ruleset_id = Less_Parser::$next_id++; |
| 6784 | 6784 | $this->originalRuleset = $this->ruleset_id; |
| 6785 | 6785 | |
| 6786 | - if( $this->selectors ){ |
|
| 6787 | - foreach($this->selectors as $sel){ |
|
| 6788 | - if( $sel->_oelements ){ |
|
| 6786 | + if ($this->selectors) { |
|
| 6787 | + foreach ($this->selectors as $sel) { |
|
| 6788 | + if ($sel->_oelements) { |
|
| 6789 | 6789 | $this->first_oelements[$sel->_oelements[0]] = true; |
| 6790 | 6790 | } |
| 6791 | 6791 | } |
| 6792 | 6792 | } |
| 6793 | 6793 | } |
| 6794 | 6794 | |
| 6795 | - public function __construct($selectors, $rules, $strictImports = null){ |
|
| 6795 | + public function __construct($selectors, $rules, $strictImports = null) { |
|
| 6796 | 6796 | $this->selectors = $selectors; |
| 6797 | 6797 | $this->rules = $rules; |
| 6798 | 6798 | $this->lookups = array(); |
@@ -6800,22 +6800,22 @@ discard block |
||
| 6800 | 6800 | $this->SetRulesetIndex(); |
| 6801 | 6801 | } |
| 6802 | 6802 | |
| 6803 | - public function accept( $visitor ){ |
|
| 6804 | - if( $this->paths ){ |
|
| 6803 | + public function accept($visitor) { |
|
| 6804 | + if ($this->paths) { |
|
| 6805 | 6805 | $paths_len = count($this->paths); |
| 6806 | - for($i = 0,$paths_len; $i < $paths_len; $i++ ){ |
|
| 6806 | + for ($i = 0, $paths_len; $i<$paths_len; $i++) { |
|
| 6807 | 6807 | $this->paths[$i] = $visitor->visitArray($this->paths[$i]); |
| 6808 | 6808 | } |
| 6809 | - }elseif( $this->selectors ){ |
|
| 6809 | + }elseif ($this->selectors) { |
|
| 6810 | 6810 | $this->selectors = $visitor->visitArray($this->selectors); |
| 6811 | 6811 | } |
| 6812 | 6812 | |
| 6813 | - if( $this->rules ){ |
|
| 6813 | + if ($this->rules) { |
|
| 6814 | 6814 | $this->rules = $visitor->visitArray($this->rules); |
| 6815 | 6815 | } |
| 6816 | 6816 | } |
| 6817 | 6817 | |
| 6818 | - public function compile($env){ |
|
| 6818 | + public function compile($env) { |
|
| 6819 | 6819 | |
| 6820 | 6820 | $ruleset = $this->PrepareRuleset($env); |
| 6821 | 6821 | |
@@ -6823,43 +6823,43 @@ discard block |
||
| 6823 | 6823 | // Store the frames around mixin definitions, |
| 6824 | 6824 | // so they can be evaluated like closures when the time comes. |
| 6825 | 6825 | $rsRuleCnt = count($ruleset->rules); |
| 6826 | - for( $i = 0; $i < $rsRuleCnt; $i++ ){ |
|
| 6827 | - if( $ruleset->rules[$i] instanceof Less_Tree_Mixin_Definition || $ruleset->rules[$i] instanceof Less_Tree_DetachedRuleset ){ |
|
| 6826 | + for ($i = 0; $i<$rsRuleCnt; $i++) { |
|
| 6827 | + if ($ruleset->rules[$i] instanceof Less_Tree_Mixin_Definition || $ruleset->rules[$i] instanceof Less_Tree_DetachedRuleset) { |
|
| 6828 | 6828 | $ruleset->rules[$i] = $ruleset->rules[$i]->compile($env); |
| 6829 | 6829 | } |
| 6830 | 6830 | } |
| 6831 | 6831 | |
| 6832 | 6832 | $mediaBlockCount = 0; |
| 6833 | - if( $env instanceof Less_Environment ){ |
|
| 6833 | + if ($env instanceof Less_Environment) { |
|
| 6834 | 6834 | $mediaBlockCount = count($env->mediaBlocks); |
| 6835 | 6835 | } |
| 6836 | 6836 | |
| 6837 | 6837 | // Evaluate mixin calls. |
| 6838 | - $this->EvalMixinCalls( $ruleset, $env, $rsRuleCnt ); |
|
| 6838 | + $this->EvalMixinCalls($ruleset, $env, $rsRuleCnt); |
|
| 6839 | 6839 | |
| 6840 | 6840 | |
| 6841 | 6841 | // Evaluate everything else |
| 6842 | - for( $i=0; $i<$rsRuleCnt; $i++ ){ |
|
| 6843 | - if(! ($ruleset->rules[$i] instanceof Less_Tree_Mixin_Definition || $ruleset->rules[$i] instanceof Less_Tree_DetachedRuleset) ){ |
|
| 6842 | + for ($i = 0; $i<$rsRuleCnt; $i++) { |
|
| 6843 | + if (!($ruleset->rules[$i] instanceof Less_Tree_Mixin_Definition || $ruleset->rules[$i] instanceof Less_Tree_DetachedRuleset)) { |
|
| 6844 | 6844 | $ruleset->rules[$i] = $ruleset->rules[$i]->compile($env); |
| 6845 | 6845 | } |
| 6846 | 6846 | } |
| 6847 | 6847 | |
| 6848 | 6848 | // Evaluate everything else |
| 6849 | - for( $i=0; $i<$rsRuleCnt; $i++ ){ |
|
| 6849 | + for ($i = 0; $i<$rsRuleCnt; $i++) { |
|
| 6850 | 6850 | $rule = $ruleset->rules[$i]; |
| 6851 | 6851 | |
| 6852 | 6852 | // for rulesets, check if it is a css guard and can be removed |
| 6853 | - if( $rule instanceof Less_Tree_Ruleset && $rule->selectors && count($rule->selectors) === 1 ){ |
|
| 6853 | + if ($rule instanceof Less_Tree_Ruleset && $rule->selectors && count($rule->selectors)===1) { |
|
| 6854 | 6854 | |
| 6855 | 6855 | // check if it can be folded in (e.g. & where) |
| 6856 | - if( $rule->selectors[0]->isJustParentSelector() ){ |
|
| 6857 | - array_splice($ruleset->rules,$i--,1); |
|
| 6856 | + if ($rule->selectors[0]->isJustParentSelector()) { |
|
| 6857 | + array_splice($ruleset->rules, $i--, 1); |
|
| 6858 | 6858 | $rsRuleCnt--; |
| 6859 | 6859 | |
| 6860 | - for($j = 0; $j < count($rule->rules); $j++ ){ |
|
| 6860 | + for ($j = 0; $j<count($rule->rules); $j++) { |
|
| 6861 | 6861 | $subRule = $rule->rules[$j]; |
| 6862 | - if( !($subRule instanceof Less_Tree_Rule) || !$subRule->variable ){ |
|
| 6862 | + if (!($subRule instanceof Less_Tree_Rule) || !$subRule->variable) { |
|
| 6863 | 6863 | array_splice($ruleset->rules, ++$i, 0, array($subRule)); |
| 6864 | 6864 | $rsRuleCnt++; |
| 6865 | 6865 | } |
@@ -6875,7 +6875,7 @@ discard block |
||
| 6875 | 6875 | |
| 6876 | 6876 | if ($mediaBlockCount) { |
| 6877 | 6877 | $len = count($env->mediaBlocks); |
| 6878 | - for($i = $mediaBlockCount; $i < $len; $i++ ){ |
|
| 6878 | + for ($i = $mediaBlockCount; $i<$len; $i++) { |
|
| 6879 | 6879 | $env->mediaBlocks[$i]->bubbleSelectors($ruleset->selectors); |
| 6880 | 6880 | } |
| 6881 | 6881 | } |
@@ -6889,23 +6889,23 @@ discard block |
||
| 6889 | 6889 | * @param Less_Tree_Ruleset $ruleset |
| 6890 | 6890 | * @param integer $rsRuleCnt |
| 6891 | 6891 | */ |
| 6892 | - private function EvalMixinCalls( $ruleset, $env, &$rsRuleCnt ){ |
|
| 6893 | - for($i=0; $i < $rsRuleCnt; $i++){ |
|
| 6892 | + private function EvalMixinCalls($ruleset, $env, &$rsRuleCnt) { |
|
| 6893 | + for ($i = 0; $i<$rsRuleCnt; $i++) { |
|
| 6894 | 6894 | $rule = $ruleset->rules[$i]; |
| 6895 | 6895 | |
| 6896 | - if( $rule instanceof Less_Tree_Mixin_Call ){ |
|
| 6896 | + if ($rule instanceof Less_Tree_Mixin_Call) { |
|
| 6897 | 6897 | $rule = $rule->compile($env); |
| 6898 | 6898 | |
| 6899 | 6899 | $temp = array(); |
| 6900 | - foreach($rule as $r){ |
|
| 6901 | - if( ($r instanceof Less_Tree_Rule) && $r->variable ){ |
|
| 6900 | + foreach ($rule as $r) { |
|
| 6901 | + if (($r instanceof Less_Tree_Rule) && $r->variable) { |
|
| 6902 | 6902 | // do not pollute the scope if the variable is |
| 6903 | 6903 | // already there. consider returning false here |
| 6904 | 6904 | // but we need a way to "return" variable from mixins |
| 6905 | - if( !$ruleset->variable($r->name) ){ |
|
| 6905 | + if (!$ruleset->variable($r->name)) { |
|
| 6906 | 6906 | $temp[] = $r; |
| 6907 | 6907 | } |
| 6908 | - }else{ |
|
| 6908 | + }else { |
|
| 6909 | 6909 | $temp[] = $r; |
| 6910 | 6910 | } |
| 6911 | 6911 | } |
@@ -6915,12 +6915,12 @@ discard block |
||
| 6915 | 6915 | $i += $temp_count; |
| 6916 | 6916 | $ruleset->resetCache(); |
| 6917 | 6917 | |
| 6918 | - }elseif( $rule instanceof Less_Tree_RulesetCall ){ |
|
| 6918 | + }elseif ($rule instanceof Less_Tree_RulesetCall) { |
|
| 6919 | 6919 | |
| 6920 | 6920 | $rule = $rule->compile($env); |
| 6921 | 6921 | $rules = array(); |
| 6922 | - foreach($rule->rules as $r){ |
|
| 6923 | - if( ($r instanceof Less_Tree_Rule) && $r->variable ){ |
|
| 6922 | + foreach ($rule->rules as $r) { |
|
| 6923 | + if (($r instanceof Less_Tree_Rule) && $r->variable) { |
|
| 6924 | 6924 | continue; |
| 6925 | 6925 | } |
| 6926 | 6926 | $rules[] = $r; |
@@ -6928,7 +6928,7 @@ discard block |
||
| 6928 | 6928 | |
| 6929 | 6929 | array_splice($ruleset->rules, $i, 1, $rules); |
| 6930 | 6930 | $temp_count = count($rules); |
| 6931 | - $rsRuleCnt += $temp_count - 1; |
|
| 6931 | + $rsRuleCnt += $temp_count-1; |
|
| 6932 | 6932 | $i += $temp_count-1; |
| 6933 | 6933 | $ruleset->resetCache(); |
| 6934 | 6934 | } |
@@ -6941,29 +6941,29 @@ discard block |
||
| 6941 | 6941 | * Compile the selectors and create a new ruleset object for the compile() method |
| 6942 | 6942 | * |
| 6943 | 6943 | */ |
| 6944 | - private function PrepareRuleset($env){ |
|
| 6944 | + private function PrepareRuleset($env) { |
|
| 6945 | 6945 | |
| 6946 | 6946 | $hasOnePassingSelector = false; |
| 6947 | 6947 | $selectors = array(); |
| 6948 | - if( $this->selectors ){ |
|
| 6948 | + if ($this->selectors) { |
|
| 6949 | 6949 | Less_Tree_DefaultFunc::error("it is currently only allowed in parametric mixin guards,"); |
| 6950 | 6950 | |
| 6951 | - foreach($this->selectors as $s){ |
|
| 6951 | + foreach ($this->selectors as $s) { |
|
| 6952 | 6952 | $selector = $s->compile($env); |
| 6953 | 6953 | $selectors[] = $selector; |
| 6954 | - if( $selector->evaldCondition ){ |
|
| 6954 | + if ($selector->evaldCondition) { |
|
| 6955 | 6955 | $hasOnePassingSelector = true; |
| 6956 | 6956 | } |
| 6957 | 6957 | } |
| 6958 | 6958 | |
| 6959 | 6959 | Less_Tree_DefaultFunc::reset(); |
| 6960 | - } else { |
|
| 6960 | + }else { |
|
| 6961 | 6961 | $hasOnePassingSelector = true; |
| 6962 | 6962 | } |
| 6963 | 6963 | |
| 6964 | - if( $this->rules && $hasOnePassingSelector ){ |
|
| 6964 | + if ($this->rules && $hasOnePassingSelector) { |
|
| 6965 | 6965 | $rules = $this->rules; |
| 6966 | - }else{ |
|
| 6966 | + }else { |
|
| 6967 | 6967 | $rules = array(); |
| 6968 | 6968 | } |
| 6969 | 6969 | |
@@ -6981,7 +6981,7 @@ discard block |
||
| 6981 | 6981 | |
| 6982 | 6982 | |
| 6983 | 6983 | // Evaluate imports |
| 6984 | - if( $ruleset->root || $ruleset->allowImports || !$ruleset->strictImports ){ |
|
| 6984 | + if ($ruleset->root || $ruleset->allowImports || !$ruleset->strictImports) { |
|
| 6985 | 6985 | $ruleset->evalImports($env); |
| 6986 | 6986 | } |
| 6987 | 6987 | |
@@ -6991,17 +6991,17 @@ discard block |
||
| 6991 | 6991 | function evalImports($env) { |
| 6992 | 6992 | |
| 6993 | 6993 | $rules_len = count($this->rules); |
| 6994 | - for($i=0; $i < $rules_len; $i++){ |
|
| 6994 | + for ($i = 0; $i<$rules_len; $i++) { |
|
| 6995 | 6995 | $rule = $this->rules[$i]; |
| 6996 | 6996 | |
| 6997 | - if( $rule instanceof Less_Tree_Import ){ |
|
| 6997 | + if ($rule instanceof Less_Tree_Import) { |
|
| 6998 | 6998 | $rules = $rule->compile($env); |
| 6999 | - if( is_array($rules) ){ |
|
| 6999 | + if (is_array($rules)) { |
|
| 7000 | 7000 | array_splice($this->rules, $i, 1, $rules); |
| 7001 | 7001 | $temp_count = count($rules)-1; |
| 7002 | 7002 | $i += $temp_count; |
| 7003 | 7003 | $rules_len += $temp_count; |
| 7004 | - }else{ |
|
| 7004 | + }else { |
|
| 7005 | 7005 | array_splice($this->rules, $i, 1, array($rules)); |
| 7006 | 7006 | } |
| 7007 | 7007 | |
@@ -7010,67 +7010,67 @@ discard block |
||
| 7010 | 7010 | } |
| 7011 | 7011 | } |
| 7012 | 7012 | |
| 7013 | - function makeImportant(){ |
|
| 7013 | + function makeImportant() { |
|
| 7014 | 7014 | |
| 7015 | 7015 | $important_rules = array(); |
| 7016 | - foreach($this->rules as $rule){ |
|
| 7017 | - if( $rule instanceof Less_Tree_Rule || $rule instanceof Less_Tree_Ruleset ){ |
|
| 7016 | + foreach ($this->rules as $rule) { |
|
| 7017 | + if ($rule instanceof Less_Tree_Rule || $rule instanceof Less_Tree_Ruleset) { |
|
| 7018 | 7018 | $important_rules[] = $rule->makeImportant(); |
| 7019 | - }else{ |
|
| 7019 | + }else { |
|
| 7020 | 7020 | $important_rules[] = $rule; |
| 7021 | 7021 | } |
| 7022 | 7022 | } |
| 7023 | 7023 | |
| 7024 | - return new Less_Tree_Ruleset($this->selectors, $important_rules, $this->strictImports ); |
|
| 7024 | + return new Less_Tree_Ruleset($this->selectors, $important_rules, $this->strictImports); |
|
| 7025 | 7025 | } |
| 7026 | 7026 | |
| 7027 | - public function matchArgs($args){ |
|
| 7027 | + public function matchArgs($args) { |
|
| 7028 | 7028 | return !$args; |
| 7029 | 7029 | } |
| 7030 | 7030 | |
| 7031 | 7031 | // lets you call a css selector with a guard |
| 7032 | - public function matchCondition( $args, $env ){ |
|
| 7032 | + public function matchCondition($args, $env) { |
|
| 7033 | 7033 | $lastSelector = end($this->selectors); |
| 7034 | 7034 | |
| 7035 | - if( !$lastSelector->evaldCondition ){ |
|
| 7035 | + if (!$lastSelector->evaldCondition) { |
|
| 7036 | 7036 | return false; |
| 7037 | 7037 | } |
| 7038 | - if( $lastSelector->condition && !$lastSelector->condition->compile( $env->copyEvalEnv( $env->frames ) ) ){ |
|
| 7038 | + if ($lastSelector->condition && !$lastSelector->condition->compile($env->copyEvalEnv($env->frames))) { |
|
| 7039 | 7039 | return false; |
| 7040 | 7040 | } |
| 7041 | 7041 | return true; |
| 7042 | 7042 | } |
| 7043 | 7043 | |
| 7044 | - function resetCache(){ |
|
| 7044 | + function resetCache() { |
|
| 7045 | 7045 | $this->_rulesets = null; |
| 7046 | 7046 | $this->_variables = null; |
| 7047 | 7047 | $this->lookups = array(); |
| 7048 | 7048 | } |
| 7049 | 7049 | |
| 7050 | - public function variables(){ |
|
| 7050 | + public function variables() { |
|
| 7051 | 7051 | $this->_variables = array(); |
| 7052 | - foreach( $this->rules as $r){ |
|
| 7053 | - if ($r instanceof Less_Tree_Rule && $r->variable === true) { |
|
| 7052 | + foreach ($this->rules as $r) { |
|
| 7053 | + if ($r instanceof Less_Tree_Rule && $r->variable===true) { |
|
| 7054 | 7054 | $this->_variables[$r->name] = $r; |
| 7055 | 7055 | } |
| 7056 | 7056 | } |
| 7057 | 7057 | } |
| 7058 | 7058 | |
| 7059 | - public function variable($name){ |
|
| 7059 | + public function variable($name) { |
|
| 7060 | 7060 | |
| 7061 | - if( is_null($this->_variables) ){ |
|
| 7061 | + if (is_null($this->_variables)) { |
|
| 7062 | 7062 | $this->variables(); |
| 7063 | 7063 | } |
| 7064 | 7064 | return isset($this->_variables[$name]) ? $this->_variables[$name] : null; |
| 7065 | 7065 | } |
| 7066 | 7066 | |
| 7067 | - public function find( $selector, $self = null ){ |
|
| 7067 | + public function find($selector, $self = null) { |
|
| 7068 | 7068 | |
| 7069 | - $key = implode(' ',$selector->_oelements); |
|
| 7069 | + $key = implode(' ', $selector->_oelements); |
|
| 7070 | 7070 | |
| 7071 | - if( !isset($this->lookups[$key]) ){ |
|
| 7071 | + if (!isset($this->lookups[$key])) { |
|
| 7072 | 7072 | |
| 7073 | - if( !$self ){ |
|
| 7073 | + if (!$self) { |
|
| 7074 | 7074 | $self = $this->ruleset_id; |
| 7075 | 7075 | } |
| 7076 | 7076 | |
@@ -7078,17 +7078,17 @@ discard block |
||
| 7078 | 7078 | |
| 7079 | 7079 | $first_oelement = $selector->_oelements[0]; |
| 7080 | 7080 | |
| 7081 | - foreach($this->rules as $rule){ |
|
| 7082 | - if( $rule instanceof Less_Tree_Ruleset && $rule->ruleset_id != $self ){ |
|
| 7081 | + foreach ($this->rules as $rule) { |
|
| 7082 | + if ($rule instanceof Less_Tree_Ruleset && $rule->ruleset_id!=$self) { |
|
| 7083 | 7083 | |
| 7084 | - if( isset($rule->first_oelements[$first_oelement]) ){ |
|
| 7084 | + if (isset($rule->first_oelements[$first_oelement])) { |
|
| 7085 | 7085 | |
| 7086 | - foreach( $rule->selectors as $ruleSelector ){ |
|
| 7086 | + foreach ($rule->selectors as $ruleSelector) { |
|
| 7087 | 7087 | $match = $selector->match($ruleSelector); |
| 7088 | - if( $match ){ |
|
| 7089 | - if( $selector->elements_len > $match ){ |
|
| 7090 | - $this->lookups[$key] = array_merge($this->lookups[$key], $rule->find( new Less_Tree_Selector(array_slice($selector->elements, $match)), $self)); |
|
| 7091 | - } else { |
|
| 7088 | + if ($match) { |
|
| 7089 | + if ($selector->elements_len>$match) { |
|
| 7090 | + $this->lookups[$key] = array_merge($this->lookups[$key], $rule->find(new Less_Tree_Selector(array_slice($selector->elements, $match)), $self)); |
|
| 7091 | + }else { |
|
| 7092 | 7092 | $this->lookups[$key][] = $rule; |
| 7093 | 7093 | } |
| 7094 | 7094 | break; |
@@ -7106,18 +7106,18 @@ discard block |
||
| 7106 | 7106 | /** |
| 7107 | 7107 | * @see Less_Tree::genCSS |
| 7108 | 7108 | */ |
| 7109 | - public function genCSS( $output ){ |
|
| 7109 | + public function genCSS($output) { |
|
| 7110 | 7110 | |
| 7111 | - if( !$this->root ){ |
|
| 7111 | + if (!$this->root) { |
|
| 7112 | 7112 | Less_Environment::$tabLevel++; |
| 7113 | 7113 | } |
| 7114 | 7114 | |
| 7115 | 7115 | $tabRuleStr = $tabSetStr = ''; |
| 7116 | - if( !Less_Parser::$options['compress'] ){ |
|
| 7117 | - if( Less_Environment::$tabLevel ){ |
|
| 7118 | - $tabRuleStr = "\n".str_repeat( ' ' , Less_Environment::$tabLevel ); |
|
| 7119 | - $tabSetStr = "\n".str_repeat( ' ' , Less_Environment::$tabLevel-1 ); |
|
| 7120 | - }else{ |
|
| 7116 | + if (!Less_Parser::$options['compress']) { |
|
| 7117 | + if (Less_Environment::$tabLevel) { |
|
| 7118 | + $tabRuleStr = "\n".str_repeat(' ', Less_Environment::$tabLevel); |
|
| 7119 | + $tabSetStr = "\n".str_repeat(' ', Less_Environment::$tabLevel-1); |
|
| 7120 | + }else { |
|
| 7121 | 7121 | $tabSetStr = $tabRuleStr = "\n"; |
| 7122 | 7122 | } |
| 7123 | 7123 | } |
@@ -7125,19 +7125,19 @@ discard block |
||
| 7125 | 7125 | |
| 7126 | 7126 | $ruleNodes = array(); |
| 7127 | 7127 | $rulesetNodes = array(); |
| 7128 | - foreach($this->rules as $rule){ |
|
| 7128 | + foreach ($this->rules as $rule) { |
|
| 7129 | 7129 | |
| 7130 | 7130 | $class = get_class($rule); |
| 7131 | - if( ($class === 'Less_Tree_Media') || ($class === 'Less_Tree_Directive') || ($this->root && $class === 'Less_Tree_Comment') || ($class === 'Less_Tree_Ruleset' && $rule->rules) ){ |
|
| 7131 | + if (($class==='Less_Tree_Media') || ($class==='Less_Tree_Directive') || ($this->root && $class==='Less_Tree_Comment') || ($class==='Less_Tree_Ruleset' && $rule->rules)) { |
|
| 7132 | 7132 | $rulesetNodes[] = $rule; |
| 7133 | - }else{ |
|
| 7133 | + }else { |
|
| 7134 | 7134 | $ruleNodes[] = $rule; |
| 7135 | 7135 | } |
| 7136 | 7136 | } |
| 7137 | 7137 | |
| 7138 | 7138 | // If this is the root node, we don't render |
| 7139 | 7139 | // a selector, or {}. |
| 7140 | - if( !$this->root ){ |
|
| 7140 | + if (!$this->root) { |
|
| 7141 | 7141 | |
| 7142 | 7142 | /* |
| 7143 | 7143 | debugInfo = tree.debugInfo(env, this, tabSetStr); |
@@ -7149,102 +7149,102 @@ discard block |
||
| 7149 | 7149 | */ |
| 7150 | 7150 | |
| 7151 | 7151 | $paths_len = count($this->paths); |
| 7152 | - for( $i = 0; $i < $paths_len; $i++ ){ |
|
| 7152 | + for ($i = 0; $i<$paths_len; $i++) { |
|
| 7153 | 7153 | $path = $this->paths[$i]; |
| 7154 | 7154 | $firstSelector = true; |
| 7155 | 7155 | |
| 7156 | - foreach($path as $p){ |
|
| 7157 | - $p->genCSS( $output, $firstSelector ); |
|
| 7156 | + foreach ($path as $p) { |
|
| 7157 | + $p->genCSS($output, $firstSelector); |
|
| 7158 | 7158 | $firstSelector = false; |
| 7159 | 7159 | } |
| 7160 | 7160 | |
| 7161 | - if( $i + 1 < $paths_len ){ |
|
| 7162 | - $output->add( ',' . $tabSetStr ); |
|
| 7161 | + if ($i+1<$paths_len) { |
|
| 7162 | + $output->add(','.$tabSetStr); |
|
| 7163 | 7163 | } |
| 7164 | 7164 | } |
| 7165 | 7165 | |
| 7166 | - $output->add( (Less_Parser::$options['compress'] ? '{' : " {") . $tabRuleStr ); |
|
| 7166 | + $output->add((Less_Parser::$options['compress'] ? '{' : " {").$tabRuleStr); |
|
| 7167 | 7167 | } |
| 7168 | 7168 | |
| 7169 | 7169 | // Compile rules and rulesets |
| 7170 | 7170 | $ruleNodes_len = count($ruleNodes); |
| 7171 | 7171 | $rulesetNodes_len = count($rulesetNodes); |
| 7172 | - for( $i = 0; $i < $ruleNodes_len; $i++ ){ |
|
| 7172 | + for ($i = 0; $i<$ruleNodes_len; $i++) { |
|
| 7173 | 7173 | $rule = $ruleNodes[$i]; |
| 7174 | 7174 | |
| 7175 | 7175 | // @page{ directive ends up with root elements inside it, a mix of rules and rulesets |
| 7176 | 7176 | // In this instance we do not know whether it is the last property |
| 7177 | - if( $i + 1 === $ruleNodes_len && (!$this->root || $rulesetNodes_len === 0 || $this->firstRoot ) ){ |
|
| 7177 | + if ($i+1===$ruleNodes_len && (!$this->root || $rulesetNodes_len===0 || $this->firstRoot)) { |
|
| 7178 | 7178 | Less_Environment::$lastRule = true; |
| 7179 | 7179 | } |
| 7180 | 7180 | |
| 7181 | - $rule->genCSS( $output ); |
|
| 7181 | + $rule->genCSS($output); |
|
| 7182 | 7182 | |
| 7183 | - if( !Less_Environment::$lastRule ){ |
|
| 7184 | - $output->add( $tabRuleStr ); |
|
| 7185 | - }else{ |
|
| 7183 | + if (!Less_Environment::$lastRule) { |
|
| 7184 | + $output->add($tabRuleStr); |
|
| 7185 | + }else { |
|
| 7186 | 7186 | Less_Environment::$lastRule = false; |
| 7187 | 7187 | } |
| 7188 | 7188 | } |
| 7189 | 7189 | |
| 7190 | - if( !$this->root ){ |
|
| 7191 | - $output->add( $tabSetStr . '}' ); |
|
| 7190 | + if (!$this->root) { |
|
| 7191 | + $output->add($tabSetStr.'}'); |
|
| 7192 | 7192 | Less_Environment::$tabLevel--; |
| 7193 | 7193 | } |
| 7194 | 7194 | |
| 7195 | 7195 | $firstRuleset = true; |
| 7196 | 7196 | $space = ($this->root ? $tabRuleStr : $tabSetStr); |
| 7197 | - for( $i = 0; $i < $rulesetNodes_len; $i++ ){ |
|
| 7197 | + for ($i = 0; $i<$rulesetNodes_len; $i++) { |
|
| 7198 | 7198 | |
| 7199 | - if( $ruleNodes_len && $firstRuleset ){ |
|
| 7200 | - $output->add( $space ); |
|
| 7201 | - }elseif( !$firstRuleset ){ |
|
| 7202 | - $output->add( $space ); |
|
| 7199 | + if ($ruleNodes_len && $firstRuleset) { |
|
| 7200 | + $output->add($space); |
|
| 7201 | + }elseif (!$firstRuleset) { |
|
| 7202 | + $output->add($space); |
|
| 7203 | 7203 | } |
| 7204 | 7204 | $firstRuleset = false; |
| 7205 | - $rulesetNodes[$i]->genCSS( $output); |
|
| 7205 | + $rulesetNodes[$i]->genCSS($output); |
|
| 7206 | 7206 | } |
| 7207 | 7207 | |
| 7208 | - if( !Less_Parser::$options['compress'] && $this->firstRoot ){ |
|
| 7209 | - $output->add( "\n" ); |
|
| 7208 | + if (!Less_Parser::$options['compress'] && $this->firstRoot) { |
|
| 7209 | + $output->add("\n"); |
|
| 7210 | 7210 | } |
| 7211 | 7211 | |
| 7212 | 7212 | } |
| 7213 | 7213 | |
| 7214 | 7214 | |
| 7215 | - function markReferenced(){ |
|
| 7216 | - if( !$this->selectors ){ |
|
| 7215 | + function markReferenced() { |
|
| 7216 | + if (!$this->selectors) { |
|
| 7217 | 7217 | return; |
| 7218 | 7218 | } |
| 7219 | - foreach($this->selectors as $selector){ |
|
| 7219 | + foreach ($this->selectors as $selector) { |
|
| 7220 | 7220 | $selector->markReferenced(); |
| 7221 | 7221 | } |
| 7222 | 7222 | } |
| 7223 | 7223 | |
| 7224 | - public function joinSelectors( $context, $selectors ){ |
|
| 7224 | + public function joinSelectors($context, $selectors) { |
|
| 7225 | 7225 | $paths = array(); |
| 7226 | - if( is_array($selectors) ){ |
|
| 7227 | - foreach($selectors as $selector) { |
|
| 7228 | - $this->joinSelector( $paths, $context, $selector); |
|
| 7226 | + if (is_array($selectors)) { |
|
| 7227 | + foreach ($selectors as $selector) { |
|
| 7228 | + $this->joinSelector($paths, $context, $selector); |
|
| 7229 | 7229 | } |
| 7230 | 7230 | } |
| 7231 | 7231 | return $paths; |
| 7232 | 7232 | } |
| 7233 | 7233 | |
| 7234 | - public function joinSelector( &$paths, $context, $selector){ |
|
| 7234 | + public function joinSelector(&$paths, $context, $selector) { |
|
| 7235 | 7235 | |
| 7236 | 7236 | $hasParentSelector = false; |
| 7237 | 7237 | |
| 7238 | - foreach($selector->elements as $el) { |
|
| 7239 | - if( $el->value === '&') { |
|
| 7238 | + foreach ($selector->elements as $el) { |
|
| 7239 | + if ($el->value==='&') { |
|
| 7240 | 7240 | $hasParentSelector = true; |
| 7241 | 7241 | } |
| 7242 | 7242 | } |
| 7243 | 7243 | |
| 7244 | - if( !$hasParentSelector ){ |
|
| 7245 | - if( $context ){ |
|
| 7246 | - foreach($context as $context_el){ |
|
| 7247 | - $paths[] = array_merge($context_el, array($selector) ); |
|
| 7244 | + if (!$hasParentSelector) { |
|
| 7245 | + if ($context) { |
|
| 7246 | + foreach ($context as $context_el) { |
|
| 7247 | + $paths[] = array_merge($context_el, array($selector)); |
|
| 7248 | 7248 | } |
| 7249 | 7249 | }else { |
| 7250 | 7250 | $paths[] = array($selector); |
@@ -7272,38 +7272,38 @@ discard block |
||
| 7272 | 7272 | $newSelectors = array(array()); |
| 7273 | 7273 | |
| 7274 | 7274 | |
| 7275 | - foreach( $selector->elements as $el){ |
|
| 7275 | + foreach ($selector->elements as $el) { |
|
| 7276 | 7276 | |
| 7277 | 7277 | // non parent reference elements just get added |
| 7278 | - if( $el->value !== '&' ){ |
|
| 7278 | + if ($el->value!=='&') { |
|
| 7279 | 7279 | $currentElements[] = $el; |
| 7280 | - } else { |
|
| 7280 | + }else { |
|
| 7281 | 7281 | // the new list of selectors to add |
| 7282 | 7282 | $selectorsMultiplied = array(); |
| 7283 | 7283 | |
| 7284 | 7284 | // merge the current list of non parent selector elements |
| 7285 | 7285 | // on to the current list of selectors to add |
| 7286 | - if( $currentElements ){ |
|
| 7287 | - $this->mergeElementsOnToSelectors( $currentElements, $newSelectors); |
|
| 7286 | + if ($currentElements) { |
|
| 7287 | + $this->mergeElementsOnToSelectors($currentElements, $newSelectors); |
|
| 7288 | 7288 | } |
| 7289 | 7289 | |
| 7290 | 7290 | // loop through our current selectors |
| 7291 | - foreach($newSelectors as $sel){ |
|
| 7291 | + foreach ($newSelectors as $sel) { |
|
| 7292 | 7292 | |
| 7293 | 7293 | // if we don't have any parent paths, the & might be in a mixin so that it can be used |
| 7294 | 7294 | // whether there are parents or not |
| 7295 | - if( !$context ){ |
|
| 7295 | + if (!$context) { |
|
| 7296 | 7296 | // the combinator used on el should now be applied to the next element instead so that |
| 7297 | 7297 | // it is not lost |
| 7298 | - if( $sel ){ |
|
| 7299 | - $sel[0]->elements = array_slice($sel[0]->elements,0); |
|
| 7300 | - $sel[0]->elements[] = new Less_Tree_Element($el->combinator, '', $el->index, $el->currentFileInfo ); |
|
| 7298 | + if ($sel) { |
|
| 7299 | + $sel[0]->elements = array_slice($sel[0]->elements, 0); |
|
| 7300 | + $sel[0]->elements[] = new Less_Tree_Element($el->combinator, '', $el->index, $el->currentFileInfo); |
|
| 7301 | 7301 | } |
| 7302 | 7302 | $selectorsMultiplied[] = $sel; |
| 7303 | 7303 | }else { |
| 7304 | 7304 | |
| 7305 | 7305 | // and the parent selectors |
| 7306 | - foreach($context as $parentSel){ |
|
| 7306 | + foreach ($context as $parentSel) { |
|
| 7307 | 7307 | // We need to put the current selectors |
| 7308 | 7308 | // then join the last selector's elements on to the parents selectors |
| 7309 | 7309 | |
@@ -7315,10 +7315,10 @@ discard block |
||
| 7315 | 7315 | |
| 7316 | 7316 | //construct the joined selector - if & is the first thing this will be empty, |
| 7317 | 7317 | // if not newJoinedSelector will be the last set of elements in the selector |
| 7318 | - if( $sel ){ |
|
| 7318 | + if ($sel) { |
|
| 7319 | 7319 | $newSelectorPath = $sel; |
| 7320 | 7320 | $lastSelector = array_pop($newSelectorPath); |
| 7321 | - $newJoinedSelector = $selector->createDerived( array_slice($lastSelector->elements,0) ); |
|
| 7321 | + $newJoinedSelector = $selector->createDerived(array_slice($lastSelector->elements, 0)); |
|
| 7322 | 7322 | $newJoinedSelectorEmpty = false; |
| 7323 | 7323 | } |
| 7324 | 7324 | else { |
@@ -7326,17 +7326,17 @@ discard block |
||
| 7326 | 7326 | } |
| 7327 | 7327 | |
| 7328 | 7328 | //put together the parent selectors after the join |
| 7329 | - if ( count($parentSel) > 1) { |
|
| 7330 | - $afterParentJoin = array_merge($afterParentJoin, array_slice($parentSel,1) ); |
|
| 7329 | + if (count($parentSel)>1) { |
|
| 7330 | + $afterParentJoin = array_merge($afterParentJoin, array_slice($parentSel, 1)); |
|
| 7331 | 7331 | } |
| 7332 | 7332 | |
| 7333 | - if ( $parentSel ){ |
|
| 7333 | + if ($parentSel) { |
|
| 7334 | 7334 | $newJoinedSelectorEmpty = false; |
| 7335 | 7335 | |
| 7336 | 7336 | // join the elements so far with the first part of the parent |
| 7337 | - $newJoinedSelector->elements[] = new Less_Tree_Element( $el->combinator, $parentSel[0]->elements[0]->value, $el->index, $el->currentFileInfo); |
|
| 7337 | + $newJoinedSelector->elements[] = new Less_Tree_Element($el->combinator, $parentSel[0]->elements[0]->value, $el->index, $el->currentFileInfo); |
|
| 7338 | 7338 | |
| 7339 | - $newJoinedSelector->elements = array_merge( $newJoinedSelector->elements, array_slice($parentSel[0]->elements, 1) ); |
|
| 7339 | + $newJoinedSelector->elements = array_merge($newJoinedSelector->elements, array_slice($parentSel[0]->elements, 1)); |
|
| 7340 | 7340 | } |
| 7341 | 7341 | |
| 7342 | 7342 | if (!$newJoinedSelectorEmpty) { |
@@ -7361,32 +7361,32 @@ discard block |
||
| 7361 | 7361 | |
| 7362 | 7362 | // if we have any elements left over (e.g. .a& .b == .b) |
| 7363 | 7363 | // add them on to all the current selectors |
| 7364 | - if( $currentElements ){ |
|
| 7364 | + if ($currentElements) { |
|
| 7365 | 7365 | $this->mergeElementsOnToSelectors($currentElements, $newSelectors); |
| 7366 | 7366 | } |
| 7367 | - foreach( $newSelectors as $new_sel){ |
|
| 7368 | - if( $new_sel ){ |
|
| 7367 | + foreach ($newSelectors as $new_sel) { |
|
| 7368 | + if ($new_sel) { |
|
| 7369 | 7369 | $paths[] = $new_sel; |
| 7370 | 7370 | } |
| 7371 | 7371 | } |
| 7372 | 7372 | } |
| 7373 | 7373 | |
| 7374 | - function mergeElementsOnToSelectors( $elements, &$selectors){ |
|
| 7374 | + function mergeElementsOnToSelectors($elements, &$selectors) { |
|
| 7375 | 7375 | |
| 7376 | - if( !$selectors ){ |
|
| 7377 | - $selectors[] = array( new Less_Tree_Selector($elements) ); |
|
| 7376 | + if (!$selectors) { |
|
| 7377 | + $selectors[] = array(new Less_Tree_Selector($elements)); |
|
| 7378 | 7378 | return; |
| 7379 | 7379 | } |
| 7380 | 7380 | |
| 7381 | 7381 | |
| 7382 | - foreach( $selectors as &$sel){ |
|
| 7382 | + foreach ($selectors as &$sel) { |
|
| 7383 | 7383 | |
| 7384 | 7384 | // if the previous thing in sel is a parent this needs to join on to it |
| 7385 | - if( $sel ){ |
|
| 7385 | + if ($sel) { |
|
| 7386 | 7386 | $last = count($sel)-1; |
| 7387 | - $sel[$last] = $sel[$last]->createDerived( array_merge($sel[$last]->elements, $elements) ); |
|
| 7388 | - }else{ |
|
| 7389 | - $sel[] = new Less_Tree_Selector( $elements ); |
|
| 7387 | + $sel[$last] = $sel[$last]->createDerived(array_merge($sel[$last]->elements, $elements)); |
|
| 7388 | + }else { |
|
| 7389 | + $sel[] = new Less_Tree_Selector($elements); |
|
| 7390 | 7390 | } |
| 7391 | 7391 | } |
| 7392 | 7392 | } |
@@ -7399,18 +7399,18 @@ discard block |
||
| 7399 | 7399 | * @package Less |
| 7400 | 7400 | * @subpackage tree |
| 7401 | 7401 | */ |
| 7402 | -class Less_Tree_RulesetCall extends Less_Tree{ |
|
| 7402 | +class Less_Tree_RulesetCall extends Less_Tree { |
|
| 7403 | 7403 | |
| 7404 | 7404 | public $variable; |
| 7405 | 7405 | public $type = "RulesetCall"; |
| 7406 | 7406 | |
| 7407 | - public function __construct($variable){ |
|
| 7407 | + public function __construct($variable) { |
|
| 7408 | 7408 | $this->variable = $variable; |
| 7409 | 7409 | } |
| 7410 | 7410 | |
| 7411 | 7411 | public function accept($visitor) {} |
| 7412 | 7412 | |
| 7413 | - public function compile( $env ){ |
|
| 7413 | + public function compile($env) { |
|
| 7414 | 7414 | $variable = new Less_Tree_Variable($this->variable); |
| 7415 | 7415 | $detachedRuleset = $variable->compile($env); |
| 7416 | 7416 | return $detachedRuleset->callEval($env); |
@@ -7425,7 +7425,7 @@ discard block |
||
| 7425 | 7425 | * @package Less |
| 7426 | 7426 | * @subpackage tree |
| 7427 | 7427 | */ |
| 7428 | -class Less_Tree_Selector extends Less_Tree{ |
|
| 7428 | +class Less_Tree_Selector extends Less_Tree { |
|
| 7429 | 7429 | |
| 7430 | 7430 | public $elements; |
| 7431 | 7431 | public $condition; |
@@ -7447,17 +7447,17 @@ discard block |
||
| 7447 | 7447 | /** |
| 7448 | 7448 | * @param boolean $isReferenced |
| 7449 | 7449 | */ |
| 7450 | - public function __construct( $elements, $extendList = array() , $condition = null, $index=null, $currentFileInfo=null, $isReferenced=null ){ |
|
| 7450 | + public function __construct($elements, $extendList = array(), $condition = null, $index = null, $currentFileInfo = null, $isReferenced = null) { |
|
| 7451 | 7451 | |
| 7452 | 7452 | $this->elements = $elements; |
| 7453 | 7453 | $this->elements_len = count($elements); |
| 7454 | 7454 | $this->extendList = $extendList; |
| 7455 | 7455 | $this->condition = $condition; |
| 7456 | - if( $currentFileInfo ){ |
|
| 7456 | + if ($currentFileInfo) { |
|
| 7457 | 7457 | $this->currentFileInfo = $currentFileInfo; |
| 7458 | 7458 | } |
| 7459 | 7459 | $this->isReferenced = $isReferenced; |
| 7460 | - if( !$condition ){ |
|
| 7460 | + if (!$condition) { |
|
| 7461 | 7461 | $this->evaldCondition = true; |
| 7462 | 7462 | } |
| 7463 | 7463 | |
@@ -7467,30 +7467,30 @@ discard block |
||
| 7467 | 7467 | public function accept($visitor) { |
| 7468 | 7468 | $this->elements = $visitor->visitArray($this->elements); |
| 7469 | 7469 | $this->extendList = $visitor->visitArray($this->extendList); |
| 7470 | - if( $this->condition ){ |
|
| 7470 | + if ($this->condition) { |
|
| 7471 | 7471 | $this->condition = $visitor->visitObj($this->condition); |
| 7472 | 7472 | } |
| 7473 | 7473 | |
| 7474 | - if( $visitor instanceof Less_Visitor_extendFinder ){ |
|
| 7474 | + if ($visitor instanceof Less_Visitor_extendFinder) { |
|
| 7475 | 7475 | $this->CacheElements(); |
| 7476 | 7476 | } |
| 7477 | 7477 | } |
| 7478 | 7478 | |
| 7479 | - public function createDerived( $elements, $extendList = null, $evaldCondition = null ){ |
|
| 7480 | - $newSelector = new Less_Tree_Selector( $elements, ($extendList ? $extendList : $this->extendList), null, $this->index, $this->currentFileInfo, $this->isReferenced); |
|
| 7479 | + public function createDerived($elements, $extendList = null, $evaldCondition = null) { |
|
| 7480 | + $newSelector = new Less_Tree_Selector($elements, ($extendList ? $extendList : $this->extendList), null, $this->index, $this->currentFileInfo, $this->isReferenced); |
|
| 7481 | 7481 | $newSelector->evaldCondition = $evaldCondition ? $evaldCondition : $this->evaldCondition; |
| 7482 | 7482 | return $newSelector; |
| 7483 | 7483 | } |
| 7484 | 7484 | |
| 7485 | 7485 | |
| 7486 | - public function match( $other ){ |
|
| 7486 | + public function match($other) { |
|
| 7487 | 7487 | |
| 7488 | - if( !$other->_oelements || ($this->elements_len < $other->_oelements_len) ){ |
|
| 7488 | + if (!$other->_oelements || ($this->elements_len<$other->_oelements_len)) { |
|
| 7489 | 7489 | return 0; |
| 7490 | 7490 | } |
| 7491 | 7491 | |
| 7492 | - for( $i = 0; $i < $other->_oelements_len; $i++ ){ |
|
| 7493 | - if( $this->elements[$i]->value !== $other->_oelements[$i]) { |
|
| 7492 | + for ($i = 0; $i<$other->_oelements_len; $i++) { |
|
| 7493 | + if ($this->elements[$i]->value!==$other->_oelements[$i]) { |
|
| 7494 | 7494 | return 0; |
| 7495 | 7495 | } |
| 7496 | 7496 | } |
@@ -7499,20 +7499,20 @@ discard block |
||
| 7499 | 7499 | } |
| 7500 | 7500 | |
| 7501 | 7501 | |
| 7502 | - public function CacheElements(){ |
|
| 7502 | + public function CacheElements() { |
|
| 7503 | 7503 | |
| 7504 | 7504 | $this->_oelements = array(); |
| 7505 | 7505 | $css = ''; |
| 7506 | 7506 | |
| 7507 | - foreach($this->elements as $v){ |
|
| 7507 | + foreach ($this->elements as $v) { |
|
| 7508 | 7508 | |
| 7509 | 7509 | $css .= $v->combinator; |
| 7510 | - if( !$v->value_is_object ){ |
|
| 7510 | + if (!$v->value_is_object) { |
|
| 7511 | 7511 | $css .= $v->value; |
| 7512 | 7512 | continue; |
| 7513 | 7513 | } |
| 7514 | 7514 | |
| 7515 | - if( !property_exists($v->value,'value') || !is_string($v->value->value) ){ |
|
| 7515 | + if (!property_exists($v->value, 'value') || !is_string($v->value->value)) { |
|
| 7516 | 7516 | $this->cacheable = false; |
| 7517 | 7517 | return; |
| 7518 | 7518 | } |
@@ -7520,67 +7520,67 @@ discard block |
||
| 7520 | 7520 | } |
| 7521 | 7521 | |
| 7522 | 7522 | $this->_oelements_len = preg_match_all('/[,&#\.\w-](?:[\w-]|(?:\\\\.))*/', $css, $matches); |
| 7523 | - if( $this->_oelements_len ){ |
|
| 7523 | + if ($this->_oelements_len) { |
|
| 7524 | 7524 | $this->_oelements = $matches[0]; |
| 7525 | 7525 | |
| 7526 | - if( $this->_oelements[0] === '&' ){ |
|
| 7526 | + if ($this->_oelements[0]==='&') { |
|
| 7527 | 7527 | array_shift($this->_oelements); |
| 7528 | 7528 | $this->_oelements_len--; |
| 7529 | 7529 | } |
| 7530 | 7530 | } |
| 7531 | 7531 | } |
| 7532 | 7532 | |
| 7533 | - public function isJustParentSelector(){ |
|
| 7533 | + public function isJustParentSelector() { |
|
| 7534 | 7534 | return !$this->mediaEmpty && |
| 7535 | - count($this->elements) === 1 && |
|
| 7536 | - $this->elements[0]->value === '&' && |
|
| 7537 | - ($this->elements[0]->combinator === ' ' || $this->elements[0]->combinator === ''); |
|
| 7535 | + count($this->elements)===1 && |
|
| 7536 | + $this->elements[0]->value==='&' && |
|
| 7537 | + ($this->elements[0]->combinator===' ' || $this->elements[0]->combinator===''); |
|
| 7538 | 7538 | } |
| 7539 | 7539 | |
| 7540 | 7540 | public function compile($env) { |
| 7541 | 7541 | |
| 7542 | 7542 | $elements = array(); |
| 7543 | - foreach($this->elements as $el){ |
|
| 7543 | + foreach ($this->elements as $el) { |
|
| 7544 | 7544 | $elements[] = $el->compile($env); |
| 7545 | 7545 | } |
| 7546 | 7546 | |
| 7547 | 7547 | $extendList = array(); |
| 7548 | - foreach($this->extendList as $el){ |
|
| 7548 | + foreach ($this->extendList as $el) { |
|
| 7549 | 7549 | $extendList[] = $el->compile($el); |
| 7550 | 7550 | } |
| 7551 | 7551 | |
| 7552 | 7552 | $evaldCondition = false; |
| 7553 | - if( $this->condition ){ |
|
| 7553 | + if ($this->condition) { |
|
| 7554 | 7554 | $evaldCondition = $this->condition->compile($env); |
| 7555 | 7555 | } |
| 7556 | 7556 | |
| 7557 | - return $this->createDerived( $elements, $extendList, $evaldCondition ); |
|
| 7557 | + return $this->createDerived($elements, $extendList, $evaldCondition); |
|
| 7558 | 7558 | } |
| 7559 | 7559 | |
| 7560 | 7560 | |
| 7561 | 7561 | /** |
| 7562 | 7562 | * @see Less_Tree::genCSS |
| 7563 | 7563 | */ |
| 7564 | - public function genCSS( $output, $firstSelector = true ){ |
|
| 7564 | + public function genCSS($output, $firstSelector = true) { |
|
| 7565 | 7565 | |
| 7566 | - if( !$firstSelector && $this->elements[0]->combinator === "" ){ |
|
| 7566 | + if (!$firstSelector && $this->elements[0]->combinator==="") { |
|
| 7567 | 7567 | $output->add(' ', $this->currentFileInfo, $this->index); |
| 7568 | 7568 | } |
| 7569 | 7569 | |
| 7570 | - foreach($this->elements as $element){ |
|
| 7571 | - $element->genCSS( $output ); |
|
| 7570 | + foreach ($this->elements as $element) { |
|
| 7571 | + $element->genCSS($output); |
|
| 7572 | 7572 | } |
| 7573 | 7573 | } |
| 7574 | 7574 | |
| 7575 | - public function markReferenced(){ |
|
| 7575 | + public function markReferenced() { |
|
| 7576 | 7576 | $this->isReferenced = true; |
| 7577 | 7577 | } |
| 7578 | 7578 | |
| 7579 | - public function getIsReferenced(){ |
|
| 7579 | + public function getIsReferenced() { |
|
| 7580 | 7580 | return !isset($this->currentFileInfo['reference']) || !$this->currentFileInfo['reference'] || $this->isReferenced; |
| 7581 | 7581 | } |
| 7582 | 7582 | |
| 7583 | - public function getIsOutput(){ |
|
| 7583 | + public function getIsOutput() { |
|
| 7584 | 7584 | return $this->evaldCondition; |
| 7585 | 7585 | } |
| 7586 | 7586 | |
@@ -7593,23 +7593,23 @@ discard block |
||
| 7593 | 7593 | * @package Less |
| 7594 | 7594 | * @subpackage tree |
| 7595 | 7595 | */ |
| 7596 | -class Less_Tree_UnicodeDescriptor extends Less_Tree{ |
|
| 7596 | +class Less_Tree_UnicodeDescriptor extends Less_Tree { |
|
| 7597 | 7597 | |
| 7598 | 7598 | public $value; |
| 7599 | 7599 | public $type = 'UnicodeDescriptor'; |
| 7600 | 7600 | |
| 7601 | - public function __construct($value){ |
|
| 7601 | + public function __construct($value) { |
|
| 7602 | 7602 | $this->value = $value; |
| 7603 | 7603 | } |
| 7604 | 7604 | |
| 7605 | 7605 | /** |
| 7606 | 7606 | * @see Less_Tree::genCSS |
| 7607 | 7607 | */ |
| 7608 | - public function genCSS( $output ){ |
|
| 7609 | - $output->add( $this->value ); |
|
| 7608 | + public function genCSS($output) { |
|
| 7609 | + $output->add($this->value); |
|
| 7610 | 7610 | } |
| 7611 | 7611 | |
| 7612 | - public function compile(){ |
|
| 7612 | + public function compile() { |
|
| 7613 | 7613 | return $this; |
| 7614 | 7614 | } |
| 7615 | 7615 | } |
@@ -7622,46 +7622,46 @@ discard block |
||
| 7622 | 7622 | * @package Less |
| 7623 | 7623 | * @subpackage tree |
| 7624 | 7624 | */ |
| 7625 | -class Less_Tree_Unit extends Less_Tree{ |
|
| 7625 | +class Less_Tree_Unit extends Less_Tree { |
|
| 7626 | 7626 | |
| 7627 | 7627 | var $numerator = array(); |
| 7628 | 7628 | var $denominator = array(); |
| 7629 | 7629 | public $backupUnit; |
| 7630 | 7630 | public $type = 'Unit'; |
| 7631 | 7631 | |
| 7632 | - public function __construct($numerator = array(), $denominator = array(), $backupUnit = null ){ |
|
| 7632 | + public function __construct($numerator = array(), $denominator = array(), $backupUnit = null) { |
|
| 7633 | 7633 | $this->numerator = $numerator; |
| 7634 | 7634 | $this->denominator = $denominator; |
| 7635 | 7635 | $this->backupUnit = $backupUnit; |
| 7636 | 7636 | } |
| 7637 | 7637 | |
| 7638 | - public function __clone(){ |
|
| 7638 | + public function __clone() { |
|
| 7639 | 7639 | } |
| 7640 | 7640 | |
| 7641 | 7641 | /** |
| 7642 | 7642 | * @see Less_Tree::genCSS |
| 7643 | 7643 | */ |
| 7644 | - public function genCSS( $output ){ |
|
| 7645 | - |
|
| 7646 | - if( $this->numerator ){ |
|
| 7647 | - $output->add( $this->numerator[0] ); |
|
| 7648 | - }elseif( $this->denominator ){ |
|
| 7649 | - $output->add( $this->denominator[0] ); |
|
| 7650 | - }elseif( !Less_Parser::$options['strictUnits'] && $this->backupUnit ){ |
|
| 7651 | - $output->add( $this->backupUnit ); |
|
| 7652 | - return ; |
|
| 7644 | + public function genCSS($output) { |
|
| 7645 | + |
|
| 7646 | + if ($this->numerator) { |
|
| 7647 | + $output->add($this->numerator[0]); |
|
| 7648 | + }elseif ($this->denominator) { |
|
| 7649 | + $output->add($this->denominator[0]); |
|
| 7650 | + }elseif (!Less_Parser::$options['strictUnits'] && $this->backupUnit) { |
|
| 7651 | + $output->add($this->backupUnit); |
|
| 7652 | + return; |
|
| 7653 | 7653 | } |
| 7654 | 7654 | } |
| 7655 | 7655 | |
| 7656 | - public function toString(){ |
|
| 7657 | - $returnStr = implode('*',$this->numerator); |
|
| 7658 | - foreach($this->denominator as $d){ |
|
| 7656 | + public function toString() { |
|
| 7657 | + $returnStr = implode('*', $this->numerator); |
|
| 7658 | + foreach ($this->denominator as $d) { |
|
| 7659 | 7659 | $returnStr .= '/'.$d; |
| 7660 | 7660 | } |
| 7661 | 7661 | return $returnStr; |
| 7662 | 7662 | } |
| 7663 | 7663 | |
| 7664 | - public function __toString(){ |
|
| 7664 | + public function __toString() { |
|
| 7665 | 7665 | return $this->toString(); |
| 7666 | 7666 | } |
| 7667 | 7667 | |
@@ -7670,45 +7670,45 @@ discard block |
||
| 7670 | 7670 | * @param Less_Tree_Unit $other |
| 7671 | 7671 | */ |
| 7672 | 7672 | public function compare($other) { |
| 7673 | - return $this->is( $other->toString() ) ? 0 : -1; |
|
| 7673 | + return $this->is($other->toString()) ? 0 : -1; |
|
| 7674 | 7674 | } |
| 7675 | 7675 | |
| 7676 | - public function is($unitString){ |
|
| 7677 | - return $this->toString() === $unitString; |
|
| 7676 | + public function is($unitString) { |
|
| 7677 | + return $this->toString()===$unitString; |
|
| 7678 | 7678 | } |
| 7679 | 7679 | |
| 7680 | - public function isLength(){ |
|
| 7680 | + public function isLength() { |
|
| 7681 | 7681 | $css = $this->toCSS(); |
| 7682 | - return !!preg_match('/px|em|%|in|cm|mm|pc|pt|ex/',$css); |
|
| 7682 | + return !!preg_match('/px|em|%|in|cm|mm|pc|pt|ex/', $css); |
|
| 7683 | 7683 | } |
| 7684 | 7684 | |
| 7685 | 7685 | public function isAngle() { |
| 7686 | - return isset( Less_Tree_UnitConversions::$angle[$this->toCSS()] ); |
|
| 7686 | + return isset(Less_Tree_UnitConversions::$angle[$this->toCSS()]); |
|
| 7687 | 7687 | } |
| 7688 | 7688 | |
| 7689 | - public function isEmpty(){ |
|
| 7689 | + public function isEmpty() { |
|
| 7690 | 7690 | return !$this->numerator && !$this->denominator; |
| 7691 | 7691 | } |
| 7692 | 7692 | |
| 7693 | 7693 | public function isSingular() { |
| 7694 | - return count($this->numerator) <= 1 && !$this->denominator; |
|
| 7694 | + return count($this->numerator)<=1 && !$this->denominator; |
|
| 7695 | 7695 | } |
| 7696 | 7696 | |
| 7697 | 7697 | |
| 7698 | - public function usedUnits(){ |
|
| 7698 | + public function usedUnits() { |
|
| 7699 | 7699 | $result = array(); |
| 7700 | 7700 | |
| 7701 | - foreach(Less_Tree_UnitConversions::$groups as $groupName){ |
|
| 7701 | + foreach (Less_Tree_UnitConversions::$groups as $groupName) { |
|
| 7702 | 7702 | $group = Less_Tree_UnitConversions::${$groupName}; |
| 7703 | 7703 | |
| 7704 | - foreach($this->numerator as $atomicUnit){ |
|
| 7705 | - if( isset($group[$atomicUnit]) && !isset($result[$groupName]) ){ |
|
| 7704 | + foreach ($this->numerator as $atomicUnit) { |
|
| 7705 | + if (isset($group[$atomicUnit]) && !isset($result[$groupName])) { |
|
| 7706 | 7706 | $result[$groupName] = $atomicUnit; |
| 7707 | 7707 | } |
| 7708 | 7708 | } |
| 7709 | 7709 | |
| 7710 | - foreach($this->denominator as $atomicUnit){ |
|
| 7711 | - if( isset($group[$atomicUnit]) && !isset($result[$groupName]) ){ |
|
| 7710 | + foreach ($this->denominator as $atomicUnit) { |
|
| 7711 | + if (isset($group[$atomicUnit]) && !isset($result[$groupName])) { |
|
| 7712 | 7712 | $result[$groupName] = $atomicUnit; |
| 7713 | 7713 | } |
| 7714 | 7714 | } |
@@ -7717,40 +7717,40 @@ discard block |
||
| 7717 | 7717 | return $result; |
| 7718 | 7718 | } |
| 7719 | 7719 | |
| 7720 | - public function cancel(){ |
|
| 7720 | + public function cancel() { |
|
| 7721 | 7721 | $counter = array(); |
| 7722 | 7722 | $backup = null; |
| 7723 | 7723 | |
| 7724 | - foreach($this->numerator as $atomicUnit){ |
|
| 7725 | - if( !$backup ){ |
|
| 7724 | + foreach ($this->numerator as $atomicUnit) { |
|
| 7725 | + if (!$backup) { |
|
| 7726 | 7726 | $backup = $atomicUnit; |
| 7727 | 7727 | } |
| 7728 | - $counter[$atomicUnit] = ( isset($counter[$atomicUnit]) ? $counter[$atomicUnit] : 0) + 1; |
|
| 7728 | + $counter[$atomicUnit] = (isset($counter[$atomicUnit]) ? $counter[$atomicUnit] : 0)+1; |
|
| 7729 | 7729 | } |
| 7730 | 7730 | |
| 7731 | - foreach($this->denominator as $atomicUnit){ |
|
| 7732 | - if( !$backup ){ |
|
| 7731 | + foreach ($this->denominator as $atomicUnit) { |
|
| 7732 | + if (!$backup) { |
|
| 7733 | 7733 | $backup = $atomicUnit; |
| 7734 | 7734 | } |
| 7735 | - $counter[$atomicUnit] = ( isset($counter[$atomicUnit]) ? $counter[$atomicUnit] : 0) - 1; |
|
| 7735 | + $counter[$atomicUnit] = (isset($counter[$atomicUnit]) ? $counter[$atomicUnit] : 0)-1; |
|
| 7736 | 7736 | } |
| 7737 | 7737 | |
| 7738 | 7738 | $this->numerator = array(); |
| 7739 | 7739 | $this->denominator = array(); |
| 7740 | 7740 | |
| 7741 | - foreach($counter as $atomicUnit => $count){ |
|
| 7742 | - if( $count > 0 ){ |
|
| 7743 | - for( $i = 0; $i < $count; $i++ ){ |
|
| 7741 | + foreach ($counter as $atomicUnit => $count) { |
|
| 7742 | + if ($count>0) { |
|
| 7743 | + for ($i = 0; $i<$count; $i++) { |
|
| 7744 | 7744 | $this->numerator[] = $atomicUnit; |
| 7745 | 7745 | } |
| 7746 | - }elseif( $count < 0 ){ |
|
| 7747 | - for( $i = 0; $i < -$count; $i++ ){ |
|
| 7746 | + }elseif ($count<0) { |
|
| 7747 | + for ($i = 0; $i<-$count; $i++) { |
|
| 7748 | 7748 | $this->denominator[] = $atomicUnit; |
| 7749 | 7749 | } |
| 7750 | 7750 | } |
| 7751 | 7751 | } |
| 7752 | 7752 | |
| 7753 | - if( !$this->numerator && !$this->denominator && $backup ){ |
|
| 7753 | + if (!$this->numerator && !$this->denominator && $backup) { |
|
| 7754 | 7754 | $this->backupUnit = $backup; |
| 7755 | 7755 | } |
| 7756 | 7756 | |
@@ -7769,9 +7769,9 @@ discard block |
||
| 7769 | 7769 | * @package Less |
| 7770 | 7770 | * @subpackage tree |
| 7771 | 7771 | */ |
| 7772 | -class Less_Tree_UnitConversions{ |
|
| 7772 | +class Less_Tree_UnitConversions { |
|
| 7773 | 7773 | |
| 7774 | - public static $groups = array('length','duration','angle'); |
|
| 7774 | + public static $groups = array('length', 'duration', 'angle'); |
|
| 7775 | 7775 | |
| 7776 | 7776 | public static $length = array( |
| 7777 | 7777 | 'm'=> 1, |
@@ -7789,9 +7789,9 @@ discard block |
||
| 7789 | 7789 | ); |
| 7790 | 7790 | |
| 7791 | 7791 | public static $angle = array( |
| 7792 | - 'rad' => 0.1591549430919, // 1/(2*M_PI), |
|
| 7793 | - 'deg' => 0.002777778, // 1/360, |
|
| 7794 | - 'grad'=> 0.0025, // 1/400, |
|
| 7792 | + 'rad' => 0.1591549430919, // 1/(2*M_PI), |
|
| 7793 | + 'deg' => 0.002777778, // 1/360, |
|
| 7794 | + 'grad'=> 0.0025, // 1/400, |
|
| 7795 | 7795 | 'turn'=> 1 |
| 7796 | 7796 | ); |
| 7797 | 7797 | |
@@ -7803,7 +7803,7 @@ discard block |
||
| 7803 | 7803 | * @package Less |
| 7804 | 7804 | * @subpackage tree |
| 7805 | 7805 | */ |
| 7806 | -class Less_Tree_Url extends Less_Tree{ |
|
| 7806 | +class Less_Tree_Url extends Less_Tree { |
|
| 7807 | 7807 | |
| 7808 | 7808 | public $attrs; |
| 7809 | 7809 | public $value; |
@@ -7811,57 +7811,57 @@ discard block |
||
| 7811 | 7811 | public $isEvald; |
| 7812 | 7812 | public $type = 'Url'; |
| 7813 | 7813 | |
| 7814 | - public function __construct($value, $currentFileInfo = null, $isEvald = null){ |
|
| 7814 | + public function __construct($value, $currentFileInfo = null, $isEvald = null) { |
|
| 7815 | 7815 | $this->value = $value; |
| 7816 | 7816 | $this->currentFileInfo = $currentFileInfo; |
| 7817 | 7817 | $this->isEvald = $isEvald; |
| 7818 | 7818 | } |
| 7819 | 7819 | |
| 7820 | - public function accept( $visitor ){ |
|
| 7820 | + public function accept($visitor) { |
|
| 7821 | 7821 | $this->value = $visitor->visitObj($this->value); |
| 7822 | 7822 | } |
| 7823 | 7823 | |
| 7824 | 7824 | /** |
| 7825 | 7825 | * @see Less_Tree::genCSS |
| 7826 | 7826 | */ |
| 7827 | - public function genCSS( $output ){ |
|
| 7828 | - $output->add( 'url(' ); |
|
| 7829 | - $this->value->genCSS( $output ); |
|
| 7830 | - $output->add( ')' ); |
|
| 7827 | + public function genCSS($output) { |
|
| 7828 | + $output->add('url('); |
|
| 7829 | + $this->value->genCSS($output); |
|
| 7830 | + $output->add(')'); |
|
| 7831 | 7831 | } |
| 7832 | 7832 | |
| 7833 | 7833 | /** |
| 7834 | 7834 | * @param Less_Functions $ctx |
| 7835 | 7835 | */ |
| 7836 | - public function compile($ctx){ |
|
| 7836 | + public function compile($ctx) { |
|
| 7837 | 7837 | $val = $this->value->compile($ctx); |
| 7838 | 7838 | |
| 7839 | - if( !$this->isEvald ){ |
|
| 7839 | + if (!$this->isEvald) { |
|
| 7840 | 7840 | // Add the base path if the URL is relative |
| 7841 | - if( Less_Parser::$options['relativeUrls'] |
|
| 7841 | + if (Less_Parser::$options['relativeUrls'] |
|
| 7842 | 7842 | && $this->currentFileInfo |
| 7843 | 7843 | && is_string($val->value) |
| 7844 | 7844 | && Less_Environment::isPathRelative($val->value) |
| 7845 | - ){ |
|
| 7845 | + ) { |
|
| 7846 | 7846 | $rootpath = $this->currentFileInfo['uri_root']; |
| 7847 | - if ( !$val->quote ){ |
|
| 7848 | - $rootpath = preg_replace('/[\(\)\'"\s]/', '\\$1', $rootpath ); |
|
| 7847 | + if (!$val->quote) { |
|
| 7848 | + $rootpath = preg_replace('/[\(\)\'"\s]/', '\\$1', $rootpath); |
|
| 7849 | 7849 | } |
| 7850 | - $val->value = $rootpath . $val->value; |
|
| 7850 | + $val->value = $rootpath.$val->value; |
|
| 7851 | 7851 | } |
| 7852 | 7852 | |
| 7853 | - $val->value = Less_Environment::normalizePath( $val->value); |
|
| 7853 | + $val->value = Less_Environment::normalizePath($val->value); |
|
| 7854 | 7854 | } |
| 7855 | 7855 | |
| 7856 | 7856 | // Add cache buster if enabled |
| 7857 | - if( Less_Parser::$options['urlArgs'] ){ |
|
| 7858 | - if( !preg_match('/^\s*data:/',$val->value) ){ |
|
| 7859 | - $delimiter = strpos($val->value,'?') === false ? '?' : '&'; |
|
| 7860 | - $urlArgs = $delimiter . Less_Parser::$options['urlArgs']; |
|
| 7861 | - $hash_pos = strpos($val->value,'#'); |
|
| 7862 | - if( $hash_pos !== false ){ |
|
| 7863 | - $val->value = substr_replace($val->value,$urlArgs, $hash_pos, 0); |
|
| 7864 | - } else { |
|
| 7857 | + if (Less_Parser::$options['urlArgs']) { |
|
| 7858 | + if (!preg_match('/^\s*data:/', $val->value)) { |
|
| 7859 | + $delimiter = strpos($val->value, '?')===false ? '?' : '&'; |
|
| 7860 | + $urlArgs = $delimiter.Less_Parser::$options['urlArgs']; |
|
| 7861 | + $hash_pos = strpos($val->value, '#'); |
|
| 7862 | + if ($hash_pos!==false) { |
|
| 7863 | + $val->value = substr_replace($val->value, $urlArgs, $hash_pos, 0); |
|
| 7864 | + }else { |
|
| 7865 | 7865 | $val->value .= $urlArgs; |
| 7866 | 7866 | } |
| 7867 | 7867 | } |
@@ -7879,12 +7879,12 @@ discard block |
||
| 7879 | 7879 | * @package Less |
| 7880 | 7880 | * @subpackage tree |
| 7881 | 7881 | */ |
| 7882 | -class Less_Tree_Value extends Less_Tree{ |
|
| 7882 | +class Less_Tree_Value extends Less_Tree { |
|
| 7883 | 7883 | |
| 7884 | 7884 | public $type = 'Value'; |
| 7885 | 7885 | public $value; |
| 7886 | 7886 | |
| 7887 | - public function __construct($value){ |
|
| 7887 | + public function __construct($value) { |
|
| 7888 | 7888 | $this->value = $value; |
| 7889 | 7889 | } |
| 7890 | 7890 | |
@@ -7892,14 +7892,14 @@ discard block |
||
| 7892 | 7892 | $this->value = $visitor->visitArray($this->value); |
| 7893 | 7893 | } |
| 7894 | 7894 | |
| 7895 | - public function compile($env){ |
|
| 7895 | + public function compile($env) { |
|
| 7896 | 7896 | |
| 7897 | 7897 | $ret = array(); |
| 7898 | 7898 | $i = 0; |
| 7899 | - foreach($this->value as $i => $v){ |
|
| 7899 | + foreach ($this->value as $i => $v) { |
|
| 7900 | 7900 | $ret[] = $v->compile($env); |
| 7901 | 7901 | } |
| 7902 | - if( $i > 0 ){ |
|
| 7902 | + if ($i>0) { |
|
| 7903 | 7903 | return new Less_Tree_Value($ret); |
| 7904 | 7904 | } |
| 7905 | 7905 | return $ret[0]; |
@@ -7908,12 +7908,12 @@ discard block |
||
| 7908 | 7908 | /** |
| 7909 | 7909 | * @see Less_Tree::genCSS |
| 7910 | 7910 | */ |
| 7911 | - function genCSS( $output ){ |
|
| 7911 | + function genCSS($output) { |
|
| 7912 | 7912 | $len = count($this->value); |
| 7913 | - for($i = 0; $i < $len; $i++ ){ |
|
| 7914 | - $this->value[$i]->genCSS( $output ); |
|
| 7915 | - if( $i+1 < $len ){ |
|
| 7916 | - $output->add( Less_Environment::$_outputMap[','] ); |
|
| 7913 | + for ($i = 0; $i<$len; $i++) { |
|
| 7914 | + $this->value[$i]->genCSS($output); |
|
| 7915 | + if ($i+1<$len) { |
|
| 7916 | + $output->add(Less_Environment::$_outputMap[',']); |
|
| 7917 | 7917 | } |
| 7918 | 7918 | } |
| 7919 | 7919 | } |
@@ -7927,7 +7927,7 @@ discard block |
||
| 7927 | 7927 | * @package Less |
| 7928 | 7928 | * @subpackage tree |
| 7929 | 7929 | */ |
| 7930 | -class Less_Tree_Variable extends Less_Tree{ |
|
| 7930 | +class Less_Tree_Variable extends Less_Tree { |
|
| 7931 | 7931 | |
| 7932 | 7932 | public $name; |
| 7933 | 7933 | public $index; |
@@ -7946,35 +7946,35 @@ discard block |
||
| 7946 | 7946 | |
| 7947 | 7947 | public function compile($env) { |
| 7948 | 7948 | |
| 7949 | - if( $this->name[1] === '@' ){ |
|
| 7950 | - $v = new Less_Tree_Variable(substr($this->name, 1), $this->index + 1, $this->currentFileInfo); |
|
| 7951 | - $name = '@' . $v->compile($env)->value; |
|
| 7952 | - }else{ |
|
| 7949 | + if ($this->name[1]==='@') { |
|
| 7950 | + $v = new Less_Tree_Variable(substr($this->name, 1), $this->index+1, $this->currentFileInfo); |
|
| 7951 | + $name = '@'.$v->compile($env)->value; |
|
| 7952 | + }else { |
|
| 7953 | 7953 | $name = $this->name; |
| 7954 | 7954 | } |
| 7955 | 7955 | |
| 7956 | 7956 | if ($this->evaluating) { |
| 7957 | - throw new Less_Exception_Compiler("Recursive variable definition for " . $name, null, $this->index, $this->currentFileInfo); |
|
| 7957 | + throw new Less_Exception_Compiler("Recursive variable definition for ".$name, null, $this->index, $this->currentFileInfo); |
|
| 7958 | 7958 | } |
| 7959 | 7959 | |
| 7960 | 7960 | $this->evaluating = true; |
| 7961 | 7961 | |
| 7962 | - foreach($env->frames as $frame){ |
|
| 7963 | - if( $v = $frame->variable($name) ){ |
|
| 7962 | + foreach ($env->frames as $frame) { |
|
| 7963 | + if ($v = $frame->variable($name)) { |
|
| 7964 | 7964 | $r = $v->value->compile($env); |
| 7965 | 7965 | $this->evaluating = false; |
| 7966 | 7966 | return $r; |
| 7967 | 7967 | } |
| 7968 | 7968 | } |
| 7969 | 7969 | |
| 7970 | - throw new Less_Exception_Compiler("variable " . $name . " is undefined in file ".$this->currentFileInfo["filename"], null, $this->index, $this->currentFileInfo); |
|
| 7970 | + throw new Less_Exception_Compiler("variable ".$name." is undefined in file ".$this->currentFileInfo["filename"], null, $this->index, $this->currentFileInfo); |
|
| 7971 | 7971 | } |
| 7972 | 7972 | |
| 7973 | 7973 | } |
| 7974 | 7974 | |
| 7975 | 7975 | |
| 7976 | 7976 | |
| 7977 | -class Less_Tree_Mixin_Call extends Less_Tree{ |
|
| 7977 | +class Less_Tree_Mixin_Call extends Less_Tree { |
|
| 7978 | 7978 | |
| 7979 | 7979 | public $selector; |
| 7980 | 7980 | public $arguments; |
@@ -7988,7 +7988,7 @@ discard block |
||
| 7988 | 7988 | * less.js: tree.mixin.Call |
| 7989 | 7989 | * |
| 7990 | 7990 | */ |
| 7991 | - public function __construct($elements, $args, $index, $currentFileInfo, $important = false){ |
|
| 7991 | + public function __construct($elements, $args, $index, $currentFileInfo, $important = false) { |
|
| 7992 | 7992 | $this->selector = new Less_Tree_Selector($elements); |
| 7993 | 7993 | $this->arguments = $args; |
| 7994 | 7994 | $this->index = $index; |
@@ -8002,7 +8002,7 @@ discard block |
||
| 8002 | 8002 | //} |
| 8003 | 8003 | |
| 8004 | 8004 | |
| 8005 | - public function compile($env){ |
|
| 8005 | + public function compile($env) { |
|
| 8006 | 8006 | |
| 8007 | 8007 | $rules = array(); |
| 8008 | 8008 | $match = false; |
@@ -8012,15 +8012,15 @@ discard block |
||
| 8012 | 8012 | $conditionResult = array(); |
| 8013 | 8013 | |
| 8014 | 8014 | $args = array(); |
| 8015 | - foreach($this->arguments as $a){ |
|
| 8016 | - $args[] = array('name'=> $a['name'], 'value' => $a['value']->compile($env) ); |
|
| 8015 | + foreach ($this->arguments as $a) { |
|
| 8016 | + $args[] = array('name'=> $a['name'], 'value' => $a['value']->compile($env)); |
|
| 8017 | 8017 | } |
| 8018 | 8018 | |
| 8019 | - foreach($env->frames as $frame){ |
|
| 8019 | + foreach ($env->frames as $frame) { |
|
| 8020 | 8020 | |
| 8021 | 8021 | $mixins = $frame->find($this->selector); |
| 8022 | 8022 | |
| 8023 | - if( !$mixins ){ |
|
| 8023 | + if (!$mixins) { |
|
| 8024 | 8024 | continue; |
| 8025 | 8025 | } |
| 8026 | 8026 | |
@@ -8035,31 +8035,31 @@ discard block |
||
| 8035 | 8035 | // we make a final decision. |
| 8036 | 8036 | |
| 8037 | 8037 | $mixins_len = count($mixins); |
| 8038 | - for( $m = 0; $m < $mixins_len; $m++ ){ |
|
| 8038 | + for ($m = 0; $m<$mixins_len; $m++) { |
|
| 8039 | 8039 | $mixin = $mixins[$m]; |
| 8040 | 8040 | |
| 8041 | - if( $this->IsRecursive( $env, $mixin ) ){ |
|
| 8041 | + if ($this->IsRecursive($env, $mixin)) { |
|
| 8042 | 8042 | continue; |
| 8043 | 8043 | } |
| 8044 | 8044 | |
| 8045 | - if( $mixin->matchArgs($args, $env) ){ |
|
| 8045 | + if ($mixin->matchArgs($args, $env)) { |
|
| 8046 | 8046 | |
| 8047 | 8047 | $candidate = array('mixin' => $mixin, 'group' => $defNone); |
| 8048 | 8048 | |
| 8049 | - if( $mixin instanceof Less_Tree_Ruleset ){ |
|
| 8049 | + if ($mixin instanceof Less_Tree_Ruleset) { |
|
| 8050 | 8050 | |
| 8051 | - for( $f = 0; $f < 2; $f++ ){ |
|
| 8051 | + for ($f = 0; $f<2; $f++) { |
|
| 8052 | 8052 | Less_Tree_DefaultFunc::value($f); |
| 8053 | - $conditionResult[$f] = $mixin->matchCondition( $args, $env); |
|
| 8053 | + $conditionResult[$f] = $mixin->matchCondition($args, $env); |
|
| 8054 | 8054 | } |
| 8055 | - if( $conditionResult[0] || $conditionResult[1] ){ |
|
| 8056 | - if( $conditionResult[0] != $conditionResult[1] ){ |
|
| 8055 | + if ($conditionResult[0] || $conditionResult[1]) { |
|
| 8056 | + if ($conditionResult[0]!=$conditionResult[1]) { |
|
| 8057 | 8057 | $candidate['group'] = $conditionResult[1] ? $defTrue : $defFalse; |
| 8058 | 8058 | } |
| 8059 | 8059 | |
| 8060 | 8060 | $candidates[] = $candidate; |
| 8061 | 8061 | } |
| 8062 | - }else{ |
|
| 8062 | + }else { |
|
| 8063 | 8063 | $candidates[] = $candidate; |
| 8064 | 8064 | } |
| 8065 | 8065 | |
@@ -8071,29 +8071,29 @@ discard block |
||
| 8071 | 8071 | |
| 8072 | 8072 | |
| 8073 | 8073 | $count = array(0, 0, 0); |
| 8074 | - for( $m = 0; $m < count($candidates); $m++ ){ |
|
| 8075 | - $count[ $candidates[$m]['group'] ]++; |
|
| 8074 | + for ($m = 0; $m<count($candidates); $m++) { |
|
| 8075 | + $count[$candidates[$m]['group']]++; |
|
| 8076 | 8076 | } |
| 8077 | 8077 | |
| 8078 | - if( $count[$defNone] > 0 ){ |
|
| 8078 | + if ($count[$defNone]>0) { |
|
| 8079 | 8079 | $defaultResult = $defFalse; |
| 8080 | - } else { |
|
| 8080 | + }else { |
|
| 8081 | 8081 | $defaultResult = $defTrue; |
| 8082 | - if( ($count[$defTrue] + $count[$defFalse]) > 1 ){ |
|
| 8083 | - throw new Exception( 'Ambiguous use of `default()` found when matching for `'. $this->format($args) + '`' ); |
|
| 8082 | + if (($count[$defTrue]+$count[$defFalse])>1) { |
|
| 8083 | + throw new Exception('Ambiguous use of `default()` found when matching for `'.$this->format($args)+'`'); |
|
| 8084 | 8084 | } |
| 8085 | 8085 | } |
| 8086 | 8086 | |
| 8087 | 8087 | |
| 8088 | 8088 | $candidates_length = count($candidates); |
| 8089 | - $length_1 = ($candidates_length == 1); |
|
| 8089 | + $length_1 = ($candidates_length==1); |
|
| 8090 | 8090 | |
| 8091 | - for( $m = 0; $m < $candidates_length; $m++){ |
|
| 8091 | + for ($m = 0; $m<$candidates_length; $m++) { |
|
| 8092 | 8092 | $candidate = $candidates[$m]['group']; |
| 8093 | - if( ($candidate === $defNone) || ($candidate === $defaultResult) ){ |
|
| 8094 | - try{ |
|
| 8093 | + if (($candidate===$defNone) || ($candidate===$defaultResult)) { |
|
| 8094 | + try { |
|
| 8095 | 8095 | $mixin = $candidates[$m]['mixin']; |
| 8096 | - if( !($mixin instanceof Less_Tree_Mixin_Definition) ){ |
|
| 8096 | + if (!($mixin instanceof Less_Tree_Mixin_Definition)) { |
|
| 8097 | 8097 | $mixin = new Less_Tree_Mixin_Definition('', array(), $mixin->rules, null, false); |
| 8098 | 8098 | $mixin->originalRuleset = $mixins[$m]->originalRuleset; |
| 8099 | 8099 | } |
@@ -8105,8 +8105,8 @@ discard block |
||
| 8105 | 8105 | } |
| 8106 | 8106 | } |
| 8107 | 8107 | |
| 8108 | - if( $match ){ |
|
| 8109 | - if( !$this->currentFileInfo || !isset($this->currentFileInfo['reference']) || !$this->currentFileInfo['reference'] ){ |
|
| 8108 | + if ($match) { |
|
| 8109 | + if (!$this->currentFileInfo || !isset($this->currentFileInfo['reference']) || !$this->currentFileInfo['reference']) { |
|
| 8110 | 8110 | Less_Tree::ReferencedArray($rules); |
| 8111 | 8111 | } |
| 8112 | 8112 | |
@@ -8114,11 +8114,11 @@ discard block |
||
| 8114 | 8114 | } |
| 8115 | 8115 | } |
| 8116 | 8116 | |
| 8117 | - if( $isOneFound ){ |
|
| 8118 | - throw new Less_Exception_Compiler('No matching definition was found for `'.$this->Format( $args ).'`', null, $this->index, $this->currentFileInfo); |
|
| 8117 | + if ($isOneFound) { |
|
| 8118 | + throw new Less_Exception_Compiler('No matching definition was found for `'.$this->Format($args).'`', null, $this->index, $this->currentFileInfo); |
|
| 8119 | 8119 | |
| 8120 | - }else{ |
|
| 8121 | - throw new Less_Exception_Compiler(trim($this->selector->toCSS()) . " is undefined in ".$this->currentFileInfo['filename'], null, $this->index); |
|
| 8120 | + }else { |
|
| 8121 | + throw new Less_Exception_Compiler(trim($this->selector->toCSS())." is undefined in ".$this->currentFileInfo['filename'], null, $this->index); |
|
| 8122 | 8122 | } |
| 8123 | 8123 | |
| 8124 | 8124 | } |
@@ -8127,23 +8127,23 @@ discard block |
||
| 8127 | 8127 | * Format the args for use in exception messages |
| 8128 | 8128 | * |
| 8129 | 8129 | */ |
| 8130 | - private function Format($args){ |
|
| 8130 | + private function Format($args) { |
|
| 8131 | 8131 | $message = array(); |
| 8132 | - if( $args ){ |
|
| 8133 | - foreach($args as $a){ |
|
| 8132 | + if ($args) { |
|
| 8133 | + foreach ($args as $a) { |
|
| 8134 | 8134 | $argValue = ''; |
| 8135 | - if( $a['name'] ){ |
|
| 8135 | + if ($a['name']) { |
|
| 8136 | 8136 | $argValue += $a['name']+':'; |
| 8137 | 8137 | } |
| 8138 | - if( is_object($a['value']) ){ |
|
| 8138 | + if (is_object($a['value'])) { |
|
| 8139 | 8139 | $argValue += $a['value']->toCSS(); |
| 8140 | - }else{ |
|
| 8140 | + }else { |
|
| 8141 | 8141 | $argValue += '???'; |
| 8142 | 8142 | } |
| 8143 | 8143 | $message[] = $argValue; |
| 8144 | 8144 | } |
| 8145 | 8145 | } |
| 8146 | - return implode(', ',$message); |
|
| 8146 | + return implode(', ', $message); |
|
| 8147 | 8147 | } |
| 8148 | 8148 | |
| 8149 | 8149 | |
@@ -8152,16 +8152,16 @@ discard block |
||
| 8152 | 8152 | * |
| 8153 | 8153 | * @return bool |
| 8154 | 8154 | */ |
| 8155 | - private function IsRecursive( $env, $mixin ){ |
|
| 8155 | + private function IsRecursive($env, $mixin) { |
|
| 8156 | 8156 | |
| 8157 | - foreach($env->frames as $recur_frame){ |
|
| 8158 | - if( !($mixin instanceof Less_Tree_Mixin_Definition) ){ |
|
| 8157 | + foreach ($env->frames as $recur_frame) { |
|
| 8158 | + if (!($mixin instanceof Less_Tree_Mixin_Definition)) { |
|
| 8159 | 8159 | |
| 8160 | - if( $mixin === $recur_frame ){ |
|
| 8160 | + if ($mixin===$recur_frame) { |
|
| 8161 | 8161 | return true; |
| 8162 | 8162 | } |
| 8163 | 8163 | |
| 8164 | - if( isset($recur_frame->originalRuleset) && $mixin->ruleset_id === $recur_frame->originalRuleset ){ |
|
| 8164 | + if (isset($recur_frame->originalRuleset) && $mixin->ruleset_id===$recur_frame->originalRuleset) { |
|
| 8165 | 8165 | return true; |
| 8166 | 8166 | } |
| 8167 | 8167 | } |
@@ -8175,34 +8175,34 @@ discard block |
||
| 8175 | 8175 | |
| 8176 | 8176 | |
| 8177 | 8177 | |
| 8178 | -class Less_Tree_Mixin_Definition extends Less_Tree_Ruleset{ |
|
| 8178 | +class Less_Tree_Mixin_Definition extends Less_Tree_Ruleset { |
|
| 8179 | 8179 | public $name; |
| 8180 | 8180 | public $selectors; |
| 8181 | 8181 | public $params; |
| 8182 | - public $arity = 0; |
|
| 8182 | + public $arity = 0; |
|
| 8183 | 8183 | public $rules; |
| 8184 | 8184 | public $lookups = array(); |
| 8185 | 8185 | public $required = 0; |
| 8186 | - public $frames = array(); |
|
| 8186 | + public $frames = array(); |
|
| 8187 | 8187 | public $condition; |
| 8188 | 8188 | public $variadic; |
| 8189 | - public $type = 'MixinDefinition'; |
|
| 8189 | + public $type = 'MixinDefinition'; |
|
| 8190 | 8190 | |
| 8191 | 8191 | |
| 8192 | 8192 | // less.js : /lib/less/tree/mixin.js : tree.mixin.Definition |
| 8193 | - public function __construct($name, $params, $rules, $condition, $variadic = false, $frames = array() ){ |
|
| 8193 | + public function __construct($name, $params, $rules, $condition, $variadic = false, $frames = array()) { |
|
| 8194 | 8194 | $this->name = $name; |
| 8195 | - $this->selectors = array(new Less_Tree_Selector(array( new Less_Tree_Element(null, $name)))); |
|
| 8195 | + $this->selectors = array(new Less_Tree_Selector(array(new Less_Tree_Element(null, $name)))); |
|
| 8196 | 8196 | |
| 8197 | 8197 | $this->params = $params; |
| 8198 | 8198 | $this->condition = $condition; |
| 8199 | 8199 | $this->variadic = $variadic; |
| 8200 | 8200 | $this->rules = $rules; |
| 8201 | 8201 | |
| 8202 | - if( $params ){ |
|
| 8202 | + if ($params) { |
|
| 8203 | 8203 | $this->arity = count($params); |
| 8204 | - foreach( $params as $p ){ |
|
| 8205 | - if (! isset($p['name']) || ($p['name'] && !isset($p['value']))) { |
|
| 8204 | + foreach ($params as $p) { |
|
| 8205 | + if (!isset($p['name']) || ($p['name'] && !isset($p['value']))) { |
|
| 8206 | 8206 | $this->required++; |
| 8207 | 8207 | } |
| 8208 | 8208 | } |
@@ -8221,29 +8221,29 @@ discard block |
||
| 8221 | 8221 | //} |
| 8222 | 8222 | |
| 8223 | 8223 | |
| 8224 | - public function toCSS(){ |
|
| 8224 | + public function toCSS() { |
|
| 8225 | 8225 | return ''; |
| 8226 | 8226 | } |
| 8227 | 8227 | |
| 8228 | 8228 | // less.js : /lib/less/tree/mixin.js : tree.mixin.Definition.evalParams |
| 8229 | - public function compileParams($env, $mixinFrames, $args = array() , &$evaldArguments = array() ){ |
|
| 8229 | + public function compileParams($env, $mixinFrames, $args = array(), &$evaldArguments = array()) { |
|
| 8230 | 8230 | $frame = new Less_Tree_Ruleset(null, array()); |
| 8231 | 8231 | $params = $this->params; |
| 8232 | 8232 | $mixinEnv = null; |
| 8233 | 8233 | $argsLength = 0; |
| 8234 | 8234 | |
| 8235 | - if( $args ){ |
|
| 8235 | + if ($args) { |
|
| 8236 | 8236 | $argsLength = count($args); |
| 8237 | - for($i = 0; $i < $argsLength; $i++ ){ |
|
| 8237 | + for ($i = 0; $i<$argsLength; $i++) { |
|
| 8238 | 8238 | $arg = $args[$i]; |
| 8239 | 8239 | |
| 8240 | - if( $arg && $arg['name'] ){ |
|
| 8240 | + if ($arg && $arg['name']) { |
|
| 8241 | 8241 | $isNamedFound = false; |
| 8242 | 8242 | |
| 8243 | - foreach($params as $j => $param){ |
|
| 8244 | - if( !isset($evaldArguments[$j]) && $arg['name'] === $params[$j]['name']) { |
|
| 8243 | + foreach ($params as $j => $param) { |
|
| 8244 | + if (!isset($evaldArguments[$j]) && $arg['name']===$params[$j]['name']) { |
|
| 8245 | 8245 | $evaldArguments[$j] = $arg['value']->compile($env); |
| 8246 | - array_unshift($frame->rules, new Less_Tree_Rule( $arg['name'], $arg['value']->compile($env) ) ); |
|
| 8246 | + array_unshift($frame->rules, new Less_Tree_Rule($arg['name'], $arg['value']->compile($env))); |
|
| 8247 | 8247 | $isNamedFound = true; |
| 8248 | 8248 | break; |
| 8249 | 8249 | } |
@@ -8253,48 +8253,48 @@ discard block |
||
| 8253 | 8253 | $i--; |
| 8254 | 8254 | $argsLength--; |
| 8255 | 8255 | continue; |
| 8256 | - } else { |
|
| 8257 | - throw new Less_Exception_Compiler("Named argument for " . $this->name .' '.$args[$i]['name'] . ' not found'); |
|
| 8256 | + }else { |
|
| 8257 | + throw new Less_Exception_Compiler("Named argument for ".$this->name.' '.$args[$i]['name'].' not found'); |
|
| 8258 | 8258 | } |
| 8259 | 8259 | } |
| 8260 | 8260 | } |
| 8261 | 8261 | } |
| 8262 | 8262 | |
| 8263 | 8263 | $argIndex = 0; |
| 8264 | - foreach($params as $i => $param){ |
|
| 8264 | + foreach ($params as $i => $param) { |
|
| 8265 | 8265 | |
| 8266 | - if ( isset($evaldArguments[$i]) ){ continue; } |
|
| 8266 | + if (isset($evaldArguments[$i])) { continue; } |
|
| 8267 | 8267 | |
| 8268 | 8268 | $arg = null; |
| 8269 | - if( isset($args[$argIndex]) ){ |
|
| 8269 | + if (isset($args[$argIndex])) { |
|
| 8270 | 8270 | $arg = $args[$argIndex]; |
| 8271 | 8271 | } |
| 8272 | 8272 | |
| 8273 | 8273 | if (isset($param['name']) && $param['name']) { |
| 8274 | 8274 | |
| 8275 | - if( isset($param['variadic']) ){ |
|
| 8275 | + if (isset($param['variadic'])) { |
|
| 8276 | 8276 | $varargs = array(); |
| 8277 | - for ($j = $argIndex; $j < $argsLength; $j++) { |
|
| 8277 | + for ($j = $argIndex; $j<$argsLength; $j++) { |
|
| 8278 | 8278 | $varargs[] = $args[$j]['value']->compile($env); |
| 8279 | 8279 | } |
| 8280 | 8280 | $expression = new Less_Tree_Expression($varargs); |
| 8281 | 8281 | array_unshift($frame->rules, new Less_Tree_Rule($param['name'], $expression->compile($env))); |
| 8282 | - }else{ |
|
| 8282 | + }else { |
|
| 8283 | 8283 | $val = ($arg && $arg['value']) ? $arg['value'] : false; |
| 8284 | 8284 | |
| 8285 | 8285 | if ($val) { |
| 8286 | 8286 | $val = $val->compile($env); |
| 8287 | - } else if ( isset($param['value']) ) { |
|
| 8287 | + }else if (isset($param['value'])) { |
|
| 8288 | 8288 | |
| 8289 | - if( !$mixinEnv ){ |
|
| 8289 | + if (!$mixinEnv) { |
|
| 8290 | 8290 | $mixinEnv = new Less_Environment(); |
| 8291 | - $mixinEnv->frames = array_merge( array($frame), $mixinFrames); |
|
| 8291 | + $mixinEnv->frames = array_merge(array($frame), $mixinFrames); |
|
| 8292 | 8292 | } |
| 8293 | 8293 | |
| 8294 | 8294 | $val = $param['value']->compile($mixinEnv); |
| 8295 | 8295 | $frame->resetCache(); |
| 8296 | - } else { |
|
| 8297 | - throw new Less_Exception_Compiler("Wrong number of arguments for " . $this->name . " (" . $argsLength . ' for ' . $this->arity . ")"); |
|
| 8296 | + }else { |
|
| 8297 | + throw new Less_Exception_Compiler("Wrong number of arguments for ".$this->name." (".$argsLength.' for '.$this->arity.")"); |
|
| 8298 | 8298 | } |
| 8299 | 8299 | |
| 8300 | 8300 | array_unshift($frame->rules, new Less_Tree_Rule($param['name'], $val)); |
@@ -8302,8 +8302,8 @@ discard block |
||
| 8302 | 8302 | } |
| 8303 | 8303 | } |
| 8304 | 8304 | |
| 8305 | - if ( isset($param['variadic']) && $args) { |
|
| 8306 | - for ($j = $argIndex; $j < $argsLength; $j++) { |
|
| 8305 | + if (isset($param['variadic']) && $args) { |
|
| 8306 | + for ($j = $argIndex; $j<$argsLength; $j++) { |
|
| 8307 | 8307 | $evaldArguments[$j] = $args[$j]['value']->compile($env); |
| 8308 | 8308 | } |
| 8309 | 8309 | } |
@@ -8317,10 +8317,10 @@ discard block |
||
| 8317 | 8317 | } |
| 8318 | 8318 | |
| 8319 | 8319 | public function compile($env) { |
| 8320 | - if( $this->frames ){ |
|
| 8321 | - return new Less_Tree_Mixin_Definition($this->name, $this->params, $this->rules, $this->condition, $this->variadic, $this->frames ); |
|
| 8320 | + if ($this->frames) { |
|
| 8321 | + return new Less_Tree_Mixin_Definition($this->name, $this->params, $this->rules, $this->condition, $this->variadic, $this->frames); |
|
| 8322 | 8322 | } |
| 8323 | - return new Less_Tree_Mixin_Definition($this->name, $this->params, $this->rules, $this->condition, $this->variadic, $env->frames ); |
|
| 8323 | + return new Less_Tree_Mixin_Definition($this->name, $this->params, $this->rules, $this->condition, $this->variadic, $env->frames); |
|
| 8324 | 8324 | } |
| 8325 | 8325 | |
| 8326 | 8326 | public function evalCall($env, $args = NULL, $important = NULL) { |
@@ -8329,9 +8329,9 @@ discard block |
||
| 8329 | 8329 | |
| 8330 | 8330 | $_arguments = array(); |
| 8331 | 8331 | |
| 8332 | - if( $this->frames ){ |
|
| 8332 | + if ($this->frames) { |
|
| 8333 | 8333 | $mixinFrames = array_merge($this->frames, $env->frames); |
| 8334 | - }else{ |
|
| 8334 | + }else { |
|
| 8335 | 8335 | $mixinFrames = $env->frames; |
| 8336 | 8336 | } |
| 8337 | 8337 | |
@@ -8346,10 +8346,10 @@ discard block |
||
| 8346 | 8346 | |
| 8347 | 8347 | |
| 8348 | 8348 | $ruleSetEnv = new Less_Environment(); |
| 8349 | - $ruleSetEnv->frames = array_merge( array($this, $frame), $mixinFrames ); |
|
| 8350 | - $ruleset = $ruleset->compile( $ruleSetEnv ); |
|
| 8349 | + $ruleSetEnv->frames = array_merge(array($this, $frame), $mixinFrames); |
|
| 8350 | + $ruleset = $ruleset->compile($ruleSetEnv); |
|
| 8351 | 8351 | |
| 8352 | - if( $important ){ |
|
| 8352 | + if ($important) { |
|
| 8353 | 8353 | $ruleset = $ruleset->makeImportant(); |
| 8354 | 8354 | } |
| 8355 | 8355 | |
@@ -8361,16 +8361,16 @@ discard block |
||
| 8361 | 8361 | |
| 8362 | 8362 | public function matchCondition($args, $env) { |
| 8363 | 8363 | |
| 8364 | - if( !$this->condition ){ |
|
| 8364 | + if (!$this->condition) { |
|
| 8365 | 8365 | return true; |
| 8366 | 8366 | } |
| 8367 | 8367 | |
| 8368 | 8368 | // set array to prevent error on array_merge |
| 8369 | - if(!is_array($this->frames)) { |
|
| 8369 | + if (!is_array($this->frames)) { |
|
| 8370 | 8370 | $this->frames = array(); |
| 8371 | 8371 | } |
| 8372 | 8372 | |
| 8373 | - $frame = $this->compileParams($env, array_merge($this->frames,$env->frames), $args ); |
|
| 8373 | + $frame = $this->compileParams($env, array_merge($this->frames, $env->frames), $args); |
|
| 8374 | 8374 | |
| 8375 | 8375 | $compile_env = new Less_Environment(); |
| 8376 | 8376 | $compile_env->frames = array_merge( |
@@ -8384,27 +8384,27 @@ discard block |
||
| 8384 | 8384 | return (bool)$this->condition->compile($compile_env); |
| 8385 | 8385 | } |
| 8386 | 8386 | |
| 8387 | - public function matchArgs($args, $env = NULL){ |
|
| 8387 | + public function matchArgs($args, $env = NULL) { |
|
| 8388 | 8388 | $argsLength = count($args); |
| 8389 | 8389 | |
| 8390 | - if( !$this->variadic ){ |
|
| 8391 | - if( $argsLength < $this->required ){ |
|
| 8390 | + if (!$this->variadic) { |
|
| 8391 | + if ($argsLength<$this->required) { |
|
| 8392 | 8392 | return false; |
| 8393 | 8393 | } |
| 8394 | - if( $argsLength > count($this->params) ){ |
|
| 8394 | + if ($argsLength>count($this->params)) { |
|
| 8395 | 8395 | return false; |
| 8396 | 8396 | } |
| 8397 | - }else{ |
|
| 8398 | - if( $argsLength < ($this->required - 1)){ |
|
| 8397 | + }else { |
|
| 8398 | + if ($argsLength<($this->required-1)) { |
|
| 8399 | 8399 | return false; |
| 8400 | 8400 | } |
| 8401 | 8401 | } |
| 8402 | 8402 | |
| 8403 | 8403 | $len = min($argsLength, $this->arity); |
| 8404 | 8404 | |
| 8405 | - for( $i = 0; $i < $len; $i++ ){ |
|
| 8406 | - if( !isset($this->params[$i]['name']) && !isset($this->params[$i]['variadic']) ){ |
|
| 8407 | - if( $args[$i]['value']->compile($env)->toCSS() != $this->params[$i]['value']->compile($env)->toCSS() ){ |
|
| 8405 | + for ($i = 0; $i<$len; $i++) { |
|
| 8406 | + if (!isset($this->params[$i]['name']) && !isset($this->params[$i]['variadic'])) { |
|
| 8407 | + if ($args[$i]['value']->compile($env)->toCSS()!=$this->params[$i]['value']->compile($env)->toCSS()) { |
|
| 8408 | 8408 | return false; |
| 8409 | 8409 | } |
| 8410 | 8410 | } |
@@ -8422,13 +8422,13 @@ discard block |
||
| 8422 | 8422 | * @package Less |
| 8423 | 8423 | * @subpackage visitor |
| 8424 | 8424 | */ |
| 8425 | -class Less_Visitor_extendFinder extends Less_Visitor{ |
|
| 8425 | +class Less_Visitor_extendFinder extends Less_Visitor { |
|
| 8426 | 8426 | |
| 8427 | 8427 | public $contexts = array(); |
| 8428 | 8428 | public $allExtendsStack; |
| 8429 | 8429 | public $foundExtends; |
| 8430 | 8430 | |
| 8431 | - public function __construct(){ |
|
| 8431 | + public function __construct() { |
|
| 8432 | 8432 | $this->contexts = array(); |
| 8433 | 8433 | $this->allExtendsStack = array(array()); |
| 8434 | 8434 | parent::__construct(); |
@@ -8437,32 +8437,32 @@ discard block |
||
| 8437 | 8437 | /** |
| 8438 | 8438 | * @param Less_Tree_Ruleset $root |
| 8439 | 8439 | */ |
| 8440 | - public function run($root){ |
|
| 8440 | + public function run($root) { |
|
| 8441 | 8441 | $root = $this->visitObj($root); |
| 8442 | - $root->allExtends =& $this->allExtendsStack[0]; |
|
| 8442 | + $root->allExtends = & $this->allExtendsStack[0]; |
|
| 8443 | 8443 | return $root; |
| 8444 | 8444 | } |
| 8445 | 8445 | |
| 8446 | - public function visitRule($ruleNode, &$visitDeeper ){ |
|
| 8446 | + public function visitRule($ruleNode, &$visitDeeper) { |
|
| 8447 | 8447 | $visitDeeper = false; |
| 8448 | 8448 | } |
| 8449 | 8449 | |
| 8450 | - public function visitMixinDefinition( $mixinDefinitionNode, &$visitDeeper ){ |
|
| 8450 | + public function visitMixinDefinition($mixinDefinitionNode, &$visitDeeper) { |
|
| 8451 | 8451 | $visitDeeper = false; |
| 8452 | 8452 | } |
| 8453 | 8453 | |
| 8454 | - public function visitRuleset($rulesetNode){ |
|
| 8454 | + public function visitRuleset($rulesetNode) { |
|
| 8455 | 8455 | |
| 8456 | - if( $rulesetNode->root ){ |
|
| 8456 | + if ($rulesetNode->root) { |
|
| 8457 | 8457 | return; |
| 8458 | 8458 | } |
| 8459 | 8459 | |
| 8460 | 8460 | $allSelectorsExtendList = array(); |
| 8461 | 8461 | |
| 8462 | 8462 | // get &:extend(.a); rules which apply to all selectors in this ruleset |
| 8463 | - if( $rulesetNode->rules ){ |
|
| 8464 | - foreach($rulesetNode->rules as $rule){ |
|
| 8465 | - if( $rule instanceof Less_Tree_Extend ){ |
|
| 8463 | + if ($rulesetNode->rules) { |
|
| 8464 | + foreach ($rulesetNode->rules as $rule) { |
|
| 8465 | + if ($rule instanceof Less_Tree_Extend) { |
|
| 8466 | 8466 | $allSelectorsExtendList[] = $rule; |
| 8467 | 8467 | $rulesetNode->extendOnEveryPath = true; |
| 8468 | 8468 | } |
@@ -8472,14 +8472,14 @@ discard block |
||
| 8472 | 8472 | |
| 8473 | 8473 | // now find every selector and apply the extends that apply to all extends |
| 8474 | 8474 | // and the ones which apply to an individual extend |
| 8475 | - foreach($rulesetNode->paths as $selectorPath){ |
|
| 8475 | + foreach ($rulesetNode->paths as $selectorPath) { |
|
| 8476 | 8476 | $selector = end($selectorPath); //$selectorPath[ count($selectorPath)-1]; |
| 8477 | 8477 | |
| 8478 | 8478 | $j = 0; |
| 8479 | - foreach($selector->extendList as $extend){ |
|
| 8479 | + foreach ($selector->extendList as $extend) { |
|
| 8480 | 8480 | $this->allExtendsStackPush($rulesetNode, $selectorPath, $extend, $j); |
| 8481 | 8481 | } |
| 8482 | - foreach($allSelectorsExtendList as $extend){ |
|
| 8482 | + foreach ($allSelectorsExtendList as $extend) { |
|
| 8483 | 8483 | $this->allExtendsStackPush($rulesetNode, $selectorPath, $extend, $j); |
| 8484 | 8484 | } |
| 8485 | 8485 | } |
@@ -8487,12 +8487,12 @@ discard block |
||
| 8487 | 8487 | $this->contexts[] = $rulesetNode->selectors; |
| 8488 | 8488 | } |
| 8489 | 8489 | |
| 8490 | - public function allExtendsStackPush($rulesetNode, $selectorPath, $extend, &$j){ |
|
| 8490 | + public function allExtendsStackPush($rulesetNode, $selectorPath, $extend, &$j) { |
|
| 8491 | 8491 | $this->foundExtends = true; |
| 8492 | 8492 | $extend = clone $extend; |
| 8493 | - $extend->findSelfSelectors( $selectorPath ); |
|
| 8493 | + $extend->findSelfSelectors($selectorPath); |
|
| 8494 | 8494 | $extend->ruleset = $rulesetNode; |
| 8495 | - if( $j === 0 ){ |
|
| 8495 | + if ($j===0) { |
|
| 8496 | 8496 | $extend->firstExtendOnThisSelectorPath = true; |
| 8497 | 8497 | } |
| 8498 | 8498 | |
@@ -8502,27 +8502,27 @@ discard block |
||
| 8502 | 8502 | } |
| 8503 | 8503 | |
| 8504 | 8504 | |
| 8505 | - public function visitRulesetOut( $rulesetNode ){ |
|
| 8506 | - if( !is_object($rulesetNode) || !$rulesetNode->root ){ |
|
| 8505 | + public function visitRulesetOut($rulesetNode) { |
|
| 8506 | + if (!is_object($rulesetNode) || !$rulesetNode->root) { |
|
| 8507 | 8507 | array_pop($this->contexts); |
| 8508 | 8508 | } |
| 8509 | 8509 | } |
| 8510 | 8510 | |
| 8511 | - public function visitMedia( $mediaNode ){ |
|
| 8511 | + public function visitMedia($mediaNode) { |
|
| 8512 | 8512 | $mediaNode->allExtends = array(); |
| 8513 | - $this->allExtendsStack[] =& $mediaNode->allExtends; |
|
| 8513 | + $this->allExtendsStack[] = & $mediaNode->allExtends; |
|
| 8514 | 8514 | } |
| 8515 | 8515 | |
| 8516 | - public function visitMediaOut(){ |
|
| 8516 | + public function visitMediaOut() { |
|
| 8517 | 8517 | array_pop($this->allExtendsStack); |
| 8518 | 8518 | } |
| 8519 | 8519 | |
| 8520 | - public function visitDirective( $directiveNode ){ |
|
| 8520 | + public function visitDirective($directiveNode) { |
|
| 8521 | 8521 | $directiveNode->allExtends = array(); |
| 8522 | - $this->allExtendsStack[] =& $directiveNode->allExtends; |
|
| 8522 | + $this->allExtendsStack[] = & $directiveNode->allExtends; |
|
| 8523 | 8523 | } |
| 8524 | 8524 | |
| 8525 | - public function visitDirectiveOut(){ |
|
| 8525 | + public function visitDirectiveOut() { |
|
| 8526 | 8526 | array_pop($this->allExtendsStack); |
| 8527 | 8527 | } |
| 8528 | 8528 | } |
@@ -8675,46 +8675,46 @@ discard block |
||
| 8675 | 8675 | * @package Less |
| 8676 | 8676 | * @subpackage visitor |
| 8677 | 8677 | */ |
| 8678 | -class Less_Visitor_joinSelector extends Less_Visitor{ |
|
| 8678 | +class Less_Visitor_joinSelector extends Less_Visitor { |
|
| 8679 | 8679 | |
| 8680 | - public $contexts = array( array() ); |
|
| 8680 | + public $contexts = array(array()); |
|
| 8681 | 8681 | |
| 8682 | 8682 | /** |
| 8683 | 8683 | * @param Less_Tree_Ruleset $root |
| 8684 | 8684 | */ |
| 8685 | - public function run( $root ){ |
|
| 8685 | + public function run($root) { |
|
| 8686 | 8686 | return $this->visitObj($root); |
| 8687 | 8687 | } |
| 8688 | 8688 | |
| 8689 | - public function visitRule( $ruleNode, &$visitDeeper ){ |
|
| 8689 | + public function visitRule($ruleNode, &$visitDeeper) { |
|
| 8690 | 8690 | $visitDeeper = false; |
| 8691 | 8691 | } |
| 8692 | 8692 | |
| 8693 | - public function visitMixinDefinition( $mixinDefinitionNode, &$visitDeeper ){ |
|
| 8693 | + public function visitMixinDefinition($mixinDefinitionNode, &$visitDeeper) { |
|
| 8694 | 8694 | $visitDeeper = false; |
| 8695 | 8695 | } |
| 8696 | 8696 | |
| 8697 | - public function visitRuleset( $rulesetNode ){ |
|
| 8697 | + public function visitRuleset($rulesetNode) { |
|
| 8698 | 8698 | |
| 8699 | 8699 | $paths = array(); |
| 8700 | 8700 | |
| 8701 | - if( !$rulesetNode->root ){ |
|
| 8701 | + if (!$rulesetNode->root) { |
|
| 8702 | 8702 | $selectors = array(); |
| 8703 | 8703 | |
| 8704 | - if( $rulesetNode->selectors && $rulesetNode->selectors ){ |
|
| 8705 | - foreach($rulesetNode->selectors as $selector){ |
|
| 8706 | - if( $selector->getIsOutput() ){ |
|
| 8704 | + if ($rulesetNode->selectors && $rulesetNode->selectors) { |
|
| 8705 | + foreach ($rulesetNode->selectors as $selector) { |
|
| 8706 | + if ($selector->getIsOutput()) { |
|
| 8707 | 8707 | $selectors[] = $selector; |
| 8708 | 8708 | } |
| 8709 | 8709 | } |
| 8710 | 8710 | } |
| 8711 | 8711 | |
| 8712 | - if( !$selectors ){ |
|
| 8712 | + if (!$selectors) { |
|
| 8713 | 8713 | $rulesetNode->selectors = null; |
| 8714 | 8714 | $rulesetNode->rules = null; |
| 8715 | - }else{ |
|
| 8715 | + }else { |
|
| 8716 | 8716 | $context = end($this->contexts); //$context = $this->contexts[ count($this->contexts) - 1]; |
| 8717 | - $paths = $rulesetNode->joinSelectors( $context, $selectors); |
|
| 8717 | + $paths = $rulesetNode->joinSelectors($context, $selectors); |
|
| 8718 | 8718 | } |
| 8719 | 8719 | |
| 8720 | 8720 | $rulesetNode->paths = $paths; |
@@ -8723,14 +8723,14 @@ discard block |
||
| 8723 | 8723 | $this->contexts[] = $paths; //different from less.js. Placed after joinSelectors() so that $this->contexts will get correct $paths |
| 8724 | 8724 | } |
| 8725 | 8725 | |
| 8726 | - public function visitRulesetOut(){ |
|
| 8726 | + public function visitRulesetOut() { |
|
| 8727 | 8727 | array_pop($this->contexts); |
| 8728 | 8728 | } |
| 8729 | 8729 | |
| 8730 | 8730 | public function visitMedia($mediaNode) { |
| 8731 | 8731 | $context = end($this->contexts); //$context = $this->contexts[ count($this->contexts) - 1]; |
| 8732 | 8732 | |
| 8733 | - if( !count($context) || (is_object($context[0]) && $context[0]->multiMedia) ){ |
|
| 8733 | + if (!count($context) || (is_object($context[0]) && $context[0]->multiMedia)) { |
|
| 8734 | 8734 | $mediaNode->rules[0]->root = true; |
| 8735 | 8735 | } |
| 8736 | 8736 | } |
@@ -8745,29 +8745,29 @@ discard block |
||
| 8745 | 8745 | * @package Less |
| 8746 | 8746 | * @subpackage visitor |
| 8747 | 8747 | */ |
| 8748 | -class Less_Visitor_processExtends extends Less_Visitor{ |
|
| 8748 | +class Less_Visitor_processExtends extends Less_Visitor { |
|
| 8749 | 8749 | |
| 8750 | 8750 | public $allExtendsStack; |
| 8751 | 8751 | |
| 8752 | 8752 | /** |
| 8753 | 8753 | * @param Less_Tree_Ruleset $root |
| 8754 | 8754 | */ |
| 8755 | - public function run( $root ){ |
|
| 8755 | + public function run($root) { |
|
| 8756 | 8756 | $extendFinder = new Less_Visitor_extendFinder(); |
| 8757 | - $extendFinder->run( $root ); |
|
| 8758 | - if( !$extendFinder->foundExtends){ |
|
| 8757 | + $extendFinder->run($root); |
|
| 8758 | + if (!$extendFinder->foundExtends) { |
|
| 8759 | 8759 | return $root; |
| 8760 | 8760 | } |
| 8761 | 8761 | |
| 8762 | - $root->allExtends = $this->doExtendChaining( $root->allExtends, $root->allExtends); |
|
| 8762 | + $root->allExtends = $this->doExtendChaining($root->allExtends, $root->allExtends); |
|
| 8763 | 8763 | |
| 8764 | 8764 | $this->allExtendsStack = array(); |
| 8765 | 8765 | $this->allExtendsStack[] = &$root->allExtends; |
| 8766 | 8766 | |
| 8767 | - return $this->visitObj( $root ); |
|
| 8767 | + return $this->visitObj($root); |
|
| 8768 | 8768 | } |
| 8769 | 8769 | |
| 8770 | - private function doExtendChaining( $extendsList, $extendsListTarget, $iterationCount = 0){ |
|
| 8770 | + private function doExtendChaining($extendsList, $extendsListTarget, $iterationCount = 0) { |
|
| 8771 | 8771 | // |
| 8772 | 8772 | // chaining is different from normal extension.. if we extend an extend then we are not just copying, altering and pasting |
| 8773 | 8773 | // the selector we would do normally, but we are also adding an extend with the same target selector |
@@ -8786,33 +8786,33 @@ discard block |
||
| 8786 | 8786 | // and the second is the target. |
| 8787 | 8787 | // the separation into two lists allows us to process a subset of chains with a bigger set, as is the |
| 8788 | 8788 | // case when processing media queries |
| 8789 | - for( $extendIndex = 0, $extendsList_len = count($extendsList); $extendIndex < $extendsList_len; $extendIndex++ ){ |
|
| 8790 | - for( $targetExtendIndex = 0; $targetExtendIndex < count($extendsListTarget); $targetExtendIndex++ ){ |
|
| 8789 | + for ($extendIndex = 0, $extendsList_len = count($extendsList); $extendIndex<$extendsList_len; $extendIndex++) { |
|
| 8790 | + for ($targetExtendIndex = 0; $targetExtendIndex<count($extendsListTarget); $targetExtendIndex++) { |
|
| 8791 | 8791 | |
| 8792 | 8792 | $extend = $extendsList[$extendIndex]; |
| 8793 | 8793 | $targetExtend = $extendsListTarget[$targetExtendIndex]; |
| 8794 | 8794 | |
| 8795 | 8795 | // look for circular references |
| 8796 | - if( in_array($targetExtend->object_id, $extend->parent_ids,true) ){ |
|
| 8796 | + if (in_array($targetExtend->object_id, $extend->parent_ids, true)) { |
|
| 8797 | 8797 | continue; |
| 8798 | 8798 | } |
| 8799 | 8799 | |
| 8800 | 8800 | // find a match in the target extends self selector (the bit before :extend) |
| 8801 | - $selectorPath = array( $targetExtend->selfSelectors[0] ); |
|
| 8802 | - $matches = $this->findMatch( $extend, $selectorPath); |
|
| 8801 | + $selectorPath = array($targetExtend->selfSelectors[0]); |
|
| 8802 | + $matches = $this->findMatch($extend, $selectorPath); |
|
| 8803 | 8803 | |
| 8804 | 8804 | |
| 8805 | - if( $matches ){ |
|
| 8805 | + if ($matches) { |
|
| 8806 | 8806 | |
| 8807 | 8807 | // we found a match, so for each self selector.. |
| 8808 | - foreach($extend->selfSelectors as $selfSelector ){ |
|
| 8808 | + foreach ($extend->selfSelectors as $selfSelector) { |
|
| 8809 | 8809 | |
| 8810 | 8810 | |
| 8811 | 8811 | // process the extend as usual |
| 8812 | - $newSelector = $this->extendSelector( $matches, $selectorPath, $selfSelector); |
|
| 8812 | + $newSelector = $this->extendSelector($matches, $selectorPath, $selfSelector); |
|
| 8813 | 8813 | |
| 8814 | 8814 | // but now we create a new extend from it |
| 8815 | - $newExtend = new Less_Tree_Extend( $targetExtend->selector, $targetExtend->option, 0); |
|
| 8815 | + $newExtend = new Less_Tree_Extend($targetExtend->selector, $targetExtend->option, 0); |
|
| 8816 | 8816 | $newExtend->selfSelectors = $newSelector; |
| 8817 | 8817 | |
| 8818 | 8818 | // add the extend onto the list of extends for that selector |
@@ -8824,12 +8824,12 @@ discard block |
||
| 8824 | 8824 | $newExtend->ruleset = $targetExtend->ruleset; |
| 8825 | 8825 | |
| 8826 | 8826 | //remember its parents for circular references |
| 8827 | - $newExtend->parent_ids = array_merge($newExtend->parent_ids,$targetExtend->parent_ids,$extend->parent_ids); |
|
| 8827 | + $newExtend->parent_ids = array_merge($newExtend->parent_ids, $targetExtend->parent_ids, $extend->parent_ids); |
|
| 8828 | 8828 | |
| 8829 | 8829 | // only process the selector once.. if we have :extend(.a,.b) then multiple |
| 8830 | 8830 | // extends will look at the same selector path, so when extending |
| 8831 | 8831 | // we know that any others will be duplicates in terms of what is added to the css |
| 8832 | - if( $targetExtend->firstExtendOnThisSelectorPath ){ |
|
| 8832 | + if ($targetExtend->firstExtendOnThisSelectorPath) { |
|
| 8833 | 8833 | $newExtend->firstExtendOnThisSelectorPath = true; |
| 8834 | 8834 | $targetExtend->ruleset->paths[] = $newSelector; |
| 8835 | 8835 | } |
@@ -8838,79 +8838,79 @@ discard block |
||
| 8838 | 8838 | } |
| 8839 | 8839 | } |
| 8840 | 8840 | |
| 8841 | - if( $extendsToAdd ){ |
|
| 8841 | + if ($extendsToAdd) { |
|
| 8842 | 8842 | // try to detect circular references to stop a stack overflow. |
| 8843 | 8843 | // may no longer be needed. $this->extendChainCount++; |
| 8844 | - if( $iterationCount > 100) { |
|
| 8844 | + if ($iterationCount>100) { |
|
| 8845 | 8845 | |
| 8846 | - try{ |
|
| 8846 | + try { |
|
| 8847 | 8847 | $selectorOne = $extendsToAdd[0]->selfSelectors[0]->toCSS(); |
| 8848 | 8848 | $selectorTwo = $extendsToAdd[0]->selector->toCSS(); |
| 8849 | - }catch(Exception $e){ |
|
| 8849 | + } catch (Exception $e) { |
|
| 8850 | 8850 | $selectorOne = "{unable to calculate}"; |
| 8851 | 8851 | $selectorTwo = "{unable to calculate}"; |
| 8852 | 8852 | } |
| 8853 | 8853 | |
| 8854 | - throw new Less_Exception_Parser("extend circular reference detected. One of the circular extends is currently:"+$selectorOne+":extend(" + $selectorTwo+")"); |
|
| 8854 | + throw new Less_Exception_Parser("extend circular reference detected. One of the circular extends is currently:"+$selectorOne+":extend(" +$selectorTwo+")"); |
|
| 8855 | 8855 | } |
| 8856 | 8856 | |
| 8857 | 8857 | // now process the new extends on the existing rules so that we can handle a extending b extending c ectending d extending e... |
| 8858 | - $extendsToAdd = $this->doExtendChaining( $extendsToAdd, $extendsListTarget, $iterationCount+1); |
|
| 8858 | + $extendsToAdd = $this->doExtendChaining($extendsToAdd, $extendsListTarget, $iterationCount+1); |
|
| 8859 | 8859 | } |
| 8860 | 8860 | |
| 8861 | 8861 | return array_merge($extendsList, $extendsToAdd); |
| 8862 | 8862 | } |
| 8863 | 8863 | |
| 8864 | 8864 | |
| 8865 | - protected function visitRule( $ruleNode, &$visitDeeper ){ |
|
| 8865 | + protected function visitRule($ruleNode, &$visitDeeper) { |
|
| 8866 | 8866 | $visitDeeper = false; |
| 8867 | 8867 | } |
| 8868 | 8868 | |
| 8869 | - protected function visitMixinDefinition( $mixinDefinitionNode, &$visitDeeper ){ |
|
| 8869 | + protected function visitMixinDefinition($mixinDefinitionNode, &$visitDeeper) { |
|
| 8870 | 8870 | $visitDeeper = false; |
| 8871 | 8871 | } |
| 8872 | 8872 | |
| 8873 | - protected function visitSelector( $selectorNode, &$visitDeeper ){ |
|
| 8873 | + protected function visitSelector($selectorNode, &$visitDeeper) { |
|
| 8874 | 8874 | $visitDeeper = false; |
| 8875 | 8875 | } |
| 8876 | 8876 | |
| 8877 | - protected function visitRuleset($rulesetNode){ |
|
| 8877 | + protected function visitRuleset($rulesetNode) { |
|
| 8878 | 8878 | |
| 8879 | 8879 | |
| 8880 | - if( $rulesetNode->root ){ |
|
| 8880 | + if ($rulesetNode->root) { |
|
| 8881 | 8881 | return; |
| 8882 | 8882 | } |
| 8883 | 8883 | |
| 8884 | - $allExtends = end($this->allExtendsStack); |
|
| 8884 | + $allExtends = end($this->allExtendsStack); |
|
| 8885 | 8885 | $paths_len = count($rulesetNode->paths); |
| 8886 | 8886 | |
| 8887 | 8887 | // look at each selector path in the ruleset, find any extend matches and then copy, find and replace |
| 8888 | - foreach($allExtends as $allExtend){ |
|
| 8889 | - for($pathIndex = 0; $pathIndex < $paths_len; $pathIndex++ ){ |
|
| 8888 | + foreach ($allExtends as $allExtend) { |
|
| 8889 | + for ($pathIndex = 0; $pathIndex<$paths_len; $pathIndex++) { |
|
| 8890 | 8890 | |
| 8891 | 8891 | // extending extends happens initially, before the main pass |
| 8892 | - if( isset($rulesetNode->extendOnEveryPath) && $rulesetNode->extendOnEveryPath ){ |
|
| 8892 | + if (isset($rulesetNode->extendOnEveryPath) && $rulesetNode->extendOnEveryPath) { |
|
| 8893 | 8893 | continue; |
| 8894 | 8894 | } |
| 8895 | 8895 | |
| 8896 | 8896 | $selectorPath = $rulesetNode->paths[$pathIndex]; |
| 8897 | 8897 | |
| 8898 | - if( end($selectorPath)->extendList ){ |
|
| 8898 | + if (end($selectorPath)->extendList) { |
|
| 8899 | 8899 | continue; |
| 8900 | 8900 | } |
| 8901 | 8901 | |
| 8902 | - $this->ExtendMatch( $rulesetNode, $allExtend, $selectorPath); |
|
| 8902 | + $this->ExtendMatch($rulesetNode, $allExtend, $selectorPath); |
|
| 8903 | 8903 | |
| 8904 | 8904 | } |
| 8905 | 8905 | } |
| 8906 | 8906 | } |
| 8907 | 8907 | |
| 8908 | 8908 | |
| 8909 | - private function ExtendMatch( $rulesetNode, $extend, $selectorPath ){ |
|
| 8909 | + private function ExtendMatch($rulesetNode, $extend, $selectorPath) { |
|
| 8910 | 8910 | $matches = $this->findMatch($extend, $selectorPath); |
| 8911 | 8911 | |
| 8912 | - if( $matches ){ |
|
| 8913 | - foreach($extend->selfSelectors as $selfSelector ){ |
|
| 8912 | + if ($matches) { |
|
| 8913 | + foreach ($extend->selfSelectors as $selfSelector) { |
|
| 8914 | 8914 | $rulesetNode->paths[] = $this->extendSelector($matches, $selectorPath, $selfSelector); |
| 8915 | 8915 | } |
| 8916 | 8916 | } |
@@ -8918,10 +8918,10 @@ discard block |
||
| 8918 | 8918 | |
| 8919 | 8919 | |
| 8920 | 8920 | |
| 8921 | - private function findMatch($extend, $haystackSelectorPath ){ |
|
| 8921 | + private function findMatch($extend, $haystackSelectorPath) { |
|
| 8922 | 8922 | |
| 8923 | 8923 | |
| 8924 | - if( !$this->HasMatches($extend, $haystackSelectorPath) ){ |
|
| 8924 | + if (!$this->HasMatches($extend, $haystackSelectorPath)) { |
|
| 8925 | 8925 | return false; |
| 8926 | 8926 | } |
| 8927 | 8927 | |
@@ -8940,41 +8940,41 @@ discard block |
||
| 8940 | 8940 | |
| 8941 | 8941 | // loop through the haystack elements |
| 8942 | 8942 | $haystack_path_len = count($haystackSelectorPath); |
| 8943 | - for($haystackSelectorIndex = 0; $haystackSelectorIndex < $haystack_path_len; $haystackSelectorIndex++ ){ |
|
| 8943 | + for ($haystackSelectorIndex = 0; $haystackSelectorIndex<$haystack_path_len; $haystackSelectorIndex++) { |
|
| 8944 | 8944 | $hackstackSelector = $haystackSelectorPath[$haystackSelectorIndex]; |
| 8945 | 8945 | |
| 8946 | 8946 | $haystack_elements_len = count($hackstackSelector->elements); |
| 8947 | - for($hackstackElementIndex = 0; $hackstackElementIndex < $haystack_elements_len; $hackstackElementIndex++ ){ |
|
| 8947 | + for ($hackstackElementIndex = 0; $hackstackElementIndex<$haystack_elements_len; $hackstackElementIndex++) { |
|
| 8948 | 8948 | |
| 8949 | 8949 | $haystackElement = $hackstackSelector->elements[$hackstackElementIndex]; |
| 8950 | 8950 | |
| 8951 | 8951 | // if we allow elements before our match we can add a potential match every time. otherwise only at the first element. |
| 8952 | - if( $extend->allowBefore || ($haystackSelectorIndex === 0 && $hackstackElementIndex === 0) ){ |
|
| 8952 | + if ($extend->allowBefore || ($haystackSelectorIndex===0 && $hackstackElementIndex===0)) { |
|
| 8953 | 8953 | $potentialMatches[] = array('pathIndex'=> $haystackSelectorIndex, 'index'=> $hackstackElementIndex, 'matched'=> 0, 'initialCombinator'=> $haystackElement->combinator); |
| 8954 | 8954 | $potentialMatches_len++; |
| 8955 | 8955 | } |
| 8956 | 8956 | |
| 8957 | - for($i = 0; $i < $potentialMatches_len; $i++ ){ |
|
| 8957 | + for ($i = 0; $i<$potentialMatches_len; $i++) { |
|
| 8958 | 8958 | |
| 8959 | 8959 | $potentialMatch = &$potentialMatches[$i]; |
| 8960 | - $potentialMatch = $this->PotentialMatch( $potentialMatch, $needleElements, $haystackElement, $hackstackElementIndex ); |
|
| 8960 | + $potentialMatch = $this->PotentialMatch($potentialMatch, $needleElements, $haystackElement, $hackstackElementIndex); |
|
| 8961 | 8961 | |
| 8962 | 8962 | |
| 8963 | 8963 | // if we are still valid and have finished, test whether we have elements after and whether these are allowed |
| 8964 | - if( $potentialMatch && $potentialMatch['matched'] === $extend->selector->elements_len ){ |
|
| 8964 | + if ($potentialMatch && $potentialMatch['matched']===$extend->selector->elements_len) { |
|
| 8965 | 8965 | $potentialMatch['finished'] = true; |
| 8966 | 8966 | |
| 8967 | - if( !$extend->allowAfter && ($hackstackElementIndex+1 < $haystack_elements_len || $haystackSelectorIndex+1 < $haystack_path_len) ){ |
|
| 8967 | + if (!$extend->allowAfter && ($hackstackElementIndex+1<$haystack_elements_len || $haystackSelectorIndex+1<$haystack_path_len)) { |
|
| 8968 | 8968 | $potentialMatch = null; |
| 8969 | 8969 | } |
| 8970 | 8970 | } |
| 8971 | 8971 | |
| 8972 | 8972 | // if null we remove, if not, we are still valid, so either push as a valid match or continue |
| 8973 | - if( $potentialMatch ){ |
|
| 8974 | - if( $potentialMatch['finished'] ){ |
|
| 8973 | + if ($potentialMatch) { |
|
| 8974 | + if ($potentialMatch['finished']) { |
|
| 8975 | 8975 | $potentialMatch['length'] = $extend->selector->elements_len; |
| 8976 | 8976 | $potentialMatch['endPathIndex'] = $haystackSelectorIndex; |
| 8977 | - $potentialMatch['endPathElementIndex'] = $hackstackElementIndex + 1; // index after end of match |
|
| 8977 | + $potentialMatch['endPathElementIndex'] = $hackstackElementIndex+1; // index after end of match |
|
| 8978 | 8978 | $potentialMatches = array(); // we don't allow matches to overlap, so start matching again |
| 8979 | 8979 | $potentialMatches_len = 0; |
| 8980 | 8980 | $matches[] = $potentialMatch; |
@@ -8995,20 +8995,20 @@ discard block |
||
| 8995 | 8995 | |
| 8996 | 8996 | // Before going through all the nested loops, lets check to see if a match is possible |
| 8997 | 8997 | // Reduces Bootstrap 3.1 compile time from ~6.5s to ~5.6s |
| 8998 | - private function HasMatches($extend, $haystackSelectorPath){ |
|
| 8998 | + private function HasMatches($extend, $haystackSelectorPath) { |
|
| 8999 | 8999 | |
| 9000 | - if( !$extend->selector->cacheable ){ |
|
| 9000 | + if (!$extend->selector->cacheable) { |
|
| 9001 | 9001 | return true; |
| 9002 | 9002 | } |
| 9003 | 9003 | |
| 9004 | 9004 | $first_el = $extend->selector->_oelements[0]; |
| 9005 | 9005 | |
| 9006 | - foreach($haystackSelectorPath as $hackstackSelector){ |
|
| 9007 | - if( !$hackstackSelector->cacheable ){ |
|
| 9006 | + foreach ($haystackSelectorPath as $hackstackSelector) { |
|
| 9007 | + if (!$hackstackSelector->cacheable) { |
|
| 9008 | 9008 | return true; |
| 9009 | 9009 | } |
| 9010 | 9010 | |
| 9011 | - if( in_array($first_el, $hackstackSelector->_oelements) ){ |
|
| 9011 | + if (in_array($first_el, $hackstackSelector->_oelements)) { |
|
| 9012 | 9012 | return true; |
| 9013 | 9013 | } |
| 9014 | 9014 | } |
@@ -9020,26 +9020,26 @@ discard block |
||
| 9020 | 9020 | /** |
| 9021 | 9021 | * @param integer $hackstackElementIndex |
| 9022 | 9022 | */ |
| 9023 | - private function PotentialMatch( $potentialMatch, $needleElements, $haystackElement, $hackstackElementIndex ){ |
|
| 9023 | + private function PotentialMatch($potentialMatch, $needleElements, $haystackElement, $hackstackElementIndex) { |
|
| 9024 | 9024 | |
| 9025 | 9025 | |
| 9026 | - if( $potentialMatch['matched'] > 0 ){ |
|
| 9026 | + if ($potentialMatch['matched']>0) { |
|
| 9027 | 9027 | |
| 9028 | 9028 | // selectors add " " onto the first element. When we use & it joins the selectors together, but if we don't |
| 9029 | 9029 | // then each selector in haystackSelectorPath has a space before it added in the toCSS phase. so we need to work out |
| 9030 | 9030 | // what the resulting combinator will be |
| 9031 | 9031 | $targetCombinator = $haystackElement->combinator; |
| 9032 | - if( $targetCombinator === '' && $hackstackElementIndex === 0 ){ |
|
| 9032 | + if ($targetCombinator==='' && $hackstackElementIndex===0) { |
|
| 9033 | 9033 | $targetCombinator = ' '; |
| 9034 | 9034 | } |
| 9035 | 9035 | |
| 9036 | - if( $needleElements[ $potentialMatch['matched'] ]->combinator !== $targetCombinator ){ |
|
| 9036 | + if ($needleElements[$potentialMatch['matched']]->combinator!==$targetCombinator) { |
|
| 9037 | 9037 | return null; |
| 9038 | 9038 | } |
| 9039 | 9039 | } |
| 9040 | 9040 | |
| 9041 | 9041 | // if we don't match, null our match to indicate failure |
| 9042 | - if( !$this->isElementValuesEqual( $needleElements[$potentialMatch['matched'] ]->value, $haystackElement->value) ){ |
|
| 9042 | + if (!$this->isElementValuesEqual($needleElements[$potentialMatch['matched']]->value, $haystackElement->value)) { |
|
| 9043 | 9043 | return null; |
| 9044 | 9044 | } |
| 9045 | 9045 | |
@@ -9050,23 +9050,23 @@ discard block |
||
| 9050 | 9050 | } |
| 9051 | 9051 | |
| 9052 | 9052 | |
| 9053 | - private function isElementValuesEqual( $elementValue1, $elementValue2 ){ |
|
| 9053 | + private function isElementValuesEqual($elementValue1, $elementValue2) { |
|
| 9054 | 9054 | |
| 9055 | - if( $elementValue1 === $elementValue2 ){ |
|
| 9055 | + if ($elementValue1===$elementValue2) { |
|
| 9056 | 9056 | return true; |
| 9057 | 9057 | } |
| 9058 | 9058 | |
| 9059 | - if( is_string($elementValue1) || is_string($elementValue2) ) { |
|
| 9059 | + if (is_string($elementValue1) || is_string($elementValue2)) { |
|
| 9060 | 9060 | return false; |
| 9061 | 9061 | } |
| 9062 | 9062 | |
| 9063 | - if( $elementValue1 instanceof Less_Tree_Attribute ){ |
|
| 9064 | - return $this->isAttributeValuesEqual( $elementValue1, $elementValue2 ); |
|
| 9063 | + if ($elementValue1 instanceof Less_Tree_Attribute) { |
|
| 9064 | + return $this->isAttributeValuesEqual($elementValue1, $elementValue2); |
|
| 9065 | 9065 | } |
| 9066 | 9066 | |
| 9067 | 9067 | $elementValue1 = $elementValue1->value; |
| 9068 | - if( $elementValue1 instanceof Less_Tree_Selector ){ |
|
| 9069 | - return $this->isSelectorValuesEqual( $elementValue1, $elementValue2 ); |
|
| 9068 | + if ($elementValue1 instanceof Less_Tree_Selector) { |
|
| 9069 | + return $this->isSelectorValuesEqual($elementValue1, $elementValue2); |
|
| 9070 | 9070 | } |
| 9071 | 9071 | |
| 9072 | 9072 | return false; |
@@ -9076,22 +9076,22 @@ discard block |
||
| 9076 | 9076 | /** |
| 9077 | 9077 | * @param Less_Tree_Selector $elementValue1 |
| 9078 | 9078 | */ |
| 9079 | - private function isSelectorValuesEqual( $elementValue1, $elementValue2 ){ |
|
| 9079 | + private function isSelectorValuesEqual($elementValue1, $elementValue2) { |
|
| 9080 | 9080 | |
| 9081 | 9081 | $elementValue2 = $elementValue2->value; |
| 9082 | - if( !($elementValue2 instanceof Less_Tree_Selector) || $elementValue1->elements_len !== $elementValue2->elements_len ){ |
|
| 9082 | + if (!($elementValue2 instanceof Less_Tree_Selector) || $elementValue1->elements_len!==$elementValue2->elements_len) { |
|
| 9083 | 9083 | return false; |
| 9084 | 9084 | } |
| 9085 | 9085 | |
| 9086 | - for( $i = 0; $i < $elementValue1->elements_len; $i++ ){ |
|
| 9086 | + for ($i = 0; $i<$elementValue1->elements_len; $i++) { |
|
| 9087 | 9087 | |
| 9088 | - if( $elementValue1->elements[$i]->combinator !== $elementValue2->elements[$i]->combinator ){ |
|
| 9089 | - if( $i !== 0 || ($elementValue1->elements[$i]->combinator || ' ') !== ($elementValue2->elements[$i]->combinator || ' ') ){ |
|
| 9088 | + if ($elementValue1->elements[$i]->combinator!==$elementValue2->elements[$i]->combinator) { |
|
| 9089 | + if ($i!==0 || ($elementValue1->elements[$i]->combinator || ' ')!==($elementValue2->elements[$i]->combinator || ' ')) { |
|
| 9090 | 9090 | return false; |
| 9091 | 9091 | } |
| 9092 | 9092 | } |
| 9093 | 9093 | |
| 9094 | - if( !$this->isElementValuesEqual($elementValue1->elements[$i]->value, $elementValue2->elements[$i]->value) ){ |
|
| 9094 | + if (!$this->isElementValuesEqual($elementValue1->elements[$i]->value, $elementValue2->elements[$i]->value)) { |
|
| 9095 | 9095 | return false; |
| 9096 | 9096 | } |
| 9097 | 9097 | } |
@@ -9103,27 +9103,27 @@ discard block |
||
| 9103 | 9103 | /** |
| 9104 | 9104 | * @param Less_Tree_Attribute $elementValue1 |
| 9105 | 9105 | */ |
| 9106 | - private function isAttributeValuesEqual( $elementValue1, $elementValue2 ){ |
|
| 9106 | + private function isAttributeValuesEqual($elementValue1, $elementValue2) { |
|
| 9107 | 9107 | |
| 9108 | - if( $elementValue1->op !== $elementValue2->op || $elementValue1->key !== $elementValue2->key ){ |
|
| 9108 | + if ($elementValue1->op!==$elementValue2->op || $elementValue1->key!==$elementValue2->key) { |
|
| 9109 | 9109 | return false; |
| 9110 | 9110 | } |
| 9111 | 9111 | |
| 9112 | - if( !$elementValue1->value || !$elementValue2->value ){ |
|
| 9113 | - if( $elementValue1->value || $elementValue2->value ) { |
|
| 9112 | + if (!$elementValue1->value || !$elementValue2->value) { |
|
| 9113 | + if ($elementValue1->value || $elementValue2->value) { |
|
| 9114 | 9114 | return false; |
| 9115 | 9115 | } |
| 9116 | 9116 | return true; |
| 9117 | 9117 | } |
| 9118 | 9118 | |
| 9119 | - $elementValue1 = ($elementValue1->value->value ? $elementValue1->value->value : $elementValue1->value ); |
|
| 9120 | - $elementValue2 = ($elementValue2->value->value ? $elementValue2->value->value : $elementValue2->value ); |
|
| 9119 | + $elementValue1 = ($elementValue1->value->value ? $elementValue1->value->value : $elementValue1->value); |
|
| 9120 | + $elementValue2 = ($elementValue2->value->value ? $elementValue2->value->value : $elementValue2->value); |
|
| 9121 | 9121 | |
| 9122 | - return $elementValue1 === $elementValue2; |
|
| 9122 | + return $elementValue1===$elementValue2; |
|
| 9123 | 9123 | } |
| 9124 | 9124 | |
| 9125 | 9125 | |
| 9126 | - private function extendSelector($matches, $selectorPath, $replacementSelector){ |
|
| 9126 | + private function extendSelector($matches, $selectorPath, $replacementSelector) { |
|
| 9127 | 9127 | |
| 9128 | 9128 | //for a set of matches, replace each match with the replacement selector |
| 9129 | 9129 | |
@@ -9132,11 +9132,11 @@ discard block |
||
| 9132 | 9132 | $path = array(); |
| 9133 | 9133 | $selectorPath_len = count($selectorPath); |
| 9134 | 9134 | |
| 9135 | - for($matchIndex = 0, $matches_len = count($matches); $matchIndex < $matches_len; $matchIndex++ ){ |
|
| 9135 | + for ($matchIndex = 0, $matches_len = count($matches); $matchIndex<$matches_len; $matchIndex++) { |
|
| 9136 | 9136 | |
| 9137 | 9137 | |
| 9138 | 9138 | $match = $matches[$matchIndex]; |
| 9139 | - $selector = $selectorPath[ $match['pathIndex'] ]; |
|
| 9139 | + $selector = $selectorPath[$match['pathIndex']]; |
|
| 9140 | 9140 | |
| 9141 | 9141 | $firstElement = new Less_Tree_Element( |
| 9142 | 9142 | $match['initialCombinator'], |
@@ -9145,63 +9145,63 @@ discard block |
||
| 9145 | 9145 | $replacementSelector->elements[0]->currentFileInfo |
| 9146 | 9146 | ); |
| 9147 | 9147 | |
| 9148 | - if( $match['pathIndex'] > $currentSelectorPathIndex && $currentSelectorPathElementIndex > 0 ){ |
|
| 9148 | + if ($match['pathIndex']>$currentSelectorPathIndex && $currentSelectorPathElementIndex>0) { |
|
| 9149 | 9149 | $last_path = end($path); |
| 9150 | - $last_path->elements = array_merge( $last_path->elements, array_slice( $selectorPath[$currentSelectorPathIndex]->elements, $currentSelectorPathElementIndex)); |
|
| 9150 | + $last_path->elements = array_merge($last_path->elements, array_slice($selectorPath[$currentSelectorPathIndex]->elements, $currentSelectorPathElementIndex)); |
|
| 9151 | 9151 | $currentSelectorPathElementIndex = 0; |
| 9152 | 9152 | $currentSelectorPathIndex++; |
| 9153 | 9153 | } |
| 9154 | 9154 | |
| 9155 | 9155 | $newElements = array_merge( |
| 9156 | - array_slice($selector->elements, $currentSelectorPathElementIndex, ($match['index'] - $currentSelectorPathElementIndex) ) // last parameter of array_slice is different than the last parameter of javascript's slice |
|
| 9156 | + array_slice($selector->elements, $currentSelectorPathElementIndex, ($match['index']-$currentSelectorPathElementIndex)) // last parameter of array_slice is different than the last parameter of javascript's slice |
|
| 9157 | 9157 | , array($firstElement) |
| 9158 | - , array_slice($replacementSelector->elements,1) |
|
| 9158 | + , array_slice($replacementSelector->elements, 1) |
|
| 9159 | 9159 | ); |
| 9160 | 9160 | |
| 9161 | - if( $currentSelectorPathIndex === $match['pathIndex'] && $matchIndex > 0 ){ |
|
| 9161 | + if ($currentSelectorPathIndex===$match['pathIndex'] && $matchIndex>0) { |
|
| 9162 | 9162 | $last_key = count($path)-1; |
| 9163 | - $path[$last_key]->elements = array_merge($path[$last_key]->elements,$newElements); |
|
| 9164 | - }else{ |
|
| 9165 | - $path = array_merge( $path, array_slice( $selectorPath, $currentSelectorPathIndex, $match['pathIndex'] )); |
|
| 9166 | - $path[] = new Less_Tree_Selector( $newElements ); |
|
| 9163 | + $path[$last_key]->elements = array_merge($path[$last_key]->elements, $newElements); |
|
| 9164 | + }else { |
|
| 9165 | + $path = array_merge($path, array_slice($selectorPath, $currentSelectorPathIndex, $match['pathIndex'])); |
|
| 9166 | + $path[] = new Less_Tree_Selector($newElements); |
|
| 9167 | 9167 | } |
| 9168 | 9168 | |
| 9169 | 9169 | $currentSelectorPathIndex = $match['endPathIndex']; |
| 9170 | 9170 | $currentSelectorPathElementIndex = $match['endPathElementIndex']; |
| 9171 | - if( $currentSelectorPathElementIndex >= count($selectorPath[$currentSelectorPathIndex]->elements) ){ |
|
| 9171 | + if ($currentSelectorPathElementIndex>=count($selectorPath[$currentSelectorPathIndex]->elements)) { |
|
| 9172 | 9172 | $currentSelectorPathElementIndex = 0; |
| 9173 | 9173 | $currentSelectorPathIndex++; |
| 9174 | 9174 | } |
| 9175 | 9175 | } |
| 9176 | 9176 | |
| 9177 | - if( $currentSelectorPathIndex < $selectorPath_len && $currentSelectorPathElementIndex > 0 ){ |
|
| 9177 | + if ($currentSelectorPathIndex<$selectorPath_len && $currentSelectorPathElementIndex>0) { |
|
| 9178 | 9178 | $last_path = end($path); |
| 9179 | - $last_path->elements = array_merge( $last_path->elements, array_slice($selectorPath[$currentSelectorPathIndex]->elements, $currentSelectorPathElementIndex)); |
|
| 9179 | + $last_path->elements = array_merge($last_path->elements, array_slice($selectorPath[$currentSelectorPathIndex]->elements, $currentSelectorPathElementIndex)); |
|
| 9180 | 9180 | $currentSelectorPathIndex++; |
| 9181 | 9181 | } |
| 9182 | 9182 | |
| 9183 | - $slice_len = $selectorPath_len - $currentSelectorPathIndex; |
|
| 9183 | + $slice_len = $selectorPath_len-$currentSelectorPathIndex; |
|
| 9184 | 9184 | $path = array_merge($path, array_slice($selectorPath, $currentSelectorPathIndex, $slice_len)); |
| 9185 | 9185 | |
| 9186 | 9186 | return $path; |
| 9187 | 9187 | } |
| 9188 | 9188 | |
| 9189 | 9189 | |
| 9190 | - protected function visitMedia( $mediaNode ){ |
|
| 9191 | - $newAllExtends = array_merge( $mediaNode->allExtends, end($this->allExtendsStack) ); |
|
| 9190 | + protected function visitMedia($mediaNode) { |
|
| 9191 | + $newAllExtends = array_merge($mediaNode->allExtends, end($this->allExtendsStack)); |
|
| 9192 | 9192 | $this->allExtendsStack[] = $this->doExtendChaining($newAllExtends, $mediaNode->allExtends); |
| 9193 | 9193 | } |
| 9194 | 9194 | |
| 9195 | - protected function visitMediaOut(){ |
|
| 9196 | - array_pop( $this->allExtendsStack ); |
|
| 9195 | + protected function visitMediaOut() { |
|
| 9196 | + array_pop($this->allExtendsStack); |
|
| 9197 | 9197 | } |
| 9198 | 9198 | |
| 9199 | - protected function visitDirective( $directiveNode ){ |
|
| 9200 | - $newAllExtends = array_merge( $directiveNode->allExtends, end($this->allExtendsStack) ); |
|
| 9199 | + protected function visitDirective($directiveNode) { |
|
| 9200 | + $newAllExtends = array_merge($directiveNode->allExtends, end($this->allExtendsStack)); |
|
| 9201 | 9201 | $this->allExtendsStack[] = $this->doExtendChaining($newAllExtends, $directiveNode->allExtends); |
| 9202 | 9202 | } |
| 9203 | 9203 | |
| 9204 | - protected function visitDirectiveOut(){ |
|
| 9204 | + protected function visitDirectiveOut() { |
|
| 9205 | 9205 | array_pop($this->allExtendsStack); |
| 9206 | 9206 | } |
| 9207 | 9207 | |
@@ -9213,65 +9213,65 @@ discard block |
||
| 9213 | 9213 | * @package Less |
| 9214 | 9214 | * @subpackage visitor |
| 9215 | 9215 | */ |
| 9216 | -class Less_Visitor_toCSS extends Less_VisitorReplacing{ |
|
| 9216 | +class Less_Visitor_toCSS extends Less_VisitorReplacing { |
|
| 9217 | 9217 | |
| 9218 | 9218 | private $charset; |
| 9219 | 9219 | |
| 9220 | - public function __construct(){ |
|
| 9220 | + public function __construct() { |
|
| 9221 | 9221 | parent::__construct(); |
| 9222 | 9222 | } |
| 9223 | 9223 | |
| 9224 | 9224 | /** |
| 9225 | 9225 | * @param Less_Tree_Ruleset $root |
| 9226 | 9226 | */ |
| 9227 | - public function run( $root ){ |
|
| 9227 | + public function run($root) { |
|
| 9228 | 9228 | return $this->visitObj($root); |
| 9229 | 9229 | } |
| 9230 | 9230 | |
| 9231 | - public function visitRule( $ruleNode ){ |
|
| 9232 | - if( $ruleNode->variable ){ |
|
| 9231 | + public function visitRule($ruleNode) { |
|
| 9232 | + if ($ruleNode->variable) { |
|
| 9233 | 9233 | return array(); |
| 9234 | 9234 | } |
| 9235 | 9235 | return $ruleNode; |
| 9236 | 9236 | } |
| 9237 | 9237 | |
| 9238 | - public function visitMixinDefinition($mixinNode){ |
|
| 9238 | + public function visitMixinDefinition($mixinNode) { |
|
| 9239 | 9239 | // mixin definitions do not get eval'd - this means they keep state |
| 9240 | 9240 | // so we have to clear that state here so it isn't used if toCSS is called twice |
| 9241 | 9241 | $mixinNode->frames = array(); |
| 9242 | 9242 | return array(); |
| 9243 | 9243 | } |
| 9244 | 9244 | |
| 9245 | - public function visitExtend(){ |
|
| 9245 | + public function visitExtend() { |
|
| 9246 | 9246 | return array(); |
| 9247 | 9247 | } |
| 9248 | 9248 | |
| 9249 | - public function visitComment( $commentNode ){ |
|
| 9250 | - if( $commentNode->isSilent() ){ |
|
| 9249 | + public function visitComment($commentNode) { |
|
| 9250 | + if ($commentNode->isSilent()) { |
|
| 9251 | 9251 | return array(); |
| 9252 | 9252 | } |
| 9253 | 9253 | return $commentNode; |
| 9254 | 9254 | } |
| 9255 | 9255 | |
| 9256 | - public function visitMedia( $mediaNode, &$visitDeeper ){ |
|
| 9256 | + public function visitMedia($mediaNode, &$visitDeeper) { |
|
| 9257 | 9257 | $mediaNode->accept($this); |
| 9258 | 9258 | $visitDeeper = false; |
| 9259 | 9259 | |
| 9260 | - if( !$mediaNode->rules ){ |
|
| 9260 | + if (!$mediaNode->rules) { |
|
| 9261 | 9261 | return array(); |
| 9262 | 9262 | } |
| 9263 | 9263 | return $mediaNode; |
| 9264 | 9264 | } |
| 9265 | 9265 | |
| 9266 | - public function visitDirective( $directiveNode ){ |
|
| 9267 | - if( isset($directiveNode->currentFileInfo['reference']) && (!property_exists($directiveNode,'isReferenced') || !$directiveNode->isReferenced) ){ |
|
| 9266 | + public function visitDirective($directiveNode) { |
|
| 9267 | + if (isset($directiveNode->currentFileInfo['reference']) && (!property_exists($directiveNode, 'isReferenced') || !$directiveNode->isReferenced)) { |
|
| 9268 | 9268 | return array(); |
| 9269 | 9269 | } |
| 9270 | - if( $directiveNode->name === '@charset' ){ |
|
| 9270 | + if ($directiveNode->name==='@charset') { |
|
| 9271 | 9271 | // Only output the debug info together with subsequent @charset definitions |
| 9272 | 9272 | // a comment (or @media statement) before the actual @charset directive would |
| 9273 | 9273 | // be considered illegal css as it has to be on the first line |
| 9274 | - if( isset($this->charset) && $this->charset ){ |
|
| 9274 | + if (isset($this->charset) && $this->charset) { |
|
| 9275 | 9275 | |
| 9276 | 9276 | //if( $directiveNode->debugInfo ){ |
| 9277 | 9277 | // $comment = new Less_Tree_Comment('/* ' . str_replace("\n",'',$directiveNode->toCSS())." */\n"); |
@@ -9287,14 +9287,14 @@ discard block |
||
| 9287 | 9287 | return $directiveNode; |
| 9288 | 9288 | } |
| 9289 | 9289 | |
| 9290 | - public function checkPropertiesInRoot( $rulesetNode ){ |
|
| 9290 | + public function checkPropertiesInRoot($rulesetNode) { |
|
| 9291 | 9291 | |
| 9292 | - if( !$rulesetNode->firstRoot ){ |
|
| 9292 | + if (!$rulesetNode->firstRoot) { |
|
| 9293 | 9293 | return; |
| 9294 | 9294 | } |
| 9295 | 9295 | |
| 9296 | - foreach($rulesetNode->rules as $ruleNode){ |
|
| 9297 | - if( $ruleNode instanceof Less_Tree_Rule && !$ruleNode->variable ){ |
|
| 9296 | + foreach ($rulesetNode->rules as $ruleNode) { |
|
| 9297 | + if ($ruleNode instanceof Less_Tree_Rule && !$ruleNode->variable) { |
|
| 9298 | 9298 | $msg = "properties must be inside selector blocks, they cannot be in the root. Index ".$ruleNode->index.($ruleNode->currentFileInfo ? (' Filename: '.$ruleNode->currentFileInfo['filename']) : null); |
| 9299 | 9299 | throw new Less_Exception_Compiler($msg); |
| 9300 | 9300 | } |
@@ -9302,14 +9302,14 @@ discard block |
||
| 9302 | 9302 | } |
| 9303 | 9303 | |
| 9304 | 9304 | |
| 9305 | - public function visitRuleset( $rulesetNode, &$visitDeeper ){ |
|
| 9305 | + public function visitRuleset($rulesetNode, &$visitDeeper) { |
|
| 9306 | 9306 | |
| 9307 | 9307 | $visitDeeper = false; |
| 9308 | 9308 | |
| 9309 | - $this->checkPropertiesInRoot( $rulesetNode ); |
|
| 9309 | + $this->checkPropertiesInRoot($rulesetNode); |
|
| 9310 | 9310 | |
| 9311 | - if( $rulesetNode->root ){ |
|
| 9312 | - return $this->visitRulesetRoot( $rulesetNode ); |
|
| 9311 | + if ($rulesetNode->root) { |
|
| 9312 | + return $this->visitRulesetRoot($rulesetNode); |
|
| 9313 | 9313 | } |
| 9314 | 9314 | |
| 9315 | 9315 | $rulesets = array(); |
@@ -9318,13 +9318,13 @@ discard block |
||
| 9318 | 9318 | |
| 9319 | 9319 | // Compile rules and rulesets |
| 9320 | 9320 | $nodeRuleCnt = count($rulesetNode->rules); |
| 9321 | - for( $i = 0; $i < $nodeRuleCnt; ){ |
|
| 9321 | + for ($i = 0; $i<$nodeRuleCnt;) { |
|
| 9322 | 9322 | $rule = $rulesetNode->rules[$i]; |
| 9323 | 9323 | |
| 9324 | - if( property_exists($rule,'rules') ){ |
|
| 9324 | + if (property_exists($rule, 'rules')) { |
|
| 9325 | 9325 | // visit because we are moving them out from being a child |
| 9326 | 9326 | $rulesets[] = $this->visitObj($rule); |
| 9327 | - array_splice($rulesetNode->rules,$i,1); |
|
| 9327 | + array_splice($rulesetNode->rules, $i, 1); |
|
| 9328 | 9328 | $nodeRuleCnt--; |
| 9329 | 9329 | continue; |
| 9330 | 9330 | } |
@@ -9334,27 +9334,27 @@ discard block |
||
| 9334 | 9334 | |
| 9335 | 9335 | // accept the visitor to remove rules and refactor itself |
| 9336 | 9336 | // then we can decide now whether we want it or not |
| 9337 | - if( $nodeRuleCnt > 0 ){ |
|
| 9337 | + if ($nodeRuleCnt>0) { |
|
| 9338 | 9338 | $rulesetNode->accept($this); |
| 9339 | 9339 | |
| 9340 | - if( $rulesetNode->rules ){ |
|
| 9340 | + if ($rulesetNode->rules) { |
|
| 9341 | 9341 | |
| 9342 | - if( count($rulesetNode->rules) > 1 ){ |
|
| 9343 | - $this->_mergeRules( $rulesetNode->rules ); |
|
| 9344 | - $this->_removeDuplicateRules( $rulesetNode->rules ); |
|
| 9342 | + if (count($rulesetNode->rules)>1) { |
|
| 9343 | + $this->_mergeRules($rulesetNode->rules); |
|
| 9344 | + $this->_removeDuplicateRules($rulesetNode->rules); |
|
| 9345 | 9345 | } |
| 9346 | 9346 | |
| 9347 | 9347 | // now decide whether we keep the ruleset |
| 9348 | - if( $rulesetNode->paths ){ |
|
| 9348 | + if ($rulesetNode->paths) { |
|
| 9349 | 9349 | //array_unshift($rulesets, $rulesetNode); |
| 9350 | - array_splice($rulesets,0,0,array($rulesetNode)); |
|
| 9350 | + array_splice($rulesets, 0, 0, array($rulesetNode)); |
|
| 9351 | 9351 | } |
| 9352 | 9352 | } |
| 9353 | 9353 | |
| 9354 | 9354 | } |
| 9355 | 9355 | |
| 9356 | 9356 | |
| 9357 | - if( count($rulesets) === 1 ){ |
|
| 9357 | + if (count($rulesets)===1) { |
|
| 9358 | 9358 | return $rulesets[0]; |
| 9359 | 9359 | } |
| 9360 | 9360 | return $rulesets; |
@@ -9366,9 +9366,9 @@ discard block |
||
| 9366 | 9366 | * |
| 9367 | 9367 | * return array|Less_Tree_Ruleset |
| 9368 | 9368 | */ |
| 9369 | - private function visitRulesetRoot( $rulesetNode ){ |
|
| 9370 | - $rulesetNode->accept( $this ); |
|
| 9371 | - if( $rulesetNode->firstRoot || $rulesetNode->rules ){ |
|
| 9369 | + private function visitRulesetRoot($rulesetNode) { |
|
| 9370 | + $rulesetNode->accept($this); |
|
| 9371 | + if ($rulesetNode->firstRoot || $rulesetNode->rules) { |
|
| 9372 | 9372 | return $rulesetNode; |
| 9373 | 9373 | } |
| 9374 | 9374 | return array(); |
@@ -9380,16 +9380,16 @@ discard block |
||
| 9380 | 9380 | * |
| 9381 | 9381 | * @return array |
| 9382 | 9382 | */ |
| 9383 | - private function visitRulesetPaths($rulesetNode){ |
|
| 9383 | + private function visitRulesetPaths($rulesetNode) { |
|
| 9384 | 9384 | |
| 9385 | 9385 | $paths = array(); |
| 9386 | - foreach($rulesetNode->paths as $p){ |
|
| 9387 | - if( $p[0]->elements[0]->combinator === ' ' ){ |
|
| 9386 | + foreach ($rulesetNode->paths as $p) { |
|
| 9387 | + if ($p[0]->elements[0]->combinator===' ') { |
|
| 9388 | 9388 | $p[0]->elements[0]->combinator = ''; |
| 9389 | 9389 | } |
| 9390 | 9390 | |
| 9391 | - foreach($p as $pi){ |
|
| 9392 | - if( $pi->getIsReferenced() && $pi->getIsOutput() ){ |
|
| 9391 | + foreach ($p as $pi) { |
|
| 9392 | + if ($pi->getIsReferenced() && $pi->getIsOutput()) { |
|
| 9393 | 9393 | $paths[] = $p; |
| 9394 | 9394 | break; |
| 9395 | 9395 | } |
@@ -9399,26 +9399,26 @@ discard block |
||
| 9399 | 9399 | return $paths; |
| 9400 | 9400 | } |
| 9401 | 9401 | |
| 9402 | - protected function _removeDuplicateRules( &$rules ){ |
|
| 9402 | + protected function _removeDuplicateRules(&$rules) { |
|
| 9403 | 9403 | // remove duplicates |
| 9404 | 9404 | $ruleCache = array(); |
| 9405 | - for( $i = count($rules)-1; $i >= 0 ; $i-- ){ |
|
| 9405 | + for ($i = count($rules)-1; $i>=0; $i--) { |
|
| 9406 | 9406 | $rule = $rules[$i]; |
| 9407 | - if( $rule instanceof Less_Tree_Rule || $rule instanceof Less_Tree_NameValue ){ |
|
| 9407 | + if ($rule instanceof Less_Tree_Rule || $rule instanceof Less_Tree_NameValue) { |
|
| 9408 | 9408 | |
| 9409 | - if( !isset($ruleCache[$rule->name]) ){ |
|
| 9409 | + if (!isset($ruleCache[$rule->name])) { |
|
| 9410 | 9410 | $ruleCache[$rule->name] = $rule; |
| 9411 | - }else{ |
|
| 9412 | - $ruleList =& $ruleCache[$rule->name]; |
|
| 9411 | + }else { |
|
| 9412 | + $ruleList = & $ruleCache[$rule->name]; |
|
| 9413 | 9413 | |
| 9414 | - if( $ruleList instanceof Less_Tree_Rule || $ruleList instanceof Less_Tree_NameValue ){ |
|
| 9415 | - $ruleList = $ruleCache[$rule->name] = array( $ruleCache[$rule->name]->toCSS() ); |
|
| 9414 | + if ($ruleList instanceof Less_Tree_Rule || $ruleList instanceof Less_Tree_NameValue) { |
|
| 9415 | + $ruleList = $ruleCache[$rule->name] = array($ruleCache[$rule->name]->toCSS()); |
|
| 9416 | 9416 | } |
| 9417 | 9417 | |
| 9418 | 9418 | $ruleCSS = $rule->toCSS(); |
| 9419 | - if( array_search($ruleCSS,$ruleList) !== false ){ |
|
| 9420 | - array_splice($rules,$i,1); |
|
| 9421 | - }else{ |
|
| 9419 | + if (array_search($ruleCSS, $ruleList)!==false) { |
|
| 9420 | + array_splice($rules, $i, 1); |
|
| 9421 | + }else { |
|
| 9422 | 9422 | $ruleList[] = $ruleCSS; |
| 9423 | 9423 | } |
| 9424 | 9424 | } |
@@ -9426,25 +9426,25 @@ discard block |
||
| 9426 | 9426 | } |
| 9427 | 9427 | } |
| 9428 | 9428 | |
| 9429 | - protected function _mergeRules( &$rules ){ |
|
| 9429 | + protected function _mergeRules(&$rules) { |
|
| 9430 | 9430 | $groups = array(); |
| 9431 | 9431 | |
| 9432 | 9432 | //obj($rules); |
| 9433 | 9433 | |
| 9434 | 9434 | $rules_len = count($rules); |
| 9435 | - for( $i = 0; $i < $rules_len; $i++ ){ |
|
| 9435 | + for ($i = 0; $i<$rules_len; $i++) { |
|
| 9436 | 9436 | $rule = $rules[$i]; |
| 9437 | 9437 | |
| 9438 | - if( ($rule instanceof Less_Tree_Rule) && $rule->merge ){ |
|
| 9438 | + if (($rule instanceof Less_Tree_Rule) && $rule->merge) { |
|
| 9439 | 9439 | |
| 9440 | 9440 | $key = $rule->name; |
| 9441 | - if( $rule->important ){ |
|
| 9441 | + if ($rule->important) { |
|
| 9442 | 9442 | $key .= ',!'; |
| 9443 | 9443 | } |
| 9444 | 9444 | |
| 9445 | - if( !isset($groups[$key]) ){ |
|
| 9445 | + if (!isset($groups[$key])) { |
|
| 9446 | 9446 | $groups[$key] = array(); |
| 9447 | - }else{ |
|
| 9447 | + }else { |
|
| 9448 | 9448 | array_splice($rules, $i--, 1); |
| 9449 | 9449 | $rules_len--; |
| 9450 | 9450 | } |
@@ -9454,16 +9454,16 @@ discard block |
||
| 9454 | 9454 | } |
| 9455 | 9455 | |
| 9456 | 9456 | |
| 9457 | - foreach($groups as $parts){ |
|
| 9457 | + foreach ($groups as $parts) { |
|
| 9458 | 9458 | |
| 9459 | - if( count($parts) > 1 ){ |
|
| 9459 | + if (count($parts)>1) { |
|
| 9460 | 9460 | $rule = $parts[0]; |
| 9461 | 9461 | $spacedGroups = array(); |
| 9462 | 9462 | $lastSpacedGroup = array(); |
| 9463 | 9463 | $parts_mapped = array(); |
| 9464 | - foreach($parts as $p){ |
|
| 9465 | - if( $p->merge === '+' ){ |
|
| 9466 | - if( $lastSpacedGroup ){ |
|
| 9464 | + foreach ($parts as $p) { |
|
| 9465 | + if ($p->merge==='+') { |
|
| 9466 | + if ($lastSpacedGroup) { |
|
| 9467 | 9467 | $spacedGroups[] = self::toExpression($lastSpacedGroup); |
| 9468 | 9468 | } |
| 9469 | 9469 | $lastSpacedGroup = array(); |
@@ -9478,19 +9478,19 @@ discard block |
||
| 9478 | 9478 | |
| 9479 | 9479 | } |
| 9480 | 9480 | |
| 9481 | - public static function toExpression($values){ |
|
| 9481 | + public static function toExpression($values) { |
|
| 9482 | 9482 | $mapped = array(); |
| 9483 | - foreach($values as $p){ |
|
| 9483 | + foreach ($values as $p) { |
|
| 9484 | 9484 | $mapped[] = $p->value; |
| 9485 | 9485 | } |
| 9486 | - return new Less_Tree_Expression( $mapped ); |
|
| 9486 | + return new Less_Tree_Expression($mapped); |
|
| 9487 | 9487 | } |
| 9488 | 9488 | |
| 9489 | - public static function toValue($values){ |
|
| 9489 | + public static function toValue($values) { |
|
| 9490 | 9490 | //return new Less_Tree_Value($values); ?? |
| 9491 | 9491 | |
| 9492 | 9492 | $mapped = array(); |
| 9493 | - foreach($values as $p){ |
|
| 9493 | + foreach ($values as $p) { |
|
| 9494 | 9494 | $mapped[] = $p; |
| 9495 | 9495 | } |
| 9496 | 9496 | return new Less_Tree_Value($mapped); |
@@ -9505,7 +9505,7 @@ discard block |
||
| 9505 | 9505 | * @package Less |
| 9506 | 9506 | * @subpackage exception |
| 9507 | 9507 | */ |
| 9508 | -class Less_Exception_Parser extends Exception{ |
|
| 9508 | +class Less_Exception_Parser extends Exception { |
|
| 9509 | 9509 | |
| 9510 | 9510 | /** |
| 9511 | 9511 | * The current file |
@@ -9535,12 +9535,12 @@ discard block |
||
| 9535 | 9535 | * @param Less_FileInfo|string $currentFile The file |
| 9536 | 9536 | * @param integer $code The exception code |
| 9537 | 9537 | */ |
| 9538 | - public function __construct($message = null, Exception $previous = null, $index = null, $currentFile = null, $code = 0){ |
|
| 9538 | + public function __construct($message = null, Exception $previous = null, $index = null, $currentFile = null, $code = 0) { |
|
| 9539 | 9539 | |
| 9540 | - if (PHP_VERSION_ID < 50300) { |
|
| 9540 | + if (PHP_VERSION_ID<50300) { |
|
| 9541 | 9541 | $this->previous = $previous; |
| 9542 | 9542 | parent::__construct($message, $code); |
| 9543 | - } else { |
|
| 9543 | + }else { |
|
| 9544 | 9544 | parent::__construct($message, $code, $previous); |
| 9545 | 9545 | } |
| 9546 | 9546 | |
@@ -9551,10 +9551,10 @@ discard block |
||
| 9551 | 9551 | } |
| 9552 | 9552 | |
| 9553 | 9553 | |
| 9554 | - protected function getInput(){ |
|
| 9554 | + protected function getInput() { |
|
| 9555 | 9555 | |
| 9556 | - if( !$this->input && $this->currentFile && $this->currentFile['filename'] && file_exists($this->currentFile['filename']) ){ |
|
| 9557 | - $this->input = file_get_contents( $this->currentFile['filename'] ); |
|
| 9556 | + if (!$this->input && $this->currentFile && $this->currentFile['filename'] && file_exists($this->currentFile['filename'])) { |
|
| 9557 | + $this->input = file_get_contents($this->currentFile['filename']); |
|
| 9558 | 9558 | } |
| 9559 | 9559 | } |
| 9560 | 9560 | |
@@ -9565,26 +9565,26 @@ discard block |
||
| 9565 | 9565 | * |
| 9566 | 9566 | * @return string |
| 9567 | 9567 | */ |
| 9568 | - public function genMessage(){ |
|
| 9568 | + public function genMessage() { |
|
| 9569 | 9569 | |
| 9570 | - if( $this->currentFile && $this->currentFile['filename'] ){ |
|
| 9570 | + if ($this->currentFile && $this->currentFile['filename']) { |
|
| 9571 | 9571 | $this->message .= ' in '.basename($this->currentFile['filename']); |
| 9572 | 9572 | } |
| 9573 | 9573 | |
| 9574 | - if( $this->index !== null ){ |
|
| 9574 | + if ($this->index!==null) { |
|
| 9575 | 9575 | $this->getInput(); |
| 9576 | - if( $this->input ){ |
|
| 9576 | + if ($this->input) { |
|
| 9577 | 9577 | $line = self::getLineNumber(); |
| 9578 | 9578 | $this->message .= ' on line '.$line.', column '.self::getColumn(); |
| 9579 | 9579 | |
| 9580 | - $lines = explode("\n",$this->input); |
|
| 9580 | + $lines = explode("\n", $this->input); |
|
| 9581 | 9581 | |
| 9582 | 9582 | $count = count($lines); |
| 9583 | 9583 | $start_line = max(0, $line-3); |
| 9584 | 9584 | $last_line = min($count, $start_line+6); |
| 9585 | 9585 | $num_len = strlen($last_line); |
| 9586 | - for( $i = $start_line; $i < $last_line; $i++ ){ |
|
| 9587 | - $this->message .= "\n".str_pad($i+1,$num_len,'0',STR_PAD_LEFT).'| '.$lines[$i]; |
|
| 9586 | + for ($i = $start_line; $i<$last_line; $i++) { |
|
| 9587 | + $this->message .= "\n".str_pad($i+1, $num_len, '0', STR_PAD_LEFT).'| '.$lines[$i]; |
|
| 9588 | 9588 | } |
| 9589 | 9589 | } |
| 9590 | 9590 | } |
@@ -9596,13 +9596,13 @@ discard block |
||
| 9596 | 9596 | * |
| 9597 | 9597 | * @return integer |
| 9598 | 9598 | */ |
| 9599 | - public function getLineNumber(){ |
|
| 9600 | - if( $this->index ){ |
|
| 9599 | + public function getLineNumber() { |
|
| 9600 | + if ($this->index) { |
|
| 9601 | 9601 | // https://bugs.php.net/bug.php?id=49790 |
| 9602 | 9602 | if (ini_get("mbstring.func_overload")) { |
| 9603 | - return substr_count(substr($this->input, 0, $this->index), "\n") + 1; |
|
| 9604 | - } else { |
|
| 9605 | - return substr_count($this->input, "\n", 0, $this->index) + 1; |
|
| 9603 | + return substr_count(substr($this->input, 0, $this->index), "\n")+1; |
|
| 9604 | + }else { |
|
| 9605 | + return substr_count($this->input, "\n", 0, $this->index)+1; |
|
| 9606 | 9606 | } |
| 9607 | 9607 | } |
| 9608 | 9608 | return 1; |
@@ -9614,11 +9614,11 @@ discard block |
||
| 9614 | 9614 | * |
| 9615 | 9615 | * @return integer |
| 9616 | 9616 | */ |
| 9617 | - public function getColumn(){ |
|
| 9617 | + public function getColumn() { |
|
| 9618 | 9618 | |
| 9619 | 9619 | $part = substr($this->input, 0, $this->index); |
| 9620 | - $pos = strrpos($part,"\n"); |
|
| 9621 | - return $this->index - $pos; |
|
| 9620 | + $pos = strrpos($part, "\n"); |
|
| 9621 | + return $this->index-$pos; |
|
| 9622 | 9622 | } |
| 9623 | 9623 | |
| 9624 | 9624 | } |
@@ -9630,7 +9630,7 @@ discard block |
||
| 9630 | 9630 | * @package Less |
| 9631 | 9631 | * @subpackage exception |
| 9632 | 9632 | */ |
| 9633 | -class Less_Exception_Chunk extends Less_Exception_Parser{ |
|
| 9633 | +class Less_Exception_Chunk extends Less_Exception_Parser { |
|
| 9634 | 9634 | |
| 9635 | 9635 | |
| 9636 | 9636 | protected $parserCurrentIndex = 0; |
@@ -9649,7 +9649,7 @@ discard block |
||
| 9649 | 9649 | * @param Less_FileInfo|string $currentFile The file |
| 9650 | 9650 | * @param integer $code The exception code |
| 9651 | 9651 | */ |
| 9652 | - public function __construct($input, Exception $previous = null, $index = null, $currentFile = null, $code = 0){ |
|
| 9652 | + public function __construct($input, Exception $previous = null, $index = null, $currentFile = null, $code = 0) { |
|
| 9653 | 9653 | |
| 9654 | 9654 | $this->message = 'ParseError: Unexpected input'; //default message |
| 9655 | 9655 | |
@@ -9670,7 +9670,7 @@ discard block |
||
| 9670 | 9670 | * We don't actually need the chunks |
| 9671 | 9671 | * |
| 9672 | 9672 | */ |
| 9673 | - protected function Chunks(){ |
|
| 9673 | + protected function Chunks() { |
|
| 9674 | 9674 | $level = 0; |
| 9675 | 9675 | $parenLevel = 0; |
| 9676 | 9676 | $lastMultiCommentEndBrace = null; |
@@ -9678,9 +9678,9 @@ discard block |
||
| 9678 | 9678 | $lastMultiComment = null; |
| 9679 | 9679 | $lastParen = null; |
| 9680 | 9680 | |
| 9681 | - for( $this->parserCurrentIndex = 0; $this->parserCurrentIndex < $this->input_len; $this->parserCurrentIndex++ ){ |
|
| 9681 | + for ($this->parserCurrentIndex = 0; $this->parserCurrentIndex<$this->input_len; $this->parserCurrentIndex++) { |
|
| 9682 | 9682 | $cc = $this->CharCode($this->parserCurrentIndex); |
| 9683 | - if ((($cc >= 97) && ($cc <= 122)) || ($cc < 34)) { |
|
| 9683 | + if ((($cc>=97) && ($cc<=122)) || ($cc<34)) { |
|
| 9684 | 9684 | // a-z or whitespace |
| 9685 | 9685 | continue; |
| 9686 | 9686 | } |
@@ -9696,7 +9696,7 @@ discard block |
||
| 9696 | 9696 | // ) |
| 9697 | 9697 | case 41: |
| 9698 | 9698 | $parenLevel--; |
| 9699 | - if( $parenLevel < 0 ){ |
|
| 9699 | + if ($parenLevel<0) { |
|
| 9700 | 9700 | return $this->fail("missing opening `(`"); |
| 9701 | 9701 | } |
| 9702 | 9702 | continue; |
@@ -9715,7 +9715,7 @@ discard block |
||
| 9715 | 9715 | // } |
| 9716 | 9716 | case 125: |
| 9717 | 9717 | $level--; |
| 9718 | - if( $level < 0 ){ |
|
| 9718 | + if ($level<0) { |
|
| 9719 | 9719 | return $this->fail("missing opening `{`"); |
| 9720 | 9720 | |
| 9721 | 9721 | } |
@@ -9723,7 +9723,7 @@ discard block |
||
| 9723 | 9723 | continue; |
| 9724 | 9724 | // \ |
| 9725 | 9725 | case 92: |
| 9726 | - if ($this->parserCurrentIndex < $this->input_len - 1) { $this->parserCurrentIndex++; continue; } |
|
| 9726 | + if ($this->parserCurrentIndex<$this->input_len-1) { $this->parserCurrentIndex++; continue; } |
|
| 9727 | 9727 | return $this->fail("unescaped `\\`"); |
| 9728 | 9728 | |
| 9729 | 9729 | // ", ' and ` |
@@ -9732,40 +9732,40 @@ discard block |
||
| 9732 | 9732 | case 96: |
| 9733 | 9733 | $matched = 0; |
| 9734 | 9734 | $currentChunkStartIndex = $this->parserCurrentIndex; |
| 9735 | - for ($this->parserCurrentIndex = $this->parserCurrentIndex + 1; $this->parserCurrentIndex < $this->input_len; $this->parserCurrentIndex++) { |
|
| 9735 | + for ($this->parserCurrentIndex = $this->parserCurrentIndex+1; $this->parserCurrentIndex<$this->input_len; $this->parserCurrentIndex++) { |
|
| 9736 | 9736 | $cc2 = $this->CharCode($this->parserCurrentIndex); |
| 9737 | - if ($cc2 > 96) { continue; } |
|
| 9738 | - if ($cc2 == $cc) { $matched = 1; break; } |
|
| 9739 | - if ($cc2 == 92) { // \ |
|
| 9740 | - if ($this->parserCurrentIndex == $this->input_len - 1) { |
|
| 9737 | + if ($cc2>96) { continue; } |
|
| 9738 | + if ($cc2==$cc) { $matched = 1; break; } |
|
| 9739 | + if ($cc2==92) { // \ |
|
| 9740 | + if ($this->parserCurrentIndex==$this->input_len-1) { |
|
| 9741 | 9741 | return $this->fail("unescaped `\\`"); |
| 9742 | 9742 | } |
| 9743 | 9743 | $this->parserCurrentIndex++; |
| 9744 | 9744 | } |
| 9745 | 9745 | } |
| 9746 | 9746 | if ($matched) { continue; } |
| 9747 | - return $this->fail("unmatched `" + chr($cc) + "`", $currentChunkStartIndex); |
|
| 9747 | + return $this->fail("unmatched `" +chr($cc)+"`", $currentChunkStartIndex); |
|
| 9748 | 9748 | |
| 9749 | 9749 | // /, check for comment |
| 9750 | 9750 | case 47: |
| 9751 | - if ($parenLevel || ($this->parserCurrentIndex == $this->input_len - 1)) { continue; } |
|
| 9751 | + if ($parenLevel || ($this->parserCurrentIndex==$this->input_len-1)) { continue; } |
|
| 9752 | 9752 | $cc2 = $this->CharCode($this->parserCurrentIndex+1); |
| 9753 | - if ($cc2 == 47) { |
|
| 9753 | + if ($cc2==47) { |
|
| 9754 | 9754 | // //, find lnfeed |
| 9755 | - for ($this->parserCurrentIndex = $this->parserCurrentIndex + 2; $this->parserCurrentIndex < $this->input_len; $this->parserCurrentIndex++) { |
|
| 9755 | + for ($this->parserCurrentIndex = $this->parserCurrentIndex+2; $this->parserCurrentIndex<$this->input_len; $this->parserCurrentIndex++) { |
|
| 9756 | 9756 | $cc2 = $this->CharCode($this->parserCurrentIndex); |
| 9757 | - if (($cc2 <= 13) && (($cc2 == 10) || ($cc2 == 13))) { break; } |
|
| 9757 | + if (($cc2<=13) && (($cc2==10) || ($cc2==13))) { break; } |
|
| 9758 | 9758 | } |
| 9759 | - } else if ($cc2 == 42) { |
|
| 9759 | + }else if ($cc2==42) { |
|
| 9760 | 9760 | // /*, find */ |
| 9761 | 9761 | $lastMultiComment = $currentChunkStartIndex = $this->parserCurrentIndex; |
| 9762 | - for ($this->parserCurrentIndex = $this->parserCurrentIndex + 2; $this->parserCurrentIndex < $this->input_len - 1; $this->parserCurrentIndex++) { |
|
| 9762 | + for ($this->parserCurrentIndex = $this->parserCurrentIndex+2; $this->parserCurrentIndex<$this->input_len-1; $this->parserCurrentIndex++) { |
|
| 9763 | 9763 | $cc2 = $this->CharCode($this->parserCurrentIndex); |
| 9764 | - if ($cc2 == 125) { $lastMultiCommentEndBrace = $this->parserCurrentIndex; } |
|
| 9765 | - if ($cc2 != 42) { continue; } |
|
| 9766 | - if ($this->CharCode($this->parserCurrentIndex+1) == 47) { break; } |
|
| 9764 | + if ($cc2==125) { $lastMultiCommentEndBrace = $this->parserCurrentIndex; } |
|
| 9765 | + if ($cc2!=42) { continue; } |
|
| 9766 | + if ($this->CharCode($this->parserCurrentIndex+1)==47) { break; } |
|
| 9767 | 9767 | } |
| 9768 | - if ($this->parserCurrentIndex == $this->input_len - 1) { |
|
| 9768 | + if ($this->parserCurrentIndex==$this->input_len-1) { |
|
| 9769 | 9769 | return $this->fail("missing closing `*/`", $currentChunkStartIndex); |
| 9770 | 9770 | } |
| 9771 | 9771 | } |
@@ -9773,20 +9773,20 @@ discard block |
||
| 9773 | 9773 | |
| 9774 | 9774 | // *, check for unmatched */ |
| 9775 | 9775 | case 42: |
| 9776 | - if (($this->parserCurrentIndex < $this->input_len - 1) && ($this->CharCode($this->parserCurrentIndex+1) == 47)) { |
|
| 9776 | + if (($this->parserCurrentIndex<$this->input_len-1) && ($this->CharCode($this->parserCurrentIndex+1)==47)) { |
|
| 9777 | 9777 | return $this->fail("unmatched `/*`"); |
| 9778 | 9778 | } |
| 9779 | 9779 | continue; |
| 9780 | 9780 | } |
| 9781 | 9781 | } |
| 9782 | 9782 | |
| 9783 | - if( $level !== 0 ){ |
|
| 9784 | - if( ($lastMultiComment > $lastOpening) && ($lastMultiCommentEndBrace > $lastMultiComment) ){ |
|
| 9783 | + if ($level!==0) { |
|
| 9784 | + if (($lastMultiComment>$lastOpening) && ($lastMultiCommentEndBrace>$lastMultiComment)) { |
|
| 9785 | 9785 | return $this->fail("missing closing `}` or `*/`", $lastOpening); |
| 9786 | - } else { |
|
| 9786 | + }else { |
|
| 9787 | 9787 | return $this->fail("missing closing `}`", $lastOpening); |
| 9788 | 9788 | } |
| 9789 | - } else if ( $parenLevel !== 0 ){ |
|
| 9789 | + }else if ($parenLevel!==0) { |
|
| 9790 | 9790 | return $this->fail("missing closing `)`", $lastParen); |
| 9791 | 9791 | } |
| 9792 | 9792 | |
@@ -9797,16 +9797,16 @@ discard block |
||
| 9797 | 9797 | //$this->emitChunk(true); |
| 9798 | 9798 | } |
| 9799 | 9799 | |
| 9800 | - public function CharCode($pos){ |
|
| 9800 | + public function CharCode($pos) { |
|
| 9801 | 9801 | return ord($this->input[$pos]); |
| 9802 | 9802 | } |
| 9803 | 9803 | |
| 9804 | 9804 | |
| 9805 | - public function fail( $msg, $index = null ){ |
|
| 9805 | + public function fail($msg, $index = null) { |
|
| 9806 | 9806 | |
| 9807 | - if( !$index ){ |
|
| 9807 | + if (!$index) { |
|
| 9808 | 9808 | $this->index = $this->parserCurrentIndex; |
| 9809 | - }else{ |
|
| 9809 | + }else { |
|
| 9810 | 9810 | $this->index = $index; |
| 9811 | 9811 | } |
| 9812 | 9812 | $this->message = 'ParseError: '.$msg; |
@@ -9833,7 +9833,7 @@ discard block |
||
| 9833 | 9833 | * @package Less |
| 9834 | 9834 | * @subpackage exception |
| 9835 | 9835 | */ |
| 9836 | -class Less_Exception_Compiler extends Less_Exception_Parser{ |
|
| 9836 | +class Less_Exception_Compiler extends Less_Exception_Parser { |
|
| 9837 | 9837 | |
| 9838 | 9838 | } |
| 9839 | 9839 | |
@@ -9879,7 +9879,7 @@ discard block |
||
| 9879 | 9879 | * @param array $contentsMap Array of filename to contents map |
| 9880 | 9880 | * @param Less_SourceMap_Generator $generator |
| 9881 | 9881 | */ |
| 9882 | - public function __construct(array $contentsMap, $generator){ |
|
| 9882 | + public function __construct(array $contentsMap, $generator) { |
|
| 9883 | 9883 | $this->contentsMap = $contentsMap; |
| 9884 | 9884 | $this->generator = $generator; |
| 9885 | 9885 | } |
@@ -9893,10 +9893,10 @@ discard block |
||
| 9893 | 9893 | * @param integer $index |
| 9894 | 9894 | * @param mixed $mapLines |
| 9895 | 9895 | */ |
| 9896 | - public function add($chunk, $fileInfo = null, $index = 0, $mapLines = null){ |
|
| 9896 | + public function add($chunk, $fileInfo = null, $index = 0, $mapLines = null) { |
|
| 9897 | 9897 | |
| 9898 | 9898 | //ignore adding empty strings |
| 9899 | - if( $chunk === '' ){ |
|
| 9899 | + if ($chunk==='') { |
|
| 9900 | 9900 | return; |
| 9901 | 9901 | } |
| 9902 | 9902 | |
@@ -9905,15 +9905,15 @@ discard block |
||
| 9905 | 9905 | $sourceColumns = ' '; |
| 9906 | 9906 | |
| 9907 | 9907 | |
| 9908 | - if( $fileInfo ){ |
|
| 9908 | + if ($fileInfo) { |
|
| 9909 | 9909 | |
| 9910 | 9910 | $url = $fileInfo['currentUri']; |
| 9911 | 9911 | |
| 9912 | - if( isset($this->contentsMap[$url]) ){ |
|
| 9912 | + if (isset($this->contentsMap[$url])) { |
|
| 9913 | 9913 | $inputSource = substr($this->contentsMap[$url], 0, $index); |
| 9914 | 9914 | $sourceLines = explode("\n", $inputSource); |
| 9915 | 9915 | $sourceColumns = end($sourceLines); |
| 9916 | - }else{ |
|
| 9916 | + }else { |
|
| 9917 | 9917 | throw new Exception('Filename '.$url.' not in contentsMap'); |
| 9918 | 9918 | } |
| 9919 | 9919 | |
@@ -9922,33 +9922,33 @@ discard block |
||
| 9922 | 9922 | $lines = explode("\n", $chunk); |
| 9923 | 9923 | $columns = end($lines); |
| 9924 | 9924 | |
| 9925 | - if($fileInfo){ |
|
| 9925 | + if ($fileInfo) { |
|
| 9926 | 9926 | |
| 9927 | - if(!$mapLines){ |
|
| 9927 | + if (!$mapLines) { |
|
| 9928 | 9928 | $this->generator->addMapping( |
| 9929 | - $this->lineNumber + 1, // generated_line |
|
| 9930 | - $this->column, // generated_column |
|
| 9931 | - count($sourceLines), // original_line |
|
| 9932 | - strlen($sourceColumns), // original_column |
|
| 9929 | + $this->lineNumber+1, // generated_line |
|
| 9930 | + $this->column, // generated_column |
|
| 9931 | + count($sourceLines), // original_line |
|
| 9932 | + strlen($sourceColumns), // original_column |
|
| 9933 | 9933 | $fileInfo |
| 9934 | 9934 | ); |
| 9935 | - }else{ |
|
| 9936 | - for($i = 0, $count = count($lines); $i < $count; $i++){ |
|
| 9935 | + }else { |
|
| 9936 | + for ($i = 0, $count = count($lines); $i<$count; $i++) { |
|
| 9937 | 9937 | $this->generator->addMapping( |
| 9938 | - $this->lineNumber + $i + 1, // generated_line |
|
| 9939 | - $i === 0 ? $this->column : 0, // generated_column |
|
| 9940 | - count($sourceLines) + $i, // original_line |
|
| 9941 | - $i === 0 ? strlen($sourceColumns) : 0, // original_column |
|
| 9938 | + $this->lineNumber+$i+1, // generated_line |
|
| 9939 | + $i===0 ? $this->column : 0, // generated_column |
|
| 9940 | + count($sourceLines)+$i, // original_line |
|
| 9941 | + $i===0 ? strlen($sourceColumns) : 0, // original_column |
|
| 9942 | 9942 | $fileInfo |
| 9943 | 9943 | ); |
| 9944 | 9944 | } |
| 9945 | 9945 | } |
| 9946 | 9946 | } |
| 9947 | 9947 | |
| 9948 | - if(count($lines) === 1){ |
|
| 9948 | + if (count($lines)===1) { |
|
| 9949 | 9949 | $this->column += strlen($columns); |
| 9950 | - }else{ |
|
| 9951 | - $this->lineNumber += count($lines) - 1; |
|
| 9950 | + }else { |
|
| 9951 | + $this->lineNumber += count($lines)-1; |
|
| 9952 | 9952 | $this->column = strlen($columns); |
| 9953 | 9953 | } |
| 9954 | 9954 | |
@@ -9994,14 +9994,14 @@ discard block |
||
| 9994 | 9994 | */ |
| 9995 | 9995 | private $charToIntMap = array( |
| 9996 | 9996 | 'A' => 0, 'B' => 1, 'C' => 2, 'D' => 3, 'E' => 4, 'F' => 5, 'G' => 6, |
| 9997 | - 'H' => 7,'I' => 8, 'J' => 9, 'K' => 10, 'L' => 11, 'M' => 12, 'N' => 13, |
|
| 9997 | + 'H' => 7, 'I' => 8, 'J' => 9, 'K' => 10, 'L' => 11, 'M' => 12, 'N' => 13, |
|
| 9998 | 9998 | 'O' => 14, 'P' => 15, 'Q' => 16, 'R' => 17, 'S' => 18, 'T' => 19, 'U' => 20, |
| 9999 | 9999 | 'V' => 21, 'W' => 22, 'X' => 23, 'Y' => 24, 'Z' => 25, 'a' => 26, 'b' => 27, |
| 10000 | 10000 | 'c' => 28, 'd' => 29, 'e' => 30, 'f' => 31, 'g' => 32, 'h' => 33, 'i' => 34, |
| 10001 | 10001 | 'j' => 35, 'k' => 36, 'l' => 37, 'm' => 38, 'n' => 39, 'o' => 40, 'p' => 41, |
| 10002 | 10002 | 'q' => 42, 'r' => 43, 's' => 44, 't' => 45, 'u' => 46, 'v' => 47, 'w' => 48, |
| 10003 | 10003 | 'x' => 49, 'y' => 50, 'z' => 51, 0 => 52, 1 => 53, 2 => 54, 3 => 55, 4 => 56, |
| 10004 | - 5 => 57, 6 => 58, 7 => 59, 8 => 60, 9 => 61, '+' => 62, '/' => 63, |
|
| 10004 | + 5 => 57, 6 => 58, 7 => 59, 8 => 60, 9 => 61, '+' => 62, '/' => 63, |
|
| 10005 | 10005 | ); |
| 10006 | 10006 | |
| 10007 | 10007 | /** |
@@ -10025,7 +10025,7 @@ discard block |
||
| 10025 | 10025 | /** |
| 10026 | 10026 | * Constructor |
| 10027 | 10027 | */ |
| 10028 | - public function __construct(){ |
|
| 10028 | + public function __construct() { |
|
| 10029 | 10029 | // I leave it here for future reference |
| 10030 | 10030 | // foreach(str_split('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/') as $i => $char) |
| 10031 | 10031 | // { |
@@ -10043,8 +10043,8 @@ discard block |
||
| 10043 | 10043 | * even on a 64 bit machine. |
| 10044 | 10044 | * @param string $aValue |
| 10045 | 10045 | */ |
| 10046 | - public function toVLQSigned($aValue){ |
|
| 10047 | - return 0xffffffff & ($aValue < 0 ? ((-$aValue) << 1) + 1 : ($aValue << 1) + 0); |
|
| 10046 | + public function toVLQSigned($aValue) { |
|
| 10047 | + return 0xffffffff&($aValue<0 ? ((-$aValue) << 1)+1 : ($aValue << 1)+0); |
|
| 10048 | 10048 | } |
| 10049 | 10049 | |
| 10050 | 10050 | /** |
@@ -10058,8 +10058,8 @@ discard block |
||
| 10058 | 10058 | * even on a 64 bit machine. |
| 10059 | 10059 | * @param integer $aValue |
| 10060 | 10060 | */ |
| 10061 | - public function fromVLQSigned($aValue){ |
|
| 10062 | - return $aValue & 1 ? $this->zeroFill(~$aValue + 2, 1) | (-1 - 0x7fffffff) : $this->zeroFill($aValue, 1); |
|
| 10061 | + public function fromVLQSigned($aValue) { |
|
| 10062 | + return $aValue&1 ? $this->zeroFill(~$aValue+2, 1)|(-1-0x7fffffff) : $this->zeroFill($aValue, 1); |
|
| 10063 | 10063 | } |
| 10064 | 10064 | |
| 10065 | 10065 | /** |
@@ -10068,18 +10068,18 @@ discard block |
||
| 10068 | 10068 | * @param string $aValue The value to encode |
| 10069 | 10069 | * @return string The encoded value |
| 10070 | 10070 | */ |
| 10071 | - public function encode($aValue){ |
|
| 10071 | + public function encode($aValue) { |
|
| 10072 | 10072 | $encoded = ''; |
| 10073 | 10073 | $vlq = $this->toVLQSigned($aValue); |
| 10074 | 10074 | do |
| 10075 | 10075 | { |
| 10076 | - $digit = $vlq & $this->mask; |
|
| 10076 | + $digit = $vlq&$this->mask; |
|
| 10077 | 10077 | $vlq = $this->zeroFill($vlq, $this->shift); |
| 10078 | - if($vlq > 0){ |
|
| 10078 | + if ($vlq>0) { |
|
| 10079 | 10079 | $digit |= $this->continuationBit; |
| 10080 | 10080 | } |
| 10081 | 10081 | $encoded .= $this->base64Encode($digit); |
| 10082 | - } while($vlq > 0); |
|
| 10082 | + } while ($vlq>0); |
|
| 10083 | 10083 | |
| 10084 | 10084 | return $encoded; |
| 10085 | 10085 | } |
@@ -10090,15 +10090,15 @@ discard block |
||
| 10090 | 10090 | * @param string $encoded The encoded value to decode |
| 10091 | 10091 | * @return integer The decoded value |
| 10092 | 10092 | */ |
| 10093 | - public function decode($encoded){ |
|
| 10093 | + public function decode($encoded) { |
|
| 10094 | 10094 | $vlq = 0; |
| 10095 | 10095 | $i = 0; |
| 10096 | 10096 | do |
| 10097 | 10097 | { |
| 10098 | 10098 | $digit = $this->base64Decode($encoded[$i]); |
| 10099 | - $vlq |= ($digit & $this->mask) << ($i * $this->shift); |
|
| 10099 | + $vlq |= ($digit&$this->mask) << ($i * $this->shift); |
|
| 10100 | 10100 | $i++; |
| 10101 | - } while($digit & $this->continuationBit); |
|
| 10101 | + } while ($digit&$this->continuationBit); |
|
| 10102 | 10102 | |
| 10103 | 10103 | return $this->fromVLQSigned($vlq); |
| 10104 | 10104 | } |
@@ -10110,8 +10110,8 @@ discard block |
||
| 10110 | 10110 | * @param integer $b number of bits to shift |
| 10111 | 10111 | * @return integer |
| 10112 | 10112 | */ |
| 10113 | - public function zeroFill($a, $b){ |
|
| 10114 | - return ($a >= 0) ? ($a >> $b) : ($a >> $b) & (PHP_INT_MAX >> ($b - 1)); |
|
| 10113 | + public function zeroFill($a, $b) { |
|
| 10114 | + return ($a>=0) ? ($a >> $b) : ($a >> $b)&(PHP_INT_MAX >> ($b-1)); |
|
| 10115 | 10115 | } |
| 10116 | 10116 | |
| 10117 | 10117 | /** |
@@ -10121,8 +10121,8 @@ discard block |
||
| 10121 | 10121 | * @return string |
| 10122 | 10122 | * @throws Exception If the number is invalid |
| 10123 | 10123 | */ |
| 10124 | - public function base64Encode($number){ |
|
| 10125 | - if($number < 0 || $number > 63){ |
|
| 10124 | + public function base64Encode($number) { |
|
| 10125 | + if ($number<0 || $number>63) { |
|
| 10126 | 10126 | throw new Exception(sprintf('Invalid number "%s" given. Must be between 0 and 63.', $number)); |
| 10127 | 10127 | } |
| 10128 | 10128 | return $this->intToCharMap[$number]; |
@@ -10135,8 +10135,8 @@ discard block |
||
| 10135 | 10135 | * @return number |
| 10136 | 10136 | * @throws Exception If the number is invalid |
| 10137 | 10137 | */ |
| 10138 | - public function base64Decode($char){ |
|
| 10139 | - if(!array_key_exists($char, $this->charToIntMap)){ |
|
| 10138 | + public function base64Decode($char) { |
|
| 10139 | + if (!array_key_exists($char, $this->charToIntMap)) { |
|
| 10140 | 10140 | throw new Exception(sprintf('Invalid base 64 digit "%s" given.', $char)); |
| 10141 | 10141 | } |
| 10142 | 10142 | return $this->charToIntMap[$char]; |
@@ -10230,7 +10230,7 @@ discard block |
||
| 10230 | 10230 | * @param Less_Tree_Ruleset $root The root node |
| 10231 | 10231 | * @param array $options Array of options |
| 10232 | 10232 | */ |
| 10233 | - public function __construct(Less_Tree_Ruleset $root, $contentsMap, $options = array()){ |
|
| 10233 | + public function __construct(Less_Tree_Ruleset $root, $contentsMap, $options = array()) { |
|
| 10234 | 10234 | $this->root = $root; |
| 10235 | 10235 | $this->contentsMap = $contentsMap; |
| 10236 | 10236 | $this->encoder = new Less_SourceMap_Base64VLQ(); |
@@ -10246,34 +10246,34 @@ discard block |
||
| 10246 | 10246 | * |
| 10247 | 10247 | * @return string |
| 10248 | 10248 | */ |
| 10249 | - public function generateCSS(){ |
|
| 10249 | + public function generateCSS() { |
|
| 10250 | 10250 | $output = new Less_Output_Mapped($this->contentsMap, $this); |
| 10251 | 10251 | |
| 10252 | 10252 | // catch the output |
| 10253 | 10253 | $this->root->genCSS($output); |
| 10254 | 10254 | |
| 10255 | 10255 | |
| 10256 | - $sourceMapUrl = $this->getOption('sourceMapURL'); |
|
| 10257 | - $sourceMapFilename = $this->getOption('sourceMapFilename'); |
|
| 10256 | + $sourceMapUrl = $this->getOption('sourceMapURL'); |
|
| 10257 | + $sourceMapFilename = $this->getOption('sourceMapFilename'); |
|
| 10258 | 10258 | $sourceMapContent = $this->generateJson(); |
| 10259 | 10259 | $sourceMapWriteTo = $this->getOption('sourceMapWriteTo'); |
| 10260 | 10260 | |
| 10261 | - if( !$sourceMapUrl && $sourceMapFilename ){ |
|
| 10261 | + if (!$sourceMapUrl && $sourceMapFilename) { |
|
| 10262 | 10262 | $sourceMapUrl = $this->normalizeFilename($sourceMapFilename); |
| 10263 | 10263 | } |
| 10264 | 10264 | |
| 10265 | 10265 | // write map to a file |
| 10266 | - if( $sourceMapWriteTo ){ |
|
| 10266 | + if ($sourceMapWriteTo) { |
|
| 10267 | 10267 | $this->saveMap($sourceMapWriteTo, $sourceMapContent); |
| 10268 | 10268 | } |
| 10269 | 10269 | |
| 10270 | 10270 | // inline the map |
| 10271 | - if( !$sourceMapUrl ){ |
|
| 10271 | + if (!$sourceMapUrl) { |
|
| 10272 | 10272 | $sourceMapUrl = sprintf('data:application/json,%s', Less_Functions::encodeURIComponent($sourceMapContent)); |
| 10273 | 10273 | } |
| 10274 | 10274 | |
| 10275 | - if( $sourceMapUrl ){ |
|
| 10276 | - $output->add( sprintf('/*# sourceMappingURL=%s */', $sourceMapUrl) ); |
|
| 10275 | + if ($sourceMapUrl) { |
|
| 10276 | + $output->add(sprintf('/*# sourceMappingURL=%s */', $sourceMapUrl)); |
|
| 10277 | 10277 | } |
| 10278 | 10278 | |
| 10279 | 10279 | return $output->toString(); |
@@ -10286,15 +10286,15 @@ discard block |
||
| 10286 | 10286 | * @param string $content The content to write |
| 10287 | 10287 | * @throws Exception If the file could not be saved |
| 10288 | 10288 | */ |
| 10289 | - protected function saveMap($file, $content){ |
|
| 10289 | + protected function saveMap($file, $content) { |
|
| 10290 | 10290 | $dir = dirname($file); |
| 10291 | 10291 | // directory does not exist |
| 10292 | - if( !is_dir($dir) ){ |
|
| 10292 | + if (!is_dir($dir)) { |
|
| 10293 | 10293 | // FIXME: create the dir automatically? |
| 10294 | 10294 | throw new Exception(sprintf('The directory "%s" does not exist. Cannot save the source map.', $dir)); |
| 10295 | 10295 | } |
| 10296 | 10296 | // FIXME: proper saving, with dir write check! |
| 10297 | - if(file_put_contents($file, $content) === false){ |
|
| 10297 | + if (file_put_contents($file, $content)===false) { |
|
| 10298 | 10298 | throw new Exception(sprintf('Cannot save the source map to "%s"', $file)); |
| 10299 | 10299 | } |
| 10300 | 10300 | return true; |
@@ -10306,7 +10306,7 @@ discard block |
||
| 10306 | 10306 | * @param string $filename |
| 10307 | 10307 | * @return string |
| 10308 | 10308 | */ |
| 10309 | - protected function normalizeFilename($filename){ |
|
| 10309 | + protected function normalizeFilename($filename) { |
|
| 10310 | 10310 | |
| 10311 | 10311 | $filename = $this->fixWindowsPath($filename); |
| 10312 | 10312 | |
@@ -10314,16 +10314,16 @@ discard block |
||
| 10314 | 10314 | $basePath = $this->getOption('sourceMapBasepath'); |
| 10315 | 10315 | |
| 10316 | 10316 | // "Trim" the 'sourceMapBasepath' from the output filename. |
| 10317 | - if (strpos($filename, $basePath) === 0) { |
|
| 10317 | + if (strpos($filename, $basePath)===0) { |
|
| 10318 | 10318 | $filename = substr($filename, strlen($basePath)); |
| 10319 | 10319 | } |
| 10320 | 10320 | |
| 10321 | 10321 | // Remove extra leading path separators. |
| 10322 | - if(strpos($filename, '\\') === 0 || strpos($filename, '/') === 0){ |
|
| 10322 | + if (strpos($filename, '\\')===0 || strpos($filename, '/')===0) { |
|
| 10323 | 10323 | $filename = substr($filename, 1); |
| 10324 | 10324 | } |
| 10325 | 10325 | |
| 10326 | - return $rootpath . $filename; |
|
| 10326 | + return $rootpath.$filename; |
|
| 10327 | 10327 | } |
| 10328 | 10328 | |
| 10329 | 10329 | /** |
@@ -10335,7 +10335,7 @@ discard block |
||
| 10335 | 10335 | * @param integer $originalColumn The column number in original file |
| 10336 | 10336 | * @param string $sourceFile The original source file |
| 10337 | 10337 | */ |
| 10338 | - public function addMapping($generatedLine, $generatedColumn, $originalLine, $originalColumn, $fileInfo ){ |
|
| 10338 | + public function addMapping($generatedLine, $generatedColumn, $originalLine, $originalColumn, $fileInfo) { |
|
| 10339 | 10339 | |
| 10340 | 10340 | $this->mappings[] = array( |
| 10341 | 10341 | 'generated_line' => $generatedLine, |
@@ -10355,7 +10355,7 @@ discard block |
||
| 10355 | 10355 | * @return string |
| 10356 | 10356 | * @see https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit# |
| 10357 | 10357 | */ |
| 10358 | - protected function generateJson(){ |
|
| 10358 | + protected function generateJson() { |
|
| 10359 | 10359 | |
| 10360 | 10360 | $sourceMap = array(); |
| 10361 | 10361 | $mappings = $this->generateMappings(); |
@@ -10366,21 +10366,21 @@ discard block |
||
| 10366 | 10366 | |
| 10367 | 10367 | // An optional name of the generated code that this source map is associated with. |
| 10368 | 10368 | $file = $this->getOption('sourceMapFilename'); |
| 10369 | - if( $file ){ |
|
| 10369 | + if ($file) { |
|
| 10370 | 10370 | $sourceMap['file'] = $file; |
| 10371 | 10371 | } |
| 10372 | 10372 | |
| 10373 | 10373 | |
| 10374 | 10374 | // An optional source root, useful for relocating source files on a server or removing repeated values in the 'sources' entry. This value is prepended to the individual entries in the 'source' field. |
| 10375 | 10375 | $root = $this->getOption('sourceRoot'); |
| 10376 | - if( $root ){ |
|
| 10376 | + if ($root) { |
|
| 10377 | 10377 | $sourceMap['sourceRoot'] = $root; |
| 10378 | 10378 | } |
| 10379 | 10379 | |
| 10380 | 10380 | |
| 10381 | 10381 | // A list of original sources used by the 'mappings' entry. |
| 10382 | 10382 | $sourceMap['sources'] = array(); |
| 10383 | - foreach($this->sources as $source_uri => $source_filename){ |
|
| 10383 | + foreach ($this->sources as $source_uri => $source_filename) { |
|
| 10384 | 10384 | $sourceMap['sources'][] = $this->normalizeFilename($source_filename); |
| 10385 | 10385 | } |
| 10386 | 10386 | |
@@ -10391,7 +10391,7 @@ discard block |
||
| 10391 | 10391 | // A string with the encoded mapping data. |
| 10392 | 10392 | $sourceMap['mappings'] = $mappings; |
| 10393 | 10393 | |
| 10394 | - if( $this->getOption('outputSourceFiles') ){ |
|
| 10394 | + if ($this->getOption('outputSourceFiles')) { |
|
| 10395 | 10395 | // An optional list of source content, useful when the 'source' can't be hosted. |
| 10396 | 10396 | // The contents are listed in the same order as the sources above. |
| 10397 | 10397 | // 'null' may be used if some original sources should be retrieved by name. |
@@ -10399,7 +10399,7 @@ discard block |
||
| 10399 | 10399 | } |
| 10400 | 10400 | |
| 10401 | 10401 | // less.js compat fixes |
| 10402 | - if( count($sourceMap['sources']) && empty($sourceMap['sourceRoot']) ){ |
|
| 10402 | + if (count($sourceMap['sources']) && empty($sourceMap['sourceRoot'])) { |
|
| 10403 | 10403 | unset($sourceMap['sourceRoot']); |
| 10404 | 10404 | } |
| 10405 | 10405 | |
@@ -10411,12 +10411,12 @@ discard block |
||
| 10411 | 10411 | * |
| 10412 | 10412 | * @return array|null |
| 10413 | 10413 | */ |
| 10414 | - protected function getSourcesContent(){ |
|
| 10415 | - if(empty($this->sources)){ |
|
| 10414 | + protected function getSourcesContent() { |
|
| 10415 | + if (empty($this->sources)) { |
|
| 10416 | 10416 | return; |
| 10417 | 10417 | } |
| 10418 | 10418 | $content = array(); |
| 10419 | - foreach($this->sources as $sourceFile){ |
|
| 10419 | + foreach ($this->sources as $sourceFile) { |
|
| 10420 | 10420 | $content[] = file_get_contents($sourceFile); |
| 10421 | 10421 | } |
| 10422 | 10422 | return $content; |
@@ -10427,9 +10427,9 @@ discard block |
||
| 10427 | 10427 | * |
| 10428 | 10428 | * @return string |
| 10429 | 10429 | */ |
| 10430 | - public function generateMappings(){ |
|
| 10430 | + public function generateMappings() { |
|
| 10431 | 10431 | |
| 10432 | - if( !count($this->mappings) ){ |
|
| 10432 | + if (!count($this->mappings)) { |
|
| 10433 | 10433 | return ''; |
| 10434 | 10434 | } |
| 10435 | 10435 | |
@@ -10438,37 +10438,37 @@ discard block |
||
| 10438 | 10438 | |
| 10439 | 10439 | // group mappings by generated line number. |
| 10440 | 10440 | $groupedMap = $groupedMapEncoded = array(); |
| 10441 | - foreach($this->mappings as $m){ |
|
| 10441 | + foreach ($this->mappings as $m) { |
|
| 10442 | 10442 | $groupedMap[$m['generated_line']][] = $m; |
| 10443 | 10443 | } |
| 10444 | 10444 | ksort($groupedMap); |
| 10445 | 10445 | |
| 10446 | 10446 | $lastGeneratedLine = $lastOriginalIndex = $lastOriginalLine = $lastOriginalColumn = 0; |
| 10447 | 10447 | |
| 10448 | - foreach($groupedMap as $lineNumber => $line_map){ |
|
| 10449 | - while(++$lastGeneratedLine < $lineNumber){ |
|
| 10448 | + foreach ($groupedMap as $lineNumber => $line_map) { |
|
| 10449 | + while (++$lastGeneratedLine<$lineNumber) { |
|
| 10450 | 10450 | $groupedMapEncoded[] = ';'; |
| 10451 | 10451 | } |
| 10452 | 10452 | |
| 10453 | 10453 | $lineMapEncoded = array(); |
| 10454 | 10454 | $lastGeneratedColumn = 0; |
| 10455 | 10455 | |
| 10456 | - foreach($line_map as $m){ |
|
| 10457 | - $mapEncoded = $this->encoder->encode($m['generated_column'] - $lastGeneratedColumn); |
|
| 10456 | + foreach ($line_map as $m) { |
|
| 10457 | + $mapEncoded = $this->encoder->encode($m['generated_column']-$lastGeneratedColumn); |
|
| 10458 | 10458 | $lastGeneratedColumn = $m['generated_column']; |
| 10459 | 10459 | |
| 10460 | 10460 | // find the index |
| 10461 | - if( $m['source_file'] ){ |
|
| 10461 | + if ($m['source_file']) { |
|
| 10462 | 10462 | $index = $this->findFileIndex($m['source_file']); |
| 10463 | - if( $index !== false ){ |
|
| 10464 | - $mapEncoded .= $this->encoder->encode($index - $lastOriginalIndex); |
|
| 10463 | + if ($index!==false) { |
|
| 10464 | + $mapEncoded .= $this->encoder->encode($index-$lastOriginalIndex); |
|
| 10465 | 10465 | $lastOriginalIndex = $index; |
| 10466 | 10466 | |
| 10467 | 10467 | // lines are stored 0-based in SourceMap spec version 3 |
| 10468 | - $mapEncoded .= $this->encoder->encode($m['original_line'] - 1 - $lastOriginalLine); |
|
| 10469 | - $lastOriginalLine = $m['original_line'] - 1; |
|
| 10468 | + $mapEncoded .= $this->encoder->encode($m['original_line']-1-$lastOriginalLine); |
|
| 10469 | + $lastOriginalLine = $m['original_line']-1; |
|
| 10470 | 10470 | |
| 10471 | - $mapEncoded .= $this->encoder->encode($m['original_column'] - $lastOriginalColumn); |
|
| 10471 | + $mapEncoded .= $this->encoder->encode($m['original_column']-$lastOriginalColumn); |
|
| 10472 | 10472 | $lastOriginalColumn = $m['original_column']; |
| 10473 | 10473 | } |
| 10474 | 10474 | } |
@@ -10476,7 +10476,7 @@ discard block |
||
| 10476 | 10476 | $lineMapEncoded[] = $mapEncoded; |
| 10477 | 10477 | } |
| 10478 | 10478 | |
| 10479 | - $groupedMapEncoded[] = implode(',', $lineMapEncoded) . ';'; |
|
| 10479 | + $groupedMapEncoded[] = implode(',', $lineMapEncoded).';'; |
|
| 10480 | 10480 | } |
| 10481 | 10481 | |
| 10482 | 10482 | return rtrim(implode($groupedMapEncoded), ';'); |
@@ -10488,7 +10488,7 @@ discard block |
||
| 10488 | 10488 | * @param string $filename |
| 10489 | 10489 | * @return integer|false |
| 10490 | 10490 | */ |
| 10491 | - protected function findFileIndex($filename){ |
|
| 10491 | + protected function findFileIndex($filename) { |
|
| 10492 | 10492 | return $this->source_keys[$filename]; |
| 10493 | 10493 | } |
| 10494 | 10494 | |
@@ -10497,11 +10497,11 @@ discard block |
||
| 10497 | 10497 | * @param string $path |
| 10498 | 10498 | * @return string |
| 10499 | 10499 | */ |
| 10500 | - public function fixWindowsPath($path, $addEndSlash = false){ |
|
| 10500 | + public function fixWindowsPath($path, $addEndSlash = false) { |
|
| 10501 | 10501 | $slash = ($addEndSlash) ? '/' : ''; |
| 10502 | - if( !empty($path) ){ |
|
| 10502 | + if (!empty($path)) { |
|
| 10503 | 10503 | $path = str_replace('\\', '/', $path); |
| 10504 | - $path = rtrim($path,'/') . $slash; |
|
| 10504 | + $path = rtrim($path, '/').$slash; |
|
| 10505 | 10505 | } |
| 10506 | 10506 | |
| 10507 | 10507 | return $path; |
@@ -27,21 +27,21 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | if (TYPO3_MODE === 'BE' && !(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_INSTALL)) { |
| 29 | 29 | |
| 30 | - /*************** |
|
| 30 | + /*************** |
|
| 31 | 31 | * Register Main Module |
| 32 | 32 | */ |
| 33 | 33 | $mainModuleName = "moox"; |
| 34 | 34 | if (!isset($TBE_MODULES[$mainModuleName])) { |
| 35 | - $temp_TBE_MODULES = array(); |
|
| 36 | - foreach ($TBE_MODULES as $key => $val) { |
|
| 37 | - if ($key == 'web') { |
|
| 38 | - $temp_TBE_MODULES[$key] = $val; |
|
| 39 | - $temp_TBE_MODULES[$mainModuleName] = ''; |
|
| 40 | - } else { |
|
| 41 | - $temp_TBE_MODULES[$key] = $val; |
|
| 42 | - } |
|
| 43 | - } |
|
| 44 | - $TBE_MODULES = $temp_TBE_MODULES; |
|
| 35 | + $temp_TBE_MODULES = array(); |
|
| 36 | + foreach ($TBE_MODULES as $key => $val) { |
|
| 37 | + if ($key == 'web') { |
|
| 38 | + $temp_TBE_MODULES[$key] = $val; |
|
| 39 | + $temp_TBE_MODULES[$mainModuleName] = ''; |
|
| 40 | + } else { |
|
| 41 | + $temp_TBE_MODULES[$key] = $val; |
|
| 42 | + } |
|
| 43 | + } |
|
| 44 | + $TBE_MODULES = $temp_TBE_MODULES; |
|
| 45 | 45 | \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule( |
| 46 | 46 | 'DCNGmbH.'.$_EXTKEY, |
| 47 | 47 | $mainModuleName, |
@@ -54,13 +54,13 @@ discard block |
||
| 54 | 54 | 'labels' => 'LLL:EXT:'.$_EXTKEY.'/Resources/Private/Language/MainModule.xlf', |
| 55 | 55 | ) |
| 56 | 56 | ); |
| 57 | - } |
|
| 58 | - \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule( |
|
| 59 | - 'DCNGmbH.'.$_EXTKEY, |
|
| 60 | - $mainModuleName, |
|
| 61 | - 'dashboard', |
|
| 62 | - 'top', |
|
| 63 | - array( |
|
| 57 | + } |
|
| 58 | + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule( |
|
| 59 | + 'DCNGmbH.'.$_EXTKEY, |
|
| 60 | + $mainModuleName, |
|
| 61 | + 'dashboard', |
|
| 62 | + 'top', |
|
| 63 | + array( |
|
| 64 | 64 | 'Administration' => 'dashboard', |
| 65 | 65 | ), |
| 66 | 66 | array( |
@@ -68,5 +68,5 @@ discard block |
||
| 68 | 68 | 'icon' => 'EXT:' . $_EXTKEY . '/Resources/Public/Icons/module-mooxcore.svg', |
| 69 | 69 | 'labels' => 'LLL:EXT:' . $_EXTKEY . '/Resources/Private/Language/DashboardModule.xlf', |
| 70 | 70 | ) |
| 71 | - ); |
|
| 71 | + ); |
|
| 72 | 72 | } |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile($_EXTKEY, 'Configuration/TypoScript', 'MOOX Core'); |
| 7 | -if ('BE' === TYPO3_MODE) { |
|
| 7 | +if ('BE'===TYPO3_MODE) { |
|
| 8 | 8 | \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScript($_EXTKEY, 'constants', '<INCLUDE_TYPOSCRIPT: source="FILE:EXT:moox_core/Configuration/TypoScript/constants.txt">'); |
| 9 | 9 | \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScript($_EXTKEY, 'setup', '<INCLUDE_TYPOSCRIPT: source="FILE:EXT:moox_core/Configuration/TypoScript/setup.txt">'); |
| 10 | 10 | } |
@@ -13,10 +13,10 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['moox_core']['setup'] = unserialize($_EXTCONF); |
| 15 | 15 | |
| 16 | -if (FALSE === (boolean) $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['moox_core']['setup']['disablePageTemplates']) { |
|
| 16 | +if (FALSE===(boolean)$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['moox_core']['setup']['disablePageTemplates']) { |
|
| 17 | 17 | \FluidTYPO3\Flux\Core::registerProviderExtensionKey('DCNGmbH.MooxCore', 'Page'); |
| 18 | 18 | } |
| 19 | -if (FALSE === (boolean) $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['moox_core']['setup']['disableContentTemplates']) { |
|
| 19 | +if (FALSE===(boolean)$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['moox_core']['setup']['disableContentTemplates']) { |
|
| 20 | 20 | \FluidTYPO3\Flux\Core::registerProviderExtensionKey('DCNGmbH.MooxCore', 'Content'); |
| 21 | 21 | } |
| 22 | 22 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | Register BE-Module for Administration |
| 26 | 26 | =========================================================================== */ |
| 27 | 27 | |
| 28 | -if (TYPO3_MODE === 'BE' && !(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_INSTALL)) { |
|
| 28 | +if (TYPO3_MODE==='BE' && !(TYPO3_REQUESTTYPE&TYPO3_REQUESTTYPE_INSTALL)) { |
|
| 29 | 29 | |
| 30 | 30 | /*************** |
| 31 | 31 | * Register Main Module |
@@ -34,10 +34,10 @@ discard block |
||
| 34 | 34 | if (!isset($TBE_MODULES[$mainModuleName])) { |
| 35 | 35 | $temp_TBE_MODULES = array(); |
| 36 | 36 | foreach ($TBE_MODULES as $key => $val) { |
| 37 | - if ($key == 'web') { |
|
| 37 | + if ($key=='web') { |
|
| 38 | 38 | $temp_TBE_MODULES[$key] = $val; |
| 39 | 39 | $temp_TBE_MODULES[$mainModuleName] = ''; |
| 40 | - } else { |
|
| 40 | + }else { |
|
| 41 | 41 | $temp_TBE_MODULES[$key] = $val; |
| 42 | 42 | } |
| 43 | 43 | } |
@@ -65,8 +65,8 @@ discard block |
||
| 65 | 65 | ), |
| 66 | 66 | array( |
| 67 | 67 | 'access' => 'user,group', |
| 68 | - 'icon' => 'EXT:' . $_EXTKEY . '/Resources/Public/Icons/module-mooxcore.svg', |
|
| 69 | - 'labels' => 'LLL:EXT:' . $_EXTKEY . '/Resources/Private/Language/Module.xlf', |
|
| 68 | + 'icon' => 'EXT:'.$_EXTKEY.'/Resources/Public/Icons/module-mooxcore.svg', |
|
| 69 | + 'labels' => 'LLL:EXT:'.$_EXTKEY.'/Resources/Private/Language/Module.xlf', |
|
| 70 | 70 | ) |
| 71 | 71 | ); |
| 72 | 72 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | * writing. "version" and "dependencies" must not be touched! |
| 11 | 11 | ***************************************************************/ |
| 12 | 12 | |
| 13 | -$EM_CONF[$_EXTKEY] = array ( |
|
| 13 | +$EM_CONF[$_EXTKEY] = array( |
|
| 14 | 14 | 'title' => 'MOOX Bootstrap Core', |
| 15 | 15 | 'description' => 'TYPO3 Responsive using Less, Bootstrap, HTML5 Boilerplate and jQuery. Extended by MOOX Design Templates, MOOX News and other MOOX Extensions.', |
| 16 | 16 | 'category' => 'fe', |
@@ -28,8 +28,8 @@ discard block |
||
| 28 | 28 | 'author' => 'MOOX Team', |
| 29 | 29 | 'author_email' => '[email protected]', |
| 30 | 30 | 'author_company' => 'DCN GmbH', |
| 31 | - 'constraints' => array ( |
|
| 32 | - 'depends' => array ( |
|
| 31 | + 'constraints' => array( |
|
| 32 | + 'depends' => array( |
|
| 33 | 33 | 'typo3' => '7.6.0-7.6.99', |
| 34 | 34 | 'cms' => '', |
| 35 | 35 | 'flux' => '7.2.0-7.3.99', |
@@ -38,11 +38,11 @@ discard block |
||
| 38 | 38 | 'fluidpages' => '', |
| 39 | 39 | 'realurl' => '', |
| 40 | 40 | ), |
| 41 | - 'conflicts' => array ( |
|
| 41 | + 'conflicts' => array( |
|
| 42 | 42 | 'css_styled_content' => '', |
| 43 | 43 | 'fluid_styled_content' => '' |
| 44 | 44 | ), |
| 45 | - 'suggests' => array ( |
|
| 45 | + 'suggests' => array( |
|
| 46 | 46 | ), |
| 47 | 47 | ), |
| 48 | 48 | '_md5_values_when_last_written' => 'a:0:{}', |
@@ -35,70 +35,70 @@ |
||
| 35 | 35 | class CompileService |
| 36 | 36 | { |
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * @param string $file |
|
| 40 | - * @return bool|string |
|
| 41 | - * @throws \Exception |
|
| 42 | - */ |
|
| 43 | - public static function getCompiledFile($file) |
|
| 44 | - { |
|
| 45 | - $file = GeneralUtility::getFileAbsFileName($file); |
|
| 46 | - $pathParts = pathinfo($file); |
|
| 47 | - if ($pathParts['extension'] === 'less') { |
|
| 48 | - try { |
|
| 49 | - $options = array( |
|
| 50 | - 'cache_dir' => GeneralUtility::getFileAbsFileName('typo3temp/mooxcore') |
|
| 51 | - ); |
|
| 52 | - $settings = ($GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_mooxcore.']['settings.'] ?: array()); |
|
| 53 | - if ($settings['cssSourceMapping']) { |
|
| 54 | - // enable source mapping |
|
| 55 | - $optionsForSourceMap = array( |
|
| 56 | - 'sourceMap' => true, |
|
| 57 | - 'sourceMapWriteTo' => GeneralUtility::getFileAbsFileName('typo3temp/mooxcore') . '/mooxcore.map', |
|
| 58 | - 'sourceMapURL' => '/typo3temp/mooxcore/mooxcore.map', |
|
| 59 | - 'sourceMapBasepath' => PATH_site, |
|
| 60 | - 'sourceMapRootpath' => '/' |
|
| 61 | - ); |
|
| 62 | - $options += $optionsForSourceMap; |
|
| 38 | + /** |
|
| 39 | + * @param string $file |
|
| 40 | + * @return bool|string |
|
| 41 | + * @throws \Exception |
|
| 42 | + */ |
|
| 43 | + public static function getCompiledFile($file) |
|
| 44 | + { |
|
| 45 | + $file = GeneralUtility::getFileAbsFileName($file); |
|
| 46 | + $pathParts = pathinfo($file); |
|
| 47 | + if ($pathParts['extension'] === 'less') { |
|
| 48 | + try { |
|
| 49 | + $options = array( |
|
| 50 | + 'cache_dir' => GeneralUtility::getFileAbsFileName('typo3temp/mooxcore') |
|
| 51 | + ); |
|
| 52 | + $settings = ($GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_mooxcore.']['settings.'] ?: array()); |
|
| 53 | + if ($settings['cssSourceMapping']) { |
|
| 54 | + // enable source mapping |
|
| 55 | + $optionsForSourceMap = array( |
|
| 56 | + 'sourceMap' => true, |
|
| 57 | + 'sourceMapWriteTo' => GeneralUtility::getFileAbsFileName('typo3temp/mooxcore') . '/mooxcore.map', |
|
| 58 | + 'sourceMapURL' => '/typo3temp/mooxcore/mooxcore.map', |
|
| 59 | + 'sourceMapBasepath' => PATH_site, |
|
| 60 | + 'sourceMapRootpath' => '/' |
|
| 61 | + ); |
|
| 62 | + $options += $optionsForSourceMap; |
|
| 63 | 63 | |
| 64 | - // disable CSS compression |
|
| 65 | - /** @var $pageRenderer \TYPO3\CMS\Core\Page\PageRenderer */ |
|
| 66 | - $pageRenderer = $GLOBALS['TSFE']->getPageRenderer(); |
|
| 67 | - $pageRenderer->disableCompressCss(); |
|
| 68 | - } |
|
| 69 | - if ($settings['overrideLessVariables']) { |
|
| 70 | - $variables = self::getVariablesFromConstants(); |
|
| 71 | - } else { |
|
| 72 | - $variables = array(); |
|
| 73 | - } |
|
| 74 | - $files = array(); |
|
| 75 | - $files[$file] = '../../' . str_replace(PATH_site, '', dirname($file)) . '/'; |
|
| 76 | - $compiledFile = \Less_Cache::Get($files, $options, $variables); |
|
| 77 | - $file = "typo3temp/mooxcore/" . $compiledFile; |
|
| 64 | + // disable CSS compression |
|
| 65 | + /** @var $pageRenderer \TYPO3\CMS\Core\Page\PageRenderer */ |
|
| 66 | + $pageRenderer = $GLOBALS['TSFE']->getPageRenderer(); |
|
| 67 | + $pageRenderer->disableCompressCss(); |
|
| 68 | + } |
|
| 69 | + if ($settings['overrideLessVariables']) { |
|
| 70 | + $variables = self::getVariablesFromConstants(); |
|
| 71 | + } else { |
|
| 72 | + $variables = array(); |
|
| 73 | + } |
|
| 74 | + $files = array(); |
|
| 75 | + $files[$file] = '../../' . str_replace(PATH_site, '', dirname($file)) . '/'; |
|
| 76 | + $compiledFile = \Less_Cache::Get($files, $options, $variables); |
|
| 77 | + $file = "typo3temp/mooxcore/" . $compiledFile; |
|
| 78 | 78 | |
| 79 | - return $file; |
|
| 80 | - } catch (\Exception $e) { |
|
| 81 | - throw new \Exception($e->getMessage()); |
|
| 82 | - } |
|
| 83 | - } |
|
| 84 | - return false; |
|
| 85 | - } |
|
| 79 | + return $file; |
|
| 80 | + } catch (\Exception $e) { |
|
| 81 | + throw new \Exception($e->getMessage()); |
|
| 82 | + } |
|
| 83 | + } |
|
| 84 | + return false; |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - /** |
|
| 88 | - * @return array |
|
| 89 | - */ |
|
| 90 | - public function getVariablesFromConstants() |
|
| 91 | - { |
|
| 92 | - $variables = array(); |
|
| 93 | - $prefix = "plugin.tx_mooxcore.settings.less."; |
|
| 94 | - if (!isset($GLOBALS['TSFE']->tmpl->flatSetup) || !is_array($GLOBALS['TSFE']->tmpl->flatSetup) || count($GLOBALS['TSFE']->tmpl->flatSetup) === 0) { |
|
| 95 | - $GLOBALS['TSFE']->tmpl->generateConfig(); |
|
| 96 | - } |
|
| 97 | - foreach ($GLOBALS['TSFE']->tmpl->flatSetup as $constant => $value) { |
|
| 98 | - if (strpos($constant, $prefix) === 0) { |
|
| 99 | - $variables[substr($constant, strlen($prefix))] = $value; |
|
| 100 | - } |
|
| 101 | - } |
|
| 102 | - return $variables; |
|
| 103 | - } |
|
| 87 | + /** |
|
| 88 | + * @return array |
|
| 89 | + */ |
|
| 90 | + public function getVariablesFromConstants() |
|
| 91 | + { |
|
| 92 | + $variables = array(); |
|
| 93 | + $prefix = "plugin.tx_mooxcore.settings.less."; |
|
| 94 | + if (!isset($GLOBALS['TSFE']->tmpl->flatSetup) || !is_array($GLOBALS['TSFE']->tmpl->flatSetup) || count($GLOBALS['TSFE']->tmpl->flatSetup) === 0) { |
|
| 95 | + $GLOBALS['TSFE']->tmpl->generateConfig(); |
|
| 96 | + } |
|
| 97 | + foreach ($GLOBALS['TSFE']->tmpl->flatSetup as $constant => $value) { |
|
| 98 | + if (strpos($constant, $prefix) === 0) { |
|
| 99 | + $variables[substr($constant, strlen($prefix))] = $value; |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | + return $variables; |
|
| 103 | + } |
|
| 104 | 104 | } |
| 105 | 105 | \ No newline at end of file |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | { |
| 45 | 45 | $file = GeneralUtility::getFileAbsFileName($file); |
| 46 | 46 | $pathParts = pathinfo($file); |
| 47 | - if ($pathParts['extension'] === 'less') { |
|
| 47 | + if ($pathParts['extension']==='less') { |
|
| 48 | 48 | try { |
| 49 | 49 | $options = array( |
| 50 | 50 | 'cache_dir' => GeneralUtility::getFileAbsFileName('typo3temp/mooxcore') |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | // enable source mapping |
| 55 | 55 | $optionsForSourceMap = array( |
| 56 | 56 | 'sourceMap' => true, |
| 57 | - 'sourceMapWriteTo' => GeneralUtility::getFileAbsFileName('typo3temp/mooxcore') . '/mooxcore.map', |
|
| 57 | + 'sourceMapWriteTo' => GeneralUtility::getFileAbsFileName('typo3temp/mooxcore').'/mooxcore.map', |
|
| 58 | 58 | 'sourceMapURL' => '/typo3temp/mooxcore/mooxcore.map', |
| 59 | 59 | 'sourceMapBasepath' => PATH_site, |
| 60 | 60 | 'sourceMapRootpath' => '/' |
@@ -68,13 +68,13 @@ discard block |
||
| 68 | 68 | } |
| 69 | 69 | if ($settings['overrideLessVariables']) { |
| 70 | 70 | $variables = self::getVariablesFromConstants(); |
| 71 | - } else { |
|
| 71 | + }else { |
|
| 72 | 72 | $variables = array(); |
| 73 | 73 | } |
| 74 | 74 | $files = array(); |
| 75 | - $files[$file] = '../../' . str_replace(PATH_site, '', dirname($file)) . '/'; |
|
| 75 | + $files[$file] = '../../'.str_replace(PATH_site, '', dirname($file)).'/'; |
|
| 76 | 76 | $compiledFile = \Less_Cache::Get($files, $options, $variables); |
| 77 | - $file = "typo3temp/mooxcore/" . $compiledFile; |
|
| 77 | + $file = "typo3temp/mooxcore/".$compiledFile; |
|
| 78 | 78 | |
| 79 | 79 | return $file; |
| 80 | 80 | } catch (\Exception $e) { |
@@ -91,11 +91,11 @@ discard block |
||
| 91 | 91 | { |
| 92 | 92 | $variables = array(); |
| 93 | 93 | $prefix = "plugin.tx_mooxcore.settings.less."; |
| 94 | - if (!isset($GLOBALS['TSFE']->tmpl->flatSetup) || !is_array($GLOBALS['TSFE']->tmpl->flatSetup) || count($GLOBALS['TSFE']->tmpl->flatSetup) === 0) { |
|
| 94 | + if (!isset($GLOBALS['TSFE']->tmpl->flatSetup) || !is_array($GLOBALS['TSFE']->tmpl->flatSetup) || count($GLOBALS['TSFE']->tmpl->flatSetup)===0) { |
|
| 95 | 95 | $GLOBALS['TSFE']->tmpl->generateConfig(); |
| 96 | 96 | } |
| 97 | 97 | foreach ($GLOBALS['TSFE']->tmpl->flatSetup as $constant => $value) { |
| 98 | - if (strpos($constant, $prefix) === 0) { |
|
| 98 | + if (strpos($constant, $prefix)===0) { |
|
| 99 | 99 | $variables[substr($constant, strlen($prefix))] = $value; |
| 100 | 100 | } |
| 101 | 101 | } |
@@ -84,12 +84,12 @@ discard block |
||
| 84 | 84 | $extensionKeys = $this->configurationService->getVariantExtensionKeysForContentType($parameters['row']['CType']); |
| 85 | 85 | $defaults = $this->configurationService->getDefaults(); |
| 86 | 86 | $preSelected = $parameters['row']['content_variant']; |
| 87 | - if (CoreContentProvider::MODE_PRESELECT === $defaults['mode'] && TRUE === empty($preSelected)) { |
|
| 87 | + if (CoreContentProvider::MODE_PRESELECT===$defaults['mode'] && TRUE===empty($preSelected)) { |
|
| 88 | 88 | $preSelected = $defaults['variant']; |
| 89 | 89 | } |
| 90 | - if (TRUE === is_array($extensionKeys) && 0 < count($extensionKeys)) { |
|
| 90 | + if (TRUE===is_array($extensionKeys) && 0<count($extensionKeys)) { |
|
| 91 | 91 | $options = $this->renderOptions($extensionKeys); |
| 92 | - } else { |
|
| 92 | + }else { |
|
| 93 | 93 | $options = array(); |
| 94 | 94 | } |
| 95 | 95 | return $this->renderSelectField($parameters, $options, $preSelected); |
@@ -104,10 +104,10 @@ discard block |
||
| 104 | 104 | foreach ($variants as $variantSetup) { |
| 105 | 105 | list ($extensionKey, $labelReference, $icon) = $variantSetup; |
| 106 | 106 | $translatedLabel = $this->translateLabel($labelReference, $extensionKey); |
| 107 | - if (NULL === $translatedLabel) { |
|
| 107 | + if (NULL===$translatedLabel) { |
|
| 108 | 108 | $translatedLabel = $extensionKey; |
| 109 | 109 | } |
| 110 | - $optionsIcon = '<img src="' . $icon . '" alt="' . $extensionKey . '" /> '; |
|
| 110 | + $optionsIcon = '<img src="'.$icon.'" alt="'.$extensionKey.'" /> '; |
|
| 111 | 111 | $options[$extensionKey] = array($optionsIcon, $translatedLabel); |
| 112 | 112 | } |
| 113 | 113 | return $options; |
@@ -126,24 +126,24 @@ discard block |
||
| 126 | 126 | foreach ($options as $extensionKey => $optionsSetup) { |
| 127 | 127 | list($optionsIcons[$extensionKey], $optionsLabels[$extensionKey]) = $optionsSetup; |
| 128 | 128 | } |
| 129 | - $hasSelectedValue = (TRUE === empty($selectedValue) || TRUE === array_key_exists($selectedValue, $optionsLabels)); |
|
| 130 | - $selected = (TRUE === empty($selectedValue) ? ' selected="selected"' : NULL); |
|
| 129 | + $hasSelectedValue = (TRUE===empty($selectedValue) || TRUE===array_key_exists($selectedValue, $optionsLabels)); |
|
| 130 | + $selected = (TRUE===empty($selectedValue) ? ' selected="selected"' : NULL); |
|
| 131 | 131 | foreach ($optionsIcons as $value => $img) { |
| 132 | - if ($value === $selectedValue) { |
|
| 132 | + if ($value===$selectedValue) { |
|
| 133 | 133 | $selectedIcon = $img; |
| 134 | 134 | break; |
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | $html = array( |
| 138 | - '<div class="form-control-wrap"><div class="input-group"><div class="input-group-addon input-group-icon">' . $selectedIcon . '</div><select class="select form-control" name="' . $parameters['itemFormElName'] . '" onchange="' . $parameters['fieldChangeFunc']['TBE_EDITOR_fieldChanged'] . ';' . $parameters['fieldChangeFunc']['alert'] . '">', |
|
| 139 | - '<option' . $selected . ' value="">' . $this->translateLabel('tt_content.nativeLabel', 'MooxCore') . '</option>' |
|
| 138 | + '<div class="form-control-wrap"><div class="input-group"><div class="input-group-addon input-group-icon">'.$selectedIcon.'</div><select class="select form-control" name="'.$parameters['itemFormElName'].'" onchange="'.$parameters['fieldChangeFunc']['TBE_EDITOR_fieldChanged'].';'.$parameters['fieldChangeFunc']['alert'].'">', |
|
| 139 | + '<option'.$selected.' value="">'.$this->translateLabel('tt_content.nativeLabel', 'MooxCore').'</option>' |
|
| 140 | 140 | ); |
| 141 | 141 | foreach ($optionsLabels as $value => $label) { |
| 142 | - $selected = $value === $selectedValue ? ' selected="selected"' : NULL; |
|
| 143 | - $html[] = '<option' . $selected . ' value="' . $value . '">' . $label . '</option>'; |
|
| 142 | + $selected = $value===$selectedValue ? ' selected="selected"' : NULL; |
|
| 143 | + $html[] = '<option'.$selected.' value="'.$value.'">'.$label.'</option>'; |
|
| 144 | 144 | } |
| 145 | - if (FALSE === $hasSelectedValue) { |
|
| 146 | - $html[] = '<option selected="selected">INVALID: ' . $selectedValue . '</option>'; |
|
| 145 | + if (FALSE===$hasSelectedValue) { |
|
| 146 | + $html[] = '<option selected="selected">INVALID: '.$selectedValue.'</option>'; |
|
| 147 | 147 | } |
| 148 | 148 | $html[] = '</select></div></div>'; |
| 149 | 149 | return implode(LF, $html); |
@@ -159,20 +159,20 @@ discard block |
||
| 159 | 159 | $defaults = $this->configurationService->getDefaults(); |
| 160 | 160 | $preSelectedVariant = $parameters['row']['content_variant']; |
| 161 | 161 | $preSelectedVersion = $parameters['row']['content_version']; |
| 162 | - if (CoreContentProvider::MODE_PRESELECT === $defaults['mode']) { |
|
| 163 | - if (TRUE === empty($preSelectedVariant)) { |
|
| 162 | + if (CoreContentProvider::MODE_PRESELECT===$defaults['mode']) { |
|
| 163 | + if (TRUE===empty($preSelectedVariant)) { |
|
| 164 | 164 | $preSelectedVariant = $defaults['variant']; |
| 165 | 165 | } |
| 166 | - if (TRUE === empty($preSelectedVersion)) { |
|
| 166 | + if (TRUE===empty($preSelectedVersion)) { |
|
| 167 | 167 | $preSelectedVersion = $defaults['version']; |
| 168 | 168 | } |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | $versions = $this->configurationService->getVariantVersions($parameters['row']['CType'], $preSelectedVariant); |
| 172 | - if (TRUE === is_array($versions) && 0 < count($versions)) { |
|
| 172 | + if (TRUE===is_array($versions) && 0<count($versions)) { |
|
| 173 | 173 | foreach ($versions as $version) { |
| 174 | 174 | $icon = $this->configurationService->getIconFromVersion($preSelectedVariant, $parameters['row']['CType'], $version); |
| 175 | - $versionIcon = '<img src="' . $icon . '" alt="" /> '; |
|
| 175 | + $versionIcon = '<img src="'.$icon.'" alt="" /> '; |
|
| 176 | 176 | $options[$version] = array($versionIcon, $version); |
| 177 | 177 | } |
| 178 | 178 | } |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | * @codeCoverageIgnore |
| 196 | 196 | */ |
| 197 | 197 | protected function loadRecord($table, $uid) { |
| 198 | - return \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord($table, (integer) $uid); |
|
| 198 | + return \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord($table, (integer)$uid); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | } |
| 202 | 202 | \ No newline at end of file |
@@ -7,11 +7,11 @@ |
||
| 7 | 7 | * InstallSignalSlot |
| 8 | 8 | */ |
| 9 | 9 | class InstallSignalSlot implements SingletonInterface { |
| 10 | - /** |
|
| 11 | - * Install AddionalConfiguration |
|
| 12 | - */ |
|
| 13 | - public function installAdditionalConfiguration() { |
|
| 14 | - $updateService = new UpdateService(); |
|
| 15 | - $updateService->main(); |
|
| 16 | - } |
|
| 10 | + /** |
|
| 11 | + * Install AddionalConfiguration |
|
| 12 | + */ |
|
| 13 | + public function installAdditionalConfiguration() { |
|
| 14 | + $updateService = new UpdateService(); |
|
| 15 | + $updateService->main(); |
|
| 16 | + } |
|
| 17 | 17 | } |
| 18 | 18 | \ No newline at end of file |
@@ -65,22 +65,22 @@ |
||
| 65 | 65 | */ |
| 66 | 66 | $settings = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$_EXTKEY]); |
| 67 | 67 | if($settings['UseRealUrlConfig'] == 1){ |
| 68 | - @include_once(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY,'Configuration/RealURL/Default.php')); |
|
| 68 | + @include_once(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY,'Configuration/RealURL/Default.php')); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | if (TYPO3_MODE === 'BE') { |
| 72 | 72 | // enable SignalSlot |
| 73 | 73 | /** @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher $signalSlotDispatcher */ |
| 74 | - $signalSlotDispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher'); |
|
| 75 | - /** |
|
| 76 | - * Provides an example .htaccess file for Apache after extension is installed and shows a warning if TYPO3 is not running on Apache. |
|
| 77 | - */ |
|
| 78 | - $signalSlotDispatcher->connect( |
|
| 79 | - 'TYPO3\\CMS\\Extensionmanager\\Service\\ExtensionManagementService', |
|
| 80 | - 'hasInstalledExtensions', |
|
| 81 | - 'DCNGmbH\\MooxCore\\Service\\InstallService', |
|
| 82 | - 'generateApacheHtaccess' |
|
| 83 | - ); |
|
| 74 | + $signalSlotDispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher'); |
|
| 75 | + /** |
|
| 76 | + * Provides an example .htaccess file for Apache after extension is installed and shows a warning if TYPO3 is not running on Apache. |
|
| 77 | + */ |
|
| 78 | + $signalSlotDispatcher->connect( |
|
| 79 | + 'TYPO3\\CMS\\Extensionmanager\\Service\\ExtensionManagementService', |
|
| 80 | + 'hasInstalledExtensions', |
|
| 81 | + 'DCNGmbH\\MooxCore\\Service\\InstallService', |
|
| 82 | + 'generateApacheHtaccess' |
|
| 83 | + ); |
|
| 84 | 84 | /** |
| 85 | 85 | * Provides an example robots.txt file after extension is installed and shows a warning if TYPO3 is not running with moox_core robots.txt. |
| 86 | 86 | */ |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | // mod.moox_MooxCoreDashboard.sideBarEnable = 0 |
| 10 | 10 | // '); |
| 11 | 11 | |
| 12 | -if (FALSE === isset($GLOBALS['TYPO3_CONF_VARS']['FE']['contentRenderingTemplates'])) { |
|
| 12 | +if (FALSE===isset($GLOBALS['TYPO3_CONF_VARS']['FE']['contentRenderingTemplates'])) { |
|
| 13 | 13 | \TYPO3\CMS\Core\Utility\GeneralUtility::sysLog('MooxCore requires an additional configuration file in typo3conf/AdditionalConfiguration.php - ' |
| 14 | 14 | . 'you can have MooxCore generate this file for you from the extension manager by running the MooxCore update script. A dummy ' |
| 15 | 15 | . 'has been created, but you will only be able to render content (not plugins!) until the file is created', |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | ); |
| 38 | 38 | |
| 39 | 39 | $types = count($GLOBALS['TYPO3_CONF_VARS']['DCNGmbH.MooxCore']['types']); |
| 40 | -for ($i = 0; $i < $types; $i++) { |
|
| 40 | +for ($i = 0; $i<$types; $i++) { |
|
| 41 | 41 | \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( |
| 42 | 42 | 'DCNGmbH.MooxCore', |
| 43 | 43 | ucfirst($GLOBALS['TYPO3_CONF_VARS']['DCNGmbH.MooxCore']['types'][$i]), |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | // Include new content elements to modWizards |
| 50 | 50 | \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig('<INCLUDE_TYPOSCRIPT: source="FILE:EXT:moox_core/Configuration/PageTS/modWizards.ts">'); |
| 51 | 51 | // If the form extension is loaded, then include the mailform element to modWizards |
| 52 | -if (TRUE === \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('form')) { |
|
| 52 | +if (TRUE===\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('form')) { |
|
| 53 | 53 | \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig('<INCLUDE_TYPOSCRIPT: source="FILE:EXT:moox_core/Configuration/PageTS/modWizardsMailform.ts">'); |
| 54 | 54 | } |
| 55 | 55 | |
@@ -63,18 +63,18 @@ discard block |
||
| 63 | 63 | $settings = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$_EXTKEY]); |
| 64 | 64 | // RTE Configuration |
| 65 | 65 | if (!$settings['disablePageTsRTE']) { |
| 66 | - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig('<INCLUDE_TYPOSCRIPT: source="FILE:EXT:' . $_EXTKEY . '/Configuration/PageTS/RTE.txt">'); |
|
| 66 | + \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig('<INCLUDE_TYPOSCRIPT: source="FILE:EXT:'.$_EXTKEY.'/Configuration/PageTS/RTE.txt">'); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /*************** |
| 70 | 70 | * Use RealUrl Config from MOOX Core |
| 71 | 71 | */ |
| 72 | 72 | $settings = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$_EXTKEY]); |
| 73 | -if($settings['UseRealUrlConfig'] == 1){ |
|
| 74 | - @include_once(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY,'Configuration/RealURL/Default.php')); |
|
| 73 | +if ($settings['UseRealUrlConfig']==1) { |
|
| 74 | + @include_once(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY, 'Configuration/RealURL/Default.php')); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | -if (TYPO3_MODE === 'BE') { |
|
| 77 | +if (TYPO3_MODE==='BE') { |
|
| 78 | 78 | // enable SignalSlot |
| 79 | 79 | /** @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher $signalSlotDispatcher */ |
| 80 | 80 | $signalSlotDispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher'); |
@@ -111,8 +111,8 @@ discard block |
||
| 111 | 111 | /*************** |
| 112 | 112 | * Register hook for processing less files |
| 113 | 113 | */ |
| 114 | -if (TYPO3_MODE === 'FE') { |
|
| 115 | - require_once(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('moox_core') . '/Contrib/less.php/Less.php'); |
|
| 114 | +if (TYPO3_MODE==='FE') { |
|
| 115 | + require_once(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('moox_core').'/Contrib/less.php/Less.php'); |
|
| 116 | 116 | |
| 117 | 117 | $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-preProcess'][] = 'DCNGmbH\\MooxCore\\Hooks\\PageRendererRender\\PreProcessHook->execute'; |
| 118 | 118 | |
@@ -36,14 +36,14 @@ |
||
| 36 | 36 | */ |
| 37 | 37 | class GetVimeoIdViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @param string $url |
|
| 41 | - * @return string |
|
| 42 | - */ |
|
| 43 | - public function render($url) {
|
|
| 44 | - if (preg_match("/https?:\/\/(?:www\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\/|album\/(\d+)\/video\/|)(\d+)(?:$|\/|\?)/", $url, $match)) {
|
|
| 45 | - $videoId = $match[3]; |
|
| 46 | - } |
|
| 47 | - return $videoId; |
|
| 48 | - } |
|
| 39 | + /** |
|
| 40 | + * @param string $url |
|
| 41 | + * @return string |
|
| 42 | + */ |
|
| 43 | + public function render($url) {
|
|
| 44 | + if (preg_match("/https?:\/\/(?:www\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\/|album\/(\d+)\/video\/|)(\d+)(?:$|\/|\?)/", $url, $match)) {
|
|
| 45 | + $videoId = $match[3]; |
|
| 46 | + } |
|
| 47 | + return $videoId; |
|
| 48 | + } |
|
| 49 | 49 | } |