phpDocumentor / ReflectionDocBlock

MIT License
9.34k stars 121 forks source link

Bug in empty shapes #351

Closed SerafimArts closed 8 months ago

SerafimArts commented 1 year ago

Given the following code

/**
 * @psalm-var list{} Empty sealed list
 * @psalm-var array{} Empty sealed array
 * @psalm-var object{} Empty sealed object
 */
foreach ($factory->create($code)->getTags() as $tag) {
    var_dump($tag->getDescription()->getBodyTemplate());
}

Expected output

string(N) "list{} Empty sealed list"
string(N) "array{} Empty sealed array"
string(N) "object{} Empty sealed object"

Actual

string(N) "list} Empty sealed list"
string(N) "array} Empty sealed array"
string(N) "object} Empty sealed object"

Problem located here: https://github.com/phpDocumentor/ReflectionDocBlock/blob/master/src/DocBlock/DescriptionFactory.php#L77-L83

The meaning of such substitutions is not entirely clear. For what?

jaapio commented 1 year ago

You are hitting an issue that conflicts with inline tags. Right now this library cannot handle both situations properly. I was working on a new version of our type resolver. But due time limits and other work that was postponed. At the moment the 1.x branch of type resolver should do this in a better way. But as I said that's work in progress.

As I'm the only person working on this, I cannot do any promises about when I will finish this work.

jaapio commented 8 months ago

I just checked this issue in more depth. The next release will support array-shapes, we are missing some types which are collected in this issue: https://github.com/phpDocumentor/TypeResolver/issues/205

Once those are addressed this will be solved automatically.