From 464bc4a0a962b2f1c606ef6d6feb52a161bb2648 Mon Sep 17 00:00:00 2001 From: "J. King" Date: Sat, 17 Oct 2020 17:55:26 -0400 Subject: [PATCH] Specify PHP 7.1 requirement --- composer.json | 2 +- lib/Encoding/AbstractEncoding.php | 9 ++++----- lib/Encoding/Encoding.php | 2 +- lib/Encoding/ISO2022JP.php | 4 ++-- lib/Encoding/Replacement.php | 2 +- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index 0896247..b6a63e7 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ ], "require": { - "php": "^7.0" + "php": "^7.1" }, "require-dev": { "ext-intl": "*", diff --git a/lib/Encoding/AbstractEncoding.php b/lib/Encoding/AbstractEncoding.php index f7790b8..6a60e05 100644 --- a/lib/Encoding/AbstractEncoding.php +++ b/lib/Encoding/AbstractEncoding.php @@ -51,7 +51,7 @@ abstract class AbstractEncoding implements Encoding { return $this->posChar; } - public function rewind() { + public function rewind(): void { $this->posByte = 0; $this->posChar = 0; $this->errMark = -1; @@ -163,7 +163,7 @@ abstract class AbstractEncoding implements Encoding { } /** 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']) { list($this->errMark, $this->errSync) = array_pop($this->errStack); } @@ -174,8 +174,7 @@ abstract class AbstractEncoding implements Encoding { } /** Handles decoding errors */ - protected function errDec(int $mode, int $charOffset, int $byteOffset) { - assert(in_array($mode, [self::MODE_NULL, self::MODE_REPLACE, self::MODE_FATAL]), "Invalid error mode $mode"); + protected function errDec(int $mode, int $charOffset, int $byteOffset): ?int { if ($mode !== self::MODE_NULL) { // expose the error to the user; this disambiguates a literal replacement character $this->posErr = $this->posChar; @@ -195,7 +194,7 @@ abstract class AbstractEncoding implements Encoding { } /** Handles encoding errors */ - protected static function errEnc(bool $htmlMode, $data = null) { + protected static function errEnc(bool $htmlMode, $data = null): string { if ($htmlMode) { return "&#".(string) $data.";"; } else { diff --git a/lib/Encoding/Encoding.php b/lib/Encoding/Encoding.php index d20bfef..ac08bb0 100644 --- a/lib/Encoding/Encoding.php +++ b/lib/Encoding/Encoding.php @@ -54,7 +54,7 @@ interface Encoding { * * 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 * diff --git a/lib/Encoding/ISO2022JP.php b/lib/Encoding/ISO2022JP.php index be2a05b..87e0a2d 100644 --- a/lib/Encoding/ISO2022JP.php +++ b/lib/Encoding/ISO2022JP.php @@ -178,7 +178,7 @@ class ISO2022JP extends AbstractEncoding implements Encoding { return $out; } - protected function stateApply(array $state) { + protected function stateApply(array $state): void { while (sizeof($this->modeStack) > $state['modeCount']) { list($this->modeMark, $this->mode) = array_pop($this->modeStack); } @@ -186,7 +186,7 @@ class ISO2022JP extends AbstractEncoding implements Encoding { parent::stateApply($state); } - public function rewind() { + public function rewind(): void { $this->modeStack = []; $this->modeMark = \PHP_INT_MIN; $this->mode = self::ASCII_STATE; diff --git a/lib/Encoding/Replacement.php b/lib/Encoding/Replacement.php index 318698b..d5f41c6 100644 --- a/lib/Encoding/Replacement.php +++ b/lib/Encoding/Replacement.php @@ -75,7 +75,7 @@ class Replacement implements Encoding { return $distance; } - public function rewind() { + public function rewind(): void { $this->done = false; }