@@ -36,14 +36,14 @@ |
||
36 | 36 | new OpenRule(new RegexMatcher('/(<[\w\.-]+)[:\/>:\s]/')), |
37 | 37 | new CloseRule(new SubStringMatcher('>'), ['context' => ['!string', '!comment']]) |
38 | 38 | ], |
39 | - 'tag.close' => new Rule(new RegexMatcher('/(<\/' . self::IDENTIFIER . '>)/')), |
|
39 | + 'tag.close' => new Rule(new RegexMatcher('/(<\/'.self::IDENTIFIER.'>)/')), |
|
40 | 40 | |
41 | - 'symbol.tag' => new Rule(new RegexMatcher('/<\\/?' . self::IDENTIFIER . '/', [ |
|
41 | + 'symbol.tag' => new Rule(new RegexMatcher('/<\\/?'.self::IDENTIFIER.'/', [ |
|
42 | 42 | 'name' => Token::NAME, |
43 | 43 | 'namespace' => '$.namespace' |
44 | 44 | ]), ['context' => ['tag', '!string']]), |
45 | 45 | |
46 | - 'symbol.attribute' => new Rule(new RegexMatcher('/' . self::IDENTIFIER . '=/', [ |
|
46 | + 'symbol.attribute' => new Rule(new RegexMatcher('/'.self::IDENTIFIER.'=/', [ |
|
47 | 47 | 'name' => Token::NAME, |
48 | 48 | 'namespace' => '$.namespace' |
49 | 49 | ]), ['context' => ['tag', '!string']]), |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | |
45 | 45 | public function setRules($rules) |
46 | 46 | { |
47 | - if(empty($rules)) { |
|
48 | - $this->_rules = [ 'none' => Validator::CONTEXT_IN_ONE_OF ]; |
|
47 | + if (empty($rules)) { |
|
48 | + $this->_rules = ['none' => Validator::CONTEXT_IN_ONE_OF]; |
|
49 | 49 | } else { |
50 | 50 | foreach ($rules as $key => $rule) { |
51 | 51 | list($plain, $type) = $this->_parse($rule); |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | private function _clean($rule, &$required) |
58 | 58 | { |
59 | 59 | if (strpos($rule, '.') !== false) { |
60 | - foreach (array_filter(array_keys($required), function ($key) use ($rule) { |
|
61 | - return fnmatch($key . '.*', $rule); |
|
60 | + foreach (array_filter(array_keys($required), function($key) use ($rule) { |
|
61 | + return fnmatch($key.'.*', $rule); |
|
62 | 62 | }) as $remove) { |
63 | 63 | unset($required[$remove]); |
64 | 64 | } |
@@ -66,11 +66,11 @@ discard block |
||
66 | 66 | } |
67 | 67 | |
68 | 68 | protected function _validate($context, $rules, $result = false) { |
69 | - if(empty($context)) { |
|
69 | + if (empty($context)) { |
|
70 | 70 | $context = ['none']; |
71 | 71 | } |
72 | 72 | |
73 | - foreach($rules as $rule => &$type) { |
|
73 | + foreach ($rules as $rule => &$type) { |
|
74 | 74 | $matched = $this->_matches($context, $rule, $type); |
75 | 75 | |
76 | 76 | if ($type & Validator::CONTEXT_NOT_IN) { |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | |
124 | 124 | $rule = substr($rule, $pos); |
125 | 125 | |
126 | - if($type & self::CONTEXT_REGEX) { |
|
126 | + if ($type & self::CONTEXT_REGEX) { |
|
127 | 127 | $rule = "/^$rule(\\.\\w+)?/i"; |
128 | 128 | } |
129 | 129 | |
@@ -131,22 +131,22 @@ discard block |
||
131 | 131 | } |
132 | 132 | |
133 | 133 | private function _matches($context, $rule, $type) { |
134 | - if($type & self::CONTEXT_EXACTLY) { |
|
134 | + if ($type & self::CONTEXT_EXACTLY) { |
|
135 | 135 | return in_array($rule, $context, true); |
136 | - } elseif($type & self::CONTEXT_REGEX) { |
|
137 | - foreach($context as $item) { |
|
138 | - if(preg_match($rule, $item)) { |
|
136 | + } elseif ($type & self::CONTEXT_REGEX) { |
|
137 | + foreach ($context as $item) { |
|
138 | + if (preg_match($rule, $item)) { |
|
139 | 139 | return true; |
140 | 140 | } |
141 | 141 | } |
142 | 142 | return false; |
143 | 143 | } else { |
144 | - if(in_array($rule, $context, true)) { |
|
144 | + if (in_array($rule, $context, true)) { |
|
145 | 145 | return true; |
146 | 146 | } |
147 | 147 | |
148 | - foreach($context as $item) { |
|
149 | - if(fnmatch("$rule.*", $item)) { |
|
148 | + foreach ($context as $item) { |
|
149 | + if (fnmatch("$rule.*", $item)) { |
|
150 | 150 | return true; |
151 | 151 | } |
152 | 152 | } |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | { |
159 | 159 | static $validator; |
160 | 160 | if (!$validator) { |
161 | - $validator = new DelegateValidator(function () { |
|
161 | + $validator = new DelegateValidator(function() { |
|
162 | 162 | return true; |
163 | 163 | }); |
164 | 164 | } |
@@ -45,7 +45,7 @@ |
||
45 | 45 | |
46 | 46 | protected function processEnd(Context $context, Language $language, Result $result, TokenIterator $tokens) |
47 | 47 | { |
48 | - foreach(array_filter($context->stack, function ($name) { |
|
48 | + foreach (array_filter($context->stack, function($name) { |
|
49 | 49 | return in_array($name, $this->closes); |
50 | 50 | }) as $hash => $name) { |
51 | 51 | $end = new Token($name, ['pos' => $this->pos]); |
@@ -19,14 +19,14 @@ |
||
19 | 19 | { |
20 | 20 | public static function rearrange(array $array, array $keys) |
21 | 21 | { |
22 | - return array_combine($keys, array_map(function ($key) use ($array) { |
|
22 | + return array_combine($keys, array_map(function($key) use ($array) { |
|
23 | 23 | return $array[$key]; |
24 | 24 | }, $keys)); |
25 | 25 | } |
26 | 26 | |
27 | 27 | public static function column(array $array, $index) |
28 | 28 | { |
29 | - return array_map(function ($e) use ($index) { return $e[$index]; }, $array); |
|
29 | + return array_map(function($e) use ($index) { return $e[$index]; }, $array); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | public static function find(array $array, callable $tester) |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | |
62 | 62 | 'comment' => new Rule(new CommentMatcher(['//'], [['/*', '*/']]), ['priority' => 3]), |
63 | 63 | |
64 | - 'call' => new Rule(new RegexMatcher('/(' . self::IDENTIFIER . ')\s*\(/iu'), ['priority' => -1]), |
|
64 | + 'call' => new Rule(new RegexMatcher('/('.self::IDENTIFIER.')\s*\(/iu'), ['priority' => -1]), |
|
65 | 65 | |
66 | 66 | 'keyword' => new Rule(new WordMatcher([ |
67 | 67 | 'do', 'if', 'in', 'for', 'let', 'new', 'try', 'var', 'case', 'else', 'enum', 'eval', |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | ]) |
91 | 91 | ], |
92 | 92 | |
93 | - 'variable' => new Rule(new RegexMatcher('/\b(?<!\.)(' . self::IDENTIFIER . ':?)/iu'), [ |
|
93 | + 'variable' => new Rule(new RegexMatcher('/\b(?<!\.)('.self::IDENTIFIER.':?)/iu'), [ |
|
94 | 94 | 'priority' => -1, |
95 | 95 | 'enabled' => $this->variables |
96 | 96 | ]) |
@@ -61,7 +61,7 @@ |
||
61 | 61 | 'string.nowdoc' => new Rule( |
62 | 62 | new RegexMatcher('/<<\s*\'(\w+)\';(?P<string>.*?)\R\1/sm', [ |
63 | 63 | 'string' => Token::NAME, |
64 | - 0 => 'keyword.nowdoc' |
|
64 | + 0 => 'keyword.nowdoc' |
|
65 | 65 | ]), ['context' => ['!comment']] |
66 | 66 | ), |
67 | 67 |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | public function __construct(array $singleLine = null, array $multiLine = null) |
32 | 32 | { |
33 | 33 | $this->singleLine = $singleLine ?: []; |
34 | - $this->multiLine = $multiLine ?: []; |
|
34 | + $this->multiLine = $multiLine ?: []; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | $all = []; |
50 | 50 | |
51 | 51 | foreach ($this->multiLine as $name => $comment) { |
52 | - $comment = array_map(function ($e) { return preg_quote($e, '/'); }, $comment); |
|
52 | + $comment = array_map(function($e) { return preg_quote($e, '/'); }, $comment); |
|
53 | 53 | |
54 | 54 | $all[] = [$name, "/({$comment[0]}(.*?){$comment[1]})/ms"]; |
55 | 55 | } |
@@ -51,7 +51,7 @@ |
||
51 | 51 | new Rule(new RegexMatcher('/(\$\w+)/i'), ['context' => ['*none', '*string.double']]), |
52 | 52 | 'special' => new Rule(new RegexMatcher('/(\$[#@_])/i'), ['context' => ['*none', '*string.double']]), |
53 | 53 | 'argument' => new Rule(new RegexMatcher('/(\$\d+)/i'), ['context' => ['*none', '*string.double']]), |
54 | - new Rule(new RegexMatcher('/\$\{(\w+)(.*?)\}/i', [ 1 => Token::NAME, 2 => 'string' ]), ['context' => ['*none', '*string.double']]) |
|
54 | + new Rule(new RegexMatcher('/\$\{(\w+)(.*?)\}/i', [1 => Token::NAME, 2 => 'string']), ['context' => ['*none', '*string.double']]) |
|
55 | 55 | ], |
56 | 56 | |
57 | 57 | 'number' => new Rule(new RegexMatcher('/(-?(?:0[0-7]+|0[xX][0-9a-fA-F]+|0b[01]+|\d+))/')), |
@@ -26,7 +26,7 @@ |
||
26 | 26 | htmlspecialchars(substr($source, $last, $token->pos - $last)) |
27 | 27 | ); |
28 | 28 | |
29 | - if($token->isStart()) { |
|
29 | + if ($token->isStart()) { |
|
30 | 30 | $result .= $stack[] = $this->getOpenTag($token); |
31 | 31 | } else { |
32 | 32 | array_pop($stack); |