Browse Source

Specify PHP 7.1 requirement

multi-byte
J. King 4 years ago
parent
commit
464bc4a0a9
  1. 2
      composer.json
  2. 9
      lib/Encoding/AbstractEncoding.php
  3. 2
      lib/Encoding/Encoding.php
  4. 4
      lib/Encoding/ISO2022JP.php
  5. 2
      lib/Encoding/Replacement.php

2
composer.json

@ -13,7 +13,7 @@
], ],
"require": { "require": {
"php": "^7.0" "php": "^7.1"
}, },
"require-dev": { "require-dev": {
"ext-intl": "*", "ext-intl": "*",

9
lib/Encoding/AbstractEncoding.php

@ -51,7 +51,7 @@ abstract class AbstractEncoding implements Encoding {
return $this->posChar; return $this->posChar;
} }
public function rewind() { public function rewind(): void {
$this->posByte = 0; $this->posByte = 0;
$this->posChar = 0; $this->posChar = 0;
$this->errMark = -1; $this->errMark = -1;
@ -163,7 +163,7 @@ abstract class AbstractEncoding implements Encoding {
} }
/** Sets the decoder's state to the values specified */ /** Sets the decoder's state to the values specified */
protected function stateApply(array $state) { protected function stateApply(array $state): void {
while (sizeof($this->errStack) > $state['errCount']) { while (sizeof($this->errStack) > $state['errCount']) {
list($this->errMark, $this->errSync) = array_pop($this->errStack); list($this->errMark, $this->errSync) = array_pop($this->errStack);
} }
@ -174,8 +174,7 @@ abstract class AbstractEncoding implements Encoding {
} }
/** Handles decoding errors */ /** Handles decoding errors */
protected function errDec(int $mode, int $charOffset, int $byteOffset) { protected function errDec(int $mode, int $charOffset, int $byteOffset): ?int {
assert(in_array($mode, [self::MODE_NULL, self::MODE_REPLACE, self::MODE_FATAL]), "Invalid error mode $mode");
if ($mode !== self::MODE_NULL) { if ($mode !== self::MODE_NULL) {
// expose the error to the user; this disambiguates a literal replacement character // expose the error to the user; this disambiguates a literal replacement character
$this->posErr = $this->posChar; $this->posErr = $this->posChar;
@ -195,7 +194,7 @@ abstract class AbstractEncoding implements Encoding {
} }
/** Handles encoding errors */ /** Handles encoding errors */
protected static function errEnc(bool $htmlMode, $data = null) { protected static function errEnc(bool $htmlMode, $data = null): string {
if ($htmlMode) { if ($htmlMode) {
return "&#".(string) $data.";"; return "&#".(string) $data.";";
} else { } else {

2
lib/Encoding/Encoding.php

@ -54,7 +54,7 @@ interface Encoding {
* *
* This is usually faster than using the seek method for the same purpose * This is usually faster than using the seek method for the same purpose
*/ */
public function rewind(); public function rewind(): void;
/** Retrieves the next $num characters (in UTF-8 encoding) from the string without advancing the character pointer /** Retrieves the next $num characters (in UTF-8 encoding) from the string without advancing the character pointer
* *

4
lib/Encoding/ISO2022JP.php

@ -178,7 +178,7 @@ class ISO2022JP extends AbstractEncoding implements Encoding {
return $out; return $out;
} }
protected function stateApply(array $state) { protected function stateApply(array $state): void {
while (sizeof($this->modeStack) > $state['modeCount']) { while (sizeof($this->modeStack) > $state['modeCount']) {
list($this->modeMark, $this->mode) = array_pop($this->modeStack); list($this->modeMark, $this->mode) = array_pop($this->modeStack);
} }
@ -186,7 +186,7 @@ class ISO2022JP extends AbstractEncoding implements Encoding {
parent::stateApply($state); parent::stateApply($state);
} }
public function rewind() { public function rewind(): void {
$this->modeStack = []; $this->modeStack = [];
$this->modeMark = \PHP_INT_MIN; $this->modeMark = \PHP_INT_MIN;
$this->mode = self::ASCII_STATE; $this->mode = self::ASCII_STATE;

2
lib/Encoding/Replacement.php

@ -75,7 +75,7 @@ class Replacement implements Encoding {
return $distance; return $distance;
} }
public function rewind() { public function rewind(): void {
$this->done = false; $this->done = false;
} }

Loading…
Cancel
Save