@@ -20,20 +20,20 @@ discard block |
||
| 20 | 20 | * |
| 21 | 21 | * @return array |
| 22 | 22 | */ |
| 23 | - protected static function toArray(Translations $translations, $includeHeaders) |
|
| 23 | + protected static function toArray( Translations $translations, $includeHeaders ) |
|
| 24 | 24 | { |
| 25 | - $messages = []; |
|
| 25 | + $messages = [ ]; |
|
| 26 | 26 | |
| 27 | - if ($includeHeaders) { |
|
| 28 | - $messages[''] = static::generateHeaders($translations); |
|
| 27 | + if ( $includeHeaders ) { |
|
| 28 | + $messages[ '' ] = static::generateHeaders( $translations ); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - foreach ($translations as $translation) { |
|
| 32 | - if ($translation->isDisabled()) { |
|
| 31 | + foreach ( $translations as $translation ) { |
|
| 32 | + if ( $translation->isDisabled() ) { |
|
| 33 | 33 | continue; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - $messages[$translation->getOriginal()] = $translation->getTranslation(); |
|
| 36 | + $messages[ $translation->getOriginal() ] = $translation->getTranslation(); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | return $messages; |
@@ -45,15 +45,15 @@ discard block |
||
| 45 | 45 | * @param array $messages |
| 46 | 46 | * @param Translations $translations |
| 47 | 47 | */ |
| 48 | - protected static function fromArray(array $messages, Translations $translations) |
|
| 48 | + protected static function fromArray( array $messages, Translations $translations ) |
|
| 49 | 49 | { |
| 50 | - foreach ($messages as $original => $translation) { |
|
| 51 | - if ($original === '') { |
|
| 52 | - static::extractHeaders($translation, $translations); |
|
| 50 | + foreach ( $messages as $original => $translation ) { |
|
| 51 | + if ( $original === '' ) { |
|
| 52 | + static::extractHeaders( $translation, $translations ); |
|
| 53 | 53 | continue; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - $translations->insert(null, $original)->setTranslation($translation); |
|
| 56 | + $translations->insert( null, $original )->setTranslation( $translation ); |
|
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | } |
@@ -5,53 +5,53 @@ discard block |
||
| 5 | 5 | class JsFunctionsScanner extends FunctionsScanner |
| 6 | 6 | { |
| 7 | 7 | protected $code; |
| 8 | - protected $status = []; |
|
| 8 | + protected $status = [ ]; |
|
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * Constructor. |
| 12 | 12 | * |
| 13 | 13 | * @param string $code The php code to scan |
| 14 | 14 | */ |
| 15 | - public function __construct($code) |
|
| 15 | + public function __construct( $code ) |
|
| 16 | 16 | { |
| 17 | 17 | // Normalize newline characters |
| 18 | - $this->code = str_replace(["\r\n", "\n\r", "\r"], "\n", $code); |
|
| 18 | + $this->code = str_replace( [ "\r\n", "\n\r", "\r" ], "\n", $code ); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * {@inheritdoc} |
| 23 | 23 | */ |
| 24 | - public function getFunctions(array $constants = []) |
|
| 24 | + public function getFunctions( array $constants = [ ] ) |
|
| 25 | 25 | { |
| 26 | - $length = strlen($this->code); |
|
| 26 | + $length = strlen( $this->code ); |
|
| 27 | 27 | $line = 1; |
| 28 | 28 | $buffer = ''; |
| 29 | - $functions = []; |
|
| 30 | - $bufferFunctions = []; |
|
| 29 | + $functions = [ ]; |
|
| 30 | + $bufferFunctions = [ ]; |
|
| 31 | 31 | $char = null; |
| 32 | 32 | |
| 33 | - for ($pos = 0; $pos < $length; ++$pos) { |
|
| 33 | + for ( $pos = 0; $pos < $length; ++$pos ) { |
|
| 34 | 34 | $prev = $char; |
| 35 | - $char = $this->code[$pos]; |
|
| 36 | - $next = isset($this->code[$pos + 1]) ? $this->code[$pos + 1] : null; |
|
| 35 | + $char = $this->code[ $pos ]; |
|
| 36 | + $next = isset( $this->code[ $pos + 1 ] ) ? $this->code[ $pos + 1 ] : null; |
|
| 37 | 37 | |
| 38 | - switch ($char) { |
|
| 38 | + switch ( $char ) { |
|
| 39 | 39 | case '\\': |
| 40 | - switch ($this->status()) { |
|
| 40 | + switch ( $this->status() ) { |
|
| 41 | 41 | case 'simple-quote': |
| 42 | - if ($next !== "'") { |
|
| 42 | + if ( $next !== "'" ) { |
|
| 43 | 43 | break 2; |
| 44 | 44 | } |
| 45 | 45 | break; |
| 46 | 46 | |
| 47 | 47 | case 'double-quote': |
| 48 | - if ($next !== '"') { |
|
| 48 | + if ( $next !== '"' ) { |
|
| 49 | 49 | break 2; |
| 50 | 50 | } |
| 51 | 51 | break; |
| 52 | 52 | |
| 53 | 53 | case 'back-tick': |
| 54 | - if ($next !== '`') { |
|
| 54 | + if ( $next !== '`' ) { |
|
| 55 | 55 | break 2; |
| 56 | 56 | } |
| 57 | 57 | break; |
@@ -60,19 +60,19 @@ discard block |
||
| 60 | 60 | $prev = $char; |
| 61 | 61 | $char = $next; |
| 62 | 62 | $pos++; |
| 63 | - $next = isset($this->code[$pos]) ? $this->code[$pos] : null; |
|
| 63 | + $next = isset( $this->code[ $pos ] ) ? $this->code[ $pos ] : null; |
|
| 64 | 64 | break; |
| 65 | 65 | |
| 66 | 66 | case "\n": |
| 67 | 67 | ++$line; |
| 68 | 68 | |
| 69 | - if ($this->status('line-comment')) { |
|
| 69 | + if ( $this->status( 'line-comment' ) ) { |
|
| 70 | 70 | $this->upStatus(); |
| 71 | 71 | } |
| 72 | 72 | break; |
| 73 | 73 | |
| 74 | 74 | case '/': |
| 75 | - switch ($this->status()) { |
|
| 75 | + switch ( $this->status() ) { |
|
| 76 | 76 | case 'simple-quote': |
| 77 | 77 | case 'double-quote': |
| 78 | 78 | case 'back-tick': |
@@ -80,23 +80,23 @@ discard block |
||
| 80 | 80 | break; |
| 81 | 81 | |
| 82 | 82 | case 'block-comment': |
| 83 | - if ($prev === '*') { |
|
| 83 | + if ( $prev === '*' ) { |
|
| 84 | 84 | $this->upStatus(); |
| 85 | 85 | } |
| 86 | 86 | break; |
| 87 | 87 | |
| 88 | 88 | default: |
| 89 | - if ($next === '/') { |
|
| 90 | - $this->downStatus('line-comment'); |
|
| 91 | - } elseif ($next === '*') { |
|
| 92 | - $this->downStatus('block-comment'); |
|
| 89 | + if ( $next === '/' ) { |
|
| 90 | + $this->downStatus( 'line-comment' ); |
|
| 91 | + } elseif ( $next === '*' ) { |
|
| 92 | + $this->downStatus( 'block-comment' ); |
|
| 93 | 93 | } |
| 94 | 94 | break; |
| 95 | 95 | } |
| 96 | 96 | break; |
| 97 | 97 | |
| 98 | 98 | case "'": |
| 99 | - switch ($this->status()) { |
|
| 99 | + switch ( $this->status() ) { |
|
| 100 | 100 | case 'simple-quote': |
| 101 | 101 | $this->upStatus(); |
| 102 | 102 | break; |
@@ -108,13 +108,13 @@ discard block |
||
| 108 | 108 | break; |
| 109 | 109 | |
| 110 | 110 | default: |
| 111 | - $this->downStatus('simple-quote'); |
|
| 111 | + $this->downStatus( 'simple-quote' ); |
|
| 112 | 112 | break; |
| 113 | 113 | } |
| 114 | 114 | break; |
| 115 | 115 | |
| 116 | 116 | case '"': |
| 117 | - switch ($this->status()) { |
|
| 117 | + switch ( $this->status() ) { |
|
| 118 | 118 | case 'double-quote': |
| 119 | 119 | $this->upStatus(); |
| 120 | 120 | break; |
@@ -126,13 +126,13 @@ discard block |
||
| 126 | 126 | break; |
| 127 | 127 | |
| 128 | 128 | default: |
| 129 | - $this->downStatus('double-quote'); |
|
| 129 | + $this->downStatus( 'double-quote' ); |
|
| 130 | 130 | break; |
| 131 | 131 | } |
| 132 | 132 | break; |
| 133 | 133 | |
| 134 | 134 | case '`': |
| 135 | - switch ($this->status()) { |
|
| 135 | + switch ( $this->status() ) { |
|
| 136 | 136 | case 'back-tick': |
| 137 | 137 | $this->upStatus(); |
| 138 | 138 | break; |
@@ -144,13 +144,13 @@ discard block |
||
| 144 | 144 | break; |
| 145 | 145 | |
| 146 | 146 | default: |
| 147 | - $this->downStatus('back-tick'); |
|
| 147 | + $this->downStatus( 'back-tick' ); |
|
| 148 | 148 | break; |
| 149 | 149 | } |
| 150 | 150 | break; |
| 151 | 151 | |
| 152 | 152 | case '(': |
| 153 | - switch ($this->status()) { |
|
| 153 | + switch ( $this->status() ) { |
|
| 154 | 154 | case 'simple-quote': |
| 155 | 155 | case 'double-quote': |
| 156 | 156 | case 'back-tick': |
@@ -159,9 +159,9 @@ discard block |
||
| 159 | 159 | break; |
| 160 | 160 | |
| 161 | 161 | default: |
| 162 | - if ($buffer && preg_match('/(\w+)$/', $buffer, $matches)) { |
|
| 163 | - $this->downStatus('function'); |
|
| 164 | - array_unshift($bufferFunctions, [$matches[1], $line, []]); |
|
| 162 | + if ( $buffer && preg_match( '/(\w+)$/', $buffer, $matches ) ) { |
|
| 163 | + $this->downStatus( 'function' ); |
|
| 164 | + array_unshift( $bufferFunctions, [ $matches[ 1 ], $line, [ ] ] ); |
|
| 165 | 165 | $buffer = ''; |
| 166 | 166 | continue 3; |
| 167 | 167 | } |
@@ -170,14 +170,14 @@ discard block |
||
| 170 | 170 | break; |
| 171 | 171 | |
| 172 | 172 | case ')': |
| 173 | - switch ($this->status()) { |
|
| 173 | + switch ( $this->status() ) { |
|
| 174 | 174 | case 'function': |
| 175 | - if (($argument = static::prepareArgument($buffer))) { |
|
| 176 | - $bufferFunctions[0][2][] = $argument; |
|
| 175 | + if ( ( $argument = static::prepareArgument( $buffer ) ) ) { |
|
| 176 | + $bufferFunctions[ 0 ][ 2 ][ ] = $argument; |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - if (!empty($bufferFunctions)) { |
|
| 180 | - $functions[] = array_shift($bufferFunctions); |
|
| 179 | + if ( ! empty( $bufferFunctions ) ) { |
|
| 180 | + $functions[ ] = array_shift( $bufferFunctions ); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | $this->upStatus(); |
@@ -187,10 +187,10 @@ discard block |
||
| 187 | 187 | break; |
| 188 | 188 | |
| 189 | 189 | case ',': |
| 190 | - switch ($this->status()) { |
|
| 190 | + switch ( $this->status() ) { |
|
| 191 | 191 | case 'function': |
| 192 | - if (($argument = static::prepareArgument($buffer))) { |
|
| 193 | - $bufferFunctions[0][2][] = $argument; |
|
| 192 | + if ( ( $argument = static::prepareArgument( $buffer ) ) ) { |
|
| 193 | + $bufferFunctions[ 0 ][ 2 ][ ] = $argument; |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | $buffer = ''; |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | |
| 201 | 201 | case ' ': |
| 202 | 202 | case '\t': |
| 203 | - switch ($this->status()) { |
|
| 203 | + switch ( $this->status() ) { |
|
| 204 | 204 | case 'double-quote': |
| 205 | 205 | case 'simple-quote': |
| 206 | 206 | case 'back-tick': |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | break; |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - switch ($this->status()) { |
|
| 216 | + switch ( $this->status() ) { |
|
| 217 | 217 | case 'line-comment': |
| 218 | 218 | case 'block-comment': |
| 219 | 219 | break; |
@@ -234,11 +234,11 @@ discard block |
||
| 234 | 234 | * |
| 235 | 235 | * @return string|bool |
| 236 | 236 | */ |
| 237 | - protected function status($match = null) |
|
| 237 | + protected function status( $match = null ) |
|
| 238 | 238 | { |
| 239 | - $status = isset($this->status[0]) ? $this->status[0] : null; |
|
| 239 | + $status = isset( $this->status[ 0 ] ) ? $this->status[ 0 ] : null; |
|
| 240 | 240 | |
| 241 | - if ($match !== null) { |
|
| 241 | + if ( $match !== null ) { |
|
| 242 | 242 | return $status === $match; |
| 243 | 243 | } |
| 244 | 244 | |
@@ -250,9 +250,9 @@ discard block |
||
| 250 | 250 | * |
| 251 | 251 | * @param string $status |
| 252 | 252 | */ |
| 253 | - protected function downStatus($status) |
|
| 253 | + protected function downStatus( $status ) |
|
| 254 | 254 | { |
| 255 | - array_unshift($this->status, $status); |
|
| 255 | + array_unshift( $this->status, $status ); |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | /** |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | */ |
| 263 | 263 | protected function upStatus() |
| 264 | 264 | { |
| 265 | - return array_shift($this->status); |
|
| 265 | + return array_shift( $this->status ); |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | /** |
@@ -272,10 +272,10 @@ discard block |
||
| 272 | 272 | * |
| 273 | 273 | * @return string |
| 274 | 274 | */ |
| 275 | - protected static function prepareArgument($argument) |
|
| 275 | + protected static function prepareArgument( $argument ) |
|
| 276 | 276 | { |
| 277 | - if ($argument && in_array($argument[0], ['"', "'", '`'], true)) { |
|
| 278 | - return static::convertString(substr($argument, 1, -1)); |
|
| 277 | + if ( $argument && in_array( $argument[ 0 ], [ '"', "'", '`' ], true ) ) { |
|
| 278 | + return static::convertString( substr( $argument, 1, -1 ) ); |
|
| 279 | 279 | } |
| 280 | 280 | } |
| 281 | 281 | |
@@ -286,16 +286,16 @@ discard block |
||
| 286 | 286 | * |
| 287 | 287 | * @return string |
| 288 | 288 | */ |
| 289 | - protected static function convertString($value) |
|
| 289 | + protected static function convertString( $value ) |
|
| 290 | 290 | { |
| 291 | - if (strpos($value, '\\') === false) { |
|
| 291 | + if ( strpos( $value, '\\' ) === false ) { |
|
| 292 | 292 | return $value; |
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | return preg_replace_callback( |
| 296 | 296 | '/\\\(n|r|t|v|e|f|"|\\\)/', |
| 297 | - function ($match) { |
|
| 298 | - switch ($match[1][0]) { |
|
| 297 | + function( $match ) { |
|
| 298 | + switch ( $match[ 1 ][ 0 ] ) { |
|
| 299 | 299 | case 'n': |
| 300 | 300 | return "\n"; |
| 301 | 301 | case 'r': |
@@ -16,8 +16,8 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | protected static function supportsCsvEscapeChar() |
| 18 | 18 | { |
| 19 | - if (static::$csvEscapeChar === null) { |
|
| 20 | - static::$csvEscapeChar = version_compare(PHP_VERSION, '5.5.4') >= 0; |
|
| 19 | + if ( static::$csvEscapeChar === null ) { |
|
| 20 | + static::$csvEscapeChar = version_compare( PHP_VERSION, '5.5.4' ) >= 0; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | return static::$csvEscapeChar; |
@@ -29,13 +29,13 @@ discard block |
||
| 29 | 29 | * |
| 30 | 30 | * @return array |
| 31 | 31 | */ |
| 32 | - protected static function fgetcsv($handle, $options) |
|
| 32 | + protected static function fgetcsv( $handle, $options ) |
|
| 33 | 33 | { |
| 34 | - if (static::supportsCsvEscapeChar()) { |
|
| 35 | - return fgetcsv($handle, 0, $options['delimiter'], $options['enclosure'], $options['escape_char']); |
|
| 34 | + if ( static::supportsCsvEscapeChar() ) { |
|
| 35 | + return fgetcsv( $handle, 0, $options[ 'delimiter' ], $options[ 'enclosure' ], $options[ 'escape_char' ] ); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - return fgetcsv($handle, 0, $options['delimiter'], $options['enclosure']); |
|
| 38 | + return fgetcsv( $handle, 0, $options[ 'delimiter' ], $options[ 'enclosure' ] ); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -45,12 +45,12 @@ discard block |
||
| 45 | 45 | * |
| 46 | 46 | * @return bool|int |
| 47 | 47 | */ |
| 48 | - protected static function fputcsv($handle, $fields, $options) |
|
| 48 | + protected static function fputcsv( $handle, $fields, $options ) |
|
| 49 | 49 | { |
| 50 | - if (static::supportsCsvEscapeChar()) { |
|
| 51 | - return fputcsv($handle, $fields, $options['delimiter'], $options['enclosure'], $options['escape_char']); |
|
| 50 | + if ( static::supportsCsvEscapeChar() ) { |
|
| 51 | + return fputcsv( $handle, $fields, $options[ 'delimiter' ], $options[ 'enclosure' ], $options[ 'escape_char' ] ); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - return fputcsv($handle, $fields, $options['delimiter'], $options['enclosure']); |
|
| 54 | + return fputcsv( $handle, $fields, $options[ 'delimiter' ], $options[ 'enclosure' ] ); |
|
| 55 | 55 | } |
| 56 | 56 | } |
@@ -13,10 +13,10 @@ discard block |
||
| 13 | 13 | * |
| 14 | 14 | * @param string $str The string to read |
| 15 | 15 | */ |
| 16 | - public function __construct($str) |
|
| 16 | + public function __construct( $str ) |
|
| 17 | 17 | { |
| 18 | 18 | $this->str = $str; |
| 19 | - $this->strlen = strlen($this->str); |
|
| 19 | + $this->strlen = strlen( $this->str ); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -26,11 +26,11 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @return string |
| 28 | 28 | */ |
| 29 | - public function read($bytes) |
|
| 29 | + public function read( $bytes ) |
|
| 30 | 30 | { |
| 31 | - $data = substr($this->str, $this->pos, $bytes); |
|
| 31 | + $data = substr( $this->str, $this->pos, $bytes ); |
|
| 32 | 32 | |
| 33 | - $this->seekto($this->pos + $bytes); |
|
| 33 | + $this->seekto( $this->pos + $bytes ); |
|
| 34 | 34 | |
| 35 | 35 | return $data; |
| 36 | 36 | } |
@@ -42,9 +42,9 @@ discard block |
||
| 42 | 42 | * |
| 43 | 43 | * @return int The new position |
| 44 | 44 | */ |
| 45 | - public function seekto($pos) |
|
| 45 | + public function seekto( $pos ) |
|
| 46 | 46 | { |
| 47 | - $this->pos = ($this->strlen < $pos) ? $this->strlen : $pos; |
|
| 47 | + $this->pos = ( $this->strlen < $pos ) ? $this->strlen : $pos; |
|
| 48 | 48 | |
| 49 | 49 | return $this->pos; |
| 50 | 50 | } |
@@ -55,11 +55,11 @@ discard block |
||
| 55 | 55 | * @param string $name The function name. |
| 56 | 56 | * @param int $line The line where the function starts. |
| 57 | 57 | */ |
| 58 | - public function __construct($name, $line) |
|
| 58 | + public function __construct( $name, $line ) |
|
| 59 | 59 | { |
| 60 | 60 | $this->name = $name; |
| 61 | 61 | $this->line = $line; |
| 62 | - $this->arguments = []; |
|
| 62 | + $this->arguments = [ ]; |
|
| 63 | 63 | $this->argumentIndex = -1; |
| 64 | 64 | $this->argumentStopped = false; |
| 65 | 65 | $this->comments = null; |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | public function stopArgument() |
| 72 | 72 | { |
| 73 | - if ($this->argumentIndex === -1) { |
|
| 73 | + if ( $this->argumentIndex === -1 ) { |
|
| 74 | 74 | $this->argumentIndex = 0; |
| 75 | 75 | } |
| 76 | 76 | $this->argumentStopped = true; |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | public function nextArgument() |
| 83 | 83 | { |
| 84 | - if ($this->argumentIndex === -1) { |
|
| 84 | + if ( $this->argumentIndex === -1 ) { |
|
| 85 | 85 | // This should neve occur, but let's stay safe - During test/development an Exception should be thrown. |
| 86 | 86 | $this->argumentIndex = 1; |
| 87 | 87 | } else { |
@@ -95,16 +95,16 @@ discard block |
||
| 95 | 95 | * |
| 96 | 96 | * @param string|null $chunk |
| 97 | 97 | */ |
| 98 | - public function addArgumentChunk($chunk) |
|
| 98 | + public function addArgumentChunk( $chunk ) |
|
| 99 | 99 | { |
| 100 | - if ($this->argumentStopped === false) { |
|
| 101 | - if ($this->argumentIndex === -1) { |
|
| 100 | + if ( $this->argumentStopped === false ) { |
|
| 101 | + if ( $this->argumentIndex === -1 ) { |
|
| 102 | 102 | $this->argumentIndex = 0; |
| 103 | 103 | } |
| 104 | - if (isset($this->arguments[$this->argumentIndex])) { |
|
| 105 | - $this->arguments[$this->argumentIndex] .= $chunk; |
|
| 104 | + if ( isset( $this->arguments[ $this->argumentIndex ] ) ) { |
|
| 105 | + $this->arguments[ $this->argumentIndex ] .= $chunk; |
|
| 106 | 106 | } else { |
| 107 | - $this->arguments[$this->argumentIndex] = $chunk; |
|
| 107 | + $this->arguments[ $this->argumentIndex ] = $chunk; |
|
| 108 | 108 | } |
| 109 | 109 | } |
| 110 | 110 | } |
@@ -114,12 +114,12 @@ discard block |
||
| 114 | 114 | * |
| 115 | 115 | * @param ParsedComment $comment |
| 116 | 116 | */ |
| 117 | - public function addComment($comment) |
|
| 117 | + public function addComment( $comment ) |
|
| 118 | 118 | { |
| 119 | - if ($this->comments === null) { |
|
| 120 | - $this->comments = []; |
|
| 119 | + if ( $this->comments === null ) { |
|
| 120 | + $this->comments = [ ]; |
|
| 121 | 121 | } |
| 122 | - $this->comments[] = $comment; |
|
| 122 | + $this->comments[ ] = $comment; |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | /** |
@@ -144,9 +144,9 @@ discard block |
||
| 144 | 144 | */ |
| 145 | 145 | public function close() |
| 146 | 146 | { |
| 147 | - $arguments = []; |
|
| 148 | - for ($i = 0; $i <= $this->argumentIndex; ++$i) { |
|
| 149 | - $arguments[$i] = isset($this->arguments[$i]) ? $this->arguments[$i] : null; |
|
| 147 | + $arguments = [ ]; |
|
| 148 | + for ( $i = 0; $i <= $this->argumentIndex; ++$i ) { |
|
| 149 | + $arguments[ $i ] = isset( $this->arguments[ $i ] ) ? $this->arguments[ $i ] : null; |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | return [ |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | * |
| 26 | 26 | * @param mixed $tag |
| 27 | 27 | */ |
| 28 | - public function enableCommentsExtraction($tag = '') |
|
| 28 | + public function enableCommentsExtraction( $tag = '' ) |
|
| 29 | 29 | { |
| 30 | 30 | $this->extractComments = $tag; |
| 31 | 31 | } |
@@ -43,13 +43,13 @@ discard block |
||
| 43 | 43 | * |
| 44 | 44 | * @param string $code The php code to scan |
| 45 | 45 | */ |
| 46 | - public function __construct($code) |
|
| 46 | + public function __construct( $code ) |
|
| 47 | 47 | { |
| 48 | 48 | $this->tokens = array_values( |
| 49 | 49 | array_filter( |
| 50 | - token_get_all($code), |
|
| 51 | - function ($token) { |
|
| 52 | - return !is_array($token) || $token[0] !== T_WHITESPACE; |
|
| 50 | + token_get_all( $code ), |
|
| 51 | + function( $token ) { |
|
| 52 | + return ! is_array( $token ) || $token[ 0 ] !== T_WHITESPACE; |
|
| 53 | 53 | } |
| 54 | 54 | ) |
| 55 | 55 | ); |
@@ -58,82 +58,82 @@ discard block |
||
| 58 | 58 | /** |
| 59 | 59 | * {@inheritdoc} |
| 60 | 60 | */ |
| 61 | - public function getFunctions(array $constants = []) |
|
| 61 | + public function getFunctions( array $constants = [ ] ) |
|
| 62 | 62 | { |
| 63 | - $count = count($this->tokens); |
|
| 63 | + $count = count( $this->tokens ); |
|
| 64 | 64 | /* @var ParsedFunction[] $bufferFunctions */ |
| 65 | - $bufferFunctions = []; |
|
| 65 | + $bufferFunctions = [ ]; |
|
| 66 | 66 | /* @var ParsedComment[] $bufferComments */ |
| 67 | - $bufferComments = []; |
|
| 67 | + $bufferComments = [ ]; |
|
| 68 | 68 | /* @var array $functions */ |
| 69 | - $functions = []; |
|
| 69 | + $functions = [ ]; |
|
| 70 | 70 | |
| 71 | - for ($k = 0; $k < $count; ++$k) { |
|
| 72 | - $value = $this->tokens[$k]; |
|
| 71 | + for ( $k = 0; $k < $count; ++$k ) { |
|
| 72 | + $value = $this->tokens[ $k ]; |
|
| 73 | 73 | |
| 74 | - if (is_string($value)) { |
|
| 75 | - if (isset($bufferFunctions[0])) { |
|
| 76 | - switch ($value) { |
|
| 74 | + if ( is_string( $value ) ) { |
|
| 75 | + if ( isset( $bufferFunctions[ 0 ] ) ) { |
|
| 76 | + switch ( $value ) { |
|
| 77 | 77 | case ',': |
| 78 | - $bufferFunctions[0]->nextArgument(); |
|
| 78 | + $bufferFunctions[ 0 ]->nextArgument(); |
|
| 79 | 79 | break; |
| 80 | 80 | case ')': |
| 81 | - $functions[] = array_shift($bufferFunctions)->close(); |
|
| 81 | + $functions[ ] = array_shift( $bufferFunctions )->close(); |
|
| 82 | 82 | break; |
| 83 | 83 | case '.': |
| 84 | 84 | break; |
| 85 | 85 | default: |
| 86 | - $bufferFunctions[0]->stopArgument(); |
|
| 86 | + $bufferFunctions[ 0 ]->stopArgument(); |
|
| 87 | 87 | break; |
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | continue; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - switch ($value[0]) { |
|
| 93 | + switch ( $value[ 0 ] ) { |
|
| 94 | 94 | case T_CONSTANT_ENCAPSED_STRING: |
| 95 | 95 | //add an argument to the current function |
| 96 | - if (isset($bufferFunctions[0])) { |
|
| 97 | - $bufferFunctions[0]->addArgumentChunk(PhpCode::convertString($value[1])); |
|
| 96 | + if ( isset( $bufferFunctions[ 0 ] ) ) { |
|
| 97 | + $bufferFunctions[ 0 ]->addArgumentChunk( PhpCode::convertString( $value[ 1 ] ) ); |
|
| 98 | 98 | } |
| 99 | 99 | break; |
| 100 | 100 | |
| 101 | 101 | case T_STRING: |
| 102 | - if (isset($bufferFunctions[0])) { |
|
| 103 | - if (isset($constants[$value[1]])) { |
|
| 104 | - $bufferFunctions[0]->addArgumentChunk($constants[$value[1]]); |
|
| 102 | + if ( isset( $bufferFunctions[ 0 ] ) ) { |
|
| 103 | + if ( isset( $constants[ $value[ 1 ] ] ) ) { |
|
| 104 | + $bufferFunctions[ 0 ]->addArgumentChunk( $constants[ $value[ 1 ] ] ); |
|
| 105 | 105 | break; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - if (strtolower($value[1]) === 'null') { |
|
| 109 | - $bufferFunctions[0]->addArgumentChunk(null); |
|
| 108 | + if ( strtolower( $value[ 1 ] ) === 'null' ) { |
|
| 109 | + $bufferFunctions[ 0 ]->addArgumentChunk( null ); |
|
| 110 | 110 | break; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - $bufferFunctions[0]->stopArgument(); |
|
| 113 | + $bufferFunctions[ 0 ]->stopArgument(); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | //new function found |
| 117 | - for ($j = $k + 1; $j < $count; ++$j) { |
|
| 118 | - $nextToken = $this->tokens[$j]; |
|
| 117 | + for ( $j = $k + 1; $j < $count; ++$j ) { |
|
| 118 | + $nextToken = $this->tokens[ $j ]; |
|
| 119 | 119 | |
| 120 | - if (is_array($nextToken) && $nextToken[0] === T_COMMENT) { |
|
| 120 | + if ( is_array( $nextToken ) && $nextToken[ 0 ] === T_COMMENT ) { |
|
| 121 | 121 | continue; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - if ($nextToken === '(') { |
|
| 125 | - $newFunction = new ParsedFunction($value[1], $value[2]); |
|
| 124 | + if ( $nextToken === '(' ) { |
|
| 125 | + $newFunction = new ParsedFunction( $value[ 1 ], $value[ 2 ] ); |
|
| 126 | 126 | |
| 127 | 127 | // add comment that was on the line before. |
| 128 | - if (isset($bufferComments[0])) { |
|
| 129 | - $comment = $bufferComments[0]; |
|
| 128 | + if ( isset( $bufferComments[ 0 ] ) ) { |
|
| 129 | + $comment = $bufferComments[ 0 ]; |
|
| 130 | 130 | |
| 131 | - if ($comment->isRelatedWith($newFunction)) { |
|
| 132 | - $newFunction->addComment($comment); |
|
| 131 | + if ( $comment->isRelatedWith( $newFunction ) ) { |
|
| 132 | + $newFunction->addComment( $comment ); |
|
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - array_unshift($bufferFunctions, $newFunction); |
|
| 136 | + array_unshift( $bufferFunctions, $newFunction ); |
|
| 137 | 137 | $k = $j; |
| 138 | 138 | } |
| 139 | 139 | break; |
@@ -141,21 +141,21 @@ discard block |
||
| 141 | 141 | break; |
| 142 | 142 | |
| 143 | 143 | case T_COMMENT: |
| 144 | - $comment = $this->parsePhpComment($value[1], $value[2]); |
|
| 144 | + $comment = $this->parsePhpComment( $value[ 1 ], $value[ 2 ] ); |
|
| 145 | 145 | |
| 146 | - if ($comment) { |
|
| 147 | - array_unshift($bufferComments, $comment); |
|
| 146 | + if ( $comment ) { |
|
| 147 | + array_unshift( $bufferComments, $comment ); |
|
| 148 | 148 | |
| 149 | 149 | // The comment is inside the function call. |
| 150 | - if (isset($bufferFunctions[0])) { |
|
| 151 | - $bufferFunctions[0]->addComment($comment); |
|
| 150 | + if ( isset( $bufferFunctions[ 0 ] ) ) { |
|
| 151 | + $bufferFunctions[ 0 ]->addComment( $comment ); |
|
| 152 | 152 | } |
| 153 | 153 | } |
| 154 | 154 | break; |
| 155 | 155 | |
| 156 | 156 | default: |
| 157 | - if (isset($bufferFunctions[0])) { |
|
| 158 | - $bufferFunctions[0]->stopArgument(); |
|
| 157 | + if ( isset( $bufferFunctions[ 0 ] ) ) { |
|
| 158 | + $bufferFunctions[ 0 ]->stopArgument(); |
|
| 159 | 159 | } |
| 160 | 160 | break; |
| 161 | 161 | } |
@@ -174,18 +174,18 @@ discard block |
||
| 174 | 174 | * |
| 175 | 175 | * @return null|ParsedComment Comment or null if comment extraction is disabled or if there is a prefix mismatch. |
| 176 | 176 | */ |
| 177 | - protected function parsePhpComment($value, $line) |
|
| 177 | + protected function parsePhpComment( $value, $line ) |
|
| 178 | 178 | { |
| 179 | - if ($this->extractComments === false) { |
|
| 179 | + if ( $this->extractComments === false ) { |
|
| 180 | 180 | return null; |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | //this returns a comment or null |
| 184 | - $comment = ParsedComment::create($value, $line); |
|
| 184 | + $comment = ParsedComment::create( $value, $line ); |
|
| 185 | 185 | |
| 186 | - $prefixes = array_filter((array) $this->extractComments); |
|
| 186 | + $prefixes = array_filter( (array)$this->extractComments ); |
|
| 187 | 187 | |
| 188 | - if ($comment && $comment->checkPrefixes($prefixes)) { |
|
| 188 | + if ( $comment && $comment->checkPrefixes( $prefixes ) ) { |
|
| 189 | 189 | return $comment; |
| 190 | 190 | } |
| 191 | 191 | |
@@ -17,25 +17,25 @@ discard block |
||
| 17 | 17 | * |
| 18 | 18 | * @return array |
| 19 | 19 | */ |
| 20 | - protected static function extractHeaders($headers, Translations $translations) |
|
| 20 | + protected static function extractHeaders( $headers, Translations $translations ) |
|
| 21 | 21 | { |
| 22 | - $headers = explode("\n", $headers); |
|
| 22 | + $headers = explode( "\n", $headers ); |
|
| 23 | 23 | $currentHeader = null; |
| 24 | 24 | |
| 25 | - foreach ($headers as $line) { |
|
| 26 | - $line = static::convertString($line); |
|
| 25 | + foreach ( $headers as $line ) { |
|
| 26 | + $line = static::convertString( $line ); |
|
| 27 | 27 | |
| 28 | - if ($line === '') { |
|
| 28 | + if ( $line === '' ) { |
|
| 29 | 29 | continue; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - if (static::isHeaderDefinition($line)) { |
|
| 33 | - $header = array_map('trim', explode(':', $line, 2)); |
|
| 34 | - $currentHeader = $header[0]; |
|
| 35 | - $translations->setHeader($currentHeader, $header[1]); |
|
| 32 | + if ( static::isHeaderDefinition( $line ) ) { |
|
| 33 | + $header = array_map( 'trim', explode( ':', $line, 2 ) ); |
|
| 34 | + $currentHeader = $header[ 0 ]; |
|
| 35 | + $translations->setHeader( $currentHeader, $header[ 1 ] ); |
|
| 36 | 36 | } else { |
| 37 | - $entry = $translations->getHeader($currentHeader); |
|
| 38 | - $translations->setHeader($currentHeader, $entry.$line); |
|
| 37 | + $entry = $translations->getHeader( $currentHeader ); |
|
| 38 | + $translations->setHeader( $currentHeader, $entry . $line ); |
|
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | 41 | } |
@@ -48,9 +48,9 @@ discard block |
||
| 48 | 48 | * |
| 49 | 49 | * @return bool |
| 50 | 50 | */ |
| 51 | - protected static function isHeaderDefinition($line) |
|
| 51 | + protected static function isHeaderDefinition( $line ) |
|
| 52 | 52 | { |
| 53 | - return (bool) preg_match('/^[\w-]+:/', $line); |
|
| 53 | + return (bool)preg_match( '/^[\w-]+:/', $line ); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /** |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * |
| 61 | 61 | * @return string |
| 62 | 62 | */ |
| 63 | - public static function convertString($value) |
|
| 63 | + public static function convertString( $value ) |
|
| 64 | 64 | { |
| 65 | 65 | return $value; |
| 66 | 66 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * @param int $firstLine The line where the comment starts. |
| 36 | 36 | * @param int $lastLine The line where the comment ends. |
| 37 | 37 | */ |
| 38 | - public function __construct($comment, $firstLine, $lastLine) |
|
| 38 | + public function __construct( $comment, $firstLine, $lastLine ) |
|
| 39 | 39 | { |
| 40 | 40 | $this->comment = $comment; |
| 41 | 41 | $this->firstLine = $firstLine; |
@@ -50,26 +50,26 @@ discard block |
||
| 50 | 50 | * |
| 51 | 51 | * @return static The parsed comment. |
| 52 | 52 | */ |
| 53 | - public static function create($value, $line) |
|
| 53 | + public static function create( $value, $line ) |
|
| 54 | 54 | { |
| 55 | - $lastLine = $line + substr_count($value, "\n"); |
|
| 55 | + $lastLine = $line + substr_count( $value, "\n" ); |
|
| 56 | 56 | |
| 57 | - $lines = array_map(function ($line) { |
|
| 58 | - if ('' === trim($line)) { |
|
| 57 | + $lines = array_map( function( $line ) { |
|
| 58 | + if ( '' === trim( $line ) ) { |
|
| 59 | 59 | return null; |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - $line = ltrim($line, "#*/ \t"); |
|
| 63 | - $line = rtrim($line, "#*/ \t"); |
|
| 62 | + $line = ltrim( $line, "#*/ \t" ); |
|
| 63 | + $line = rtrim( $line, "#*/ \t" ); |
|
| 64 | 64 | |
| 65 | - return trim($line); |
|
| 66 | - }, explode("\n", $value)); |
|
| 65 | + return trim( $line ); |
|
| 66 | + }, explode( "\n", $value ) ); |
|
| 67 | 67 | |
| 68 | 68 | // Remove empty lines. |
| 69 | - $lines = array_filter($lines); |
|
| 70 | - $value = implode(' ', $lines); |
|
| 69 | + $lines = array_filter( $lines ); |
|
| 70 | + $value = implode( ' ', $lines ); |
|
| 71 | 71 | |
| 72 | - return new static($value, $line, $lastLine); |
|
| 72 | + return new static( $value, $line, $lastLine ); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | * @param ParsedFunction $function The function to check. |
| 109 | 109 | * @return bool Whether the comment is related or not. |
| 110 | 110 | */ |
| 111 | - public function isRelatedWith(ParsedFunction $function) |
|
| 111 | + public function isRelatedWith( ParsedFunction $function ) |
|
| 112 | 112 | { |
| 113 | 113 | return $this->getLastLine() === $function->getLine() || $this->getLastLine() === $function->getLine() - 1; |
| 114 | 114 | } |
@@ -119,18 +119,18 @@ discard block |
||
| 119 | 119 | * @param array $prefixes An array of prefixes to check. |
| 120 | 120 | * @return bool Whether the comment matches the prefixes or not. |
| 121 | 121 | */ |
| 122 | - public function checkPrefixes(array $prefixes) |
|
| 122 | + public function checkPrefixes( array $prefixes ) |
|
| 123 | 123 | { |
| 124 | - if ('' === $this->comment) { |
|
| 124 | + if ( '' === $this->comment ) { |
|
| 125 | 125 | return false; |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - if (empty($prefixes)) { |
|
| 128 | + if ( empty( $prefixes ) ) { |
|
| 129 | 129 | return true; |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - foreach ($prefixes as $prefix) { |
|
| 133 | - if (strpos($this->comment, $prefix) === 0) { |
|
| 132 | + foreach ( $prefixes as $prefix ) { |
|
| 133 | + if ( strpos( $this->comment, $prefix ) === 0 ) { |
|
| 134 | 134 | return true; |
| 135 | 135 | } |
| 136 | 136 | } |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | * |
| 15 | 15 | * @return array |
| 16 | 16 | */ |
| 17 | - abstract public function getFunctions(array $constants = []); |
|
| 17 | + abstract public function getFunctions( array $constants = [ ] ); |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * Search for specific functions and create translations. |
@@ -25,18 +25,18 @@ discard block |
||
| 25 | 25 | * @param array $options The extractor options |
| 26 | 26 | * @throws Exception |
| 27 | 27 | */ |
| 28 | - public function saveGettextFunctions($translations, array $options) |
|
| 28 | + public function saveGettextFunctions( $translations, array $options ) |
|
| 29 | 29 | { |
| 30 | - $translations = is_array($translations) ? $translations : [$translations]; |
|
| 30 | + $translations = is_array( $translations ) ? $translations : [ $translations ]; |
|
| 31 | 31 | |
| 32 | 32 | /** @var Translations[] $translationByDomain [domain => translations, ..] */ |
| 33 | - $translationByDomain = array_reduce($translations, function ($carry, Translations $translations) { |
|
| 34 | - $carry[$translations->getDomain()] = $translations; |
|
| 33 | + $translationByDomain = array_reduce( $translations, function( $carry, Translations $translations ) { |
|
| 34 | + $carry[ $translations->getDomain() ] = $translations; |
|
| 35 | 35 | return $carry; |
| 36 | - }, []); |
|
| 36 | + }, [ ] ); |
|
| 37 | 37 | |
| 38 | - $functions = $options['functions']; |
|
| 39 | - $file = $options['file']; |
|
| 38 | + $functions = $options[ 'functions' ]; |
|
| 39 | + $file = $options[ 'file' ]; |
|
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | 42 | * List of source code comments already associated with a function. |
@@ -45,55 +45,55 @@ discard block |
||
| 45 | 45 | * |
| 46 | 46 | * @var ParsedComment[] $commentsCache |
| 47 | 47 | */ |
| 48 | - $commentsCache = []; |
|
| 48 | + $commentsCache = [ ]; |
|
| 49 | 49 | |
| 50 | - foreach ($this->getFunctions($options['constants']) as $function) { |
|
| 51 | - list($name, $line, $args) = $function; |
|
| 50 | + foreach ( $this->getFunctions( $options[ 'constants' ] ) as $function ) { |
|
| 51 | + list( $name, $line, $args ) = $function; |
|
| 52 | 52 | |
| 53 | - if (isset($options['lineOffset'])) { |
|
| 54 | - $line += $options['lineOffset']; |
|
| 53 | + if ( isset( $options[ 'lineOffset' ] ) ) { |
|
| 54 | + $line += $options[ 'lineOffset' ]; |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - if (!isset($functions[$name])) { |
|
| 57 | + if ( ! isset( $functions[ $name ] ) ) { |
|
| 58 | 58 | continue; |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - $deconstructed = $this->deconstructArgs($functions[$name], $args); |
|
| 61 | + $deconstructed = $this->deconstructArgs( $functions[ $name ], $args ); |
|
| 62 | 62 | |
| 63 | - if (!$deconstructed) { |
|
| 63 | + if ( ! $deconstructed ) { |
|
| 64 | 64 | continue; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - list($domain, $context, $original, $plural) = $deconstructed; |
|
| 67 | + list( $domain, $context, $original, $plural ) = $deconstructed; |
|
| 68 | 68 | |
| 69 | - if ((string)$original === '') { |
|
| 69 | + if ( (string)$original === '' ) { |
|
| 70 | 70 | continue; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | $isDefaultDomain = $domain === null; |
| 74 | 74 | |
| 75 | - $domainTranslations = isset($translationByDomain[$domain]) ? $translationByDomain[$domain] : false; |
|
| 75 | + $domainTranslations = isset( $translationByDomain[ $domain ] ) ? $translationByDomain[ $domain ] : false; |
|
| 76 | 76 | |
| 77 | - if (!empty($options['domainOnly']) && $isDefaultDomain) { |
|
| 77 | + if ( ! empty( $options[ 'domainOnly' ] ) && $isDefaultDomain ) { |
|
| 78 | 78 | // If we want to find translations for a specific domain, skip default domain messages |
| 79 | 79 | continue; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - if (!$domainTranslations) { |
|
| 82 | + if ( ! $domainTranslations ) { |
|
| 83 | 83 | continue; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - $translation = $domainTranslations->insert($context, $original, $plural); |
|
| 87 | - $translation->addReference($file, $line); |
|
| 86 | + $translation = $domainTranslations->insert( $context, $original, $plural ); |
|
| 87 | + $translation->addReference( $file, $line ); |
|
| 88 | 88 | |
| 89 | - if (isset($function[3])) { |
|
| 89 | + if ( isset( $function[ 3 ] ) ) { |
|
| 90 | 90 | /* @var ParsedComment $extractedComment */ |
| 91 | - foreach ($function[3] as $extractedComment) { |
|
| 92 | - if (in_array($extractedComment, $commentsCache, true)) { |
|
| 91 | + foreach ( $function[ 3 ] as $extractedComment ) { |
|
| 92 | + if ( in_array( $extractedComment, $commentsCache, true ) ) { |
|
| 93 | 93 | continue; |
| 94 | 94 | } |
| 95 | - $translation->addExtractedComment($extractedComment->getComment()); |
|
| 96 | - $commentsCache[] = $extractedComment; |
|
| 95 | + $translation->addExtractedComment( $extractedComment->getComment() ); |
|
| 96 | + $commentsCache[ ] = $extractedComment; |
|
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | 99 | } |
@@ -107,75 +107,75 @@ discard block |
||
| 107 | 107 | * @return array|null |
| 108 | 108 | * @throws Exception |
| 109 | 109 | */ |
| 110 | - protected function deconstructArgs($function, $args) |
|
| 110 | + protected function deconstructArgs( $function, $args ) |
|
| 111 | 111 | { |
| 112 | 112 | $domain = null; |
| 113 | 113 | $context = null; |
| 114 | 114 | $original = null; |
| 115 | 115 | $plural = null; |
| 116 | 116 | |
| 117 | - switch ($function) { |
|
| 117 | + switch ( $function ) { |
|
| 118 | 118 | case 'noop': |
| 119 | 119 | case 'gettext': |
| 120 | - if (!isset($args[0])) { |
|
| 120 | + if ( ! isset( $args[ 0 ] ) ) { |
|
| 121 | 121 | return null; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - $original = $args[0]; |
|
| 124 | + $original = $args[ 0 ]; |
|
| 125 | 125 | break; |
| 126 | 126 | case 'ngettext': |
| 127 | - if (!isset($args[1])) { |
|
| 127 | + if ( ! isset( $args[ 1 ] ) ) { |
|
| 128 | 128 | return null; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - list($original, $plural) = $args; |
|
| 131 | + list( $original, $plural ) = $args; |
|
| 132 | 132 | break; |
| 133 | 133 | case 'pgettext': |
| 134 | - if (!isset($args[1])) { |
|
| 134 | + if ( ! isset( $args[ 1 ] ) ) { |
|
| 135 | 135 | return null; |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - list($context, $original) = $args; |
|
| 138 | + list( $context, $original ) = $args; |
|
| 139 | 139 | break; |
| 140 | 140 | case 'dgettext': |
| 141 | - if (!isset($args[1])) { |
|
| 141 | + if ( ! isset( $args[ 1 ] ) ) { |
|
| 142 | 142 | return null; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - list($domain, $original) = $args; |
|
| 145 | + list( $domain, $original ) = $args; |
|
| 146 | 146 | break; |
| 147 | 147 | case 'dpgettext': |
| 148 | - if (!isset($args[2])) { |
|
| 148 | + if ( ! isset( $args[ 2 ] ) ) { |
|
| 149 | 149 | return null; |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - list($domain, $context, $original) = $args; |
|
| 152 | + list( $domain, $context, $original ) = $args; |
|
| 153 | 153 | break; |
| 154 | 154 | case 'npgettext': |
| 155 | - if (!isset($args[2])) { |
|
| 155 | + if ( ! isset( $args[ 2 ] ) ) { |
|
| 156 | 156 | return null; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - list($context, $original, $plural) = $args; |
|
| 159 | + list( $context, $original, $plural ) = $args; |
|
| 160 | 160 | break; |
| 161 | 161 | case 'dnpgettext': |
| 162 | - if (!isset($args[3])) { |
|
| 162 | + if ( ! isset( $args[ 3 ] ) ) { |
|
| 163 | 163 | return null; |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - list($domain, $context, $original, $plural) = $args; |
|
| 166 | + list( $domain, $context, $original, $plural ) = $args; |
|
| 167 | 167 | break; |
| 168 | 168 | case 'dngettext': |
| 169 | - if (!isset($args[2])) { |
|
| 169 | + if ( ! isset( $args[ 2 ] ) ) { |
|
| 170 | 170 | return null; |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - list($domain, $original, $plural) = $args; |
|
| 173 | + list( $domain, $original, $plural ) = $args; |
|
| 174 | 174 | break; |
| 175 | 175 | default: |
| 176 | - throw new Exception(sprintf('Not valid function %s', $function)); |
|
| 176 | + throw new Exception( sprintf( 'Not valid function %s', $function ) ); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - return [$domain, $context, $original, $plural]; |
|
| 179 | + return [ $domain, $context, $original, $plural ]; |
|
| 180 | 180 | } |
| 181 | 181 | } |