Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Switch phpdoc libraries #10

Open
j6s opened this issue May 23, 2019 · 0 comments
Open

Switch phpdoc libraries #10

j6s opened this issue May 23, 2019 · 0 comments

Comments

@j6s
Copy link
Owner

j6s commented May 23, 2019

Currently, phparch (or - more accurately, the DocBlockTypeAnnotations Visitor) uses phpdocumentor in order to parse PHPDoc comments and it's TypeResolver in order to resolve the symbols in these comments to fully qualified names.

The problem is, that the TypeResolver version used by the current stable version of phpdocumentor does not handle arrays of multiple types (e.g. (Foo|Bar)[] or (Foo|null)[]). There is a beta version of the type resolver and phpdocumentor that handle this, but there has been very little action there. Additionally, many other libraries depend on the current version of phpdocumentor - so most environments probably already have a dependency that prevents this library from simply building on top of beta / new versions.

All of this leads me to believe that something else should be used in order to parse docblocks.
In a quick research I found the following libraries that could be helpful. Further research must be done.

Requirements for a type resolver:

  • Given a classname and a context it should be able to resolve a fully qualified name, resolving all imports / use statements.
  • Should support nullable types @return ?Foo
  • Should support simple array syntax @return Foo[]
  • Should support compound array syntax @return (Foo|Bar)[]
  • Should support alternate array syntax @return array<Foo>
  • Optional: Support for generic type annotations @return Collection<Foo>

For reference:
https://github.com/php-fig/fig-standards/blob/master/proposed/phpdoc.md

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant