Render function and method signatures using PHP7's format.
| From: | Richard Quadling | Date: | Tue, 02 May 2017 10:17:09 +0000 |
| Subject: | Render function and method signatures using PHP7's format. | ||
| Groups: | php.doc | ||
| Request: | Send a blank email to phpdoc+get-969386575@lists.php.net to get a copy of this message | ||
Hello all.
Currently, PHD renders method and function signatures with the return type
up front, similar to C and other languages. Prior to PHP 7, I'd say that
there was nothing wrong with this, as there was no PHP code equivalent and
it's placement was probably discussed at length and agreed upon.
But with PHP7's return type hinting placing the return type at the end of
the signature, we are now in the situation that the first port of call for
a developer, when reading example function usage, has to NOT use the
general structure from the documentation and place the return type at the
end of the signature for their function and method definitions. Whilst
return type hinting is relatively new and PHP5 still has a significant
client usage, this won't always be the case and eventually everyone will
look back and gently wipe away the tear as it rolls slowly down their cheek
at the mention of PHP5.
I'm trying to get https://github.com/php-fig/fig-standards/pull/899
(Align
PSR-5 @method signatures with PHP7 with regard to return types) accepted
(that's in progress with the current owner of PSR-5).
In addition to PSR-5, once the standard is accepted, tools like PHP-CS,
PHPStan, PHPDocumentor, will be able to suggest/coerce/enforce (pick a term
you're happy with) this standard.
But I think if we already have a signature format (PHP 7), then PHP's own
documentation should follow it. And if that's done, all the other players
will (hopefully) fall in place.
Once PHP and PSR-5 define the standard, it will be some grunt work to get
the major frameworks and libraries updated to the standard.
In terms of PHP documentation, I'm hoping that amending PHD is the solution
here and not have to alter the methodsynopsis tags in php-doc. Though, if
that's necessary, a painful but easy task.
So, thoughts/opinions please.
Regards,
Richard Quadling.