mirror of
https://github.com/fenom-template/fenom.git
synced 2023-08-10 21:13:07 +03:00
Fix '~=' operator
This commit is contained in:
parent
f6c4da8297
commit
f3de50813e
@ -724,16 +724,21 @@ class Template extends Render
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} elseif ($tokens->is('~')) { // string concatenation operator: 'asd' ~ $var
|
} elseif ($tokens->is('~')) { // string concatenation operator: 'asd' ~ $var
|
||||||
$concat = array(array_pop($exp));
|
if($tokens->isNext('=')) { // ~=
|
||||||
while ($tokens->is('~')) {
|
$exp[] = ".=";
|
||||||
$tokens->next();
|
$tokens->next()->next();
|
||||||
if ($tokens->is(T_LNUMBER, T_DNUMBER)) {
|
} else {
|
||||||
$concat[] = "strval(" . $this->parseTerm($tokens) . ")";
|
$concat = array(array_pop($exp));
|
||||||
} else {
|
while ($tokens->is('~')) {
|
||||||
$concat[] = $this->parseTerm($tokens);
|
$tokens->next();
|
||||||
|
if ($tokens->is(T_LNUMBER, T_DNUMBER)) {
|
||||||
|
$concat[] = "strval(" . $this->parseTerm($tokens) . ")";
|
||||||
|
} else {
|
||||||
|
$concat[] = $this->parseTerm($tokens);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
$exp[] = "(" . implode(".", $concat) . ")";
|
||||||
}
|
}
|
||||||
$exp[] = "(" . implode(".", $concat) . ")";
|
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1170,6 +1170,7 @@ class TemplateTest extends TestCase
|
|||||||
array('{"string" ~ ++$one ~ "end"}', "string2end"),
|
array('{"string" ~ ++$one ~ "end"}', "string2end"),
|
||||||
array('{"string" ~ "one" ~ "end"}', "stringoneend"),
|
array('{"string" ~ "one" ~ "end"}', "stringoneend"),
|
||||||
array('{"string" ~ 1 ~ "end"}', "string1end"),
|
array('{"string" ~ 1 ~ "end"}', "string1end"),
|
||||||
|
array('{$one ~= "string"} is {$one}', "1string is 1string"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1536,6 +1537,7 @@ class TemplateTest extends TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider providerConcat
|
* @dataProvider providerConcat
|
||||||
|
* @group testConcat
|
||||||
*/
|
*/
|
||||||
public function testConcat($code, $result)
|
public function testConcat($code, $result)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user