Add more possessive quantifiers, unicode flag and support for more post-heredoc syntax, fix test file syntax being invalid
parent
6ab1b6a7d2
commit
d8054d1d2f
|
@ -248,19 +248,19 @@ class ClassMapGenerator
|
|||
// strip heredocs/nowdocs
|
||||
$contents = preg_replace('{
|
||||
# opening heredoc/nowdoc delimiter (word-chars)
|
||||
<<<[ \t]*([\'"]?)(\w+)\\1
|
||||
<<<[ \t]*+([\'"]?)(\w++)\\1
|
||||
# needs to be followed by a newline
|
||||
(?:\r\n|\n|\r)
|
||||
# the meat of it, matching line by line until end delimiter
|
||||
(?:
|
||||
# a valid line is optional white-space (possessive match) not followed by the end delimiter, then anything goes for the rest of the line
|
||||
[\t ]*+(?!\\2 [\t \r\n]*[;,.)])[^\r\n]*
|
||||
[\t ]*+(?!\\2 \b)[^\r\n]*+
|
||||
# end of line(s)
|
||||
[\r\n]+
|
||||
[\r\n]++
|
||||
)*
|
||||
# end delimiter
|
||||
[\t ]* \\2 (?=[\t \r\n]*[;,.)])
|
||||
}x', 'null', $contents);
|
||||
[\t ]*+ \\2 (?=\b)
|
||||
}xu', 'null', $contents);
|
||||
|
||||
// strip strings
|
||||
$contents = preg_replace('{"[^"\\\\]*+(\\\\.[^"\\\\]*+)*+"|\'[^\'\\\\]*+(\\\\.[^\'\\\\]*+)*+\'}s', 'null', $contents);
|
||||
|
|
|
@ -23,7 +23,7 @@ class FailHeredocMarkerInText
|
|||
{
|
||||
}
|
||||
But, what are you blind McFly, it's there. How else do you explain that wreck out there? Doc, Doc. Oh, no. You're alive. Bullet proof vest, how did you know, I never got a chance to tell you. About all that talk about screwing up future events, the space time continuum. Okay, alright, I'll prove it to you.
|
||||
MARKERINTEXT
|
||||
. MARKERINTEXT
|
||||
class FailHeredocMarkerInText2
|
||||
{
|
||||
}
|
||||
|
@ -95,6 +95,33 @@ NOWDOCTABBED . <<<'NOWDOCPHP73'
|
|||
{
|
||||
return 'class FailSimpleString {}';
|
||||
}
|
||||
|
||||
public function test_unicode_heredoc()
|
||||
{
|
||||
return array(1, 2, <<<öéçив必
|
||||
class FailUnicode
|
||||
{
|
||||
}
|
||||
öéçив必, 3, 4);
|
||||
}
|
||||
|
||||
public function test_wrapped_in_curly_brackets()
|
||||
{
|
||||
return ${<<<FOO
|
||||
class FailCurlyBrackets
|
||||
{
|
||||
}
|
||||
FOO};
|
||||
}
|
||||
|
||||
public function test_wrapped_in_angle_brackets()
|
||||
{
|
||||
return [<<<FOO
|
||||
class FailAngleBrackets
|
||||
{
|
||||
}
|
||||
FOO];
|
||||
}
|
||||
}
|
||||
|
||||
// Issue #10067.
|
||||
|
|
Loading…
Reference in New Issue