mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-30 12:06:56 +00:00
Compile starts/ends with using PHP8 functions str_starts/ends_with
This commit is contained in:
@@ -24,7 +24,7 @@ class EndsWithBinary extends AbstractBinary
|
||||
->subcompile($this->getNode('left'))
|
||||
->raw(sprintf(') && is_string($%s = ', $right))
|
||||
->subcompile($this->getNode('right'))
|
||||
->raw(sprintf(') && (\'\' === $%2$s || $%2$s === substr($%1$s, -strlen($%2$s))))', $left, $right))
|
||||
->raw(sprintf(') && str_ends_with($%1$s, $%2$s))', $left, $right))
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ class StartsWithBinary extends AbstractBinary
|
||||
->subcompile($this->getNode('left'))
|
||||
->raw(sprintf(') && is_string($%s = ', $right))
|
||||
->subcompile($this->getNode('right'))
|
||||
->raw(sprintf(') && (\'\' === $%2$s || 0 === strpos($%1$s, $%2$s)))', $left, $right))
|
||||
->raw(sprintf(') && str_starts_with($%1$s, $%2$s))', $left, $right))
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user