Skip to content

Commit 3eaaf26

Browse files
committed
Fixed the code snippets for the expression language functions
1 parent 8cbdf15 commit 3eaaf26

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

Diff for: components/expression_language/extending.rst

+2-6
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ This method has 3 arguments:
3535
3636
$language = new ExpressionLanguage();
3737
$language->register('lowercase', function ($str) {
38-
is_string(%1$s) ? strtolower(%1$s) : %1$s;
38+
return sprintf('(is_string(%1$s) ? strtolower(%1$s) : %1$s)', $str);
3939
}, function ($arguments, $str) {
4040
if (!is_string($str)) {
4141
return $str;
@@ -69,11 +69,7 @@ Override ``registerFunctions`` to add your own functions::
6969
parent::registerFunctions(); // do not forget to also register core functions
7070

7171
$this->register('lowercase', function ($str) {
72-
if (!is_string($str)) {
73-
return $str;
74-
}
75-
76-
return sprintf('strtolower(%s)', $str);
72+
return sprintf('(is_string(%1$s) ? strtolower(%1$s) : %1$s)', $str);
7773
}, function ($arguments, $str) {
7874
if (!is_string($str)) {
7975
return $str;

0 commit comments

Comments
 (0)