Skip to content

Commit 755b1c1

Browse files
raulfraileweaverryan
authored andcommitted
Fix function example in expression language component
The is_string check needs to be part of the runtime code, not of the compilation code, because it needs to check that the argument is a string, not the compiled code to access it (which is always a string as it is source code
1 parent a2ce937 commit 755b1c1

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

components/expression_language/extending.rst

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,7 @@ This method has 3 arguments:
3535
3636
$language = new ExpressionLanguage();
3737
$language->register('lowercase', function ($str) {
38-
if (!is_string($str)) {
39-
return $str;
40-
}
41-
42-
return sprintf('strtolower(%s)', $str);
38+
return sprintf('$result = (is_string(%1$s)) ? strtolower(%1$s) : %1$s; return $result;', $str);
4339
}, function ($arguments, $str) {
4440
if (!is_string($str)) {
4541
return $str;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy