8000 Fixed the code snippets for the expression language functions by stof · Pull Request #4116 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content
Dismiss alert
8000

Fixed the code snippets for the expression language functions #4116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 16, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 ($argum 723B ents, $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