phpDocumentor / Reflection

Reflection library to do Static Analysis for PHP Projects
MIT License
117 stars 51 forks source link

Invalid service in DefinitionErrorExceptionPass.php #191

Closed henryruhs closed 3 years ago

henryruhs commented 3 years ago

Using phpDocumentor v3.0.0 I get this error using a simple vendor/bin/phpdoc run:

In DefinitionErrorExceptionPass.php line 54:

  Invalid service "phpDocumentor\Reflection\Php\Factory\DocBlock": class "php  
  Documentor\Reflection\Php\Factory\DocBlock" does not exist.

GitHub workflow that reproduces the issue: https://github.com/redaxscript/redaxscript-api-sync/runs/1507114868

jaapio commented 3 years ago

Looking at your composer install action you are installing the latest version of this lib from 4.x which is not yet compatible with phpDocumentor. Please remember that composer is not a recommended way to install phpDocumentor.

I'm not 100% sure how to fix this on the short term.

henryruhs commented 3 years ago

@jaapio Hey, thanks for reaching out to me.

Issue

You are right, the composer log says:

Locking phpdocumentor/reflection (4.x-dev 6272b5e)

That is your guys "fault" as you use dev dependencies in phpdocumentor 3.0.0 and therfore I had to enable the "minimum-stability": "dev" flag:

- Root composer.json requires phpdocumentor/phpdocumentor 3.0.0 -> satisfiable by phpdocumentor/phpdocumentor[v3.0.0].
    - phpdocumentor/phpdocumentor v3.0.0 requires phpdocumentor/graphviz ^2.0@dev -> found phpdocumentor/graphviz[dev-master, 2.0.0-alpha1, 2.0.0-beta1, 2.0.0-beta2, 2.x-dev (alias of dev-master)] but it does not match your minimum-stability.

See: https://github.com/redaxscript/redaxscript-api-sync/runs/1522985574

Solution

I was kind of a smart ass and fixed my composer.json that way:

"require-dev":
{
    "phpdocumentor/graphviz": "2.0.0-alpha1",
    "phpdocumentor/phpdocumentor": "3.0.0"
}

That being said... please don't use dev dependencies in stable releases and consider to publish phpdocumentor 3.0.1 with graphviz 2.0.0-alpha1 as soon as possible.

See: https://github.com/redaxscript/redaxscript-api-sync/runs/1523105578

jaapio commented 3 years ago

I reconsidered this issue, we will stop the support for 4.x and move over to 5.x I forced pushed the 4.x branch back to 4.0.1 so your issue should be solved by now.

henryruhs commented 3 years ago

@jaapio Okay, but the problem is still that you use @dev dependencies... this can break any time in the future if you don't lock the dependencies in a proper way.

jaapio commented 3 years ago

But that was not about this library right ;-)

The alpha usage slipped through during the release cycle and should be fixed. But that's something for later.

henryruhs commented 3 years ago

Oh well, you are right. Thanks for the fix and have a great weekend!