@@ -29,11 +29,9 @@ |
||
| 29 | 29 | function getenv_docker($env, $default) {
|
| 30 | 30 | if ($fileEnv = getenv($env . '_FILE')) {
|
| 31 | 31 | return rtrim(file_get_contents($fileEnv), "\r\n"); |
| 32 | - } |
|
| 33 | - else if (($val = getenv($env)) !== false) {
|
|
| 32 | + } else if (($val = getenv($env)) !== false) {
|
|
| 34 | 33 | return $val; |
| 35 | - } |
|
| 36 | - else {
|
|
| 34 | + } else {
|
|
| 37 | 35 | return $default; |
| 38 | 36 | } |
| 39 | 37 | } |
@@ -771,8 +771,11 @@ |
||
| 771 | 771 | <li class='mega-import-theme'><a href='<?php echo $import_url; ?>'><span class='dashicons dashicons-download'></span><?php _e( 'Import a theme', 'megamenu' ); ?></a></li> |
| 772 | 772 | <?php if ( $this->string_contains( $this->id, array( 'custom' ) ) ) : ?> |
| 773 | 773 | <li class='mega-delete-theme'><a class='delete confirm' href='<?php echo $delete_url; ?>'><span class='dashicons dashicons-trash'></span><?php _e( 'Delete theme', 'megamenu' ); ?></a></li> |
| 774 | - <?php else : ?> |
|
| 775 | - <li class='mega-revert-theme'><a class='confirm' href='<?php echo $revert_url; ?>'><span class='dashicons dashicons-update-alt'></span><?php _e( 'Revert theme', 'megamenu' ); ?></a></li> |
|
| 774 | + <?php else { |
|
| 775 | + : ?> |
|
| 776 | + <li class='mega-revert-theme'><a class='confirm' href='<?php echo $revert_url; |
|
| 777 | +} |
|
| 778 | +?>'><span class='dashicons dashicons-update-alt'></span><?php _e( 'Revert theme', 'megamenu' ); ?></a></li> |
|
| 776 | 779 | <?php endif; ?> |
| 777 | 780 | </ul> |
| 778 | 781 | </div> |
@@ -442,12 +442,12 @@ discard block |
||
| 442 | 442 | if (!is_array($p)) continue; |
| 443 | 443 | |
| 444 | 444 | switch ($p[0]) { |
| 445 | - case "interpolate": |
|
| 446 | - $p = $this->compileValue($p); |
|
| 447 | - break; |
|
| 448 | - case "string": |
|
| 449 | - $p = $this->compileValue($p); |
|
| 450 | - break; |
|
| 445 | + case "interpolate": |
|
| 446 | + $p = $this->compileValue($p); |
|
| 447 | + break; |
|
| 448 | + case "string": |
|
| 449 | + $p = $this->compileValue($p); |
|
| 450 | + break; |
|
| 451 | 451 | } |
| 452 | 452 | } |
| 453 | 453 | |
@@ -468,12 +468,12 @@ discard block |
||
| 468 | 468 | if (!is_array($p)) continue; |
| 469 | 469 | |
| 470 | 470 | switch ($p[0]) { |
| 471 | - case "self": |
|
| 472 | - $p = "&"; |
|
| 473 | - break; |
|
| 474 | - default: |
|
| 475 | - $p = $this->compileValue($p); |
|
| 476 | - break; |
|
| 471 | + case "self": |
|
| 472 | + $p = "&"; |
|
| 473 | + break; |
|
| 474 | + default: |
|
| 475 | + $p = $this->compileValue($p); |
|
| 476 | + break; |
|
| 477 | 477 | } |
| 478 | 478 | } |
| 479 | 479 | |
@@ -622,204 +622,204 @@ discard block |
||
| 622 | 622 | $this->sourceParser = isset($child[-2]) ? $child[-2] : $this->parser; |
| 623 | 623 | |
| 624 | 624 | switch ($child[0]) { |
| 625 | - case "import": |
|
| 626 | - list(,$rawPath) = $child; |
|
| 627 | - $rawPath = $this->reduce($rawPath); |
|
| 628 | - if (!$this->compileImport($rawPath, $out)) { |
|
| 629 | - $out->lines[] = "@import " . $this->compileValue($rawPath) . ";"; |
|
| 630 | - } |
|
| 631 | - break; |
|
| 632 | - case "directive": |
|
| 633 | - list(, $directive) = $child; |
|
| 634 | - $s = "@" . $directive->name; |
|
| 635 | - if (!empty($directive->value)) { |
|
| 636 | - $s .= " " . $this->compileValue($directive->value); |
|
| 637 | - } |
|
| 638 | - $this->compileNestedBlock($directive, array($s)); |
|
| 639 | - break; |
|
| 640 | - case "media": |
|
| 641 | - $this->compileMedia($child[1]); |
|
| 642 | - break; |
|
| 643 | - case "block": |
|
| 644 | - $this->compileBlock($child[1]); |
|
| 645 | - break; |
|
| 646 | - case "charset": |
|
| 647 | - $out->lines[] = "@charset ".$this->compileValue($child[1]).";"; |
|
| 648 | - break; |
|
| 649 | - case "assign": |
|
| 650 | - list(,$name, $value) = $child; |
|
| 651 | - if ($name[0] == "var") { |
|
| 652 | - $isDefault = !empty($child[3]); |
|
| 653 | - |
|
| 654 | - if ($isDefault) { |
|
| 655 | - $existingValue = $this->get($name[1], true); |
|
| 656 | - $shouldSet = $existingValue === true || $existingValue == self::$null; |
|
| 657 | - } |
|
| 658 | - |
|
| 659 | - if (!$isDefault || $shouldSet) { |
|
| 660 | - $this->set($name[1], $this->reduce($value)); |
|
| 661 | - } |
|
| 662 | - break; |
|
| 663 | - } |
|
| 664 | - |
|
| 665 | - // if the value reduces to null from something else then |
|
| 666 | - // the property should be discarded |
|
| 667 | - if ($value[0] != "null") { |
|
| 668 | - $value = $this->reduce($value); |
|
| 669 | - if ($value[0] == "null") { |
|
| 670 | - break; |
|
| 671 | - } |
|
| 672 | - } |
|
| 673 | - |
|
| 674 | - $compiledValue = $this->compileValue($value); |
|
| 675 | - $out->lines[] = $this->formatter->property( |
|
| 676 | - $this->compileValue($name), |
|
| 677 | - $compiledValue); |
|
| 678 | - break; |
|
| 679 | - case "comment": |
|
| 680 | - $out->lines[] = $child[1]; |
|
| 681 | - break; |
|
| 682 | - case "mixin": |
|
| 683 | - case "function": |
|
| 684 | - list(,$block) = $child; |
|
| 685 | - $this->set(self::$namespaces[$block->type] . $block->name, $block); |
|
| 686 | - break; |
|
| 687 | - case "extend": |
|
| 688 | - list(, $selectors) = $child; |
|
| 689 | - foreach ($selectors as $sel) { |
|
| 690 | - // only use the first one |
|
| 691 | - $sel = current($this->evalSelector($sel)); |
|
| 692 | - $this->pushExtends($sel, $out->selectors); |
|
| 693 | - } |
|
| 694 | - break; |
|
| 695 | - case "if": |
|
| 696 | - list(, $if) = $child; |
|
| 697 | - if ($this->isTruthy($this->reduce($if->cond, true))) { |
|
| 698 | - return $this->compileChildren($if->children, $out); |
|
| 699 | - } else { |
|
| 700 | - foreach ($if->cases as $case) { |
|
| 701 | - if ($case->type == "else" || |
|
| 702 | - $case->type == "elseif" && $this->isTruthy($this->reduce($case->cond))) |
|
| 703 | - { |
|
| 704 | - return $this->compileChildren($case->children, $out); |
|
| 705 | - } |
|
| 706 | - } |
|
| 707 | - } |
|
| 708 | - break; |
|
| 709 | - case "return": |
|
| 710 | - return $this->reduce($child[1], true); |
|
| 711 | - case "each": |
|
| 712 | - list(,$each) = $child; |
|
| 713 | - $list = $this->coerceList($this->reduce($each->list)); |
|
| 714 | - foreach ($list[2] as $item) { |
|
| 715 | - $this->pushEnv(); |
|
| 716 | - $this->set($each->var, $item); |
|
| 717 | - // TODO: allow return from here |
|
| 718 | - $this->compileChildren($each->children, $out); |
|
| 719 | - $this->popEnv(); |
|
| 720 | - } |
|
| 721 | - break; |
|
| 722 | - case "while": |
|
| 723 | - list(,$while) = $child; |
|
| 724 | - while ($this->isTruthy($this->reduce($while->cond, true))) { |
|
| 725 | - $ret = $this->compileChildren($while->children, $out); |
|
| 726 | - if ($ret) return $ret; |
|
| 727 | - } |
|
| 728 | - break; |
|
| 729 | - case "for": |
|
| 730 | - list(,$for) = $child; |
|
| 731 | - $start = $this->reduce($for->start, true); |
|
| 732 | - $start = $start[1]; |
|
| 733 | - $end = $this->reduce($for->end, true); |
|
| 734 | - $end = $end[1]; |
|
| 735 | - $d = $start < $end ? 1 : -1; |
|
| 736 | - |
|
| 737 | - while (true) { |
|
| 738 | - if ((!$for->until && $start - $d == $end) || |
|
| 739 | - ($for->until && $start == $end)) |
|
| 740 | - { |
|
| 741 | - break; |
|
| 742 | - } |
|
| 743 | - |
|
| 744 | - $this->set($for->var, array("number", $start, "")); |
|
| 745 | - $start += $d; |
|
| 746 | - |
|
| 747 | - $ret = $this->compileChildren($for->children, $out); |
|
| 748 | - if ($ret) return $ret; |
|
| 749 | - } |
|
| 750 | - |
|
| 751 | - break; |
|
| 752 | - case "nestedprop": |
|
| 753 | - list(,$prop) = $child; |
|
| 754 | - $prefixed = array(); |
|
| 755 | - $prefix = $this->compileValue($prop->prefix) . "-"; |
|
| 756 | - foreach ($prop->children as $child) { |
|
| 757 | - if ($child[0] == "assign") { |
|
| 758 | - array_unshift($child[1][2], $prefix); |
|
| 759 | - } |
|
| 760 | - if ($child[0] == "nestedprop") { |
|
| 761 | - array_unshift($child[1]->prefix[2], $prefix); |
|
| 762 | - } |
|
| 763 | - $prefixed[] = $child; |
|
| 764 | - } |
|
| 765 | - $this->compileChildren($prefixed, $out); |
|
| 766 | - break; |
|
| 767 | - case "include": // including a mixin |
|
| 768 | - list(,$name, $argValues, $content) = $child; |
|
| 769 | - $mixin = $this->get(self::$namespaces["mixin"] . $name, false); |
|
| 770 | - if (!$mixin) { |
|
| 771 | - $this->throwError("Undefined mixin $name"); |
|
| 772 | - } |
|
| 773 | - |
|
| 774 | - $callingScope = $this->env; |
|
| 775 | - |
|
| 776 | - // push scope, apply args |
|
| 777 | - $this->pushEnv(); |
|
| 778 | - if ($this->env->depth > 0) { |
|
| 779 | - $this->env->depth--; |
|
| 780 | - } |
|
| 781 | - |
|
| 782 | - if (isset($content)) { |
|
| 783 | - $content->scope = $callingScope; |
|
| 784 | - $this->setRaw(self::$namespaces["special"] . "content", $content); |
|
| 785 | - } |
|
| 786 | - |
|
| 787 | - if (isset($mixin->args)) { |
|
| 788 | - $this->applyArguments($mixin->args, $argValues); |
|
| 789 | - } |
|
| 790 | - |
|
| 791 | - foreach ($mixin->children as $child) { |
|
| 792 | - $this->compileChild($child, $out); |
|
| 793 | - } |
|
| 794 | - |
|
| 795 | - $this->popEnv(); |
|
| 796 | - |
|
| 797 | - break; |
|
| 798 | - case "mixin_content": |
|
| 799 | - $content = $this->get(self::$namespaces["special"] . "content"); |
|
| 800 | - if (!isset($content)) { |
|
| 801 | - $this->throwError("Expected @content inside of mixin"); |
|
| 802 | - } |
|
| 803 | - |
|
| 804 | - $strongTypes = array('include', 'block', 'for', 'while'); |
|
| 805 | - foreach ($content->children as $child) { |
|
| 806 | - $this->storeEnv = (in_array($child[0], $strongTypes)) |
|
| 807 | - ? null |
|
| 808 | - : $content->scope; |
|
| 809 | - |
|
| 810 | - $this->compileChild($child, $out); |
|
| 811 | - } |
|
| 812 | - |
|
| 813 | - unset($this->storeEnv); |
|
| 814 | - break; |
|
| 815 | - case "debug": |
|
| 816 | - list(,$value, $pos) = $child; |
|
| 817 | - $line = $this->parser->getLineNo($pos); |
|
| 818 | - $value = $this->compileValue($this->reduce($value, true)); |
|
| 819 | - fwrite(STDERR, "Line $line DEBUG: $value\n"); |
|
| 820 | - break; |
|
| 821 | - default: |
|
| 822 | - $this->throwError("unknown child type: $child[0]"); |
|
| 625 | + case "import": |
|
| 626 | + list(,$rawPath) = $child; |
|
| 627 | + $rawPath = $this->reduce($rawPath); |
|
| 628 | + if (!$this->compileImport($rawPath, $out)) { |
|
| 629 | + $out->lines[] = "@import " . $this->compileValue($rawPath) . ";"; |
|
| 630 | + } |
|
| 631 | + break; |
|
| 632 | + case "directive": |
|
| 633 | + list(, $directive) = $child; |
|
| 634 | + $s = "@" . $directive->name; |
|
| 635 | + if (!empty($directive->value)) { |
|
| 636 | + $s .= " " . $this->compileValue($directive->value); |
|
| 637 | + } |
|
| 638 | + $this->compileNestedBlock($directive, array($s)); |
|
| 639 | + break; |
|
| 640 | + case "media": |
|
| 641 | + $this->compileMedia($child[1]); |
|
| 642 | + break; |
|
| 643 | + case "block": |
|
| 644 | + $this->compileBlock($child[1]); |
|
| 645 | + break; |
|
| 646 | + case "charset": |
|
| 647 | + $out->lines[] = "@charset ".$this->compileValue($child[1]).";"; |
|
| 648 | + break; |
|
| 649 | + case "assign": |
|
| 650 | + list(,$name, $value) = $child; |
|
| 651 | + if ($name[0] == "var") { |
|
| 652 | + $isDefault = !empty($child[3]); |
|
| 653 | + |
|
| 654 | + if ($isDefault) { |
|
| 655 | + $existingValue = $this->get($name[1], true); |
|
| 656 | + $shouldSet = $existingValue === true || $existingValue == self::$null; |
|
| 657 | + } |
|
| 658 | + |
|
| 659 | + if (!$isDefault || $shouldSet) { |
|
| 660 | + $this->set($name[1], $this->reduce($value)); |
|
| 661 | + } |
|
| 662 | + break; |
|
| 663 | + } |
|
| 664 | + |
|
| 665 | + // if the value reduces to null from something else then |
|
| 666 | + // the property should be discarded |
|
| 667 | + if ($value[0] != "null") { |
|
| 668 | + $value = $this->reduce($value); |
|
| 669 | + if ($value[0] == "null") { |
|
| 670 | + break; |
|
| 671 | + } |
|
| 672 | + } |
|
| 673 | + |
|
| 674 | + $compiledValue = $this->compileValue($value); |
|
| 675 | + $out->lines[] = $this->formatter->property( |
|
| 676 | + $this->compileValue($name), |
|
| 677 | + $compiledValue); |
|
| 678 | + break; |
|
| 679 | + case "comment": |
|
| 680 | + $out->lines[] = $child[1]; |
|
| 681 | + break; |
|
| 682 | + case "mixin": |
|
| 683 | + case "function": |
|
| 684 | + list(,$block) = $child; |
|
| 685 | + $this->set(self::$namespaces[$block->type] . $block->name, $block); |
|
| 686 | + break; |
|
| 687 | + case "extend": |
|
| 688 | + list(, $selectors) = $child; |
|
| 689 | + foreach ($selectors as $sel) { |
|
| 690 | + // only use the first one |
|
| 691 | + $sel = current($this->evalSelector($sel)); |
|
| 692 | + $this->pushExtends($sel, $out->selectors); |
|
| 693 | + } |
|
| 694 | + break; |
|
| 695 | + case "if": |
|
| 696 | + list(, $if) = $child; |
|
| 697 | + if ($this->isTruthy($this->reduce($if->cond, true))) { |
|
| 698 | + return $this->compileChildren($if->children, $out); |
|
| 699 | + } else { |
|
| 700 | + foreach ($if->cases as $case) { |
|
| 701 | + if ($case->type == "else" || |
|
| 702 | + $case->type == "elseif" && $this->isTruthy($this->reduce($case->cond))) |
|
| 703 | + { |
|
| 704 | + return $this->compileChildren($case->children, $out); |
|
| 705 | + } |
|
| 706 | + } |
|
| 707 | + } |
|
| 708 | + break; |
|
| 709 | + case "return": |
|
| 710 | + return $this->reduce($child[1], true); |
|
| 711 | + case "each": |
|
| 712 | + list(,$each) = $child; |
|
| 713 | + $list = $this->coerceList($this->reduce($each->list)); |
|
| 714 | + foreach ($list[2] as $item) { |
|
| 715 | + $this->pushEnv(); |
|
| 716 | + $this->set($each->var, $item); |
|
| 717 | + // TODO: allow return from here |
|
| 718 | + $this->compileChildren($each->children, $out); |
|
| 719 | + $this->popEnv(); |
|
| 720 | + } |
|
| 721 | + break; |
|
| 722 | + case "while": |
|
| 723 | + list(,$while) = $child; |
|
| 724 | + while ($this->isTruthy($this->reduce($while->cond, true))) { |
|
| 725 | + $ret = $this->compileChildren($while->children, $out); |
|
| 726 | + if ($ret) return $ret; |
|
| 727 | + } |
|
| 728 | + break; |
|
| 729 | + case "for": |
|
| 730 | + list(,$for) = $child; |
|
| 731 | + $start = $this->reduce($for->start, true); |
|
| 732 | + $start = $start[1]; |
|
| 733 | + $end = $this->reduce($for->end, true); |
|
| 734 | + $end = $end[1]; |
|
| 735 | + $d = $start < $end ? 1 : -1; |
|
| 736 | + |
|
| 737 | + while (true) { |
|
| 738 | + if ((!$for->until && $start - $d == $end) || |
|
| 739 | + ($for->until && $start == $end)) |
|
| 740 | + { |
|
| 741 | + break; |
|
| 742 | + } |
|
| 743 | + |
|
| 744 | + $this->set($for->var, array("number", $start, "")); |
|
| 745 | + $start += $d; |
|
| 746 | + |
|
| 747 | + $ret = $this->compileChildren($for->children, $out); |
|
| 748 | + if ($ret) return $ret; |
|
| 749 | + } |
|
| 750 | + |
|
| 751 | + break; |
|
| 752 | + case "nestedprop": |
|
| 753 | + list(,$prop) = $child; |
|
| 754 | + $prefixed = array(); |
|
| 755 | + $prefix = $this->compileValue($prop->prefix) . "-"; |
|
| 756 | + foreach ($prop->children as $child) { |
|
| 757 | + if ($child[0] == "assign") { |
|
| 758 | + array_unshift($child[1][2], $prefix); |
|
| 759 | + } |
|
| 760 | + if ($child[0] == "nestedprop") { |
|
| 761 | + array_unshift($child[1]->prefix[2], $prefix); |
|
| 762 | + } |
|
| 763 | + $prefixed[] = $child; |
|
| 764 | + } |
|
| 765 | + $this->compileChildren($prefixed, $out); |
|
| 766 | + break; |
|
| 767 | + case "include": // including a mixin |
|
| 768 | + list(,$name, $argValues, $content) = $child; |
|
| 769 | + $mixin = $this->get(self::$namespaces["mixin"] . $name, false); |
|
| 770 | + if (!$mixin) { |
|
| 771 | + $this->throwError("Undefined mixin $name"); |
|
| 772 | + } |
|
| 773 | + |
|
| 774 | + $callingScope = $this->env; |
|
| 775 | + |
|
| 776 | + // push scope, apply args |
|
| 777 | + $this->pushEnv(); |
|
| 778 | + if ($this->env->depth > 0) { |
|
| 779 | + $this->env->depth--; |
|
| 780 | + } |
|
| 781 | + |
|
| 782 | + if (isset($content)) { |
|
| 783 | + $content->scope = $callingScope; |
|
| 784 | + $this->setRaw(self::$namespaces["special"] . "content", $content); |
|
| 785 | + } |
|
| 786 | + |
|
| 787 | + if (isset($mixin->args)) { |
|
| 788 | + $this->applyArguments($mixin->args, $argValues); |
|
| 789 | + } |
|
| 790 | + |
|
| 791 | + foreach ($mixin->children as $child) { |
|
| 792 | + $this->compileChild($child, $out); |
|
| 793 | + } |
|
| 794 | + |
|
| 795 | + $this->popEnv(); |
|
| 796 | + |
|
| 797 | + break; |
|
| 798 | + case "mixin_content": |
|
| 799 | + $content = $this->get(self::$namespaces["special"] . "content"); |
|
| 800 | + if (!isset($content)) { |
|
| 801 | + $this->throwError("Expected @content inside of mixin"); |
|
| 802 | + } |
|
| 803 | + |
|
| 804 | + $strongTypes = array('include', 'block', 'for', 'while'); |
|
| 805 | + foreach ($content->children as $child) { |
|
| 806 | + $this->storeEnv = (in_array($child[0], $strongTypes)) |
|
| 807 | + ? null |
|
| 808 | + : $content->scope; |
|
| 809 | + |
|
| 810 | + $this->compileChild($child, $out); |
|
| 811 | + } |
|
| 812 | + |
|
| 813 | + unset($this->storeEnv); |
|
| 814 | + break; |
|
| 815 | + case "debug": |
|
| 816 | + list(,$value, $pos) = $child; |
|
| 817 | + $line = $this->parser->getLineNo($pos); |
|
| 818 | + $value = $this->compileValue($this->reduce($value, true)); |
|
| 819 | + fwrite(STDERR, "Line $line DEBUG: $value\n"); |
|
| 820 | + break; |
|
| 821 | + default: |
|
| 822 | + $this->throwError("unknown child type: $child[0]"); |
|
| 823 | 823 | } |
| 824 | 824 | } |
| 825 | 825 | |
@@ -840,13 +840,13 @@ discard block |
||
| 840 | 840 | // should $value cause its operand to eval |
| 841 | 841 | protected function shouldEval($value) { |
| 842 | 842 | switch ($value[0]) { |
| 843 | - case "exp": |
|
| 844 | - if ($value[1] == "/") { |
|
| 845 | - return $this->shouldEval($value[2], $value[3]); |
|
| 846 | - } |
|
| 847 | - case "var": |
|
| 848 | - case "fncall": |
|
| 849 | - return true; |
|
| 843 | + case "exp": |
|
| 844 | + if ($value[1] == "/") { |
|
| 845 | + return $this->shouldEval($value[2], $value[3]); |
|
| 846 | + } |
|
| 847 | + case "var": |
|
| 848 | + case "fncall": |
|
| 849 | + return true; |
|
| 850 | 850 | } |
| 851 | 851 | return false; |
| 852 | 852 | } |
@@ -947,11 +947,11 @@ discard block |
||
| 947 | 947 | $exp = $this->reduce($exp); |
| 948 | 948 | if ($exp[0] == "number") { |
| 949 | 949 | switch ($op) { |
| 950 | - case "+": |
|
| 951 | - return $exp; |
|
| 952 | - case "-": |
|
| 953 | - $exp[1] *= -1; |
|
| 954 | - return $exp; |
|
| 950 | + case "+": |
|
| 951 | + return $exp; |
|
| 952 | + case "-": |
|
| 953 | + $exp[1] *= -1; |
|
| 954 | + return $exp; |
|
| 955 | 955 | } |
| 956 | 956 | } |
| 957 | 957 | |
@@ -1033,19 +1033,19 @@ discard block |
||
| 1033 | 1033 | list($type) = $value; |
| 1034 | 1034 | |
| 1035 | 1035 | switch ($type) { |
| 1036 | - case "list": |
|
| 1037 | - $value = $this->extractInterpolation($value); |
|
| 1038 | - if ($value[0] != "list") { |
|
| 1039 | - return array("keyword", $this->compileValue($value)); |
|
| 1040 | - } |
|
| 1041 | - foreach ($value[2] as $key => $item) { |
|
| 1042 | - $value[2][$key] = $this->normalizeValue($item); |
|
| 1043 | - } |
|
| 1044 | - return $value; |
|
| 1045 | - case "number": |
|
| 1046 | - return $this->normalizeNumber($value); |
|
| 1047 | - default: |
|
| 1048 | - return $value; |
|
| 1036 | + case "list": |
|
| 1037 | + $value = $this->extractInterpolation($value); |
|
| 1038 | + if ($value[0] != "list") { |
|
| 1039 | + return array("keyword", $this->compileValue($value)); |
|
| 1040 | + } |
|
| 1041 | + foreach ($value[2] as $key => $item) { |
|
| 1042 | + $value[2][$key] = $this->normalizeValue($item); |
|
| 1043 | + } |
|
| 1044 | + return $value; |
|
| 1045 | + case "number": |
|
| 1046 | + return $this->normalizeNumber($value); |
|
| 1047 | + default: |
|
| 1048 | + return $value; |
|
| 1049 | 1049 | } |
| 1050 | 1050 | } |
| 1051 | 1051 | |
@@ -1126,30 +1126,30 @@ discard block |
||
| 1126 | 1126 | $lval = isset($left[$i]) ? $left[$i] : 0; |
| 1127 | 1127 | $rval = isset($right[$i]) ? $right[$i] : 0; |
| 1128 | 1128 | switch ($op) { |
| 1129 | - case '+': |
|
| 1130 | - $out[] = $lval + $rval; |
|
| 1131 | - break; |
|
| 1132 | - case '-': |
|
| 1133 | - $out[] = $lval - $rval; |
|
| 1134 | - break; |
|
| 1135 | - case '*': |
|
| 1136 | - $out[] = $lval * $rval; |
|
| 1137 | - break; |
|
| 1138 | - case '%': |
|
| 1139 | - $out[] = $lval % $rval; |
|
| 1140 | - break; |
|
| 1141 | - case '/': |
|
| 1142 | - if ($rval == 0) { |
|
| 1143 | - $this->throwError("color: Can't divide by zero"); |
|
| 1144 | - } |
|
| 1145 | - $out[] = $lval / $rval; |
|
| 1146 | - break; |
|
| 1147 | - case "==": |
|
| 1148 | - return $this->op_eq($left, $right); |
|
| 1149 | - case "!=": |
|
| 1150 | - return $this->op_neq($left, $right); |
|
| 1151 | - default: |
|
| 1152 | - $this->throwError("color: unknown op $op"); |
|
| 1129 | + case '+': |
|
| 1130 | + $out[] = $lval + $rval; |
|
| 1131 | + break; |
|
| 1132 | + case '-': |
|
| 1133 | + $out[] = $lval - $rval; |
|
| 1134 | + break; |
|
| 1135 | + case '*': |
|
| 1136 | + $out[] = $lval * $rval; |
|
| 1137 | + break; |
|
| 1138 | + case '%': |
|
| 1139 | + $out[] = $lval % $rval; |
|
| 1140 | + break; |
|
| 1141 | + case '/': |
|
| 1142 | + if ($rval == 0) { |
|
| 1143 | + $this->throwError("color: Can't divide by zero"); |
|
| 1144 | + } |
|
| 1145 | + $out[] = $lval / $rval; |
|
| 1146 | + break; |
|
| 1147 | + case "==": |
|
| 1148 | + return $this->op_eq($left, $right); |
|
| 1149 | + case "!=": |
|
| 1150 | + return $this->op_neq($left, $right); |
|
| 1151 | + default: |
|
| 1152 | + $this->throwError("color: unknown op $op"); |
|
| 1153 | 1153 | } |
| 1154 | 1154 | } |
| 1155 | 1155 | |
@@ -1223,82 +1223,82 @@ discard block |
||
| 1223 | 1223 | |
| 1224 | 1224 | list($type) = $value; |
| 1225 | 1225 | switch ($type) { |
| 1226 | - case "keyword": |
|
| 1227 | - return $value[1]; |
|
| 1228 | - case "color": |
|
| 1229 | - // [1] - red component (either number for a %) |
|
| 1230 | - // [2] - green component |
|
| 1231 | - // [3] - blue component |
|
| 1232 | - // [4] - optional alpha component |
|
| 1233 | - list(, $r, $g, $b) = $value; |
|
| 1234 | - |
|
| 1235 | - $r = round((int)$r); |
|
| 1236 | - $g = round((int)$g); |
|
| 1237 | - $b = round((int)$b); |
|
| 1238 | - |
|
| 1239 | - if (count($value) == 5 && $value[4] != 1) { // rgba |
|
| 1240 | - return 'rgba('.$r.', '.$g.', '.$b.', '.$value[4].')'; |
|
| 1241 | - } |
|
| 1242 | - |
|
| 1243 | - $h = sprintf("#%02x%02x%02x", $r, $g, $b); |
|
| 1244 | - |
|
| 1245 | - // Converting hex color to short notation (e.g. #003399 to #039) |
|
| 1246 | - if ($h[1] === $h[2] && $h[3] === $h[4] && $h[5] === $h[6]) { |
|
| 1247 | - $h = '#' . $h[1] . $h[3] . $h[5]; |
|
| 1248 | - } |
|
| 1249 | - |
|
| 1250 | - return $h; |
|
| 1251 | - case "number": |
|
| 1252 | - return round($value[1], $this->numberPrecision) . $value[2]; |
|
| 1253 | - case "string": |
|
| 1254 | - return $value[1] . $this->compileStringContent($value) . $value[1]; |
|
| 1255 | - case "function": |
|
| 1256 | - $args = !empty($value[2]) ? $this->compileValue($value[2]) : ""; |
|
| 1257 | - return "$value[1]($args)"; |
|
| 1258 | - case "list": |
|
| 1259 | - $value = $this->extractInterpolation($value); |
|
| 1260 | - if ($value[0] != "list") return $this->compileValue($value); |
|
| 1261 | - |
|
| 1262 | - list(, $delim, $items) = $value; |
|
| 1263 | - |
|
| 1264 | - $filtered = array(); |
|
| 1265 | - foreach ($items as $item) { |
|
| 1266 | - if ($item[0] == "null") continue; |
|
| 1267 | - $filtered[] = $this->compileValue($item); |
|
| 1268 | - } |
|
| 1269 | - |
|
| 1270 | - return implode("$delim ", $filtered); |
|
| 1271 | - case "interpolated": # node created by extractInterpolation |
|
| 1272 | - list(, $interpolate, $left, $right) = $value; |
|
| 1273 | - list(,, $whiteLeft, $whiteRight) = $interpolate; |
|
| 1274 | - |
|
| 1275 | - $left = count($left[2]) > 0 ? |
|
| 1276 | - $this->compileValue($left).$whiteLeft : ""; |
|
| 1277 | - |
|
| 1278 | - $right = count($right[2]) > 0 ? |
|
| 1279 | - $whiteRight.$this->compileValue($right) : ""; |
|
| 1280 | - |
|
| 1281 | - return $left.$this->compileValue($interpolate).$right; |
|
| 1282 | - |
|
| 1283 | - case "interpolate": # raw parse node |
|
| 1284 | - list(, $exp) = $value; |
|
| 1285 | - |
|
| 1286 | - // strip quotes if it's a string |
|
| 1287 | - $reduced = $this->reduce($exp); |
|
| 1288 | - switch ($reduced[0]) { |
|
| 1226 | + case "keyword": |
|
| 1227 | + return $value[1]; |
|
| 1228 | + case "color": |
|
| 1229 | + // [1] - red component (either number for a %) |
|
| 1230 | + // [2] - green component |
|
| 1231 | + // [3] - blue component |
|
| 1232 | + // [4] - optional alpha component |
|
| 1233 | + list(, $r, $g, $b) = $value; |
|
| 1234 | + |
|
| 1235 | + $r = round((int)$r); |
|
| 1236 | + $g = round((int)$g); |
|
| 1237 | + $b = round((int)$b); |
|
| 1238 | + |
|
| 1239 | + if (count($value) == 5 && $value[4] != 1) { // rgba |
|
| 1240 | + return 'rgba('.$r.', '.$g.', '.$b.', '.$value[4].')'; |
|
| 1241 | + } |
|
| 1242 | + |
|
| 1243 | + $h = sprintf("#%02x%02x%02x", $r, $g, $b); |
|
| 1244 | + |
|
| 1245 | + // Converting hex color to short notation (e.g. #003399 to #039) |
|
| 1246 | + if ($h[1] === $h[2] && $h[3] === $h[4] && $h[5] === $h[6]) { |
|
| 1247 | + $h = '#' . $h[1] . $h[3] . $h[5]; |
|
| 1248 | + } |
|
| 1249 | + |
|
| 1250 | + return $h; |
|
| 1251 | + case "number": |
|
| 1252 | + return round($value[1], $this->numberPrecision) . $value[2]; |
|
| 1253 | + case "string": |
|
| 1254 | + return $value[1] . $this->compileStringContent($value) . $value[1]; |
|
| 1255 | + case "function": |
|
| 1256 | + $args = !empty($value[2]) ? $this->compileValue($value[2]) : ""; |
|
| 1257 | + return "$value[1]($args)"; |
|
| 1258 | + case "list": |
|
| 1259 | + $value = $this->extractInterpolation($value); |
|
| 1260 | + if ($value[0] != "list") return $this->compileValue($value); |
|
| 1261 | + |
|
| 1262 | + list(, $delim, $items) = $value; |
|
| 1263 | + |
|
| 1264 | + $filtered = array(); |
|
| 1265 | + foreach ($items as $item) { |
|
| 1266 | + if ($item[0] == "null") continue; |
|
| 1267 | + $filtered[] = $this->compileValue($item); |
|
| 1268 | + } |
|
| 1269 | + |
|
| 1270 | + return implode("$delim ", $filtered); |
|
| 1271 | + case "interpolated": # node created by extractInterpolation |
|
| 1272 | + list(, $interpolate, $left, $right) = $value; |
|
| 1273 | + list(,, $whiteLeft, $whiteRight) = $interpolate; |
|
| 1274 | + |
|
| 1275 | + $left = count($left[2]) > 0 ? |
|
| 1276 | + $this->compileValue($left).$whiteLeft : ""; |
|
| 1277 | + |
|
| 1278 | + $right = count($right[2]) > 0 ? |
|
| 1279 | + $whiteRight.$this->compileValue($right) : ""; |
|
| 1280 | + |
|
| 1281 | + return $left.$this->compileValue($interpolate).$right; |
|
| 1282 | + |
|
| 1283 | + case "interpolate": # raw parse node |
|
| 1284 | + list(, $exp) = $value; |
|
| 1285 | + |
|
| 1286 | + // strip quotes if it's a string |
|
| 1287 | + $reduced = $this->reduce($exp); |
|
| 1288 | + switch ($reduced[0]) { |
|
| 1289 | 1289 | case "string": |
| 1290 | 1290 | $reduced = array("keyword", |
| 1291 | 1291 | $this->compileStringContent($reduced)); |
| 1292 | 1292 | break; |
| 1293 | 1293 | case "null": |
| 1294 | 1294 | $reduced = array("keyword", ""); |
| 1295 | - } |
|
| 1295 | + } |
|
| 1296 | 1296 | |
| 1297 | 1297 | return $this->compileValue($reduced); |
| 1298 | - case "null": |
|
| 1299 | - return "null"; |
|
| 1300 | - default: |
|
| 1301 | - $this->throwError("unknown value type: $type"); |
|
| 1298 | + case "null": |
|
| 1299 | + return "null"; |
|
| 1300 | + default: |
|
| 1301 | + $this->throwError("unknown value type: $type"); |
|
| 1302 | 1302 | } |
| 1303 | 1303 | } |
| 1304 | 1304 | |
@@ -1741,16 +1741,16 @@ discard block |
||
| 1741 | 1741 | |
| 1742 | 1742 | protected function coerceColor($value) { |
| 1743 | 1743 | switch ($value[0]) { |
| 1744 | - case "color": return $value; |
|
| 1745 | - case "keyword": |
|
| 1746 | - $name = $value[1]; |
|
| 1747 | - if (isset(self::$cssColors[$name])) { |
|
| 1748 | - $rgba = explode(',', self::$cssColors[$name]); |
|
| 1749 | - return isset($rgba[3]) |
|
| 1750 | - ? array('color', (int) $rgba[0], (int) $rgba[1], (int) $rgba[2], (int) $rgba[3]) |
|
| 1751 | - : array('color', (int) $rgba[0], (int) $rgba[1], (int) $rgba[2]); |
|
| 1752 | - } |
|
| 1753 | - return null; |
|
| 1744 | + case "color": return $value; |
|
| 1745 | + case "keyword": |
|
| 1746 | + $name = $value[1]; |
|
| 1747 | + if (isset(self::$cssColors[$name])) { |
|
| 1748 | + $rgba = explode(',', self::$cssColors[$name]); |
|
| 1749 | + return isset($rgba[3]) |
|
| 1750 | + ? array('color', (int) $rgba[0], (int) $rgba[1], (int) $rgba[2], (int) $rgba[3]) |
|
| 1751 | + : array('color', (int) $rgba[0], (int) $rgba[1], (int) $rgba[2]); |
|
| 1752 | + } |
|
| 1753 | + return null; |
|
| 1754 | 1754 | } |
| 1755 | 1755 | |
| 1756 | 1756 | return null; |
@@ -1758,10 +1758,10 @@ discard block |
||
| 1758 | 1758 | |
| 1759 | 1759 | protected function coerceString($value) { |
| 1760 | 1760 | switch ($value[0]) { |
| 1761 | - case "string": |
|
| 1762 | - return $value; |
|
| 1763 | - case "keyword": |
|
| 1764 | - return array("string", "", array($value[1])); |
|
| 1761 | + case "string": |
|
| 1762 | + return $value; |
|
| 1763 | + case "keyword": |
|
| 1764 | + return array("string", "", array($value[1])); |
|
| 1765 | 1765 | } |
| 1766 | 1766 | return null; |
| 1767 | 1767 | } |
@@ -1974,16 +1974,16 @@ discard block |
||
| 1974 | 1974 | // 4, 5, 6 - hsl |
| 1975 | 1975 | // 7 - a |
| 1976 | 1976 | switch ($i) { |
| 1977 | - case 1: |
|
| 1978 | - case 2: |
|
| 1979 | - case 3: |
|
| 1980 | - $max = 255; break; |
|
| 1981 | - case 4: |
|
| 1982 | - $max = 360; break; |
|
| 1983 | - case 7: |
|
| 1984 | - $max = 1; break; |
|
| 1985 | - default: |
|
| 1986 | - $max = 100; |
|
| 1977 | + case 1: |
|
| 1978 | + case 2: |
|
| 1979 | + case 3: |
|
| 1980 | + $max = 255; break; |
|
| 1981 | + case 4: |
|
| 1982 | + $max = 360; break; |
|
| 1983 | + case 7: |
|
| 1984 | + $max = 1; break; |
|
| 1985 | + default: |
|
| 1986 | + $max = 100; |
|
| 1987 | 1987 | } |
| 1988 | 1988 | |
| 1989 | 1989 | $scale = $scale / 100; |
@@ -2324,12 +2324,12 @@ discard block |
||
| 2324 | 2324 | protected function listSeparatorForJoin($list1, $sep) { |
| 2325 | 2325 | if (!isset($sep)) return $list1[1]; |
| 2326 | 2326 | switch ($this->compileValue($sep)) { |
| 2327 | - case "comma": |
|
| 2328 | - return ","; |
|
| 2329 | - case "space": |
|
| 2330 | - return ""; |
|
| 2331 | - default: |
|
| 2332 | - return $list1[1]; |
|
| 2327 | + case "comma": |
|
| 2328 | + return ","; |
|
| 2329 | + case "space": |
|
| 2330 | + return ""; |
|
| 2331 | + default: |
|
| 2332 | + return $list1[1]; |
|
| 2333 | 2333 | } |
| 2334 | 2334 | } |
| 2335 | 2335 | |
@@ -2376,18 +2376,18 @@ discard block |
||
| 2376 | 2376 | protected function lib_type_of($args) { |
| 2377 | 2377 | $value = $args[0]; |
| 2378 | 2378 | switch ($value[0]) { |
| 2379 | - case "keyword": |
|
| 2380 | - if ($value == self::$true || $value == self::$false) { |
|
| 2381 | - return "bool"; |
|
| 2382 | - } |
|
| 2383 | - |
|
| 2384 | - if ($this->coerceColor($value)) { |
|
| 2385 | - return "color"; |
|
| 2386 | - } |
|
| 2387 | - |
|
| 2388 | - return "string"; |
|
| 2389 | - default: |
|
| 2390 | - return $value[0]; |
|
| 2379 | + case "keyword": |
|
| 2380 | + if ($value == self::$true || $value == self::$false) { |
|
| 2381 | + return "bool"; |
|
| 2382 | + } |
|
| 2383 | + |
|
| 2384 | + if ($this->coerceColor($value)) { |
|
| 2385 | + return "color"; |
|
| 2386 | + } |
|
| 2387 | + |
|
| 2388 | + return "string"; |
|
| 2389 | + default: |
|
| 2390 | + return $value[0]; |
|
| 2391 | 2391 | } |
| 2392 | 2392 | } |
| 2393 | 2393 | |
@@ -163,7 +163,10 @@ discard block |
||
| 163 | 163 | protected function matchExtendsSingle($single, &$outOrigin) { |
| 164 | 164 | $counts = array(); |
| 165 | 165 | foreach ($single as $part) { |
| 166 | - if (!is_string($part)) return false; // hmm |
|
| 166 | + if (!is_string($part)) { |
|
| 167 | + return false; |
|
| 168 | + } |
|
| 169 | + // hmm |
|
| 167 | 170 | |
| 168 | 171 | if (isset($this->extendsMap[$part])) { |
| 169 | 172 | foreach ($this->extendsMap[$part] as $idx) { |
@@ -180,10 +183,14 @@ discard block |
||
| 180 | 183 | list($target, $origin) = $this->extends[$idx]; |
| 181 | 184 | |
| 182 | 185 | // check count |
| 183 | - if ($count != count($target)) continue; |
|
| 186 | + if ($count != count($target)) { |
|
| 187 | + continue; |
|
| 188 | + } |
|
| 184 | 189 | |
| 185 | 190 | // check if target is subset of single |
| 186 | - if (array_diff(array_intersect($single, $target), $target)) continue; |
|
| 191 | + if (array_diff(array_intersect($single, $target), $target)) { |
|
| 192 | + continue; |
|
| 193 | + } |
|
| 187 | 194 | |
| 188 | 195 | $rem = array_diff($single, $target); |
| 189 | 196 | |
@@ -229,7 +236,9 @@ discard block |
||
| 229 | 236 | |
| 230 | 237 | protected function matchExtends($selector, &$out, $from = 0, $initial=true) { |
| 231 | 238 | foreach ($selector as $i => $part) { |
| 232 | - if ($i < $from) continue; |
|
| 239 | + if ($i < $from) { |
|
| 240 | + continue; |
|
| 241 | + } |
|
| 233 | 242 | |
| 234 | 243 | if ($this->matchExtendsSingle($part, $origin)) { |
| 235 | 244 | $before = array_slice($selector, 0, $i); |
@@ -253,7 +262,9 @@ discard block |
||
| 253 | 262 | $after); |
| 254 | 263 | |
| 255 | 264 | |
| 256 | - if ($result == $selector) continue; |
|
| 265 | + if ($result == $selector) { |
|
| 266 | + continue; |
|
| 267 | + } |
|
| 257 | 268 | $out[] = $result; |
| 258 | 269 | |
| 259 | 270 | // recursively check for more matches |
@@ -279,7 +290,9 @@ discard block |
||
| 279 | 290 | $selectors = array(); |
| 280 | 291 | foreach ($block->selectors as $s) { |
| 281 | 292 | $selectors[] = $s; |
| 282 | - if (!is_array($s)) continue; |
|
| 293 | + if (!is_array($s)) { |
|
| 294 | + continue; |
|
| 295 | + } |
|
| 283 | 296 | // check extends |
| 284 | 297 | if (!empty($this->extendsMap)) { |
| 285 | 298 | $this->matchExtends($s, $selectors); |
@@ -439,7 +452,9 @@ discard block |
||
| 439 | 452 | |
| 440 | 453 | protected function evalSelectorPart($piece) { |
| 441 | 454 | foreach ($piece as &$p) { |
| 442 | - if (!is_array($p)) continue; |
|
| 455 | + if (!is_array($p)) { |
|
| 456 | + continue; |
|
| 457 | + } |
|
| 443 | 458 | |
| 444 | 459 | switch ($p[0]) { |
| 445 | 460 | case "interpolate": |
@@ -457,7 +472,10 @@ discard block |
||
| 457 | 472 | // compiles to string |
| 458 | 473 | // self(&) should have been replaced by now |
| 459 | 474 | protected function compileSelector($selector) { |
| 460 | - if (!is_array($selector)) return $selector; // media and the like |
|
| 475 | + if (!is_array($selector)) { |
|
| 476 | + return $selector; |
|
| 477 | + } |
|
| 478 | + // media and the like |
|
| 461 | 479 | |
| 462 | 480 | return implode(" ", array_map( |
| 463 | 481 | array($this, "compileSelectorPart"), $selector)); |
@@ -465,7 +483,9 @@ discard block |
||
| 465 | 483 | |
| 466 | 484 | protected function compileSelectorPart($piece) { |
| 467 | 485 | foreach ($piece as &$p) { |
| 468 | - if (!is_array($p)) continue; |
|
| 486 | + if (!is_array($p)) { |
|
| 487 | + continue; |
|
| 488 | + } |
|
| 469 | 489 | |
| 470 | 490 | switch ($p[0]) { |
| 471 | 491 | case "self": |
@@ -482,7 +502,9 @@ discard block |
||
| 482 | 502 | |
| 483 | 503 | protected function hasSelectorPlaceholder($selector) |
| 484 | 504 | { |
| 485 | - if (!is_array($selector)) return false; |
|
| 505 | + if (!is_array($selector)) { |
|
| 506 | + return false; |
|
| 507 | + } |
|
| 486 | 508 | |
| 487 | 509 | foreach ($selector as $parts) { |
| 488 | 510 | foreach ($parts as $part) { |
@@ -498,7 +520,9 @@ discard block |
||
| 498 | 520 | protected function compileChildren($stms, $out) { |
| 499 | 521 | foreach ($stms as $stm) { |
| 500 | 522 | $ret = $this->compileChild($stm, $out); |
| 501 | - if (isset($ret)) return $ret; |
|
| 523 | + if (isset($ret)) { |
|
| 524 | + return $ret; |
|
| 525 | + } |
|
| 502 | 526 | } |
| 503 | 527 | } |
| 504 | 528 | |
@@ -601,9 +625,13 @@ discard block |
||
| 601 | 625 | } |
| 602 | 626 | if ($rawPath[0] == "list") { |
| 603 | 627 | // handle a list of strings |
| 604 | - if (count($rawPath[2]) == 0) return false; |
|
| 628 | + if (count($rawPath[2]) == 0) { |
|
| 629 | + return false; |
|
| 630 | + } |
|
| 605 | 631 | foreach ($rawPath[2] as $path) { |
| 606 | - if ($path[0] != "string") return false; |
|
| 632 | + if ($path[0] != "string") { |
|
| 633 | + return false; |
|
| 634 | + } |
|
| 607 | 635 | } |
| 608 | 636 | |
| 609 | 637 | foreach ($rawPath[2] as $path) { |
@@ -723,7 +751,9 @@ discard block |
||
| 723 | 751 | list(,$while) = $child; |
| 724 | 752 | while ($this->isTruthy($this->reduce($while->cond, true))) { |
| 725 | 753 | $ret = $this->compileChildren($while->children, $out); |
| 726 | - if ($ret) return $ret; |
|
| 754 | + if ($ret) { |
|
| 755 | + return $ret; |
|
| 756 | + } |
|
| 727 | 757 | } |
| 728 | 758 | break; |
| 729 | 759 | case "for": |
@@ -745,7 +775,9 @@ discard block |
||
| 745 | 775 | $start += $d; |
| 746 | 776 | |
| 747 | 777 | $ret = $this->compileChildren($for->children, $out); |
| 748 | - if ($ret) return $ret; |
|
| 778 | + if ($ret) { |
|
| 779 | + return $ret; |
|
| 780 | + } |
|
| 749 | 781 | } |
| 750 | 782 | |
| 751 | 783 | break; |
@@ -826,9 +858,13 @@ discard block |
||
| 826 | 858 | protected function expToString($exp) { |
| 827 | 859 | list(, $op, $left, $right, $inParens, $whiteLeft, $whiteRight) = $exp; |
| 828 | 860 | $content = array($this->reduce($left)); |
| 829 | - if ($whiteLeft) $content[] = " "; |
|
| 861 | + if ($whiteLeft) { |
|
| 862 | + $content[] = " "; |
|
| 863 | + } |
|
| 830 | 864 | $content[] = $op; |
| 831 | - if ($whiteRight) $content[] = " "; |
|
| 865 | + if ($whiteRight) { |
|
| 866 | + $content[] = " "; |
|
| 867 | + } |
|
| 832 | 868 | $content[] = $this->reduce($right); |
| 833 | 869 | return array("string", "", $content); |
| 834 | 870 | } |
@@ -1109,14 +1145,22 @@ discard block |
||
| 1109 | 1145 | } |
| 1110 | 1146 | |
| 1111 | 1147 | protected function op_and($left, $right, $shouldEval) { |
| 1112 | - if (!$shouldEval) return; |
|
| 1113 | - if ($left != self::$false) return $right; |
|
| 1148 | + if (!$shouldEval) { |
|
| 1149 | + return; |
|
| 1150 | + } |
|
| 1151 | + if ($left != self::$false) { |
|
| 1152 | + return $right; |
|
| 1153 | + } |
|
| 1114 | 1154 | return $left; |
| 1115 | 1155 | } |
| 1116 | 1156 | |
| 1117 | 1157 | protected function op_or($left, $right, $shouldEval) { |
| 1118 | - if (!$shouldEval) return; |
|
| 1119 | - if ($left != self::$false) return $left; |
|
| 1158 | + if (!$shouldEval) { |
|
| 1159 | + return; |
|
| 1160 | + } |
|
| 1161 | + if ($left != self::$false) { |
|
| 1162 | + return $left; |
|
| 1163 | + } |
|
| 1120 | 1164 | return $right; |
| 1121 | 1165 | } |
| 1122 | 1166 | |
@@ -1153,8 +1197,11 @@ discard block |
||
| 1153 | 1197 | } |
| 1154 | 1198 | } |
| 1155 | 1199 | |
| 1156 | - if (isset($left[4])) $out[4] = $left[4]; |
|
| 1157 | - elseif (isset($right[4])) $out[4] = $right[4]; |
|
| 1200 | + if (isset($left[4])) { |
|
| 1201 | + $out[4] = $left[4]; |
|
| 1202 | + } elseif (isset($right[4])) { |
|
| 1203 | + $out[4] = $right[4]; |
|
| 1204 | + } |
|
| 1158 | 1205 | |
| 1159 | 1206 | return $this->fixColor($out); |
| 1160 | 1207 | } |
@@ -1257,13 +1304,17 @@ discard block |
||
| 1257 | 1304 | return "$value[1]($args)"; |
| 1258 | 1305 | case "list": |
| 1259 | 1306 | $value = $this->extractInterpolation($value); |
| 1260 | - if ($value[0] != "list") return $this->compileValue($value); |
|
| 1307 | + if ($value[0] != "list") { |
|
| 1308 | + return $this->compileValue($value); |
|
| 1309 | + } |
|
| 1261 | 1310 | |
| 1262 | 1311 | list(, $delim, $items) = $value; |
| 1263 | 1312 | |
| 1264 | 1313 | $filtered = array(); |
| 1265 | 1314 | foreach ($items as $item) { |
| 1266 | - if ($item[0] == "null") continue; |
|
| 1315 | + if ($item[0] == "null") { |
|
| 1316 | + continue; |
|
| 1317 | + } |
|
| 1267 | 1318 | $filtered[] = $this->compileValue($item); |
| 1268 | 1319 | } |
| 1269 | 1320 | |
@@ -1521,7 +1572,9 @@ discard block |
||
| 1521 | 1572 | } |
| 1522 | 1573 | |
| 1523 | 1574 | protected function setExisting($name, $value, $env = null) { |
| 1524 | - if (!isset($env)) $env = $this->getStoreEnv(); |
|
| 1575 | + if (!isset($env)) { |
|
| 1576 | + $env = $this->getStoreEnv(); |
|
| 1577 | + } |
|
| 1525 | 1578 | |
| 1526 | 1579 | if (isset($env->store[$name]) || !isset($env->parent)) { |
| 1527 | 1580 | $env->store[$name] = $value; |
@@ -1538,8 +1591,12 @@ discard block |
||
| 1538 | 1591 | public function get($name, $defaultValue = null, $env = null) { |
| 1539 | 1592 | $name = $this->normalizeName($name); |
| 1540 | 1593 | |
| 1541 | - if (!isset($env)) $env = $this->getStoreEnv(); |
|
| 1542 | - if (!isset($defaultValue)) $defaultValue = self::$defaultValue; |
|
| 1594 | + if (!isset($env)) { |
|
| 1595 | + $env = $this->getStoreEnv(); |
|
| 1596 | + } |
|
| 1597 | + if (!isset($defaultValue)) { |
|
| 1598 | + $defaultValue = self::$defaultValue; |
|
| 1599 | + } |
|
| 1543 | 1600 | |
| 1544 | 1601 | if (isset($env->store[$name])) { |
| 1545 | 1602 | return $env->store[$name]; |
@@ -1705,7 +1762,9 @@ discard block |
||
| 1705 | 1762 | } |
| 1706 | 1763 | } |
| 1707 | 1764 | |
| 1708 | - if (!isset($prototype)) return $posArgs; |
|
| 1765 | + if (!isset($prototype)) { |
|
| 1766 | + return $posArgs; |
|
| 1767 | + } |
|
| 1709 | 1768 | |
| 1710 | 1769 | $finalArgs = array(); |
| 1711 | 1770 | foreach ($prototype as $i => $names) { |
@@ -1767,19 +1826,23 @@ discard block |
||
| 1767 | 1826 | } |
| 1768 | 1827 | |
| 1769 | 1828 | public function assertList($value) { |
| 1770 | - if ($value[0] != "list") |
|
| 1771 | - $this->throwError("expecting list"); |
|
| 1829 | + if ($value[0] != "list") { |
|
| 1830 | + $this->throwError("expecting list"); |
|
| 1831 | + } |
|
| 1772 | 1832 | return $value; |
| 1773 | 1833 | } |
| 1774 | 1834 | |
| 1775 | 1835 | public function assertColor($value) { |
| 1776 | - if ($color = $this->coerceColor($value)) return $color; |
|
| 1836 | + if ($color = $this->coerceColor($value)) { |
|
| 1837 | + return $color; |
|
| 1838 | + } |
|
| 1777 | 1839 | $this->throwError("expecting color"); |
| 1778 | 1840 | } |
| 1779 | 1841 | |
| 1780 | 1842 | public function assertNumber($value) { |
| 1781 | - if ($value[0] != "number") |
|
| 1782 | - $this->throwError("expecting number"); |
|
| 1843 | + if ($value[0] != "number") { |
|
| 1844 | + $this->throwError("expecting number"); |
|
| 1845 | + } |
|
| 1783 | 1846 | return $value[1]; |
| 1784 | 1847 | } |
| 1785 | 1848 | |
@@ -1796,8 +1859,12 @@ discard block |
||
| 1796 | 1859 | // make sure a color's components don't go out of bounds |
| 1797 | 1860 | protected function fixColor($c) { |
| 1798 | 1861 | foreach (range(1, 3) as $i) { |
| 1799 | - if ($c[$i] < 0) $c[$i] = 0; |
|
| 1800 | - if ($c[$i] > 255) $c[$i] = 255; |
|
| 1862 | + if ($c[$i] < 0) { |
|
| 1863 | + $c[$i] = 0; |
|
| 1864 | + } |
|
| 1865 | + if ($c[$i] > 255) { |
|
| 1866 | + $c[$i] = 255; |
|
| 1867 | + } |
|
| 1801 | 1868 | } |
| 1802 | 1869 | |
| 1803 | 1870 | return $c; |
@@ -1814,36 +1881,42 @@ discard block |
||
| 1814 | 1881 | } else { |
| 1815 | 1882 | $d = $max - $min; |
| 1816 | 1883 | |
| 1817 | - if ($l < 255) |
|
| 1818 | - $s = $d / $l; |
|
| 1819 | - else |
|
| 1820 | - $s = $d / (510 - $l); |
|
| 1884 | + if ($l < 255) { |
|
| 1885 | + $s = $d / $l; |
|
| 1886 | + } else { |
|
| 1887 | + $s = $d / (510 - $l); |
|
| 1888 | + } |
|
| 1821 | 1889 | |
| 1822 | - if ($red == $max) |
|
| 1823 | - $h = 60 * ($green - $blue) / $d; |
|
| 1824 | - elseif ($green == $max) |
|
| 1825 | - $h = 60 * ($blue - $red) / $d + 120; |
|
| 1826 | - elseif ($blue == $max) |
|
| 1827 | - $h = 60 * ($red - $green) / $d + 240; |
|
| 1890 | + if ($red == $max) { |
|
| 1891 | + $h = 60 * ($green - $blue) / $d; |
|
| 1892 | + } elseif ($green == $max) { |
|
| 1893 | + $h = 60 * ($blue - $red) / $d + 120; |
|
| 1894 | + } elseif ($blue == $max) { |
|
| 1895 | + $h = 60 * ($red - $green) / $d + 240; |
|
| 1896 | + } |
|
| 1828 | 1897 | } |
| 1829 | 1898 | |
| 1830 | 1899 | return array('hsl', fmod($h, 360), $s * 100, $l / 5.1); |
| 1831 | 1900 | } |
| 1832 | 1901 | |
| 1833 | 1902 | public function hueToRGB($m1, $m2, $h) { |
| 1834 | - if ($h < 0) |
|
| 1835 | - $h += 1; |
|
| 1836 | - elseif ($h > 1) |
|
| 1837 | - $h -= 1; |
|
| 1903 | + if ($h < 0) { |
|
| 1904 | + $h += 1; |
|
| 1905 | + } elseif ($h > 1) { |
|
| 1906 | + $h -= 1; |
|
| 1907 | + } |
|
| 1838 | 1908 | |
| 1839 | - if ($h * 6 < 1) |
|
| 1840 | - return $m1 + ($m2 - $m1) * $h * 6; |
|
| 1909 | + if ($h * 6 < 1) { |
|
| 1910 | + return $m1 + ($m2 - $m1) * $h * 6; |
|
| 1911 | + } |
|
| 1841 | 1912 | |
| 1842 | - if ($h * 2 < 1) |
|
| 1843 | - return $m2; |
|
| 1913 | + if ($h * 2 < 1) { |
|
| 1914 | + return $m2; |
|
| 1915 | + } |
|
| 1844 | 1916 | |
| 1845 | - if ($h * 3 < 2) |
|
| 1846 | - return $m1 + ($m2 - $m1) * (2/3 - $h) * 6; |
|
| 1917 | + if ($h * 3 < 2) { |
|
| 1918 | + return $m1 + ($m2 - $m1) * (2/3 - $h) * 6; |
|
| 1919 | + } |
|
| 1847 | 1920 | |
| 1848 | 1921 | return $m1; |
| 1849 | 1922 | } |
@@ -1874,7 +1947,9 @@ discard block |
||
| 1874 | 1947 | protected static $lib_if = array("condition", "if-true", "if-false"); |
| 1875 | 1948 | protected function lib_if($args) { |
| 1876 | 1949 | list($cond,$t, $f) = $args; |
| 1877 | - if (!$this->isTruthy($cond)) return $f; |
|
| 1950 | + if (!$this->isTruthy($cond)) { |
|
| 1951 | + return $f; |
|
| 1952 | + } |
|
| 1878 | 1953 | return $t; |
| 1879 | 1954 | } |
| 1880 | 1955 | |
@@ -1936,7 +2011,9 @@ discard block |
||
| 1936 | 2011 | } |
| 1937 | 2012 | |
| 1938 | 2013 | $rgb = $this->toRGB($hsl[1], $hsl[2], $hsl[3]); |
| 1939 | - if (isset($color[4])) $rgb[4] = $color[4]; |
|
| 2014 | + if (isset($color[4])) { |
|
| 2015 | + $rgb[4] = $color[4]; |
|
| 2016 | + } |
|
| 1940 | 2017 | $color = $rgb; |
| 1941 | 2018 | } |
| 1942 | 2019 | |
@@ -2036,7 +2113,9 @@ discard block |
||
| 2036 | 2113 | protected static $lib_opacity = array("color"); |
| 2037 | 2114 | protected function lib_opacity($args) { |
| 2038 | 2115 | $value = $args[0]; |
| 2039 | - if ($value[0] === 'number') return null; |
|
| 2116 | + if ($value[0] === 'number') { |
|
| 2117 | + return null; |
|
| 2118 | + } |
|
| 2040 | 2119 | return $this->lib_alpha($args); |
| 2041 | 2120 | } |
| 2042 | 2121 | |
@@ -2115,7 +2194,9 @@ discard block |
||
| 2115 | 2194 | $hsl = $this->toHSL($color[1], $color[2], $color[3]); |
| 2116 | 2195 | $hsl[$idx] += $amount; |
| 2117 | 2196 | $out = $this->toRGB($hsl[1], $hsl[2], $hsl[3]); |
| 2118 | - if (isset($color[4])) $out[4] = $color[4]; |
|
| 2197 | + if (isset($color[4])) { |
|
| 2198 | + $out[4] = $color[4]; |
|
| 2199 | + } |
|
| 2119 | 2200 | return $out; |
| 2120 | 2201 | } |
| 2121 | 2202 | |
@@ -2143,7 +2224,9 @@ discard block |
||
| 2143 | 2224 | protected static $lib_saturate = array("color", "amount"); |
| 2144 | 2225 | protected function lib_saturate($args) { |
| 2145 | 2226 | $value = $args[0]; |
| 2146 | - if ($value[0] === 'number') return null; |
|
| 2227 | + if ($value[0] === 'number') { |
|
| 2228 | + return null; |
|
| 2229 | + } |
|
| 2147 | 2230 | $color = $this->assertColor($value); |
| 2148 | 2231 | $amount = 100*$this->coercePercent($args[1]); |
| 2149 | 2232 | return $this->adjustHsl($color, 2, $amount); |
@@ -2159,7 +2242,9 @@ discard block |
||
| 2159 | 2242 | protected static $lib_grayscale = array("color"); |
| 2160 | 2243 | protected function lib_grayscale($args) { |
| 2161 | 2244 | $value = $args[0]; |
| 2162 | - if ($value[0] === 'number') return null; |
|
| 2245 | + if ($value[0] === 'number') { |
|
| 2246 | + return null; |
|
| 2247 | + } |
|
| 2163 | 2248 | return $this->adjustHsl($this->assertColor($value), 2, -100); |
| 2164 | 2249 | } |
| 2165 | 2250 | |
@@ -2171,7 +2256,9 @@ discard block |
||
| 2171 | 2256 | protected static $lib_invert = array("color"); |
| 2172 | 2257 | protected function lib_invert($args) { |
| 2173 | 2258 | $value = $args[0]; |
| 2174 | - if ($value[0] === 'number') return null; |
|
| 2259 | + if ($value[0] === 'number') { |
|
| 2260 | + return null; |
|
| 2261 | + } |
|
| 2175 | 2262 | $color = $this->assertColor($value); |
| 2176 | 2263 | $color[1] = 255 - $color[1]; |
| 2177 | 2264 | $color[2] = 255 - $color[2]; |
@@ -2214,15 +2301,18 @@ discard block |
||
| 2214 | 2301 | protected static $lib_unquote = array("string"); |
| 2215 | 2302 | protected function lib_unquote($args) { |
| 2216 | 2303 | $str = $args[0]; |
| 2217 | - if ($str[0] == "string") $str[1] = ""; |
|
| 2304 | + if ($str[0] == "string") { |
|
| 2305 | + $str[1] = ""; |
|
| 2306 | + } |
|
| 2218 | 2307 | return $str; |
| 2219 | 2308 | } |
| 2220 | 2309 | |
| 2221 | 2310 | protected static $lib_quote = array("string"); |
| 2222 | 2311 | protected function lib_quote($args) { |
| 2223 | 2312 | $value = $args[0]; |
| 2224 | - if ($value[0] == "string" && !empty($value[1])) |
|
| 2225 | - return $value; |
|
| 2313 | + if ($value[0] == "string" && !empty($value[1])) { |
|
| 2314 | + return $value; |
|
| 2315 | + } |
|
| 2226 | 2316 | return array("string", '"', array($value)); |
| 2227 | 2317 | } |
| 2228 | 2318 | |
@@ -2322,7 +2412,9 @@ discard block |
||
| 2322 | 2412 | } |
| 2323 | 2413 | |
| 2324 | 2414 | protected function listSeparatorForJoin($list1, $sep) { |
| 2325 | - if (!isset($sep)) return $list1[1]; |
|
| 2415 | + if (!isset($sep)) { |
|
| 2416 | + return $list1[1]; |
|
| 2417 | + } |
|
| 2326 | 2418 | switch ($this->compileValue($sep)) { |
| 2327 | 2419 | case "comma": |
| 2328 | 2420 | return ","; |
@@ -2667,8 +2759,9 @@ discard block |
||
| 2667 | 2759 | $this->whitespace(); |
| 2668 | 2760 | while (false !== $this->parseChunk()); |
| 2669 | 2761 | |
| 2670 | - if ($this->count != strlen($this->buffer)) |
|
| 2671 | - $this->throwParseError(); |
|
| 2762 | + if ($this->count != strlen($this->buffer)) { |
|
| 2763 | + $this->throwParseError(); |
|
| 2764 | + } |
|
| 2672 | 2765 | |
| 2673 | 2766 | if (!empty($this->env->parent)) { |
| 2674 | 2767 | $this->throwParseError("unclosed block"); |
@@ -2912,7 +3005,9 @@ discard block |
||
| 2912 | 3005 | { |
| 2913 | 3006 | $directive = $this->pushSpecialBlock("directive"); |
| 2914 | 3007 | $directive->name = $dirName; |
| 2915 | - if (isset($dirValue)) $directive->value = $dirValue; |
|
| 3008 | + if (isset($dirValue)) { |
|
| 3009 | + $directive->value = $dirValue; |
|
| 3010 | + } |
|
| 2916 | 3011 | return true; |
| 2917 | 3012 | } |
| 2918 | 3013 | |
@@ -3030,7 +3125,9 @@ discard block |
||
| 3030 | 3125 | } |
| 3031 | 3126 | |
| 3032 | 3127 | protected function literal($what, $eatWhitespace = null) { |
| 3033 | - if (!isset($eatWhitespace)) $eatWhitespace = $this->eatWhiteDefault; |
|
| 3128 | + if (!isset($eatWhitespace)) { |
|
| 3129 | + $eatWhitespace = $this->eatWhiteDefault; |
|
| 3130 | + } |
|
| 3034 | 3131 | |
| 3035 | 3132 | // shortcut on single letter |
| 3036 | 3133 | if (!isset($what[1]) && isset($this->buffer[$this->count])) { |
@@ -3081,7 +3178,9 @@ discard block |
||
| 3081 | 3178 | protected function append($statement, $pos=null) { |
| 3082 | 3179 | if ($pos !== null) { |
| 3083 | 3180 | $statement[-1] = $pos; |
| 3084 | - if (!$this->rootParser) $statement[-2] = $this; |
|
| 3181 | + if (!$this->rootParser) { |
|
| 3182 | + $statement[-2] = $this; |
|
| 3183 | + } |
|
| 3085 | 3184 | } |
| 3086 | 3185 | $this->env->children[] = $statement; |
| 3087 | 3186 | } |
@@ -3089,8 +3188,9 @@ discard block |
||
| 3089 | 3188 | // last child that was appended |
| 3090 | 3189 | protected function last() { |
| 3091 | 3190 | $i = count($this->env->children) - 1; |
| 3092 | - if (isset($this->env->children[$i])) |
|
| 3093 | - return $this->env->children[$i]; |
|
| 3191 | + if (isset($this->env->children[$i])) { |
|
| 3192 | + return $this->env->children[$i]; |
|
| 3193 | + } |
|
| 3094 | 3194 | } |
| 3095 | 3195 | |
| 3096 | 3196 | // high level parsers (they return parts of ast) |
@@ -3107,8 +3207,12 @@ discard block |
||
| 3107 | 3207 | |
| 3108 | 3208 | if (($this->literal("only") && ($only = true) || $this->literal("not") && ($not = true) || true) && $this->mixedKeyword($mediaType)) { |
| 3109 | 3209 | $prop = array("mediaType"); |
| 3110 | - if (isset($only)) $prop[] = array("keyword", "only"); |
|
| 3111 | - if (isset($not)) $prop[] = array("keyword", "not"); |
|
| 3210 | + if (isset($only)) { |
|
| 3211 | + $prop[] = array("keyword", "only"); |
|
| 3212 | + } |
|
| 3213 | + if (isset($not)) { |
|
| 3214 | + $prop[] = array("keyword", "not"); |
|
| 3215 | + } |
|
| 3112 | 3216 | $media = array("list", "", array()); |
| 3113 | 3217 | foreach ((array)$mediaType as $type) { |
| 3114 | 3218 | if (is_array($type)) { |
@@ -3123,7 +3227,9 @@ discard block |
||
| 3123 | 3227 | |
| 3124 | 3228 | if (empty($parts) || $this->literal("and")) { |
| 3125 | 3229 | $this->genericList($expressions, "mediaExpression", "and", false); |
| 3126 | - if (is_array($expressions)) $parts = array_merge($parts, $expressions[2]); |
|
| 3230 | + if (is_array($expressions)) { |
|
| 3231 | + $parts = array_merge($parts, $expressions[2]); |
|
| 3232 | + } |
|
| 3127 | 3233 | } |
| 3128 | 3234 | |
| 3129 | 3235 | $out = $parts; |
@@ -3139,7 +3245,9 @@ discard block |
||
| 3139 | 3245 | $this->literal(")")) |
| 3140 | 3246 | { |
| 3141 | 3247 | $out = array("mediaExp", $feature); |
| 3142 | - if ($value) $out[] = $value; |
|
| 3248 | + if ($value) { |
|
| 3249 | + $out[] = $value; |
|
| 3250 | + } |
|
| 3143 | 3251 | return true; |
| 3144 | 3252 | } |
| 3145 | 3253 | |
@@ -3193,7 +3301,9 @@ discard block |
||
| 3193 | 3301 | while ($this->$parseItem($value)) { |
| 3194 | 3302 | $items[] = $value; |
| 3195 | 3303 | if ($delim) { |
| 3196 | - if (!$this->literal($delim)) break; |
|
| 3304 | + if (!$this->literal($delim)) { |
|
| 3305 | + break; |
|
| 3306 | + } |
|
| 3197 | 3307 | } |
| 3198 | 3308 | } |
| 3199 | 3309 | |
@@ -3249,10 +3359,14 @@ discard block |
||
| 3249 | 3359 | |
| 3250 | 3360 | // don't turn negative numbers into expressions |
| 3251 | 3361 | if ($op == "-" && $whiteBefore) { |
| 3252 | - if (!$whiteAfter) break; |
|
| 3362 | + if (!$whiteAfter) { |
|
| 3363 | + break; |
|
| 3364 | + } |
|
| 3253 | 3365 | } |
| 3254 | 3366 | |
| 3255 | - if (!$this->value($rhs)) break; |
|
| 3367 | + if (!$this->value($rhs)) { |
|
| 3368 | + break; |
|
| 3369 | + } |
|
| 3256 | 3370 | |
| 3257 | 3371 | // peek and see if rhs belongs to next operator |
| 3258 | 3372 | if ($this->peek($opstr, $next) && self::$precedence[$next[1]] > self::$precedence[$op]) { |
@@ -3298,14 +3412,30 @@ discard block |
||
| 3298 | 3412 | $this->seek($s); |
| 3299 | 3413 | } |
| 3300 | 3414 | |
| 3301 | - if ($this->parenValue($out)) return true; |
|
| 3302 | - if ($this->interpolation($out)) return true; |
|
| 3303 | - if ($this->variable($out)) return true; |
|
| 3304 | - if ($this->color($out)) return true; |
|
| 3305 | - if ($this->unit($out)) return true; |
|
| 3306 | - if ($this->string($out)) return true; |
|
| 3307 | - if ($this->func($out)) return true; |
|
| 3308 | - if ($this->progid($out)) return true; |
|
| 3415 | + if ($this->parenValue($out)) { |
|
| 3416 | + return true; |
|
| 3417 | + } |
|
| 3418 | + if ($this->interpolation($out)) { |
|
| 3419 | + return true; |
|
| 3420 | + } |
|
| 3421 | + if ($this->variable($out)) { |
|
| 3422 | + return true; |
|
| 3423 | + } |
|
| 3424 | + if ($this->color($out)) { |
|
| 3425 | + return true; |
|
| 3426 | + } |
|
| 3427 | + if ($this->unit($out)) { |
|
| 3428 | + return true; |
|
| 3429 | + } |
|
| 3430 | + if ($this->string($out)) { |
|
| 3431 | + return true; |
|
| 3432 | + } |
|
| 3433 | + if ($this->func($out)) { |
|
| 3434 | + return true; |
|
| 3435 | + } |
|
| 3436 | + if ($this->progid($out)) { |
|
| 3437 | + return true; |
|
| 3438 | + } |
|
| 3309 | 3439 | |
| 3310 | 3440 | if ($this->keyword($keyword)) { |
| 3311 | 3441 | if ($keyword == "null") { |
@@ -3412,7 +3542,9 @@ discard block |
||
| 3412 | 3542 | |
| 3413 | 3543 | $args[] = $arg; |
| 3414 | 3544 | |
| 3415 | - if (!$this->literal(",")) break; |
|
| 3545 | + if (!$this->literal(",")) { |
|
| 3546 | + break; |
|
| 3547 | + } |
|
| 3416 | 3548 | |
| 3417 | 3549 | $args[] = array("string", "", array(", ")); |
| 3418 | 3550 | } |
@@ -3454,7 +3586,9 @@ discard block |
||
| 3454 | 3586 | } |
| 3455 | 3587 | |
| 3456 | 3588 | $args[] = $arg; |
| 3457 | - if (!$this->literal(",")) break; |
|
| 3589 | + if (!$this->literal(",")) { |
|
| 3590 | + break; |
|
| 3591 | + } |
|
| 3458 | 3592 | } |
| 3459 | 3593 | |
| 3460 | 3594 | if (!$this->literal(")")) { |
@@ -3571,7 +3705,9 @@ discard block |
||
| 3571 | 3705 | |
| 3572 | 3706 | $this->eatWhiteDefault = $oldWhite; |
| 3573 | 3707 | |
| 3574 | - if (count($parts) == 0) return false; |
|
| 3708 | + if (count($parts) == 0) { |
|
| 3709 | + return false; |
|
| 3710 | + } |
|
| 3575 | 3711 | |
| 3576 | 3712 | if ($this->eatWhiteDefault) { |
| 3577 | 3713 | $this->whitespace(); |
@@ -3630,7 +3766,9 @@ discard block |
||
| 3630 | 3766 | |
| 3631 | 3767 | $this->eatWhiteDefault = $oldWhite; |
| 3632 | 3768 | |
| 3633 | - if (count($content) == 0) return false; |
|
| 3769 | + if (count($content) == 0) { |
|
| 3770 | + return false; |
|
| 3771 | + } |
|
| 3634 | 3772 | |
| 3635 | 3773 | // trim the end |
| 3636 | 3774 | if (is_string(end($content))) { |
@@ -3660,7 +3798,9 @@ discard block |
||
| 3660 | 3798 | |
| 3661 | 3799 | $out = array("interpolate", $value, $left, $right); |
| 3662 | 3800 | $this->eatWhiteDefault = $oldWhite; |
| 3663 | - if ($this->eatWhiteDefault) $this->whitespace(); |
|
| 3801 | + if ($this->eatWhiteDefault) { |
|
| 3802 | + $this->whitespace(); |
|
| 3803 | + } |
|
| 3664 | 3804 | return true; |
| 3665 | 3805 | } |
| 3666 | 3806 | |
@@ -3693,7 +3833,9 @@ discard block |
||
| 3693 | 3833 | } |
| 3694 | 3834 | |
| 3695 | 3835 | $this->eatWhiteDefault = $oldWhite; |
| 3696 | - if (count($parts) == 0) return false; |
|
| 3836 | + if (count($parts) == 0) { |
|
| 3837 | + return false; |
|
| 3838 | + } |
|
| 3697 | 3839 | |
| 3698 | 3840 | // match comment hack |
| 3699 | 3841 | if (preg_match(self::$whitePattern, |
@@ -3717,7 +3859,9 @@ discard block |
||
| 3717 | 3859 | $selectors = array(); |
| 3718 | 3860 | while ($this->selector($sel)) { |
| 3719 | 3861 | $selectors[] = $sel; |
| 3720 | - if (!$this->literal(",")) break; |
|
| 3862 | + if (!$this->literal(",")) { |
|
| 3863 | + break; |
|
| 3864 | + } |
|
| 3721 | 3865 | while ($this->literal(",")); // ignore extra |
| 3722 | 3866 | } |
| 3723 | 3867 | |
@@ -3832,7 +3976,9 @@ discard block |
||
| 3832 | 3976 | $this->literal(")")) |
| 3833 | 3977 | { |
| 3834 | 3978 | $parts[] = "("; |
| 3835 | - if (!empty($str)) $parts[] = $str; |
|
| 3979 | + if (!empty($str)) { |
|
| 3980 | + $parts[] = $str; |
|
| 3981 | + } |
|
| 3836 | 3982 | $parts[] = ")"; |
| 3837 | 3983 | } else { |
| 3838 | 3984 | $this->seek($ss); |
@@ -3898,7 +4044,9 @@ discard block |
||
| 3898 | 4044 | |
| 3899 | 4045 | $this->eatWhiteDefault = $oldWhite; |
| 3900 | 4046 | |
| 3901 | - if (count($parts) == 0) return false; |
|
| 4047 | + if (count($parts) == 0) { |
|
| 4048 | + return false; |
|
| 4049 | + } |
|
| 3902 | 4050 | |
| 3903 | 4051 | $out = $parts; |
| 3904 | 4052 | return true; |
@@ -3952,8 +4100,13 @@ discard block |
||
| 3952 | 4100 | } else { |
| 3953 | 4101 | $validChars = $allowNewline ? "." : "[^\n]"; |
| 3954 | 4102 | } |
| 3955 | - if (!$this->match('('.$validChars.'*?)'.$this->preg_quote($what), $m, !$until)) return false; |
|
| 3956 | - if ($until) $this->count -= strlen($what); // give back $what |
|
| 4103 | + if (!$this->match('('.$validChars.'*?)'.$this->preg_quote($what), $m, !$until)) { |
|
| 4104 | + return false; |
|
| 4105 | + } |
|
| 4106 | + if ($until) { |
|
| 4107 | + $this->count -= strlen($what); |
|
| 4108 | + } |
|
| 4109 | + // give back $what |
|
| 3957 | 4110 | $out = $m[1]; |
| 3958 | 4111 | return true; |
| 3959 | 4112 | } |
@@ -4024,12 +4177,16 @@ discard block |
||
| 4024 | 4177 | |
| 4025 | 4178 | // try to match something on head of buffer |
| 4026 | 4179 | protected function match($regex, &$out, $eatWhitespace = null) { |
| 4027 | - if (!isset($eatWhitespace)) $eatWhitespace = $this->eatWhiteDefault; |
|
| 4180 | + if (!isset($eatWhitespace)) { |
|
| 4181 | + $eatWhitespace = $this->eatWhiteDefault; |
|
| 4182 | + } |
|
| 4028 | 4183 | |
| 4029 | 4184 | $r = '/'.$regex.'/Ais'; |
| 4030 | 4185 | if (preg_match($r, $this->buffer, $out, null, $this->count)) { |
| 4031 | 4186 | $this->count += strlen($out[0]); |
| 4032 | - if ($eatWhitespace) $this->whitespace(); |
|
| 4187 | + if ($eatWhitespace) { |
|
| 4188 | + $this->whitespace(); |
|
| 4189 | + } |
|
| 4033 | 4190 | return true; |
| 4034 | 4191 | } |
| 4035 | 4192 | return false; |
@@ -4052,7 +4209,9 @@ discard block |
||
| 4052 | 4209 | } |
| 4053 | 4210 | |
| 4054 | 4211 | protected function peek($regex, &$out, $from=null) { |
| 4055 | - if (!isset($from)) $from = $this->count; |
|
| 4212 | + if (!isset($from)) { |
|
| 4213 | + $from = $this->count; |
|
| 4214 | + } |
|
| 4056 | 4215 | |
| 4057 | 4216 | $r = '/'.$regex.'/Ais'; |
| 4058 | 4217 | $result = preg_match($r, $this->buffer, $out, null, $from); |
@@ -4061,8 +4220,11 @@ discard block |
||
| 4061 | 4220 | } |
| 4062 | 4221 | |
| 4063 | 4222 | protected function seek($where = null) { |
| 4064 | - if ($where === null) return $this->count; |
|
| 4065 | - else $this->count = $where; |
|
| 4223 | + if ($where === null) { |
|
| 4224 | + return $this->count; |
|
| 4225 | + } else { |
|
| 4226 | + $this->count = $where; |
|
| 4227 | + } |
|
| 4066 | 4228 | return true; |
| 4067 | 4229 | } |
| 4068 | 4230 | |
@@ -4113,7 +4275,9 @@ discard block |
||
| 4113 | 4275 | } |
| 4114 | 4276 | |
| 4115 | 4277 | protected function block($block) { |
| 4116 | - if (empty($block->lines) && empty($block->children)) return; |
|
| 4278 | + if (empty($block->lines) && empty($block->children)) { |
|
| 4279 | + return; |
|
| 4280 | + } |
|
| 4117 | 4281 | |
| 4118 | 4282 | $inner = $pre = $this->indentStr(); |
| 4119 | 4283 | |
@@ -4139,7 +4303,9 @@ discard block |
||
| 4139 | 4303 | |
| 4140 | 4304 | if (!empty($block->selectors)) { |
| 4141 | 4305 | $this->indentLevel--; |
| 4142 | - if (empty($block->children)) echo $this->break; |
|
| 4306 | + if (empty($block->children)) { |
|
| 4307 | + echo $this->break; |
|
| 4308 | + } |
|
| 4143 | 4309 | echo $pre . $this->close . $this->break; |
| 4144 | 4310 | } |
| 4145 | 4311 | } |
@@ -4215,7 +4381,9 @@ discard block |
||
| 4215 | 4381 | if (!empty($block->lines)) { |
| 4216 | 4382 | $glue = $this->break.$inner; |
| 4217 | 4383 | echo $inner . implode($glue, $block->lines); |
| 4218 | - if (!empty($block->children)) echo $this->break; |
|
| 4384 | + if (!empty($block->children)) { |
|
| 4385 | + echo $this->break; |
|
| 4386 | + } |
|
| 4219 | 4387 | } |
| 4220 | 4388 | |
| 4221 | 4389 | foreach ($block->children as $i => $child) { |
@@ -4341,17 +4509,23 @@ discard block |
||
| 4341 | 4509 | * @return boolean True if compile required. |
| 4342 | 4510 | */ |
| 4343 | 4511 | protected function needsCompile($in, $out) { |
| 4344 | - if (!is_file($out)) return true; |
|
| 4512 | + if (!is_file($out)) { |
|
| 4513 | + return true; |
|
| 4514 | + } |
|
| 4345 | 4515 | |
| 4346 | 4516 | $mtime = filemtime($out); |
| 4347 | - if (filemtime($in) > $mtime) return true; |
|
| 4517 | + if (filemtime($in) > $mtime) { |
|
| 4518 | + return true; |
|
| 4519 | + } |
|
| 4348 | 4520 | |
| 4349 | 4521 | // look for modified imports |
| 4350 | 4522 | $icache = $this->importsCacheName($out); |
| 4351 | 4523 | if (is_readable($icache)) { |
| 4352 | 4524 | $imports = unserialize(file_get_contents($icache)); |
| 4353 | 4525 | foreach ($imports as $import) { |
| 4354 | - if (filemtime($import) > $mtime) return true; |
|
| 4526 | + if (filemtime($import) > $mtime) { |
|
| 4527 | + return true; |
|
| 4528 | + } |
|
| 4355 | 4529 | } |
| 4356 | 4530 | } |
| 4357 | 4531 | return false; |
@@ -4426,7 +4600,9 @@ discard block |
||
| 4426 | 4600 | } |
| 4427 | 4601 | |
| 4428 | 4602 | $this->cacheDir = $cacheDir; |
| 4429 | - if (!is_dir($this->cacheDir)) mkdir($this->cacheDir, 0755, true); |
|
| 4603 | + if (!is_dir($this->cacheDir)) { |
|
| 4604 | + mkdir($this->cacheDir, 0755, true); |
|
| 4605 | + } |
|
| 4430 | 4606 | |
| 4431 | 4607 | if (!isset($scss)) { |
| 4432 | 4608 | $scss = new scssc(); |
@@ -696,8 +696,9 @@ discard block |
||
| 696 | 696 | |
| 697 | 697 | function sfwc_appearance_tab_content() {
|
| 698 | 698 | global $sfwc_active_tab; |
| 699 | - if ( '' || 'appearance' != $sfwc_active_tab ) |
|
| 700 | - return; |
|
| 699 | + if ( '' || 'appearance' != $sfwc_active_tab ) { |
|
| 700 | + return; |
|
| 701 | + } |
|
| 701 | 702 | ?> |
| 702 | 703 | |
| 703 | 704 | <div id="sub_accounts_settings_appearance_tab"> |
@@ -859,8 +860,9 @@ discard block |
||
| 859 | 860 | |
| 860 | 861 | global $sfwc_active_tab; |
| 861 | 862 | |
| 862 | - if ( 'options' != $sfwc_active_tab ) |
|
| 863 | - return; |
|
| 863 | + if ( 'options' != $sfwc_active_tab ) { |
|
| 864 | + return; |
|
| 865 | + } |
|
| 864 | 866 | ?> |
| 865 | 867 | |
| 866 | 868 | <div id="sub_accounts_settings_options_tab"> |
@@ -432,9 +432,11 @@ |
||
| 432 | 432 | } |
| 433 | 433 | } |
| 434 | 434 | |
| 435 | - if ( empty( $sdk_symlink ) ) // Has symlinks, therefore, we need to configure WP_FS__DIR based on the symlink. |
|
| 435 | + if ( empty( $sdk_symlink ) ) { |
|
| 436 | + // Has symlinks, therefore, we need to configure WP_FS__DIR based on the symlink. |
|
| 436 | 437 | { |
| 437 | 438 | $partial_path_right = basename( $file_path ); |
| 439 | + } |
|
| 438 | 440 | $partial_path_left = dirname( $file_path ); |
| 439 | 441 | $realpath = realpath( $plugins_or_theme_dir_path . $partial_path_right ); |
| 440 | 442 | |
@@ -953,12 +953,14 @@ |
||
| 953 | 953 | |
| 954 | 954 | $dir = "/{$module_type}";
|
| 955 | 955 | |
| 956 | - if ( ! is_dir( WP_LANG_DIR . $dir ) ) |
|
| 957 | - return array(); |
|
| 956 | + if ( ! is_dir( WP_LANG_DIR . $dir ) ) { |
|
| 957 | + return array(); |
|
| 958 | + } |
|
| 958 | 959 | |
| 959 | 960 | $files = scandir( WP_LANG_DIR . $dir ); |
| 960 | - if ( ! $files ) |
|
| 961 | - return array(); |
|
| 961 | + if ( ! $files ) { |
|
| 962 | + return array(); |
|
| 963 | + } |
|
| 962 | 964 | |
| 963 | 965 | $language_data = array(); |
| 964 | 966 | |
@@ -74,9 +74,11 @@ |
||
| 74 | 74 | return false; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - if ( ! $location ) // allows the wp_redirect filter to cancel a redirect |
|
| 77 | + if ( ! $location ) { |
|
| 78 | + // allows the wp_redirect filter to cancel a redirect |
|
| 78 | 79 | {
|
| 79 | - return false; |
|
| 80 | + return false; |
|
| 81 | + } |
|
| 80 | 82 | } |
| 81 | 83 | |
| 82 | 84 | $location = fs_sanitize_redirect( $location ); |
@@ -1272,7 +1272,8 @@ discard block |
||
| 1272 | 1272 | <?php if ( $has_annual ) : ?> |
| 1273 | 1273 | // Select annual by default. |
| 1274 | 1274 | $plan.find('.nav-tab[data-billing-cycle=annual]').click();
|
| 1275 | - <?php else : ?> |
|
| 1275 | + <?php else { |
|
| 1276 | + : ?> |
|
| 1276 | 1277 | // Select first tab. |
| 1277 | 1278 | $plan.find('.nav-tab:first').click();
|
| 1278 | 1279 | <?php endif ?> |
@@ -1315,7 +1316,9 @@ discard block |
||
| 1315 | 1316 | <ul> |
| 1316 | 1317 | <?php if ( ! empty( $api->version ) ) { ?>
|
| 1317 | 1318 | <li> |
| 1318 | - <strong><?php fs_esc_html_echo_x_inline( 'Version', 'product version', 'version', $api->slug ); ?> |
|
| 1319 | + <strong><?php fs_esc_html_echo_x_inline( 'Version', 'product version', 'version', $api->slug ); |
|
| 1320 | +} |
|
| 1321 | +?> |
|
| 1319 | 1322 | :</strong> <?php echo $api->version; ?></li> |
| 1320 | 1323 | <?php |
| 1321 | 1324 | } |
@@ -511,7 +511,8 @@ discard block |
||
| 511 | 511 | <input type="checkbox" class="fs-toggle-beta-mode" <?php checked( true, $p['value'] ) ?>/><span><?php |
| 512 | 512 | fs_esc_html_echo_inline( 'Join the Beta program', 'join-beta', $slug ) |
| 513 | 513 | ?></span></label> |
| 514 | - <?php else : ?> |
|
| 514 | + <?php else { |
|
| 515 | + : ?> |
|
| 515 | 516 | <code><?php echo htmlspecialchars( $p['value'] ) ?></code> |
| 516 | 517 | <?php endif ?> |
| 517 | 518 | <?php if ( 'email' === $p['id'] && ! $user->is_verified() ) : ?> |
@@ -549,9 +550,11 @@ discard block |
||
| 549 | 550 | 'is_localhost' => $site->is_localhost(), |
| 550 | 551 | 'install_id' => $site->id, |
| 551 | 552 | 'class' => 'button-primary', |
| 552 | - ); |
|
| 553 | + ); |
|
| 554 | +} |
|
| 553 | 555 | fs_require_template( 'account/partials/activate-license-button.php', $view_params ); ?> |
| 554 | - <?php else : ?> |
|
| 556 | + <?php else { |
|
| 557 | + : ?> |
|
| 555 | 558 | <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" |
| 556 | 559 | method="POST" class="button-group"> |
| 557 | 560 | <?php if ( $show_upgrade && $is_premium ) : ?> |
@@ -567,7 +570,9 @@ discard block |
||
| 567 | 570 | class="button<?php |
| 568 | 571 | echo $show_upgrade ? |
| 569 | 572 | ' button-primary fs-upgrade' : |
| 570 | - ' fs-change-plan'; ?> button-upgrade"><i |
|
| 573 | + ' fs-change-plan'; |
|
| 574 | +} |
|
| 575 | +?> button-upgrade"><i |
|
| 571 | 576 | class="dashicons dashicons-cart"></i> <?php echo esc_html( $show_upgrade ? $upgrade_text : $change_plan_text ) ?></a> |
| 572 | 577 | <?php endif ?> |
| 573 | 578 | </form> |