xp-framework / core

The XP Framework is an all-purpose, object oriented PHP framework.
Other
19 stars 6 forks source link

Add support for compact API documentation #305

Closed thekid closed 1 year ago

thekid commented 2 years ago

This pull request makes it possible to generate one-line apidoc comments for XP Compiler.

Example

Input using array component types, which PHP doesn't syntactically support:

function main(array<string> $args): int { ... }

XP Compiler emits this type as array, erasing the component type. However, we still want IDEs and reflective access to pick up the more precise type, so apidoc is emitted. To ensure line number stay intact, we need to emit the comment as a single line on the same line as the function declaration:

/** @param string[] */ function main(array $args): int { ... }