| Conditions | 1 | 
| Paths | 1 | 
| Total Lines | 85 | 
| Code Lines | 57 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 1 | ||
| Bugs | 0 | Features | 0 | 
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php  | 
            ||
| 32 | public function getRules()  | 
            ||
| 33 |     { | 
            ||
| 34 | return [  | 
            ||
| 35 |             'string.single' => new Rule(new SubStringMatcher('\''), [ | 
            ||
| 36 | 'context' => ['!keyword.escape', '!comment', '!string', '!keyword.nowdoc'],  | 
            ||
| 37 | 'factory' => new TokenFactory(ContextualToken::class),  | 
            ||
| 38 | ]),  | 
            ||
| 39 | |||
| 40 |             'string.double' => new Rule(new SubStringMatcher('"'), [ | 
            ||
| 41 | 'context' => ['!keyword.escape', '!comment', '!string'],  | 
            ||
| 42 | 'factory' => new TokenFactory(ContextualToken::class),  | 
            ||
| 43 | ]),  | 
            ||
| 44 | |||
| 45 |             'string.heredoc' => new Rule(new RegexMatcher('/<<<\s*(\w+)(?P<string>.*?)\n\1;/sm', ['string' => Token::NAME, 0 => 'keyword.heredoc']), ['context' => ['!comment']]), | 
            ||
| 46 |             'string.nowdoc' => new Rule(new RegexMatcher('/<<<\s*\'(\w+)\'(?P<string>.*?)\n\1;/sm', ['string' => Token::NAME, 0 => 'keyword.nowdoc']), ['context' => ['!comment']]), | 
            ||
| 47 | |||
| 48 |             'variable' => new Rule(new RegexMatcher('/[^\\\](\$[a-z_]\w*)/i'), [ | 
            ||
| 49 | 'context' => ['*comment.docblock', '!string.nowdoc', '!string.single', '!comment']  | 
            ||
| 50 | ]),  | 
            ||
| 51 |             'variable.property' => new Rule(new RegexMatcher('/(?=(?:\w|\)|\])\s*->([a-z_]\w*))/i'), [ | 
            ||
| 52 | 'priority' => -2  | 
            ||
| 53 | ]),  | 
            ||
| 54 | |||
| 55 |             'symbol.function' => new Rule(new RegexMatcher('/function\s+([a-z_]\w+)\s*\(/i')), | 
            ||
| 56 | 'symbol.class' => [  | 
            ||
| 57 |                 new Rule(new RegexMatcher('/(?:class|new|use|extends)\s+([\w\\\]+)/i')), | 
            ||
| 58 |                 new Rule(new RegexMatcher('/([\w\\\]+)::/i')), | 
            ||
| 59 |                 new Rule(new RegexMatcher('/@(?:var|property(?:-read|-write)?)\s+([^\$][\w\\\]+)/i'), ['context' => ['comment.docblock']]), | 
            ||
| 60 | ],  | 
            ||
| 61 | |||
| 62 | 'symbol.class.interface' => [  | 
            ||
| 63 |                 new Rule(new RegexMatcher('/interface\s+([\w\\\]+)/i')), | 
            ||
| 64 |                 new Rule(new RegexMatcher('/implements\s+([\w\\\]+)(?:,\s*([\w\\\]+))*/i'), [ | 
            ||
| 65 | 1 => Token::NAME,  | 
            ||
| 66 | 2 => Token::NAME  | 
            ||
| 67 | ]),  | 
            ||
| 68 | ],  | 
            ||
| 69 | |||
| 70 |             'keyword.escape' => new Rule(new RegexMatcher('/(\\\(?:x[0-9a-fA-F]{1,2}|u\{[0-9a-fA-F]{1,6}\}|[0-7]{1,3}|.))/i'), [ | 
            ||
| 71 | 'context' => ['string']  | 
            ||
| 72 | ]),  | 
            ||
| 73 | |||
| 74 | 'comment' => new Rule(new CommentMatcher(['//', '#'], [  | 
            ||
| 75 | '$.docblock' => ['/**', '*/'],  | 
            ||
| 76 | ['/* ', '*/']  | 
            ||
| 77 | ])),  | 
            ||
| 78 | |||
| 79 |             'keyword.annotation' => new Rule(new RegexMatcher('/[\s]+(@[\w-]+)/i'), [ | 
            ||
| 80 | 'context' => ['comment.docblock']  | 
            ||
| 81 | ]),  | 
            ||
| 82 | |||
| 83 |             'call' => new Rule(new RegexMatcher('/([a-z_]\w*)\s*\(/i'), ['priority' => -1]), | 
            ||
| 84 | |||
| 85 | 'constant' => new Rule(new WordMatcher(array_merge([  | 
            ||
| 86 | '__CLASS__', '__DIR__', '__FILE__', '__FUNCTION__',  | 
            ||
| 87 | '__LINE__', '__METHOD__', '__NAMESPACE__', '__TRAIT__',  | 
            ||
| 88 | ], array_keys(get_defined_constants(true)["Core"]))), ['priority' => -2]),  | 
            ||
| 89 |             'constant.static' => new Rule(new RegexMatcher('/(?:[\w\\\]+::|const\s+)(\w+)/i'), ['priority' => -2]   ), | 
            ||
| 90 | |||
| 91 | 'keyword' => new Rule(new WordMatcher([  | 
            ||
| 92 | '__halt_compiler', 'abstract', 'and', 'array',  | 
            ||
| 93 | 'as', 'break', 'callable', 'case', 'catch',  | 
            ||
| 94 | 'class', 'clone', 'const', 'continue', 'declare',  | 
            ||
| 95 | 'default', 'die', 'do', 'echo', 'else', 'elseif',  | 
            ||
| 96 | 'empty', 'enddeclare', 'endfor', 'endforeach', 'endif',  | 
            ||
| 97 | 'endswitch', 'endwhile', 'eval', 'exit', 'extends',  | 
            ||
| 98 | 'final', 'finally', 'for', 'foreach', 'function',  | 
            ||
| 99 | 'global', 'goto', 'if', 'implements', 'include', 'include_once',  | 
            ||
| 100 | 'instanceof', 'insteadof', 'interface', 'isset', 'list',  | 
            ||
| 101 | 'namespace', 'new', 'or', 'print', 'private', 'protected',  | 
            ||
| 102 | 'public', 'require', 'require_once', 'return', 'static',  | 
            ||
| 103 | 'switch', 'throw', 'trait', 'try', 'unset', 'parent', 'self',  | 
            ||
| 104 | 'use', 'var', 'while', 'xor', 'yield'  | 
            ||
| 105 | ]), ['context' => ['!string', '!variable', '!comment']]),  | 
            ||
| 106 | |||
| 107 | 'keyword.cast' => new Rule(  | 
            ||
| 108 |                 new RegexMatcher('/(\((?:int|integer|bool|boolean|float|double|real|string|array|object|unset)\))/') | 
            ||
| 109 | ),  | 
            ||
| 110 | |||
| 111 |             'delimiter' => new Rule(new RegexMatcher('/(<\?php|<\?=|\?>)/')), | 
            ||
| 112 |             'number' => new Rule(new RegexMatcher('/(-?(?:0[0-7]+|0[xX][0-9a-fA-F]+|0b[01]+|\d+))/')), | 
            ||
| 113 | |||
| 114 | 'operator.punctuation' => new Rule(new WordMatcher([',', ';'], ['separated' => false]), ['priority' => 0]),  | 
            ||
| 115 | ];  | 
            ||
| 116 | }  | 
            ||
| 117 | |||
| 140 | }  |