From 54262b509b2cabb2a794c73b3cc70617c2eb9190 Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Sun, 4 Jul 2021 19:20:55 +0200 Subject: [PATCH] Leverage str_ends_with added the php80 polyfill to requirements when necessary --- Exception/ParseException.php | 2 +- Parser.php | 4 ++-- composer.json | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Exception/ParseException.php b/Exception/ParseException.php index 82c05a71..268586ef 100644 --- a/Exception/ParseException.php +++ b/Exception/ParseException.php @@ -114,7 +114,7 @@ private function updateRepr() $this->message = $this->rawMessage; $dot = false; - if ('.' === substr($this->message, -1)) { + if (str_ends_with($this->message, '.')) { $this->message = substr($this->message, 0, -1); $dot = true; } diff --git a/Parser.php b/Parser.php index 32e6d34f..68efea6c 100644 --- a/Parser.php +++ b/Parser.php @@ -463,7 +463,7 @@ private function doParse(string $value, int $flags) $value .= ' '; } - if ('' !== trim($line) && '\\' === substr($line, -1)) { + if ('' !== trim($line) && str_ends_with($line, '\\')) { $value .= ltrim(substr($line, 0, -1)); } elseif ('' !== trim($line)) { $value .= trim($line); @@ -472,7 +472,7 @@ private function doParse(string $value, int $flags) if ('' === trim($line)) { $previousLineWasNewline = true; $previousLineWasTerminatedWithBackslash = false; - } elseif ('\\' === substr($line, -1)) { + } elseif (str_ends_with($line, '\\')) { $previousLineWasNewline = false; $previousLineWasTerminatedWithBackslash = true; } else { diff --git a/composer.json b/composer.json index 10120348..cb4c1f26 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,8 @@ ], "require": { "php": ">=7.1.3", - "symfony/polyfill-ctype": "~1.8" + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-php80": "^1.16" }, "require-dev": { "symfony/console": "^3.4|^4.0|^5.0"