Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Stud.IP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jan-Hendrik Willms
Stud.IP
Commits
772895be
Commit
772895be
authored
2 years ago
by
Elmar Ludwig
Committed by
David Siegfried
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
require Closure instead of callable, fixes #2446
Closes #2446 Merge request
studip/studip!1669
parent
43f35cc4
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
vendor/exTpl/Expression.php
+1
-1
1 addition, 1 deletion
vendor/exTpl/Expression.php
vendor/exTpl/Template.php
+4
-1
4 additions, 1 deletion
vendor/exTpl/Template.php
vendor/exTpl/template_test.php
+7
-3
7 additions, 3 deletions
vendor/exTpl/template_test.php
with
12 additions
and
5 deletions
vendor/exTpl/Expression.php
+
1
−
1
View file @
772895be
...
...
@@ -320,7 +320,7 @@ class FunctionExpression implements Expression
$arguments
[]
=
$expr
->
value
(
$context
);
}
if
(
is_
callable
(
$callable
)
)
{
if
(
$
callable
instanceof
\Closure
)
{
return
call_user_func_array
(
$callable
,
$arguments
);
}
...
...
This diff is collapsed.
Click to expand it.
vendor/exTpl/Template.php
+
4
−
1
View file @
772895be
...
...
@@ -49,7 +49,10 @@ class Template
public
function
__construct
(
$string
)
{
$this
->
template
=
new
ArrayNode
();
$this
->
functions
=
array
(
'count'
=>
'count'
,
'strlen'
=>
'mb_strlen'
);
$this
->
functions
=
array
(
'count'
=>
function
(
$a
)
{
return
count
(
$a
);
},
'strlen'
=>
function
(
$a
)
{
return
mb_strlen
(
$a
);
}
);
self
::
parseTemplate
(
$this
->
template
,
$string
,
0
);
}
...
...
This diff is collapsed.
Click to expand it.
vendor/exTpl/template_test.php
+
7
−
3
View file @
772895be
...
...
@@ -168,8 +168,12 @@ class template_test extends PHPUnit\Framework\TestCase
public
function
testFilters
()
{
$bindings
=
array
(
'pi'
=>
3.14159
,
'format_number'
=>
'number_format'
,
'upper'
=>
'strtoupper'
);
$template
=
'{pi|format_number(3) ~ ":" ~ "foobar"|upper}'
;
$bindings
=
array
(
'pi'
=>
3.14159
,
'format'
=>
function
(
$a
,
$b
)
{
return
number_format
(
$a
,
$b
);
},
'upper'
=>
function
(
$a
)
{
return
strtoupper
(
$a
);
}
);
$template
=
'{pi|format(3) ~ ":" ~ "foobar"|upper}'
;
$expected
=
'3.142:FOOBAR'
;
$tmpl_obj
=
new
Template
(
$template
);
...
...
@@ -178,7 +182,7 @@ class template_test extends PHPUnit\Framework\TestCase
public
function
testRawFilter
()
{
$bindings
=
array
(
'foo'
=>
'<img>'
,
'upper'
=>
'
strtoupper
'
);
$bindings
=
array
(
'foo'
=>
'<img>'
,
'upper'
=>
function
(
$a
)
{
return
strtoupper
(
$a
);
}
);
$template
=
'{foo}:{foo|upper|raw}'
;
$expected
=
'<img>:<IMG>'
;
$tmpl_obj
=
new
Template
(
$template
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment