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

Switch phpdoc libraries #10

@j6s

Description

@j6s

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions