Skip to content

Commit

Permalink
Leverage str_ends_with
Browse files Browse the repository at this point in the history
added the php80 polyfill to requirements when necessary
  • Loading branch information
Tobion committed Jul 21, 2021
1 parent d5a2222 commit 54262b5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Exception/ParseException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 54262b5

Please sign in to comment.