Completed
Push — master ( ed4efe...199c93 )
by Jesse
01:47
created
src/Emitter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,5 +8,5 @@
 block discarded – undo
8 8
 	 * @param \donatj\Printf\Lexeme $lexItem
9 9
 	 * @internal This is for use by the Parser
10 10
 	 */
11
-	public function emit( Lexeme $lexItem ) : void;
11
+	public function emit(Lexeme $lexItem) : void;
12 12
 }
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
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 	 *
18 18
 	 * @internal
19 19
 	 */
20
-	public function __construct( Lexeme ...$lexItems ) {
20
+	public function __construct(Lexeme ...$lexItems) {
21 21
 		$this->lexItems = $lexItems;
22 22
 	}
23 23
 
@@ -27,8 +27,8 @@  discard block
 block discarded – undo
27 27
 	 * This is useful for checking if a printf string parsed without error.
28 28
 	 */
29 29
 	public function getInvalid() : ?Lexeme {
30
-		foreach( $this->lexItems as $lexItem ) {
31
-			if( $lexItem->getLexItemType() === Lexeme::T_INVALID ) {
30
+		foreach ($this->lexItems as $lexItem) {
31
+			if ($lexItem->getLexItemType() === Lexeme::T_INVALID) {
32 32
 				return $lexItem;
33 33
 			}
34 34
 		}
@@ -39,8 +39,8 @@  discard block
 block discarded – undo
39 39
 	/**
40 40
 	 * @internal
41 41
 	 */
42
-	public function offsetSet( $offset, $value ) {
43
-		if( $offset === null ) {
42
+	public function offsetSet($offset, $value) {
43
+		if ($offset === null) {
44 44
 			$this->lexItems[] = $value;
45 45
 		} else {
46 46
 			$this->lexItems[$offset] = $value;
@@ -50,21 +50,21 @@  discard block
 block discarded – undo
50 50
 	/**
51 51
 	 * @internal
52 52
 	 */
53
-	public function offsetExists( $offset ) {
53
+	public function offsetExists($offset) {
54 54
 		return isset($this->lexItems[$offset]);
55 55
 	}
56 56
 
57 57
 	/**
58 58
 	 * @internal
59 59
 	 */
60
-	public function offsetUnset( $offset ) {
60
+	public function offsetUnset($offset) {
61 61
 		unset($this->lexItems[$offset]);
62 62
 	}
63 63
 
64 64
 	/**
65 65
 	 * @internal
66 66
 	 */
67
-	public function offsetGet( $offset ) {
67
+	public function offsetGet($offset) {
68 68
 		return isset($this->lexItems[$offset]) ? $this->lexItems[$offset] : null;
69 69
 	}
70 70
 
@@ -99,11 +99,11 @@  discard block
 block discarded – undo
99 99
 	public function argTypes() : array {
100 100
 		$noNumInc = 1;
101 101
 		$args     = [];
102
-		foreach( $this->lexItems as $item ) {
103
-			if( $item instanceof ArgumentLexeme ) {
102
+		foreach ($this->lexItems as $item) {
103
+			if ($item instanceof ArgumentLexeme) {
104 104
 				$type = $item->argType();
105 105
 
106
-				if( $item->getArg() !== null ) {
106
+				if ($item->getArg() !== null) {
107 107
 					$args[$item->getArg()] = $type;
108 108
 				} else {
109 109
 					$args[$noNumInc] = $type;
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
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 	 * @param \donatj\Printf\Lexeme $lexItem
12 12
 	 * @internal This is for use by the Parser
13 13
 	 */
14
-	public function emit( Lexeme $lexItem ) : void {
14
+	public function emit(Lexeme $lexItem) : void {
15 15
 		$this->lexemes[] = $lexItem;
16 16
 	}
17 17
 
Please login to merge, or discard this patch.
src/Parser.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -14,19 +14,19 @@  discard block
 block discarded – undo
14 14
 	 *
15 15
 	 * @param \donatj\Printf\Emitter $emitter The given Emitter will be parsed Lexemes as parsed
16 16
 	 */
17
-	public function __construct( Emitter $emitter ) {
17
+	public function __construct(Emitter $emitter) {
18 18
 		$this->emitter = $emitter;
19 19
 	}
20 20
 
21 21
 	/**
22 22
 	 * Parses a printf string and pass parsed lexemes to the configured Emitter
23 23
 	 */
24
-	public function parseStr( string $string ) : void {
24
+	public function parseStr(string $string) : void {
25 25
 		$lexer = new StringLexer($string);
26 26
 
27
-		while( ($next = $lexer->next()) && !$next->isEof() ) {
28
-			if( $next->getString() === '%' ) {
29
-				if( $lexer->hasPrefix('%') ) {
27
+		while (($next = $lexer->next()) && !$next->isEof()) {
28
+			if ($next->getString() === '%') {
29
+				if ($lexer->hasPrefix('%')) {
30 30
 					$this->emitter->emit(
31 31
 						new Lexeme(Lexeme::T_LITERAL_STRING, '%', $lexer->pos())
32 32
 					);
@@ -45,11 +45,11 @@  discard block
 block discarded – undo
45 45
 		}
46 46
 	}
47 47
 
48
-	private function lexString( Emitter $emitter, StringLexer $lexer ) : void {
48
+	private function lexString(Emitter $emitter, StringLexer $lexer) : void {
49 49
 		$pos    = $lexer->pos();
50 50
 		$buffer = '';
51
-		while( ($next = $lexer->next()) && !$next->isEof() ) {
52
-			if( $next->getString() === '%' ) {
51
+		while (($next = $lexer->next()) && !$next->isEof()) {
52
+			if ($next->getString() === '%') {
53 53
 				$lexer->rewind();
54 54
 				break;
55 55
 			}
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 		);
63 63
 	}
64 64
 
65
-	private function lexSprintf( Emitter $emitter, StringLexer $lexer ) : void {
65
+	private function lexSprintf(Emitter $emitter, StringLexer $lexer) : void {
66 66
 		$pos  = $lexer->pos();
67 67
 		$next = $lexer->next();
68 68
 
@@ -73,17 +73,17 @@  discard block
 block discarded – undo
73 73
 		$leftJustified = null;
74 74
 		$precision     = null;
75 75
 
76
-		if( $next->getString() !== '0' && ctype_digit($next->getString()) ) {
76
+		if ($next->getString() !== '0' && ctype_digit($next->getString())) {
77 77
 			$lexer->rewind();
78 78
 			$int = $this->eatInt($lexer);
79
-			if( $lexer->hasPrefix('$') ) {
79
+			if ($lexer->hasPrefix('$')) {
80 80
 				$lexer->next();
81 81
 				$next = $lexer->next();
82 82
 				$arg  = $int;
83 83
 			}
84 84
 		}
85 85
 
86
-		switch( $next->getString() ) {
86
+		switch ($next->getString()) {
87 87
 			case '0':
88 88
 				$padChar = '0';
89 89
 				$next    = $lexer->next();
@@ -98,23 +98,23 @@  discard block
 block discarded – undo
98 98
 				$next    = $lexer->next();
99 99
 		}
100 100
 
101
-		if( $next->getString() === '-' ) {
101
+		if ($next->getString() === '-') {
102 102
 			$leftJustified = true;
103 103
 			$next          = $lexer->next();
104 104
 		}
105 105
 
106
-		if( $padChar !== null ) {
106
+		if ($padChar !== null) {
107 107
 			$lexer->rewind();
108 108
 			$peek = $lexer->peek();
109
-			if( ctype_digit($peek->getString()) ) {
109
+			if (ctype_digit($peek->getString())) {
110 110
 				$padWidth = $this->eatInt($lexer);
111 111
 			}
112 112
 
113 113
 			$next = $lexer->next();
114 114
 		}
115 115
 
116
-		if( $next->getString() === '.' ) {
117
-			if( ctype_digit($lexer->peek()->getString()) ) {
116
+		if ($next->getString() === '.') {
117
+			if (ctype_digit($lexer->peek()->getString())) {
118 118
 				$precision = $this->eatInt($lexer);
119 119
 			}
120 120
 
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 		}
123 123
 
124 124
 		$tType = Lexeme::T_INVALID;
125
-		if( in_array($next->getString(), ArgumentLexeme::VALID_T_TYPES, true) ) {
125
+		if (in_array($next->getString(), ArgumentLexeme::VALID_T_TYPES, true)) {
126 126
 			$tType = $next->getString();
127 127
 		}
128 128
 
@@ -143,10 +143,10 @@  discard block
 block discarded – undo
143 143
 		);
144 144
 	}
145 145
 
146
-	private function eatInt( StringLexer $lexer ) : string {
146
+	private function eatInt(StringLexer $lexer) : string {
147 147
 		$int = '';
148
-		while( ($next = $lexer->next()) && !$next->isEof() ) {
149
-			if( !ctype_digit($next->getString()) ) {
148
+		while (($next = $lexer->next()) && !$next->isEof()) {
149
+			if (!ctype_digit($next->getString())) {
150 150
 				$lexer->rewind();
151 151
 				break;
152 152
 			}
Please login to merge, or discard this patch.