New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ReflectionMethod accepts string|object, not mixed #147
Conversation
We need some clean way to represent union types for docbook, and to have PhD properly render these, before we should add union types to the manual. See php/phd#25 (comment). |
Thanks for the pointer. In the meantime, can't we follow the footsteps of the doc pages that have already adopted union types in the following form? <type>bool|array</type> That would allow us to start working on better type documentation right now, and should be trivial to replace programmatically once a suitable syntax has been made available. There are quite a few doc pages already using this syntax: https://pastebin.com/q3Yu5GPd |
This just makes more work for translations, because we need to do 2 passes instead of just 1. Moreover, a lot of arguments in PHP 7.x do actually accept "mixed" due to legacy behaviour which only got removed with PHP 8.0. As we need to update the prototypes anyway due to named parameters it would be better to combine all of this into one single change/commit by basing ourselves on the stubs when they are finalized. |
Just stumbled upon another one here: https://www.php.net/manual/en/function.getmyuid.php The doc says
|
IMO, leave it as is for PHP 7 docs, but do it properly for PHP 8 docs. It seems to me that it might be benefical to have separate signatures for PHP 7/8, at least for some functions. The PHP 8 signatures should be generated (semi-)automatically.
That would even be counter productive, since
Clear no from me. That should be |
Will PHP 7 & PHP 8 have different doc pages? |
That's not planned. |
So I didn't get your comment, sorry?
|
Sorry, pretty unclear explanation from side, indeed. What I meant is that we should focus on (semi-)automatic generation of the PHP 8 function signatures. If these are identical to those for PHP 7, just replace them (that would be the case for However, thinking more about it, there's nothing wrong with fixing the PHP 7 signatures as soon as we have support for union types. |
I have applied this (with proper union type markup) as http://svn.php.net/viewvc?view=revision&revision=351060. Wrt. getmyuid() returning |
ReflectionMethod's constructor currently uses
mixed
for its$class
parameter, when it actually accepts either astring
or anobject
.There is precedence in the docs to use union types notation (see this for example), so is it OK if I convert more
mixed
to union types in the future?