This commit is contained in:
2026-03-10 15:07:29 +07:00
parent e2189983f6
commit 1f599a859b
52 changed files with 4136 additions and 1811 deletions

View File

@@ -296,8 +296,11 @@ class Context
$key = preg_replace("|\[([0-9]+)\]|", ".$1", $key);
} elseif (preg_match("|\[[0-9a-z._]+\]|", $key, $matches)) {
$index = $this->get(str_replace(["[", "]"], "", $matches[0]));
if (strlen($index)) {
$key = preg_replace("|\[([0-9a-z._]+)\]|", ".$index", $key);
if ($index !== null && (is_scalar($index) || (is_object($index) && method_exists($index, '__toString')))) {
$index = (string) $index;
if (strlen($index)) {
$key = preg_replace("|\[([0-9a-z._]+)\]|", ".$index", $key);
}
}
}

View File

@@ -416,6 +416,14 @@ class StandardFilters
*/
public static function remove($input, $string)
{
if ($input === null) {
return '';
}
if ($string === null) {
$string = '';
}
return str_replace($string, '', $input);
}
@@ -430,6 +438,14 @@ class StandardFilters
*/
public static function remove_first($input, $string)
{
if ($input === null) {
return '';
}
if ($string === null || $string === '') {
return $input;
}
if (($pos = strpos($input, $string)) !== false) {
$input = substr_replace($input, '', $pos, strlen($string));
}
@@ -449,6 +465,18 @@ class StandardFilters
*/
public static function replace($input, $string, $replacement = '')
{
if ($input === null) {
return '';
}
if ($string === null) {
$string = '';
}
if ($replacement === null) {
$replacement = '';
}
return str_replace($string, $replacement, $input);
}
@@ -464,6 +492,18 @@ class StandardFilters
*/
public static function replace_first($input, $string, $replacement = '')
{
if ($input === null) {
return '';
}
if ($string === null || $string === '') {
return $input;
}
if ($replacement === null) {
$replacement = '';
}
if (($pos = strpos($input, $string)) !== false) {
$input = substr_replace($input, $replacement, $pos, strlen($string));
}
@@ -522,6 +562,10 @@ class StandardFilters
*/
public static function size($input)
{
if ($input === null) {
return 0;
}
if ($input instanceof \Iterator) {
return iterator_count($input);
}
@@ -542,7 +586,7 @@ class StandardFilters
}
// only plain values and stringable objects left at this point
return strlen($input);
return strlen((string)$input);
}
@@ -640,6 +684,10 @@ class StandardFilters
*/
public static function strip($input)
{
if ($input === null) {
return '';
}
return trim($input);
}
@@ -697,7 +745,12 @@ class StandardFilters
*/
public static function truncate($input, $characters = 100, $ending = '...')
{
if ($input === null) {
return '';
}
if (is_string($input) || is_numeric($input)) {
$input = (string)$input;
if (strlen($input) > $characters) {
return mb_substr($input, 0, $characters) . $ending;
}