@@ -34,7 +34,7 @@ |
||
34 | 34 | ], $options); |
35 | 35 | |
36 | 36 | if ($options['escape']) { |
37 | - $words = array_map(function ($word) { |
|
37 | + $words = array_map(function($word) { |
|
38 | 38 | return preg_quote($word, '/'); |
39 | 39 | }, $words); |
40 | 40 | } |
@@ -119,6 +119,9 @@ discard block |
||
119 | 119 | ; |
120 | 120 | } |
121 | 121 | |
122 | + /** |
|
123 | + * @param string $source |
|
124 | + */ |
|
122 | 125 | protected function benchmark($source, Language $language, FormatterInterface $formatter, $geshi = null) |
123 | 126 | { |
124 | 127 | gc_collect_cycles(); // force garbage collector |
@@ -170,6 +173,9 @@ discard block |
||
170 | 173 | ]; |
171 | 174 | } |
172 | 175 | |
176 | + /** |
|
177 | + * @param string $source |
|
178 | + */ |
|
173 | 179 | protected function geshi($source, $language) |
174 | 180 | { |
175 | 181 | // Silence GeSHi notices |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | protected function execute(InputInterface $input, OutputInterface $output) |
34 | 34 | { |
35 | - $dir = __DIR__ . static::DIRECTORY; |
|
35 | + $dir = __DIR__.static::DIRECTORY; |
|
36 | 36 | $iterator = new \RecursiveIteratorIterator( |
37 | 37 | new \RecursiveDirectoryIterator( |
38 | 38 | $dir, |
@@ -124,17 +124,17 @@ discard block |
||
124 | 124 | gc_collect_cycles(); // force garbage collector |
125 | 125 | $memory = $this->getMemory(); |
126 | 126 | |
127 | - $tokenization = $this->_benchmark(function () use ($language, $source) { |
|
127 | + $tokenization = $this->_benchmark(function() use ($language, $source) { |
|
128 | 128 | return $language->tokenize($source); |
129 | 129 | }); |
130 | 130 | $tokens = $tokenization['result']; |
131 | 131 | |
132 | - $parsing = $this->_benchmark(function () use ($language, $tokens) { |
|
132 | + $parsing = $this->_benchmark(function() use ($language, $tokens) { |
|
133 | 133 | return $language->parse($tokens); |
134 | 134 | }); |
135 | 135 | $parsed = $tokenization['result']; |
136 | 136 | |
137 | - $formatting = $this->_benchmark(function () use ($formatter, $parsed) { |
|
137 | + $formatting = $this->_benchmark(function() use ($formatter, $parsed) { |
|
138 | 138 | return $formatter->format($parsed); |
139 | 139 | }); |
140 | 140 |
@@ -98,6 +98,9 @@ |
||
98 | 98 | || $input->hasParameterOption('-r'); |
99 | 99 | } |
100 | 100 | |
101 | + /** |
|
102 | + * @param string $filename |
|
103 | + */ |
|
101 | 104 | private function regenerate(InputInterface $input, $filename) |
102 | 105 | { |
103 | 106 | $filename = str_replace(DIRECTORY_SEPARATOR, '/', $filename); |
@@ -39,8 +39,8 @@ discard block |
||
39 | 39 | $this->_keylighter = KeyLighter::get(); |
40 | 40 | $this->_formatter = new TestFormatter(); |
41 | 41 | |
42 | - $this->_input = realpath(__DIR__ . '/../../../Tests/Samples'); |
|
43 | - $this->_output = realpath(__DIR__ . '/../../../Tests/Expected/Test'); |
|
42 | + $this->_input = realpath(__DIR__.'/../../../Tests/Samples'); |
|
43 | + $this->_output = realpath(__DIR__.'/../../../Tests/Expected/Test'); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | protected function execute(InputInterface $input, OutputInterface $output) |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | if ($this->review($input, $output, $tokens, $reviewer)) { |
71 | 71 | $result = StringHelper::normalize($this->_formatter->format($tokens)); |
72 | 72 | |
73 | - if (!file_exists($this->_output . '/' . dirname($pathname))) { |
|
74 | - mkdir($this->_output . '/' . dirname($pathname), 0755, true); |
|
73 | + if (!file_exists($this->_output.'/'.dirname($pathname))) { |
|
74 | + mkdir($this->_output.'/'.dirname($pathname), 0755, true); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | file_put_contents("{$this->_output}/$pathname.tkn", $result); |
@@ -43,6 +43,9 @@ discard block |
||
43 | 43 | return $result . ($this->_options['lines']['enable'] ? $this->formatLineEnd($this->_line++) : ''); |
44 | 44 | } |
45 | 45 | |
46 | + /** |
|
47 | + * @param string $text |
|
48 | + */ |
|
46 | 49 | private function _content($text) |
47 | 50 | { |
48 | 51 | $content = $this->content($text); |
@@ -57,11 +60,17 @@ discard block |
||
57 | 60 | return $text; |
58 | 61 | } |
59 | 62 | |
63 | + /** |
|
64 | + * @param integer $line |
|
65 | + */ |
|
60 | 66 | protected function formatLineStart($line) |
61 | 67 | { |
62 | 68 | return null; |
63 | 69 | } |
64 | 70 | |
71 | + /** |
|
72 | + * @param integer $line |
|
73 | + */ |
|
65 | 74 | protected function formatLineEnd($line) |
66 | 75 | { |
67 | 76 | return null; |
@@ -40,15 +40,15 @@ |
||
40 | 40 | } |
41 | 41 | $result .= $this->_content(substr($source, $last)); |
42 | 42 | |
43 | - return $result . ($this->_options['lines']['enable'] ? $this->formatLineEnd($this->_line++) : ''); |
|
43 | + return $result.($this->_options['lines']['enable'] ? $this->formatLineEnd($this->_line++) : ''); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | private function _content($text) |
47 | 47 | { |
48 | 48 | $content = $this->content($text); |
49 | 49 | |
50 | - return $this->_options['lines']['enable'] ? preg_replace_callback('/\R/u', function ($feed) { |
|
51 | - return $this->formatLineEnd($this->_line++) . $feed[0] . $this->formatLineStart($this->_line); |
|
50 | + return $this->_options['lines']['enable'] ? preg_replace_callback('/\R/u', function($feed) { |
|
51 | + return $this->formatLineEnd($this->_line++).$feed[0].$this->formatLineStart($this->_line); |
|
52 | 52 | }, $content) : $content; |
53 | 53 | } |
54 | 54 |
@@ -60,7 +60,7 @@ |
||
60 | 60 | return sprintf( |
61 | 61 | '<%s class="%s">', |
62 | 62 | $this->_tag, |
63 | - $this->_prefix . str_replace('.', " {$this->_prefix}", $token->name) |
|
63 | + $this->_prefix.str_replace('.', " {$this->_prefix}", $token->name) |
|
64 | 64 | ); |
65 | 65 | } |
66 | 66 |
@@ -37,7 +37,7 @@ |
||
37 | 37 | public function __construct(array $options = []) |
38 | 38 | { |
39 | 39 | parent::__construct(array_replace_recursive([ |
40 | - 'styles' => include __DIR__ . '/../Styles/Cli/Default.php' |
|
40 | + 'styles' => include __DIR__.'/../Styles/Cli/Default.php' |
|
41 | 41 | ], $options)); |
42 | 42 | |
43 | 43 | $this->_styles = $this->_options['styles']; |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | public function __construct(array $options = []) |
37 | 37 | { |
38 | 38 | parent::__construct(array_replace_recursive([ |
39 | - 'styles' => include __DIR__ . '/../Styles/Cli/Default.php' |
|
39 | + 'styles' => include __DIR__.'/../Styles/Cli/Default.php' |
|
40 | 40 | ], $options)); |
41 | 41 | |
42 | 42 | $this->_styles = $this->_options['styles']; |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | |
45 | 45 | public function format(Tokens $tokens) |
46 | 46 | { |
47 | - return parent::format($tokens) . Console::reset(); |
|
47 | + return parent::format($tokens).Console::reset(); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | protected function token(Token $token) |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | |
63 | 63 | protected function formatLineStart($line) |
64 | 64 | { |
65 | - return str_pad($line, 5, ' ', STR_PAD_LEFT) . ' | ' . Console::set(Console::current()); |
|
65 | + return str_pad($line, 5, ' ', STR_PAD_LEFT).' | '.Console::set(Console::current()); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | protected function formatLineEnd($line) |
@@ -44,17 +44,17 @@ |
||
44 | 44 | ]), |
45 | 45 | |
46 | 46 | 'variable' => [ |
47 | - new Rule(new RegexMatcher('/(?<!`)(\$' . $namespace . '[a-z_]\w*)/i', $namespaceGroup), [ |
|
47 | + new Rule(new RegexMatcher('/(?<!`)(\$'.$namespace.'[a-z_]\w*)/i', $namespaceGroup), [ |
|
48 | 48 | 'context' => $variableRules, |
49 | 49 | 'priority' => 0, |
50 | 50 | ]), |
51 | - new Rule(new RegexMatcher('/[^`](\$\{' . $namespace . '.*?\})/i', $namespaceGroup), [ |
|
51 | + new Rule(new RegexMatcher('/[^`](\$\{'.$namespace.'.*?\})/i', $namespaceGroup), [ |
|
52 | 52 | 'context' => $variableRules, |
53 | 53 | 'priority' => 0, |
54 | 54 | ]), |
55 | 55 | ], |
56 | 56 | |
57 | - 'variable.splat' => new Rule(new RegexMatcher('/[^`](\@' . $namespace . '[a-z_]\w*)/i', $namespaceGroup), [ |
|
57 | + 'variable.splat' => new Rule(new RegexMatcher('/[^`](\@'.$namespace.'[a-z_]\w*)/i', $namespaceGroup), [ |
|
58 | 58 | 'context' => $variableRules, |
59 | 59 | 'priority' => 0, |
60 | 60 | ]), |
@@ -43,8 +43,8 @@ |
||
43 | 43 | ])), |
44 | 44 | ], |
45 | 45 | 'diff' => [ |
46 | - 'add' => new Rule(new RegexMatcher('/(?:^\+.*?(?>\R|$))+/mi', [ 0 => Token::NAME ])), |
|
47 | - 'remove' => new Rule(new RegexMatcher('/(?:^-.*?(?>\R|$))+/mi', [ 0 => Token::NAME ])), |
|
46 | + 'add' => new Rule(new RegexMatcher('/(?:^\+.*?(?>\R|$))+/mi', [0 => Token::NAME])), |
|
47 | + 'remove' => new Rule(new RegexMatcher('/(?:^-.*?(?>\R|$))+/mi', [0 => Token::NAME])), |
|
48 | 48 | ], |
49 | 49 | ]); |
50 | 50 | } |