- substr: documentation ( source)
- var_dump: documentation ( source)
- token_get_all: documentation ( source)
- array_shift: documentation ( source)
<?php
const MADNESS = <<<EOM
<?php
yield // this comment doesn't make sense, but hey, why not?
/* the blank line above doesn't make sense either, as well as this comment */
/* and thinking about it – */ // why not go batshit crazy with this? /* he */
from gen2();
EOM;
$comments = token_get_all("<?php" . substr(token_get_all(MADNESS)[2][1], 5, -4));
array_shift($comments); // drop <?php
var_dump($comments);