@@ -14,16 +14,16 @@ discard block |
||
14 | 14 | * |
15 | 15 | * @param Emitter $emitter |
16 | 16 | */ |
17 | - public function __construct( Emitter $emitter ) { |
|
17 | + public function __construct(Emitter $emitter) { |
|
18 | 18 | $this->emitter = $emitter; |
19 | 19 | } |
20 | 20 | |
21 | - public function parseStr( string $string ) : void { |
|
21 | + public function parseStr(string $string) : void { |
|
22 | 22 | $lexer = new StringLexer($string); |
23 | 23 | |
24 | - while( ($next = $lexer->next()) && !$next->isEof() ) { |
|
25 | - if( $next->getString() === '%' ) { |
|
26 | - if( $lexer->hasPrefix('%') ) { |
|
24 | + while (($next = $lexer->next()) && !$next->isEof()) { |
|
25 | + if ($next->getString() === '%') { |
|
26 | + if ($lexer->hasPrefix('%')) { |
|
27 | 27 | $this->emitter->emit( |
28 | 28 | new Lexeme(Lexeme::T_LITERAL_STRING, '%', $lexer->pos()) |
29 | 29 | ); |
@@ -42,11 +42,11 @@ discard block |
||
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
45 | - private function lexString( Emitter $emitter, StringLexer $lexer ) : void { |
|
45 | + private function lexString(Emitter $emitter, StringLexer $lexer) : void { |
|
46 | 46 | $pos = $lexer->pos(); |
47 | 47 | $buffer = ''; |
48 | - while( ($next = $lexer->next()) && !$next->isEof() ) { |
|
49 | - if( $next->getString() === '%' ) { |
|
48 | + while (($next = $lexer->next()) && !$next->isEof()) { |
|
49 | + if ($next->getString() === '%') { |
|
50 | 50 | $lexer->rewind(); |
51 | 51 | break; |
52 | 52 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | ); |
60 | 60 | } |
61 | 61 | |
62 | - private function lexSprintf( Emitter $emitter, StringLexer $lexer ) : void { |
|
62 | + private function lexSprintf(Emitter $emitter, StringLexer $lexer) : void { |
|
63 | 63 | $pos = $lexer->pos(); |
64 | 64 | $next = $lexer->next(); |
65 | 65 | |
@@ -70,17 +70,17 @@ discard block |
||
70 | 70 | $leftJustified = null; |
71 | 71 | $precision = null; |
72 | 72 | |
73 | - if( $next->getString() !== '0' && ctype_digit($next->getString()) ) { |
|
73 | + if ($next->getString() !== '0' && ctype_digit($next->getString())) { |
|
74 | 74 | $lexer->rewind(); |
75 | 75 | $int = $this->eatInt($lexer); |
76 | - if( $lexer->hasPrefix('$') ) { |
|
76 | + if ($lexer->hasPrefix('$')) { |
|
77 | 77 | $lexer->next(); |
78 | 78 | $next = $lexer->next(); |
79 | 79 | $arg = $int; |
80 | 80 | } |
81 | 81 | } |
82 | 82 | |
83 | - switch( $next->getString() ) { |
|
83 | + switch ($next->getString()) { |
|
84 | 84 | case '0': |
85 | 85 | $padChar = '0'; |
86 | 86 | $next = $lexer->next(); |
@@ -95,23 +95,23 @@ discard block |
||
95 | 95 | $next = $lexer->next(); |
96 | 96 | } |
97 | 97 | |
98 | - if( $next->getString() === '-' ) { |
|
98 | + if ($next->getString() === '-') { |
|
99 | 99 | $leftJustified = true; |
100 | 100 | $next = $lexer->next(); |
101 | 101 | } |
102 | 102 | |
103 | - if( $padChar !== null ) { |
|
103 | + if ($padChar !== null) { |
|
104 | 104 | $lexer->rewind(); |
105 | 105 | $peek = $lexer->peek(); |
106 | - if( ctype_digit($peek->getString()) ) { |
|
106 | + if (ctype_digit($peek->getString())) { |
|
107 | 107 | $padWidth = $this->eatInt($lexer); |
108 | 108 | } |
109 | 109 | |
110 | 110 | $next = $lexer->next(); |
111 | 111 | } |
112 | 112 | |
113 | - if( $next->getString() === '.' ) { |
|
114 | - if( ctype_digit($lexer->peek()->getString()) ) { |
|
113 | + if ($next->getString() === '.') { |
|
114 | + if (ctype_digit($lexer->peek()->getString())) { |
|
115 | 115 | $precision = $this->eatInt($lexer); |
116 | 116 | } |
117 | 117 | |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | } |
120 | 120 | |
121 | 121 | $tType = Lexeme::T_INVALID; |
122 | - if( in_array($next->getString(), ArgumentLexeme::VALID_T_TYPES, true) ) { |
|
122 | + if (in_array($next->getString(), ArgumentLexeme::VALID_T_TYPES, true)) { |
|
123 | 123 | $tType = $next->getString(); |
124 | 124 | } |
125 | 125 | |
@@ -140,10 +140,10 @@ discard block |
||
140 | 140 | ); |
141 | 141 | } |
142 | 142 | |
143 | - private function eatInt( StringLexer $lexer ) : string { |
|
143 | + private function eatInt(StringLexer $lexer) : string { |
|
144 | 144 | $int = ''; |
145 | - while( ($next = $lexer->next()) && !$next->isEof() ) { |
|
146 | - if( !ctype_digit($next->getString()) ) { |
|
145 | + while (($next = $lexer->next()) && !$next->isEof()) { |
|
146 | + if (!ctype_digit($next->getString())) { |
|
147 | 147 | $lexer->rewind(); |
148 | 148 | break; |
149 | 149 | } |