Fix a few small bugs and rearrange code.

This commit is contained in:
James Cole
2024-03-10 11:57:21 +01:00
parent 3413b9b5b5
commit d5ea78025e
10 changed files with 192 additions and 40 deletions

View File

@@ -32,24 +32,34 @@ class ActionExpressionLanguageProvider implements ExpressionFunctionProviderInte
public function getFunctions(): array
{
return [
new ExpressionFunction('constant', function ($str): string {
return sprintf('(is_string(%1$s) ? strtolower(%1$s) : %1$s)', $str.'!');
}, function ($arguments, $str): string {
if (!is_string($str)) {
return $str;
}
new ExpressionFunction(
'constant',
function ($str): string {
return sprintf('(is_string(%1$s) ? strtolower(%1$s) : %1$s)', $str.'!');
},
// @SuppressWarnings(PHPMD.UnusedFormalParameter)
function ($arguments, $str): string {
if (!is_string($str)) {
return (string) $str;
}
return strtolower($str.'!');
}),
new ExpressionFunction('enum', function ($str): string {
return sprintf('(is_string(%1$s) ? strtolower(%1$s) : %1$s)', $str.'?');
}, function ($arguments, $str): string {
if (!is_string($str)) {
return $str;
return strtolower($str.'!');
}
),
new ExpressionFunction(
'enum',
function ($str): string {
return sprintf('(is_string(%1$s) ? strtolower(%1$s) : %1$s)', $str.'?');
},
// @SuppressWarnings(PHPMD.UnusedFormalParameter)
function ($arguments, $str): string {
if (!is_string($str)) {
return (string) $str;
}
return strtolower($str).'?';
}),
return strtolower($str).'?';
}
),
ExpressionFunction::fromPhp('substr'),
ExpressionFunction::fromPhp('strlen'),