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
|
// strip heredocs/nowdocs
|
||||||
$contents = preg_replace('{
|
$contents = preg_replace('{
|
||||||
# opening heredoc/nowdoc delimiter (word-chars)
|
# opening heredoc/nowdoc delimiter (word-chars)
|
||||||
<<<[ \t]*([\'"]?)(\w+)\\1
|
<<<[ \t]*+([\'"]?)(\w++)\\1
|
||||||
# needs to be followed by a newline
|
# needs to be followed by a newline
|
||||||
(?:\r\n|\n|\r)
|
(?:\r\n|\n|\r)
|
||||||
# the meat of it, matching line by line until end delimiter
|
# 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
|
# 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)
|
# end of line(s)
|
||||||
[\r\n]+
|
[\r\n]++
|
||||||
)*
|
)*
|
||||||
# end delimiter
|
# end delimiter
|
||||||
[\t ]* \\2 (?=[\t \r\n]*[;,.)])
|
[\t ]*+ \\2 (?=\b)
|
||||||
}x', 'null', $contents);
|
}xu', 'null', $contents);
|
||||||
|
|
||||||
// strip strings
|
// strip strings
|
||||||
$contents = preg_replace('{"[^"\\\\]*+(\\\\.[^"\\\\]*+)*+"|\'[^\'\\\\]*+(\\\\.[^\'\\\\]*+)*+\'}s', 'null', $contents);
|
$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.
|
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
|
class FailHeredocMarkerInText2
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -95,6 +95,33 @@ NOWDOCTABBED . <<<'NOWDOCPHP73'
|
||||||
{
|
{
|
||||||
return 'class FailSimpleString {}';
|
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.
|
// Issue #10067.
|
||||||
|
|
Loading…
Reference in New Issue