Skip to content

Commit

Permalink
bug #4116 Fixed the code snippets for the expression language functio…
Browse files Browse the repository at this point in the history
…ns (stof)

This PR was merged into the 2.4 branch.

Discussion
----------

Fixed the code snippets for the expression language functions

| Q             | A
| ------------- | ---
| Doc fix?      | yes
| New docs?     | no
| Applies to    | 2.4+
| Fixed tickets | n/a

The compilation callable was broken for the example of the lowercase function (in 2 different ways in the different snippet as the first one was attempted to be fixed in #3771 but my comment asking to remove the return statement inside the compiled expression was misunderstood and the other return statement returning the compiled expression was removed as well.).

Commits
-------

3eaaf26 Fixed the code snippets for the expression language functions
  • Loading branch information
weaverryan committed Aug 16, 2014
2 parents 1f14a0e + 3eaaf26 commit 4629d8b
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions components/expression_language/extending.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ This method has 3 arguments:
$language = new ExpressionLanguage();
$language->register('lowercase', function ($str) {
is_string(%1$s) ? strtolower(%1$s) : %1$s;
return sprintf('(is_string(%1$s) ? strtolower(%1$s) : %1$s)', $str);
}, function ($arguments, $str) {
if (!is_string($str)) {
return $str;
Expand Down Expand Up @@ -69,11 +69,7 @@ Override ``registerFunctions`` to add your own functions::
parent::registerFunctions(); // do not forget to also register core functions

$this->register('lowercase', function ($str) {
if (!is_string($str)) {
return $str;
}

return sprintf('strtolower(%s)', $str);
return sprintf('(is_string(%1$s) ? strtolower(%1$s) : %1$s)', $str);
}, function ($arguments, $str) {
if (!is_string($str)) {
return $str;
Expand Down

0 comments on commit 4629d8b

Please sign in to comment.