@@ -33,9 +33,13 @@ discard block |
||
| 33 | 33 | $rules = $this->writeRule($rules, $newRules); |
| 34 | 34 | } |
| 35 | 35 | //there may be processing instructions at the end |
| 36 | - if ($processing = $this->processingInstructions($this->tss, $pos, strlen($this->tss), count($rules)+$indexStart)) $rules = array_merge($rules, $processing['rules']); |
|
| 36 | + if ($processing = $this->processingInstructions($this->tss, $pos, strlen($this->tss), count($rules)+$indexStart)) { |
|
| 37 | + $rules = array_merge($rules, $processing['rules']); |
|
| 38 | + } |
|
| 37 | 39 | usort($rules, [$this, 'sortRules']); |
| 38 | - if (empty($rules)) throw new \Exception("No TSS rules parsed"); |
|
| 40 | + if (empty($rules)) { |
|
| 41 | + throw new \Exception("No TSS rules parsed"); |
|
| 42 | + } |
|
| 39 | 43 | return $rules; |
| 40 | 44 | } |
| 41 | 45 | |
@@ -70,8 +74,7 @@ discard block |
||
| 70 | 74 | $pos = strpos($tss, ';', $spacePos); |
| 71 | 75 | $args = substr($tss, $spacePos+1, $pos-$spacePos-1); |
| 72 | 76 | $rules = array_merge($rules, $this->$funcName($args, $indexStart)); |
| 73 | - } |
|
| 74 | - else { |
|
| 77 | + } else { |
|
| 75 | 78 | break; |
| 76 | 79 | } |
| 77 | 80 | } |
@@ -87,7 +90,9 @@ discard block |
||
| 87 | 90 | |
| 88 | 91 | private function sortRules($a, $b) { |
| 89 | 92 | //If they have the same depth, compare on index |
| 90 | - if ($a->depth === $b->depth) return $a->index < $b->index ? -1 : 1; |
|
| 93 | + if ($a->depth === $b->depth) { |
|
| 94 | + return $a->index < $b->index ? -1 : 1; |
|
| 95 | + } |
|
| 91 | 96 | |
| 92 | 97 | return ($a->depth < $b->depth) ? -1 : 1; |
| 93 | 98 | } |
@@ -96,7 +101,9 @@ discard block |
||
| 96 | 101 | $pos = 0; |
| 97 | 102 | while (($pos = strpos($str, $open, $pos)) !== false) { |
| 98 | 103 | $end = strpos($str, $close, $pos); |
| 99 | - if ($end === false) break; |
|
| 104 | + if ($end === false) { |
|
| 105 | + break; |
|
| 106 | + } |
|
| 100 | 107 | $str = substr_replace($str, '', $pos, $end-$pos+2); |
| 101 | 108 | } |
| 102 | 109 | |
@@ -109,7 +116,9 @@ discard block |
||
| 109 | 116 | $return = []; |
| 110 | 117 | |
| 111 | 118 | foreach ($rules as $rule) { |
| 112 | - if (trim($rule) === '') continue; |
|
| 119 | + if (trim($rule) === '') { |
|
| 120 | + continue; |
|
| 121 | + } |
|
| 113 | 122 | $parts = explode(':', $rule, 2); |
| 114 | 123 | |
| 115 | 124 | $parts[1] = $stringExtractor->rebuild($parts[1]); |