Skip to content

Commit bec5954

Browse files
committed
Optimized some strlen() calls when possible
1 parent 8d5b01e commit bec5954

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Helper/QuestionHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ private function mostRecentlyEnteredValue(string $entered): string
382382
}
383383

384384
$choices = explode(',', $entered);
385-
if (\strlen($lastChoice = trim($choices[\count($choices) - 1])) > 0) {
385+
if ('' !== $lastChoice = trim($choices[\count($choices) - 1])) {
386386
return $lastChoice;
387387
}
388388

Input/StringInput.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ private function tokenize(string $input): array
5050
while ($cursor < $length) {
5151
if (preg_match('/\s+/A', $input, $match, 0, $cursor)) {
5252
} elseif (preg_match('/([^="\'\s]+?)(=?)('.self::REGEX_QUOTED_STRING.'+)/A', $input, $match, 0, $cursor)) {
53-
$tokens[] = $match[1].$match[2].stripcslashes(str_replace(['"\'', '\'"', '\'\'', '""'], '', substr($match[3], 1, \strlen($match[3]) - 2)));
53+
$tokens[] = $match[1].$match[2].stripcslashes(str_replace(['"\'', '\'"', '\'\'', '""'], '', substr($match[3], 1, -1)));
5454
} elseif (preg_match('/'.self::REGEX_QUOTED_STRING.'/A', $input, $match, 0, $cursor)) {
55-
$tokens[] = stripcslashes(substr($match[0], 1, \strlen($match[0]) - 2));
55+
$tokens[] = stripcslashes(substr($match[0], 1, -1));
5656
} elseif (preg_match('/'.self::REGEX_STRING.'/A', $input, $match, 0, $cursor)) {
5757
$tokens[] = stripcslashes($match[1]);
5858
} else {

0 commit comments

Comments
 (0)