Skip to content

Commit

Permalink
Fix usage of underscore in the function name (#702)
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry authored Mar 18, 2017
1 parent c294545 commit 8d3d23a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ final class FunctionTreeTokenizer
public function tokenize(string $value): array
{
$value = preg_replace(
'/(.*?)<((?:.*?:)?(?:\p{L}|[0-9])+?)\((.*?)/',
'/(.*?)<((?:.*?:)?(?:\p{L}|_|[0-9])+?)\((.*?)/',
sprintf('$1%1$sFUNCTION_START__$2__%1$s$3', self::DELIMITER),
$value
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ final class SubPatternsLexer implements LexerInterface
'/^(<\(.+\)>)/' => TokenType::IDENTITY_TYPE,
'/^(<\S+\(.*\)>)/' => TokenType::FUNCTION_TYPE,
'/^(<\S+>)/' => null,
'/^(\[[^\[\]]+\])/' => TokenType::STRING_ARRAY_TYPE,
'/^(\[[^\[\]]*\])/' => TokenType::STRING_ARRAY_TYPE,
'/^(@[^\ @\{\<]+\(.*\))/' => self::REFERENCE_LEXER, // Function with text
'/^(@[^\ @\<]+\{.*\}->\S+\(.*\))/' => self::REFERENCE_LEXER, // Range or list with function
'/^(@[^\ @\<]+\{.*\}->[^\(\)\ \{]+)/' => self::REFERENCE_LEXER, // Range or list with property
Expand Down
18 changes: 18 additions & 0 deletions tests/Loader/LoaderIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2832,5 +2832,23 @@ public function provideFixturesToGenerate()
],
],
];

yield '[function] call nested PHP native function' => [
[
\stdClass::class => [
'dummy' => [
'foo' => '<json_encode([])>',
],
],
],
[
'parameters' => [],
'objects' => [
'dummy' => StdClassFactory::create([
'foo' => '[]',
]),
],
],
];
}
}

0 comments on commit 8d3d23a

Please sign in to comment.