Fails to load file starting with two comments
mfonda opened this issue · 1 comments
mfonda commented
Having trouble loading a file starting with consecutive two non-docblock comments:
Example file:
<?php
// Comment one
// Comment two
include 'vendor/autoload.php';
$projectFactory = \phpDocumentor\Reflection\Php\ProjectFactory::createInstance();
$project = $projectFactory->create('MyProject', [__FILE__]);
Result of php example.php
:
Fatal error: Uncaught exception 'OutOfBoundsException' with message 'No matching factory found for PhpParser\Comment' in /home/mfonda/dev/php-method-search/vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/Php/ProjectFactoryStrategies.php on line 54
OutOfBoundsException: No matching factory found for PhpParser\Comment in /home/mfonda/dev/php-method-search/vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/Php/ProjectFactoryStrategies.php on line 54
Call Stack:
0.0002 240120 1. {main}() /home/mfonda/dev/php-method-search/example.php:0
0.0323 5731584 2. phpDocumentor\Reflection\Php\ProjectFactory->create() /home/mfonda/dev/php-method-search/example.php:8
0.0332 5776816 3. phpDocumentor\Reflection\Php\Factory\File->create() /home/mfonda/dev/php-method-search/vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/Php/ProjectFactory.php:79
0.0333 5783992 4. phpDocumentor\Reflection\Php\Factory\File->phpDocumentor\Reflection\Php\Factory\{closure}() /home/mfonda/dev/php-method-search/vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/Php/Factory/File.php:113
0.0333 5784264 5. phpDocumentor\Reflection\Php\Factory\File->createFile() /home/mfonda/dev/php-method-search/vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/Php/Factory/File.php:72
0.0384 6088504 6. phpDocumentor\Reflection\Php\Factory\File->createDocBlock() /home/mfonda/dev/php-method-search/vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/Php/Factory/File.php:125
0.0392 6143248 7. phpDocumentor\Reflection\Php\ProjectFactoryStrategies->findMatching() /home/mfonda/dev/php-method-search/vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/Php/Factory/File.php:200
It seems this is only the case when the file starts with two consecutive non-docblock comments.
The following files all work just fine:
<?php
/** Comment one */
/** Comment two */
<?php
/** Comment one */
// Comment two
<?php
// Comment one
$x = 42;
// Comment two
jaapio commented
Hi,
Sorry for the very long delay. Most likely you already found out what was going on. But for future documentation.
The ProjectFactory
expects an array of objects implementing the phpDocumentor\Reflection\File
interface. Not just an array of strings.
I found that this was in correctly documented in the readme and fixed that issue.
Please open an new issue when you have any problems using our library.