fix regex for heredoc/nowdoc

* take into account relaxed changes introduced in php 7.3
  * see: 4887357269
* allow " as well as ', which was introduced in php 5.3

closes #8080
main
Rob Bast 5 years ago
parent 625bcee63a
commit 971528916b

@ -162,7 +162,7 @@ class ClassMapGenerator
} }
// strip heredocs/nowdocs // strip heredocs/nowdocs
$contents = preg_replace('{<<<\s*(\'?)(\w+)\\1(?:\r\n|\n|\r)(?:.*?)(?:\r\n|\n|\r)\\2(?=\r\n|\n|\r|;)}s', 'null', $contents); $contents = preg_replace('{<<<\s*([\'"]?)(\w+)\\1(?:\r\n|\n|\r)(?:.*?)(?:\r\n|\n|\r|\s*)\\2(?=\r\n|\n|\r|\s|;)}s', 'null', $contents);
// strip strings // strip strings
$contents = preg_replace('{"[^"\\\\]*+(\\\\.[^"\\\\]*+)*+"|\'[^\'\\\\]*+(\\\\.[^\'\\\\]*+)*+\'}s', 'null', $contents); $contents = preg_replace('{"[^"\\\\]*+(\\\\.[^"\\\\]*+)*+"|\'[^\'\\\\]*+(\\\\.[^\'\\\\]*+)*+\'}s', 'null', $contents);
// strip leading non-php code if needed // strip leading non-php code if needed

@ -33,12 +33,18 @@ class Fail5
} }
ANOTHER ANOTHER
. <<< 'ONEMORE' . <<< "ONEMORE"
class Fail6 class Fail6
{ {
} }
ONEMORE; ONEMORE
. <<<PHP73
class Fail7
{
}
PHP73;
} }
public function test2() public function test2()

Loading…
Cancel
Save