Completed
Push — master ( 377317...d33e5b )
by Kacper
08:14
created
bin/Commands/Dev/GenerateTableCommand.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -26,10 +26,10 @@  discard block
 block discarded – undo
26 26
 {
27 27
     protected function execute(InputInterface $input, OutputInterface $output)
28 28
     {
29
-        if($input->getOption('dry')) {
29
+        if ($input->getOption('dry')) {
30 30
             $output->writeln($this->generate());
31 31
         } else {
32
-            $path = __DIR__ . '/../../../Docs/languages.md';
32
+            $path = __DIR__.'/../../../Docs/languages.md';
33 33
 
34 34
             $output->writeln("<info>Opening file ./Docs/languages.md ...</info>", OutputInterface::VERBOSITY_VERBOSE);
35 35
             $content = file_get_contents($path);
@@ -54,19 +54,19 @@  discard block
 block discarded – undo
54 54
     protected function generate()
55 55
     {
56 56
         $result = [];
57
-        foreach(['name', 'mime', 'extension'] as $what) {
58
-            foreach(KeyLighter::get()->registeredLanguages($what, true) as $name => $class) {
57
+        foreach (['name', 'mime', 'extension'] as $what) {
58
+            foreach (KeyLighter::get()->registeredLanguages($what, true) as $name => $class) {
59 59
                 $result[$class][$what][] = $name;
60 60
             }
61 61
         }
62 62
 
63
-        $return  =  'Class | Name | MIME | Extension'.PHP_EOL;
64
-        $return .=  '------|------|------|----------'.PHP_EOL;
65
-        foreach($result as $class => $aliases) {
63
+        $return  = 'Class | Name | MIME | Extension'.PHP_EOL;
64
+        $return .= '------|------|------|----------'.PHP_EOL;
65
+        foreach ($result as $class => $aliases) {
66 66
             $return .= '`'.$class.'` | ';
67 67
             $return .= (isset($aliases['name']) ? '`'.implode('`, `', $aliases['name']).'`' : 'none').' | ';
68 68
             $return .= (isset($aliases['mime']) ? '`'.implode('`, `', $aliases['mime']).'`' : 'none').' | ';
69
-            $return .= (isset($aliases['extension']) ? '`'.implode('`, `', $aliases['extension']).'`' : 'none'). PHP_EOL;
69
+            $return .= (isset($aliases['extension']) ? '`'.implode('`, `', $aliases['extension']).'`' : 'none').PHP_EOL;
70 70
         }
71 71
 
72 72
         return $return;
Please login to merge, or discard this patch.
bin/Commands/Dev/GenerateMetadataCommand.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -26,11 +26,11 @@  discard block
 block discarded – undo
26 26
 {
27 27
     protected function execute(InputInterface $input, OutputInterface $output)
28 28
     {
29
-        if($input->getOption('dry')) {
29
+        if ($input->getOption('dry')) {
30 30
             $output->writeln($this->generate($output));
31 31
         } else {
32 32
             file_put_contents(
33
-                __DIR__ . '/../../../Config/metadata.php',
33
+                __DIR__.'/../../../Config/metadata.php',
34 34
                 '<?php return '.$this->generate($output).';'
35 35
             );
36 36
         }
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 
48 48
     protected function generate(OutputInterface $output)
49 49
     {
50
-        $dir = __DIR__ . '/../../../Language'.DIRECTORY_SEPARATOR;
50
+        $dir = __DIR__.'/../../../Language'.DIRECTORY_SEPARATOR;
51 51
         $iterator = new \RecursiveIteratorIterator(
52 52
             new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS),
53 53
             \RecursiveIteratorIterator::LEAVES_ONLY
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
             ), OutputInterface::VERBOSITY_VERBOSE);
66 66
 
67 67
 
68
-            if($metadata = $this->process($output, $class)) {
68
+            if ($metadata = $this->process($output, $class)) {
69 69
                 $result[] = $metadata;
70 70
             }
71 71
         }
Please login to merge, or discard this patch.
KeyLighter.php 1 patch
Spacing   +8 added lines, -10 removed lines patch added patch discarded remove patch
@@ -70,21 +70,19 @@  discard block
 block discarded – undo
70 70
     public function languageByName($name, $params = [])
71 71
     {
72 72
         return isset($this->_languages['name'][$name]) ?
73
-            $this->_languages['name'][$name]($params) :
74
-            new PlainText($params);
73
+            $this->_languages['name'][$name]($params) : new PlainText($params);
75 74
     }
76 75
 
77 76
     public function languageByMime($mime, $params = [])
78 77
     {
79 78
         return isset($this->_languages['mime'][$mime]) ?
80
-            $this->_languages['mime'][$mime]($params) :
81
-            new PlainText($params);
79
+            $this->_languages['mime'][$mime]($params) : new PlainText($params);
82 80
     }
83 81
 
84 82
     public function languageByExt($filename, $params = [])
85 83
     {
86
-        foreach($this->_languages['extension'] as $mask => $class) {
87
-            if(fnmatch($mask, $filename)) {
84
+        foreach ($this->_languages['extension'] as $mask => $class) {
85
+            if (fnmatch($mask, $filename)) {
88 86
                 return $class($params);
89 87
             }
90 88
         }
@@ -110,7 +108,7 @@  discard block
 block discarded – undo
110 108
 
111 109
     public function registeredLanguages($by = 'name', $class = false)
112 110
     {
113
-        return array_map(function ($e) use($class) {
111
+        return array_map(function($e) use($class) {
114 112
             return $e([])->getFQN($class);
115 113
         }, $this->_languages[$by]);
116 114
     }
@@ -150,7 +148,7 @@  discard block
 block discarded – undo
150 148
 
151 149
     public function init()
152 150
     {
153
-        foreach(include __DIR__.'/Config/metadata.php' as $alias) {
151
+        foreach (include __DIR__.'/Config/metadata.php' as $alias) {
154 152
             $class = $alias[0];
155 153
             unset($alias[0]);
156 154
 
@@ -166,13 +164,13 @@  discard block
 block discarded – undo
166 164
      */
167 165
     public function register($class, array $options)
168 166
     {
169
-        if(!is_callable($class) && is_subclass_of($class, Language::class)) {
167
+        if (!is_callable($class) && is_subclass_of($class, Language::class)) {
170 168
             $class = function($arguments = []) use ($class) {
171 169
                 return new $class($arguments);
172 170
             };
173 171
         }
174 172
 
175
-        foreach(array_intersect_key($options, array_flip(['name', 'mime', 'extension'])) as $name => $values) {
173
+        foreach (array_intersect_key($options, array_flip(['name', 'mime', 'extension'])) as $name => $values) {
176 174
             $this->_languages[$name] = array_merge($this->_languages[$name], array_fill_keys($values, $class));
177 175
         }
178 176
     }
Please login to merge, or discard this patch.
Language/Xml.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -36,14 +36,14 @@
 block discarded – undo
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']]),
Please login to merge, or discard this patch.
Parser/Validator/Validator.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
Parser/Token/TerminatorToken.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@
 block discarded – undo
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]);
Please login to merge, or discard this patch.
Utils/ArrayHelper.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,14 +19,14 @@
 block discarded – undo
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)
Please login to merge, or discard this patch.
Language/Http.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -54,8 +54,8 @@
 block discarded – undo
54 54
         $split = preg_split('/\R\R/', $source, 2);
55 55
 
56 56
         $http = $split[0];
57
-        if(isset($split[1]) && $payload = $split[1]) {
58
-            if(preg_match('/Content-Type: ([^;]*)/', $http, $matches)) {
57
+        if (isset($split[1]) && $payload = $split[1]) {
58
+            if (preg_match('/Content-Type: ([^;]*)/', $http, $matches)) {
59 59
                 $mime = $matches[1];
60 60
             } else {
61 61
                 $mime = 'text/plain';
Please login to merge, or discard this patch.
Language/JavaScript.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
             ])
Please login to merge, or discard this patch.