Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
43ad4ad1
Commit
43ad4ad1
authored
May 10, 2009
by
Dries Buytaert
Browse files
- Patch
#458566
by chx: work around PHP's curly bracket madness.
parent
b9b0063a
Changes
2
Hide whitespace changes
Inline
Side-by-side
includes/registry.inc
View file @
43ad4ad1
...
...
@@ -254,7 +254,9 @@ function _registry_skip_body(&$tokens) {
// Scan through the rest of the tokens until we reach the matching
// end brace.
while
(
$num_braces
&&
(
$token
=
next
(
$tokens
)))
{
if
(
$token
==
'{'
)
{
// PHP is really logical to have three different tokens for { with
// inconsistent names and only one for a closing brace.
if
(
$token
==
'{'
||
(
is_array
(
$token
)
&&
(
$token
[
0
]
==
T_DOLLAR_OPEN_CURLY_BRACES
||
$token
[
0
]
==
T_CURLY_OPEN
)))
{
++
$num_braces
;
}
elseif
(
$token
==
'}'
)
{
...
...
modules/simpletest/tests/registry.test
View file @
43ad4ad1
...
...
@@ -135,3 +135,23 @@ CONTENTS;
}
class
RegistrySkipBodyTestCase
extends
DrupalWebTestCase
{
public
static
function
getInfo
()
{
return
array
(
'name'
=>
t
(
'Skip function body test'
),
'description'
=>
t
(
'Tokenize a simple function and check that the body is skipped right'
),
'group'
=>
t
(
'System'
),
);
}
function
testRegistrySkipBody
()
{
// This string contains all three kinds of opening braces.
$function
=
'<?php function foo () { $x = "{$y}"; $x = "${y}" }'
;
$tokens
=
token_get_all
(
$function
);
_registry_skip_body
(
$tokens
);
// Consume the last }
each
(
$tokens
);
$this
->
assertIdentical
(
each
(
$tokens
),
FALSE
,
t
(
'Tokens skipped'
));
}
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment