phpDocumentor/Reflection

Define in function or method failed to parse

marcimat opened this issue · 1 comments

Hi, seems somewhere between requirement^5.0 and ^5.0@dev (used in phpDocumentor) (now with commit 7666c4b) a define declaration into function or method failed to parse.

It seems that cdda55c introduce this problem, as I don’t get it with the previous 07ce695

Steps to reproduce :

composer.json

{
    "require": {
        "phpdocumentor/reflection": "5.x-dev#cdda55ca794780f1fe119e16b9f8ff3245d4a5ac"
    }
}

test.php

<?php
function test() {
	define('TEST', true);
}

demo.php

<?php
include_once 'vendor/autoload.php';
$projectFactory = \phpDocumentor\Reflection\Php\ProjectFactory::createInstance();
$projectFiles = [new \phpDocumentor\Reflection\File\LocalFile('test.php')];
$project = $projectFactory->create('My Project', $projectFiles);
var_dump($project);

Run.

php demo.php

That gives:

Fatal error: Uncaught AssertionError: assert($file instanceof FileElement) in vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/Php/Factory/Define.php:103

Hope it helps.

This is fixed and will be part of the next release.

Thank you for your nice and clear bug report.