@@ -53,28 +53,28 @@ |
||
53 | 53 | * |
54 | 54 | * @var string|null |
55 | 55 | */ |
56 | - protected $_rule = null; |
|
56 | + protected $_rule = null; |
|
57 | 57 | |
58 | 58 | /** |
59 | 59 | * Data. |
60 | 60 | * |
61 | 61 | * @var mixed |
62 | 62 | */ |
63 | - protected $_data = null; |
|
63 | + protected $_data = null; |
|
64 | 64 | |
65 | 65 | /** |
66 | 66 | * Piece of todo sequence. |
67 | 67 | * |
68 | 68 | * @var array|null |
69 | 69 | */ |
70 | - protected $_todo = null; |
|
70 | + protected $_todo = null; |
|
71 | 71 | |
72 | 72 | /** |
73 | 73 | * Depth in the trace. |
74 | 74 | * |
75 | 75 | * @var int |
76 | 76 | */ |
77 | - protected $_depth = -1; |
|
77 | + protected $_depth = -1; |
|
78 | 78 | |
79 | 79 | /** |
80 | 80 | * Whether the rule is transitional or not (i.e. not declared in the grammar |
@@ -63,21 +63,21 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @var string|null |
65 | 65 | */ |
66 | - protected $_tokenName = null; |
|
66 | + protected $_tokenName = null; |
|
67 | 67 | |
68 | 68 | /** |
69 | 69 | * Namespace. |
70 | 70 | * |
71 | 71 | * @var string|null |
72 | 72 | */ |
73 | - protected $_namespace = null; |
|
73 | + protected $_namespace = null; |
|
74 | 74 | |
75 | 75 | /** |
76 | 76 | * Token representation. |
77 | 77 | * |
78 | 78 | * @var string|null |
79 | 79 | */ |
80 | - protected $_regex = null; |
|
80 | + protected $_regex = null; |
|
81 | 81 | |
82 | 82 | /** |
83 | 83 | * AST of the regex. |
@@ -91,28 +91,28 @@ discard block |
||
91 | 91 | * |
92 | 92 | * @var string|null |
93 | 93 | */ |
94 | - protected $_value = null; |
|
94 | + protected $_value = null; |
|
95 | 95 | |
96 | 96 | /** |
97 | 97 | * Whether the token is kept or not in the AST. |
98 | 98 | * |
99 | 99 | * @var bool |
100 | 100 | */ |
101 | - protected $_kept = false; |
|
101 | + protected $_kept = false; |
|
102 | 102 | |
103 | 103 | /** |
104 | 104 | * Unification index. |
105 | 105 | * |
106 | 106 | * @var int |
107 | 107 | */ |
108 | - protected $_unification = -1; |
|
108 | + protected $_unification = -1; |
|
109 | 109 | |
110 | 110 | /** |
111 | 111 | * Token offset. |
112 | 112 | * |
113 | 113 | * @var int |
114 | 114 | */ |
115 | - protected $_offset = 0; |
|
115 | + protected $_offset = 0; |
|
116 | 116 | |
117 | 117 | /** |
118 | 118 | * Constructor. |
@@ -55,14 +55,14 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @var string |
57 | 57 | */ |
58 | - protected $_id = ''; |
|
58 | + protected $_id = ''; |
|
59 | 59 | |
60 | 60 | /** |
61 | 61 | * Value of the node (non-null for token nodes). |
62 | 62 | * |
63 | 63 | * @var array|null |
64 | 64 | */ |
65 | - protected $_value = null; |
|
65 | + protected $_value = null; |
|
66 | 66 | |
67 | 67 | /** |
68 | 68 | * Children. |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * |
84 | 84 | * @var array |
85 | 85 | */ |
86 | - protected $_data = []; |
|
86 | + protected $_data = []; |
|
87 | 87 | |
88 | 88 | |
89 | 89 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | ) { |
104 | 104 | $this->setId($id); |
105 | 105 | |
106 | - if (!empty($value)) { |
|
106 | + if ( ! empty($value)) { |
|
107 | 107 | $this->setValue($value); |
108 | 108 | } |
109 | 109 | |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | */ |
211 | 211 | public function isToken() |
212 | 212 | { |
213 | - return !empty($this->_value); |
|
213 | + return ! empty($this->_value); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | /** |
@@ -55,28 +55,28 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @var array |
57 | 57 | */ |
58 | - protected $_lexerState = null; |
|
58 | + protected $_lexerState = null; |
|
59 | 59 | |
60 | 60 | /** |
61 | 61 | * Text. |
62 | 62 | * |
63 | 63 | * @var string |
64 | 64 | */ |
65 | - protected $_text = null; |
|
65 | + protected $_text = null; |
|
66 | 66 | |
67 | 67 | /** |
68 | 68 | * Tokens. |
69 | 69 | * |
70 | 70 | * @var array |
71 | 71 | */ |
72 | - protected $_tokens = []; |
|
72 | + protected $_tokens = []; |
|
73 | 73 | |
74 | 74 | /** |
75 | 75 | * Namespace stacks. |
76 | 76 | * |
77 | 77 | * @var \SplStack |
78 | 78 | */ |
79 | - protected $_nsStack = null; |
|
79 | + protected $_nsStack = null; |
|
80 | 80 | |
81 | 81 | /** |
82 | 82 | * PCRE options. |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function __construct(array $pragmas = []) |
96 | 96 | { |
97 | - if (!isset($pragmas['lexer.unicode']) || true === $pragmas['lexer.unicode']) { |
|
97 | + if ( ! isset($pragmas['lexer.unicode']) || true === $pragmas['lexer.unicode']) { |
|
98 | 98 | $this->_pcreOptions .= 'u'; |
99 | 99 | } |
100 | 100 | |
@@ -156,9 +156,9 @@ discard block |
||
156 | 156 | |
157 | 157 | if (null === $nextToken) { |
158 | 158 | throw new Compiler\Exception\UnrecognizedToken( |
159 | - 'Unrecognized token "%s" at line 1 and column %d:' . |
|
160 | - "\n" . '%s' . "\n" . |
|
161 | - str_repeat(' ', mb_strlen(substr($text, 0, $offset))) . '↑', |
|
159 | + 'Unrecognized token "%s" at line 1 and column %d:'. |
|
160 | + "\n".'%s'."\n". |
|
161 | + str_repeat(' ', mb_strlen(substr($text, 0, $offset))).'↑', |
|
162 | 162 | 0, |
163 | 163 | [ |
164 | 164 | mb_substr(substr($text, $offset), 0, 1), |
@@ -226,8 +226,8 @@ discard block |
||
226 | 226 | |
227 | 227 | if ($i > ($c = count($this->_nsStack))) { |
228 | 228 | throw new Compiler\Exception\Lexer( |
229 | - 'Cannot shift namespace %d-times, from token ' . |
|
230 | - '%s in namespace %s, because the stack ' . |
|
229 | + 'Cannot shift namespace %d-times, from token '. |
|
230 | + '%s in namespace %s, because the stack '. |
|
231 | 231 | 'contains only %d namespaces.', |
232 | 232 | 1, |
233 | 233 | [ |
@@ -247,9 +247,9 @@ discard block |
||
247 | 247 | $shift = true; |
248 | 248 | } |
249 | 249 | |
250 | - if (!isset($this->_tokens[$nextState])) { |
|
250 | + if ( ! isset($this->_tokens[$nextState])) { |
|
251 | 251 | throw new Compiler\Exception\Lexer( |
252 | - 'Namespace %s does not exist, called by token %s ' . |
|
252 | + 'Namespace %s does not exist, called by token %s '. |
|
253 | 253 | 'in namespace %s.', |
254 | 254 | 2, |
255 | 255 | [ |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | { |
292 | 292 | $_regex = str_replace('#', '\#', $regex); |
293 | 293 | $preg = @preg_match( |
294 | - '#\G(?|' . $_regex . ')#' . $this->_pcreOptions, |
|
294 | + '#\G(?|'.$_regex.')#'.$this->_pcreOptions, |
|
295 | 295 | $this->_text, |
296 | 296 | $matches, |
297 | 297 | 0, |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | |
313 | 313 | if ('' === $matches[0]) { |
314 | 314 | throw new Compiler\Exception\Lexer( |
315 | - 'A lexeme must not match an empty value, which is the ' . |
|
315 | + 'A lexeme must not match an empty value, which is the '. |
|
316 | 316 | 'case of "%s" (%s).', |
317 | 317 | 3, |
318 | 318 | [$lexeme, $regex] |
@@ -56,14 +56,14 @@ discard block |
||
56 | 56 | * |
57 | 57 | * @var array |
58 | 58 | */ |
59 | - protected $_pragmas = null; |
|
59 | + protected $_pragmas = null; |
|
60 | 60 | |
61 | 61 | /** |
62 | 62 | * List of skipped tokens. |
63 | 63 | * |
64 | 64 | * @var array |
65 | 65 | */ |
66 | - protected $_skip = null; |
|
66 | + protected $_skip = null; |
|
67 | 67 | |
68 | 68 | /** |
69 | 69 | * Associative array (token name => token regex), to be defined in |
@@ -71,14 +71,14 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @var array |
73 | 73 | */ |
74 | - protected $_tokens = null; |
|
74 | + protected $_tokens = null; |
|
75 | 75 | |
76 | 76 | /** |
77 | 77 | * Rules, to be defined as associative array, name => Rule object. |
78 | 78 | * |
79 | 79 | * @var Rule[] |
80 | 80 | */ |
81 | - protected $_rules = null; |
|
81 | + protected $_rules = null; |
|
82 | 82 | |
83 | 83 | /** |
84 | 84 | * Lexer iterator. |
@@ -92,35 +92,35 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @var array |
94 | 94 | */ |
95 | - protected $_errorToken = null; |
|
95 | + protected $_errorToken = null; |
|
96 | 96 | |
97 | 97 | /** |
98 | 98 | * Trace of activated rules. |
99 | 99 | * |
100 | 100 | * @var array |
101 | 101 | */ |
102 | - protected $_trace = []; |
|
102 | + protected $_trace = []; |
|
103 | 103 | |
104 | 104 | /** |
105 | 105 | * Stack of todo list. |
106 | 106 | * |
107 | 107 | * @var array |
108 | 108 | */ |
109 | - protected $_todo = null; |
|
109 | + protected $_todo = null; |
|
110 | 110 | |
111 | 111 | /** |
112 | 112 | * AST. |
113 | 113 | * |
114 | 114 | * @var \JMS\Serializer\Type\Compiler\Llk\TreeNode |
115 | 115 | */ |
116 | - protected $_tree = null; |
|
116 | + protected $_tree = null; |
|
117 | 117 | |
118 | 118 | /** |
119 | 119 | * Current depth while building the trace. |
120 | 120 | * |
121 | 121 | * @var int |
122 | 122 | */ |
123 | - protected $_depth = -1; |
|
123 | + protected $_depth = -1; |
|
124 | 124 | |
125 | 125 | |
126 | 126 | |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | } |
189 | 189 | |
190 | 190 | if (false === $this->backtrack()) { |
191 | - $token = $this->_errorToken; |
|
191 | + $token = $this->_errorToken; |
|
192 | 192 | |
193 | 193 | if (null === $this->_errorToken) { |
194 | 194 | $token = $this->_tokenSequence->current(); |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | $line = 1; |
199 | 199 | $column = 1; |
200 | 200 | |
201 | - if (!empty($text)) { |
|
201 | + if ( ! empty($text)) { |
|
202 | 202 | if (0 === $offset) { |
203 | 203 | $leftnl = 0; |
204 | 204 | } else { |
@@ -215,8 +215,8 @@ discard block |
||
215 | 215 | } |
216 | 216 | |
217 | 217 | throw new Compiler\Exception\UnexpectedToken( |
218 | - 'Unexpected token "%s" (%s) at line %d and column %d:' . |
|
219 | - "\n" . '%s' . "\n" . str_repeat(' ', $column - 1) . '↑', |
|
218 | + 'Unexpected token "%s" (%s) at line %d and column %d:'. |
|
219 | + "\n".'%s'."\n".str_repeat(' ', $column - 1).'↑', |
|
220 | 220 | 0, |
221 | 221 | [ |
222 | 222 | $token['value'], |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | |
238 | 238 | $tree = $this->_buildTree(); |
239 | 239 | |
240 | - if (!($tree instanceof TreeNode)) { |
|
240 | + if ( ! ($tree instanceof TreeNode)) { |
|
241 | 241 | throw new Compiler\Exception( |
242 | 242 | 'Parsing error: cannot build AST, the trace is corrupted.', |
243 | 243 | 1 |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | $this->_depth |
422 | 422 | ); |
423 | 423 | array_pop($this->_todo); |
424 | - $this->_todo[] = new Rule\Ekzit( |
|
424 | + $this->_todo[] = new Rule\Ekzit( |
|
425 | 425 | $name, |
426 | 426 | $min, |
427 | 427 | $this->_todo |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | end($children); |
634 | 634 | $last = current($children); |
635 | 635 | |
636 | - if (!is_object($last)) { |
|
636 | + if ( ! is_object($last)) { |
|
637 | 637 | return false; |
638 | 638 | } |
639 | 639 | |
@@ -752,7 +752,7 @@ discard block |
||
752 | 752 | */ |
753 | 753 | final public function getRule($name) |
754 | 754 | { |
755 | - if (!isset($this->_rules[$name])) { |
|
755 | + if ( ! isset($this->_rules[$name])) { |
|
756 | 756 | return null; |
757 | 757 | } |
758 | 758 | |
@@ -779,7 +779,7 @@ discard block |
||
779 | 779 | \assert([] !== $this->_rules); |
780 | 780 | |
781 | 781 | foreach ($this->_rules as $rule => $_) { |
782 | - if (!is_int($rule)) { |
|
782 | + if ( ! is_int($rule)) { |
|
783 | 783 | break; |
784 | 784 | } |
785 | 785 | } |
@@ -53,35 +53,35 @@ discard block |
||
53 | 53 | * |
54 | 54 | * @var string |
55 | 55 | */ |
56 | - protected $_name = null; |
|
56 | + protected $_name = null; |
|
57 | 57 | |
58 | 58 | /** |
59 | 59 | * Rule's children. Can be an array of names or a single name. |
60 | 60 | * |
61 | 61 | * @var mixed |
62 | 62 | */ |
63 | - protected $_children = null; |
|
63 | + protected $_children = null; |
|
64 | 64 | |
65 | 65 | /** |
66 | 66 | * Node ID. |
67 | 67 | * |
68 | 68 | * @var string |
69 | 69 | */ |
70 | - protected $_nodeId = null; |
|
70 | + protected $_nodeId = null; |
|
71 | 71 | |
72 | 72 | /** |
73 | 73 | * Node options. |
74 | 74 | * |
75 | 75 | * @var array |
76 | 76 | */ |
77 | - protected $_nodeOptions = []; |
|
77 | + protected $_nodeOptions = []; |
|
78 | 78 | |
79 | 79 | /** |
80 | 80 | * Default ID. |
81 | 81 | * |
82 | 82 | * @var string |
83 | 83 | */ |
84 | - protected $_defaultId = null; |
|
84 | + protected $_defaultId = null; |
|
85 | 85 | |
86 | 86 | /** |
87 | 87 | * Default options. |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @var string |
97 | 97 | */ |
98 | - protected $_pp = null; |
|
98 | + protected $_pp = null; |
|
99 | 99 | |
100 | 100 | /** |
101 | 101 | * Whether the rule is transitional or not (i.e. not declared in the grammar |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * |
104 | 104 | * @var bool |
105 | 105 | */ |
106 | - protected $_transitional = true; |
|
106 | + protected $_transitional = true; |
|
107 | 107 | |
108 | 108 | |
109 | 109 |