Conditions | 1 |
Paths | 1 |
Total Lines | 58 |
Lines | 0 |
Ratio | 0 % |
Changes | 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 |
||
123 | protected function bootGrammar(): GrammarInterface |
||
124 | { |
||
125 | return new Grammar([ |
||
126 | new Concatenation(0, ['DocBlock'], 'Document'), |
||
127 | new Concatenation(1, ['__any'], 'Document'), |
||
128 | new Alternation(2, [0, 1], null), |
||
129 | (new Repetition('Document', 0, -1, 2, null))->setDefaultId('Document'), |
||
130 | new Terminal(4, 'T_WORD', false), |
||
131 | new Terminal(5, 'T_DOC_DEFINITION', false), |
||
132 | new Terminal(6, 'T_VARIABLE', false), |
||
133 | new Terminal(7, 'T_SUFFIX_ARRAY', false), |
||
134 | new Terminal(8, 'T_NAMESPACE', false), |
||
135 | new Terminal(9, 'T_AND', false), |
||
136 | new Terminal(10, 'T_OR', false), |
||
137 | new Terminal(11, 'T_ANGLE_LEFT', false), |
||
138 | new Terminal(12, 'T_ANGLE_RIGHT', false), |
||
139 | new Terminal(13, 'T_COMMA', false), |
||
140 | new Alternation('__any', [4, 5, 6, 7, 8, 9, 10, 11, 12, 13], null), |
||
141 | new Repetition(15, 0, 1, 'TypeHint', null), |
||
142 | new Concatenation(16, ['DocBlockVariable'], null), |
||
143 | (new Concatenation('DocBlock', ['DocBlockTitle', 15, 16], 'DocBlock'))->setDefaultId('DocBlock'), |
||
144 | new Terminal(18, 'T_DOC_DEFINITION', true), |
||
145 | (new Concatenation('DocBlockTitle', [18], 'DocBlockTitle'))->setDefaultId('DocBlockTitle'), |
||
146 | new Terminal(20, 'T_VARIABLE', true), |
||
147 | (new Concatenation('DocBlockVariable', [20], 'DocBlockVariable'))->setDefaultId('DocBlockVariable'), |
||
148 | new Concatenation(22, ['__arrayTypeHint'], 'TypeHint'), |
||
149 | new Concatenation(23, ['__genericTypeHint'], 'TypeHint'), |
||
150 | new Concatenation(24, ['__scalarTypeHint'], 'TypeHint'), |
||
151 | new Alternation(25, [22, 23, 24], null), |
||
152 | new Repetition(26, 0, 1, '__typeHintContinuation', null), |
||
153 | (new Concatenation('TypeHint', [25, 26], null))->setDefaultId('TypeHint'), |
||
154 | new Concatenation(28, ['__typeHintDisjunction'], null), |
||
155 | new Alternation('__typeHintContinuation', ['__typeHintConjunction', 28], null), |
||
156 | new Terminal(30, 'T_OR', false), |
||
157 | new Concatenation('__typeHintDisjunction', [30, 'TypeHint'], 'Disjunction'), |
||
158 | new Terminal(32, 'T_AND', false), |
||
159 | new Concatenation('__typeHintConjunction', [32, 'TypeHint'], 'Conjunction'), |
||
160 | new Terminal(34, 'T_SUFFIX_ARRAY', false), |
||
161 | new Concatenation('__arrayTypeHint', ['__typeDefinition', 34], 'Array'), |
||
162 | new Terminal(36, 'T_ANGLE_LEFT', false), |
||
163 | new Repetition(37, 0, 1, '__genericArguments', null), |
||
164 | new Terminal(38, 'T_ANGLE_RIGHT', false), |
||
165 | new Concatenation('__genericTypeHint', ['__typeDefinition', 36, 37, 38], 'Generic'), |
||
166 | new Terminal(40, 'T_COMMA', false), |
||
167 | new Concatenation(41, [40, '__scalarTypeHint'], null), |
||
168 | new Repetition(42, 0, 1, 41, null), |
||
169 | new Concatenation('__genericArguments', ['__scalarTypeHint', 42], 'GenericArguments'), |
||
170 | new Concatenation('__scalarTypeHint', ['__typeDefinition'], 'Scalar'), |
||
171 | new Terminal(45, 'T_NAMESPACE', false), |
||
172 | new Repetition(46, 0, 1, 45, null), |
||
173 | new Terminal(47, 'T_WORD', true), |
||
174 | new Terminal(48, 'T_NAMESPACE', false), |
||
175 | new Terminal(49, 'T_WORD', true), |
||
176 | new Concatenation(50, [48, 49], null), |
||
177 | new Repetition(51, 0, -1, 50, null), |
||
178 | new Concatenation('__typeDefinition', [46, 47, 51], 'Type') |
||
179 | ], static::PARSER_ROOT_RULE, static::PARSER_DELEGATES); |
||
180 | } |
||
181 | } |
||
182 |