Passed
Branch master (4246ff)
by Jesse
03:22
created
Category
src/Parser.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -14,16 +14,16 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
119 119
 		}
120 120
 
121 121
 		$tType = Lexeme::T_INVALID;
122
-		if( isset(PrintfLexeme::CHAR_MAP[$next->getString()]) ) {
122
+		if (isset(PrintfLexeme::CHAR_MAP[$next->getString()])) {
123 123
 			$tType = PrintfLexeme::CHAR_MAP[$next->getString()];
124 124
 		}
125 125
 
@@ -140,10 +140,10 @@  discard block
 block discarded – undo
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
 			}
Please login to merge, or discard this patch.
src/PrintfLexeme.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	public const ARG_TYPE_STRING  = 'string';
43 43
 
44 44
 	/** @var int[] string    s */
45
-	public const STRING_TYPES = [ self::T_STRING ];
45
+	public const STRING_TYPES = [self::T_STRING];
46 46
 
47 47
 	/** @var int[] integer    d, u, c, o, x, X, b */
48 48
 	public const INTEGER_TYPES = [
@@ -112,15 +112,15 @@  discard block
 block discarded – undo
112 112
 	 *   PrintfLexeme::ARG_TYPE_STRING
113 113
 	 */
114 114
 	public function argType() : string {
115
-		if( in_array($this->lexItemType, self::INTEGER_TYPES, true) ) {
115
+		if (in_array($this->lexItemType, self::INTEGER_TYPES, true)) {
116 116
 			return self::ARG_TYPE_INT;
117 117
 		}
118 118
 
119
-		if( in_array($this->lexItemType, self::DOUBLE_TYPES, true) ) {
119
+		if (in_array($this->lexItemType, self::DOUBLE_TYPES, true)) {
120 120
 			return self::ARG_TYPE_DOUBLE;
121 121
 		}
122 122
 
123
-		if( in_array($this->lexItemType, self::STRING_TYPES, true) ) {
123
+		if (in_array($this->lexItemType, self::STRING_TYPES, true)) {
124 124
 			return self::ARG_TYPE_STRING;
125 125
 		}
126 126
 
Please login to merge, or discard this patch.
src/LexemeEmitter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
 	/**
11 11
 	 * @internal This is for use by the Parser
12 12
 	 */
13
-	public function emit( Lexeme $lexItem ) {
13
+	public function emit(Lexeme $lexItem) {
14 14
 		$this->lexemes[] = $lexItem;
15 15
 	}
16 16
 
Please login to merge, or discard this patch.
src/StringLexer.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -14,11 +14,11 @@  discard block
 block discarded – undo
14 14
 	/**
15 15
 	 * StringScanner constructor.
16 16
 	 */
17
-	public function __construct( string $string ) {
17
+	public function __construct(string $string) {
18 18
 		$this->string = $string;
19 19
 	}
20 20
 
21
-	public function peek( $size = 1 ) : CharData {
21
+	public function peek($size = 1) : CharData {
22 22
 		$str = substr($this->string, $this->pos, $size);
23 23
 
24 24
 		return new CharData($str, strlen($str) < $size);
@@ -38,19 +38,19 @@  discard block
 block discarded – undo
38 38
 
39 39
 	public function rewind() : void {
40 40
 		$this->pos--;
41
-		if( $this->pos < 0 ) {
41
+		if ($this->pos < 0) {
42 42
 			//@todo custom exception
43 43
 			throw new \RuntimeException('cannot rewind');
44 44
 		}
45 45
 	}
46 46
 
47
-	public function hasPrefix( string $prefix ) : bool {
47
+	public function hasPrefix(string $prefix) : bool {
48 48
 		$peek = $this->peek(strlen($prefix));
49 49
 
50 50
 		return $peek->getString() === $prefix;
51 51
 	}
52 52
 
53
-	public function substr( $start, $length ) : string {
53
+	public function substr($start, $length) : string {
54 54
 		return substr($this->string, $start, $length);
55 55
 	}
56 56
 }
Please login to merge, or discard this patch.
src/Lexeme.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
 	/**
24 24
 	 * LexItem constructor.
25 25
 	 */
26
-	public function __construct( string $lexItemType, string $val, int $pos ) {
26
+	public function __construct(string $lexItemType, string $val, int $pos) {
27 27
 		$this->lexItemType = $lexItemType;
28 28
 		$this->val         = $val;
29 29
 		$this->pos         = $pos;
Please login to merge, or discard this patch.
src/CharData.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
 	 */
14 14
 	private $eof;
15 15
 
16
-	public function __construct( string $string, bool $eof ) {
16
+	public function __construct(string $string, bool $eof) {
17 17
 		$this->string = $string;
18 18
 		$this->eof    = $eof;
19 19
 	}
Please login to merge, or discard this patch.
src/Emitter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,5 +7,5 @@
 block discarded – undo
7 7
 	/**
8 8
 	 * @internal This is for use by the Parser
9 9
 	 */
10
-	public function emit( Lexeme $lexItem );
10
+	public function emit(Lexeme $lexItem);
11 11
 }
Please login to merge, or discard this patch.
src/LexemeCollection.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 	/**
13 13
 	 * LexemeCollection constructor.
14 14
 	 */
15
-	public function __construct( Lexeme ...$lexItems ) {
15
+	public function __construct(Lexeme ...$lexItems) {
16 16
 		$this->lexItems = $lexItems;
17 17
 	}
18 18
 
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
 	 * Retrieve the first invalid Lexeme or null if all are valid.
21 21
 	 */
22 22
 	public function getInvalid() : ?Lexeme {
23
-		foreach( $this->lexItems as $lexItem ) {
24
-			if( $lexItem->getLexItemType() === Lexeme::T_INVALID ) {
23
+		foreach ($this->lexItems as $lexItem) {
24
+			if ($lexItem->getLexItemType() === Lexeme::T_INVALID) {
25 25
 				return $lexItem;
26 26
 			}
27 27
 		}
@@ -29,23 +29,23 @@  discard block
 block discarded – undo
29 29
 		return null;
30 30
 	}
31 31
 
32
-	public function offsetSet( $offset, $value ) {
33
-		if( $offset === null ) {
32
+	public function offsetSet($offset, $value) {
33
+		if ($offset === null) {
34 34
 			$this->lexItems[] = $value;
35 35
 		} else {
36 36
 			$this->lexItems[$offset] = $value;
37 37
 		}
38 38
 	}
39 39
 
40
-	public function offsetExists( $offset ) {
40
+	public function offsetExists($offset) {
41 41
 		return isset($this->lexItems[$offset]);
42 42
 	}
43 43
 
44
-	public function offsetUnset( $offset ) {
44
+	public function offsetUnset($offset) {
45 45
 		unset($this->lexItems[$offset]);
46 46
 	}
47 47
 
48
-	public function offsetGet( $offset ) {
48
+	public function offsetGet($offset) {
49 49
 		return isset($this->lexItems[$offset]) ? $this->lexItems[$offset] : null;
50 50
 	}
51 51
 
@@ -73,11 +73,11 @@  discard block
 block discarded – undo
73 73
 	public function argTypes() : array {
74 74
 		$noNumInc = 1;
75 75
 		$args     = [];
76
-		foreach( $this->lexItems as $item ) {
77
-			if( $item instanceof PrintfLexeme ) {
76
+		foreach ($this->lexItems as $item) {
77
+			if ($item instanceof PrintfLexeme) {
78 78
 				$type = $item->argType();
79 79
 
80
-				if( $item->getArg() !== null ) {
80
+				if ($item->getArg() !== null) {
81 81
 					$args[$item->getArg()] = $type;
82 82
 				} else {
83 83
 					$args[$noNumInc] = $type;
Please login to merge, or discard this patch.