mirror of
https://github.com/composer/composer
synced 2025-05-10 00:53:06 +00:00
Add more possessive quantifiers, unicode flag and support for more post-heredoc syntax, fix test file syntax being invalid
This commit is contained in:
parent
6ab1b6a7d2
commit
d8054d1d2f
2 changed files with 33 additions and 6 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue