1
0
Fork 0

Fix class names in comments being parsed in short_open_tags files, fixes #7289

pull/7316/head
Jordi Boggiano 2018-05-04 10:55:52 +02:00
parent a3ed8484be
commit 3b9d6769bf
3 changed files with 5 additions and 8 deletions

View File

@ -179,6 +179,10 @@ class ClassMapGenerator
if (false !== $pos && false === strpos(substr($contents, $pos), '<?')) {
$contents = substr($contents, 0, $pos);
}
// strip comments if short open tags are in the file
if (preg_match('{(<\?)(?!(php|hh))}i', $contents)) {
$contents = preg_replace('{//.* | /\*(?:[^*]++|\*(?!/))*\*/}x', '', $contents);
}
preg_match_all('{
(?:

View File

@ -62,14 +62,6 @@ class ClassMapGeneratorTest extends TestCase
'ShortOpenTagDocblock' => realpath(__DIR__) . '/Fixtures/classmap/ShortOpenTagDocblock.php',
);
/**
* @wontfix If short_open_tag is not enabled, we end up parsing the docblock because
* php_strip_whitespace won't recognize the file. Funky edge-case (does not apply to HHVM).
*/
if (!defined('HHVM_VERSION') && !ini_get('short_open_tag')) {
$classmap['description'] = realpath(__DIR__) . '/Fixtures/classmap/ShortOpenTagDocblock.php';
}
$data = array(
array(__DIR__ . '/Fixtures/Namespaced', array(
'Namespaced\\Bar' => realpath(__DIR__) . '/Fixtures/Namespaced/Bar.inc',

View File

@ -2,4 +2,5 @@
/**
* Some class description here.
*/
// other class name in comment
class ShortOpenTagDocblock {}