Completed
Branch 0.8-dev (af4386)
by Kacper
03:08
created
Parser/Validator/Validator.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -42,11 +42,11 @@  discard block
 block discarded – undo
42 42
 
43 43
     public function setRules($rules)
44 44
     {
45
-        if(empty($rules)) {
46
-            $this->_rules = [ 'none' => Validator::CONTEXT_IN_ONE_OF ];
45
+        if (empty($rules)) {
46
+            $this->_rules = ['none' => Validator::CONTEXT_IN_ONE_OF];
47 47
         } else {
48 48
             foreach ($rules as $key => $rule) {
49
-                list($plain, $type)     = $this->_parse($rule);
49
+                list($plain, $type) = $this->_parse($rule);
50 50
                 $this->_rules[$plain] = $type;
51 51
             }
52 52
         }
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
     private function _clean($rule, $type, &$required)
56 56
     {
57 57
         if (strpos($rule, '.') !== false) {
58
-            foreach (array_filter(array_keys($required), function ($key) use ($rule) {
58
+            foreach (array_filter(array_keys($required), function($key) use ($rule) {
59 59
                 return fnmatch($key . '.*', $rule);
60 60
             }) as $remove) {
61 61
                 unset($required[$remove]);
@@ -64,16 +64,16 @@  discard block
 block discarded – undo
64 64
     }
65 65
 
66 66
     protected function _validate($context, $rules) {
67
-        if(empty($rules)) {
67
+        if (empty($rules)) {
68 68
             return true;
69 69
         }
70 70
 
71
-        if(empty($context)) {
71
+        if (empty($context)) {
72 72
             $context = ['none'];
73 73
         }
74 74
 
75 75
         $result = false; // At least one rule must match
76
-        while(list($rule, $type) = each($rules)) {
76
+        while (list($rule, $type) = each($rules)) {
77 77
             $matched = $this->_matches($context, $rule, $type);
78 78
 
79 79
             if ($type & Validator::CONTEXT_NOT_IN) {
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 
127 127
         $rule = substr($rule, $pos);
128 128
 
129
-        if($type & self::CONTEXT_REGEX) {
129
+        if ($type & self::CONTEXT_REGEX) {
130 130
             $rule = "/^$rule(\\.\\w+)?/i";
131 131
         }
132 132
 
@@ -134,22 +134,22 @@  discard block
 block discarded – undo
134 134
     }
135 135
 
136 136
     private function _matches($context, $rule, $type) {
137
-        if($type & self::CONTEXT_EXACTLY) {
137
+        if ($type & self::CONTEXT_EXACTLY) {
138 138
             return in_array($rule, $context, true);
139
-        } elseif($type & self::CONTEXT_REGEX) {
140
-            foreach($context as $item) {
141
-                if(preg_match($rule, $item)) {
139
+        } elseif ($type & self::CONTEXT_REGEX) {
140
+            foreach ($context as $item) {
141
+                if (preg_match($rule, $item)) {
142 142
                     return true;
143 143
                 }
144 144
             }
145 145
             return false;
146 146
         } else {
147
-            if(in_array($rule, $context, true)) {
147
+            if (in_array($rule, $context, true)) {
148 148
                 return true;
149 149
             }
150 150
 
151
-            foreach($context as $item) {
152
-                if(fnmatch("$rule.*", $item)) {
151
+            foreach ($context as $item) {
152
+                if (fnmatch("$rule.*", $item)) {
153 153
                     return true;
154 154
                 }
155 155
             }
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
     {
162 162
         static $validator;
163 163
         if (!$validator) {
164
-            $validator = new DelegateValidator(function () {
164
+            $validator = new DelegateValidator(function() {
165 165
                 return true;
166 166
             });
167 167
         }
Please login to merge, or discard this patch.
Language/Css.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@
 block discarded – undo
69 69
                 new CloseRule(new SubStringMatcher(')')),
70 70
             ],
71 71
 
72
-            'keyword.at-rule' => new Rule(new RegexMatcher('/(@(?:-[a-z]+-)?(?:'.implode('|', $at).'))/'), [
72
+            'keyword.at-rule' => new Rule(new RegexMatcher('/(@(?:-[a-z]+-)?(?:' . implode('|', $at) . '))/'), [
73 73
                 'priority' => 2
74 74
             ]),
75 75
 
Please login to merge, or discard this patch.
Parser/Rules.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -107,7 +107,7 @@
 block discarded – undo
107 107
     public function all()
108 108
     {
109 109
         $items = $this->getArrayCopy();
110
-        if(empty($items)) return [];
110
+        if (empty($items)) return [];
111 111
 
112 112
         return call_user_func_array('array_merge', $items);
113 113
     }
Please login to merge, or discard this patch.
Parser/Token/ContextualToken.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@
 block discarded – undo
43 43
                 $this->_end->_valid = false;
44 44
             }
45 45
         } else {
46
-            if (!$this->rule->validator->validate($context, [$this->name => Validator::CONTEXT_IN ])) {
46
+            if (!$this->rule->validator->validate($context, [$this->name => Validator::CONTEXT_IN])) {
47 47
                 $this->setValid(false);
48 48
             } else {
49 49
                 $this->_valid       = false;
Please login to merge, or discard this patch.
Parser/Token/LanguageToken.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -58,11 +58,11 @@
 block discarded – undo
58 58
 
59 59
     public function process(array &$context, Language $language, Result $result, TokenIterator $tokens)
60 60
     {
61
-        if(!$this->isValid($language, $context)) {
61
+        if (!$this->isValid($language, $context)) {
62 62
             return true;
63 63
         }
64 64
 
65
-        if($this->isStart()) {
65
+        if ($this->isStart()) {
66 66
             $result->merge($this->getInjected()->parse($tokens));
67 67
         } else {
68 68
             $this->setStart($result[0]);
Please login to merge, or discard this patch.
Parser/Token/Token.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -197,18 +197,18 @@  discard block
 block discarded – undo
197 197
      * @return bool Continue?
198 198
      */
199 199
     public function process(array &$context, Language $language, Result $result, TokenIterator $tokens) {
200
-        if(!$this->isValid($language, $context)) {
200
+        if (!$this->isValid($language, $context)) {
201 201
             return true;
202 202
         }
203 203
 
204
-        if($this->isStart()) {
204
+        if ($this->isStart()) {
205 205
             $result->append($this);
206 206
             $context[$tokens->key()] = $this->name;
207 207
         } else {
208
-            if($this->_start) {
208
+            if ($this->_start) {
209 209
                 unset($context[spl_object_hash($this->_start)]);
210 210
             } else {
211
-                $start = ArrayHelper::find(array_reverse($context), function ($k, $v) {
211
+                $start = ArrayHelper::find(array_reverse($context), function($k, $v) {
212 212
                     return $v === $this->closedBy;
213 213
                 });
214 214
 
@@ -240,11 +240,11 @@  discard block
 block discarded – undo
240 240
                 return $multiplier;
241 241
             }
242 242
         } elseif (($rule = Helper::cmp($b->rule->priority, $a->rule->priority)) !== 0) {
243
-            return $multiplier*$rule;
243
+            return $multiplier * $rule;
244 244
         } elseif (($rule = Helper::cmp($b->index, $a->index)) !== 0) {
245
-            return $multiplier*$rule;
245
+            return $multiplier * $rule;
246 246
         } else {
247
-            return $multiplier*($a->id < $b->id ? -1 : 1);
247
+            return $multiplier * ($a->id < $b->id ? -1 : 1);
248 248
         }
249 249
     }
250 250
 }
Please login to merge, or discard this patch.
Language/Language.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
         ]);
100 100
 
101 101
         for ($tokens->next(); $tokens->valid(); $tokens->next()) {
102
-            if(!$tokens->current()->process($context, $this, $result, $tokens)) {
102
+            if (!$tokens->current()->process($context, $this, $result, $tokens)) {
103 103
                 break;
104 104
             }
105 105
         }
@@ -149,8 +149,8 @@  discard block
 block discarded – undo
149 149
     private function _rules($embedded = false)
150 150
     {
151 151
         $rules = clone $this->rules;
152
-        if(is_bool($embedded)) {
153
-            $rules->addMany(['language.'.$this->getIdentifier() => $this->getEnds($embedded)]);
152
+        if (is_bool($embedded)) {
153
+            $rules->addMany(['language.' . $this->getIdentifier() => $this->getEnds($embedded)]);
154 154
         }
155 155
 
156 156
         foreach ($rules->all() as $rule) {
Please login to merge, or discard this patch.