Merge branch 'fix'

This commit is contained in:
Yuri Kuznetsov
2024-05-04 23:03:14 +03:00
2 changed files with 15 additions and 3 deletions
+3 -3
View File
@@ -868,7 +868,7 @@ class Parser
$offset = -1;
while (true) {
$index = strrpos($expression, $operator, $offset);
$index = strrpos($modifiedExpression, $operator, $offset);
if ($index === false) {
break;
@@ -889,7 +889,7 @@ class Parser
if (strlen($operator) === 1) {
if ($index < strlen($expression) - 1) {
$possibleRightOperator = trim($operator . $expression[$index + 1]);
$possibleRightOperator = trim($operator . $modifiedExpression[$index + 1]);
}
}
@@ -905,7 +905,7 @@ class Parser
if (strlen($operator) === 1) {
if ($index > 0) {
$possibleLeftOperator = trim($expression[$index - 1] . $operator);
$possibleLeftOperator = trim($modifiedExpression[$index - 1] . $operator);
}
}
@@ -1568,4 +1568,16 @@ class EvaluatorTest extends TestCase
/** @noinspection PhpUnhandledExceptionInspection */
$this->evaluator->processSafe($expression);
}
public function testStringsWithOperator(): void
{
$expression = "\$a = '='";
$vars = (object) [];
/** @noinspection PhpUnhandledExceptionInspection */
$this->evaluator->process($expression, null, $vars);
$this->assertEquals("=", $vars->a);
}
}