@@ -127,6 +127,7 @@ |
||
| 127 | 127 | |
| 128 | 128 | /** |
| 129 | 129 | * |
| 130 | + * @param boolean $allTouched |
|
| 130 | 131 | */ |
| 131 | 132 | protected function stop($allTouched) { |
| 132 | 133 | throw new DoneParsingException($allTouched); |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | * |
| 23 | 23 | */ |
| 24 | 24 | public function __construct() { |
| 25 | - if ($regexes = $this->stopAfter()) { |
|
| 25 | + if ( $regexes = $this->stopAfter() ) { |
|
| 26 | 26 | $this->stopAfter = array_combine($regexes, array_fill(0, count($regexes), false)); |
| 27 | 27 | } |
| 28 | 28 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * Implements JsonStreamingParser\Listener::endDocument(). |
| 32 | 32 | */ |
| 33 | 33 | public function endDocument() { |
| 34 | - if (!empty($this->stopAfter)) { |
|
| 34 | + if ( !empty($this->stopAfter) ) { |
|
| 35 | 35 | $this->stop(false); |
| 36 | 36 | } |
| 37 | 37 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | $this->indent++; |
| 46 | 46 | $this->array[$this->indent] = false; |
| 47 | - if ($this->lastKey !== null) { |
|
| 47 | + if ( $this->lastKey !== null ) { |
|
| 48 | 48 | $this->trace[] = $this->lastKey; |
| 49 | 49 | } |
| 50 | 50 | } |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | $this->indent++; |
| 67 | 67 | $this->array[$this->indent] = true; |
| 68 | 68 | $this->array_index[$this->indent] = -1; |
| 69 | - if ($this->lastKey !== null) { |
|
| 69 | + if ( $this->lastKey !== null ) { |
|
| 70 | 70 | $this->trace[] = $this->lastKey; |
| 71 | 71 | } |
| 72 | 72 | } |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | /** |
| 84 | 84 | * Implements JsonStreamingParser\Listener::key(). |
| 85 | 85 | */ |
| 86 | - public function key($key) { |
|
| 86 | + public function key( $key ) { |
|
| 87 | 87 | $this->lastKey = $key; |
| 88 | 88 | $this->composeKey(); |
| 89 | 89 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | /** |
| 94 | 94 | * Implements JsonStreamingParser\Listener::value(). |
| 95 | 95 | */ |
| 96 | - public function value($value) { |
|
| 96 | + public function value( $value ) { |
|
| 97 | 97 | $this->arrayKey(); |
| 98 | 98 | $this->composeKey(); |
| 99 | 99 | |
@@ -105,17 +105,17 @@ discard block |
||
| 105 | 105 | /** |
| 106 | 106 | * |
| 107 | 107 | */ |
| 108 | - protected function touch(array $path) { |
|
| 109 | - if ($this->stopAfter) { |
|
| 108 | + protected function touch( array $path ) { |
|
| 109 | + if ( $this->stopAfter ) { |
|
| 110 | 110 | $pathString = implode($this->separator, $path); |
| 111 | - foreach ($this->stopAfter as $regex => &$touched) { |
|
| 112 | - if (preg_match($regex, $pathString)) { |
|
| 111 | + foreach ( $this->stopAfter as $regex => &$touched ) { |
|
| 112 | + if ( preg_match($regex, $pathString) ) { |
|
| 113 | 113 | $touched = true; |
| 114 | 114 | } |
| 115 | - elseif ($touched) { |
|
| 115 | + elseif ( $touched ) { |
|
| 116 | 116 | unset($this->stopAfter[$regex]); |
| 117 | 117 | |
| 118 | - if (empty($this->stopAfter)) { |
|
| 118 | + if ( empty($this->stopAfter) ) { |
|
| 119 | 119 | $this->stop(true); |
| 120 | 120 | } |
| 121 | 121 | } |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | /** |
| 129 | 129 | * |
| 130 | 130 | */ |
| 131 | - protected function stop($allTouched) { |
|
| 131 | + protected function stop( $allTouched ) { |
|
| 132 | 132 | throw new DoneParsingException($allTouched); |
| 133 | 133 | } |
| 134 | 134 | |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | * Trigger a new key, numeric or associative. |
| 144 | 144 | */ |
| 145 | 145 | protected function arrayKey() { |
| 146 | - if (!empty($this->array[$this->indent])) { |
|
| 146 | + if ( !empty($this->array[$this->indent]) ) { |
|
| 147 | 147 | $this->array_index[$this->indent]++; |
| 148 | 148 | $this->key($this->array_index[$this->indent]); |
| 149 | 149 | } |
@@ -152,10 +152,10 @@ discard block |
||
| 152 | 152 | /** |
| 153 | 153 | * Optional helper to save a scalar value into a non-scalar path. |
| 154 | 154 | */ |
| 155 | - protected function setValue(array &$container, array $key, $value) { |
|
| 155 | + protected function setValue( array &$container, array $key, $value ) { |
|
| 156 | 156 | $element = &$container; |
| 157 | - foreach ($key as $subkey) { |
|
| 158 | - $element =& $element[$subkey]; |
|
| 157 | + foreach ( $key as $subkey ) { |
|
| 158 | + $element = & $element[$subkey]; |
|
| 159 | 159 | } |
| 160 | 160 | $element = $value; |
| 161 | 161 | } |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | /** |
| 164 | 164 | * Remember a value into the provided value property. |
| 165 | 165 | */ |
| 166 | - protected function rememberValue(array $path, $value) { |
|
| 166 | + protected function rememberValue( array $path, $value ) { |
|
| 167 | 167 | $this->setValue($this->value, $path, $value); |
| 168 | 168 | } |
| 169 | 169 | |
@@ -189,13 +189,13 @@ discard block |
||
| 189 | 189 | * |
| 190 | 190 | * @return void |
| 191 | 191 | */ |
| 192 | - abstract public function gotPath(array $path); |
|
| 192 | + abstract public function gotPath( array $path ); |
|
| 193 | 193 | |
| 194 | 194 | /** |
| 195 | 195 | * Get notified about a new value, including complete path. |
| 196 | 196 | * |
| 197 | 197 | * @return void |
| 198 | 198 | */ |
| 199 | - abstract public function gotValue(array $path, $value); |
|
| 199 | + abstract public function gotValue( array $path, $value ); |
|
| 200 | 200 | |
| 201 | 201 | } |
@@ -20,17 +20,17 @@ |
||
| 20 | 20 | /** |
| 21 | 21 | * Implements PathAwareJsonListener::gotPath(). |
| 22 | 22 | */ |
| 23 | - public function gotPath(array $path) { |
|
| 23 | + public function gotPath( array $path ) { |
|
| 24 | 24 | // Ignore empty non-scalars |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * Implements PathAwareJsonListener::gotValue(). |
| 29 | 29 | */ |
| 30 | - public function gotValue(array $path, $value) { |
|
| 31 | - foreach ($this->regexes as $regex => $target) { |
|
| 30 | + public function gotValue( array $path, $value ) { |
|
| 31 | + foreach ( $this->regexes as $regex => $target ) { |
|
| 32 | 32 | $pathString = implode($this->separator, $path); |
| 33 | - if (($targetString = preg_replace($regex, $target, $pathString)) != $pathString) { |
|
| 33 | + if ( ($targetString = preg_replace($regex, $target, $pathString)) != $pathString ) { |
|
| 34 | 34 | $target = explode($this->separator, $targetString); |
| 35 | 35 | return $this->rememberValue($target, $value); |
| 36 | 36 | } |
@@ -20,16 +20,16 @@ |
||
| 20 | 20 | /** |
| 21 | 21 | * Implements PathAwareJsonListener::gotPath(). |
| 22 | 22 | */ |
| 23 | - public function gotPath(array $path) { |
|
| 23 | + public function gotPath( array $path ) { |
|
| 24 | 24 | // Ignore empty non-scalars |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * Implements PathAwareJsonListener::gotValue(). |
| 29 | 29 | */ |
| 30 | - public function gotValue(array $path, $value) { |
|
| 31 | - foreach ($this->regexes as $regex) { |
|
| 32 | - if (preg_match($regex, implode($this->separator, $path))) { |
|
| 30 | + public function gotValue( array $path, $value ) { |
|
| 31 | + foreach ( $this->regexes as $regex ) { |
|
| 32 | + if ( preg_match($regex, implode($this->separator, $path)) ) { |
|
| 33 | 33 | return $this->rememberValue($path, $value); |
| 34 | 34 | } |
| 35 | 35 | } |
@@ -6,7 +6,7 @@ |
||
| 6 | 6 | |
| 7 | 7 | public $allTouched; |
| 8 | 8 | |
| 9 | - public function __construct($allTouched) { |
|
| 9 | + public function __construct( $allTouched ) { |
|
| 10 | 10 | $this->allTouched = $allTouched; |
| 11 | 11 | } |
| 12 | 12 | |