1
0
Fork 0

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
pull/8082/head
Rob Bast 2019-04-03 10:33:58 +02:00
parent 625bcee63a
commit 971528916b
2 changed files with 9 additions and 3 deletions

View File

@ -162,7 +162,7 @@ class ClassMapGenerator
}
// 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
$contents = preg_replace('{"[^"\\\\]*+(\\\\.[^"\\\\]*+)*+"|\'[^\'\\\\]*+(\\\\.[^\'\\\\]*+)*+\'}s', 'null', $contents);
// strip leading non-php code if needed

View File

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