Le 20/04/2021 à 11:44, Máté Kocsis a écrit :
Hi Pierre,
PHP doesn't have such an advanced type inference capability: just consider
dynamic calls, or regular function invocations
where the return type information is not available.
Yes I know it doesn't have it, it was a subtle way of asking if one day,
the compiler may have inferences capabilities. I know it's not really
possible until it continues loading code dynamically at runtime, but in
some scenarios (such as preload, or inherited/implemented class type
checking) it may be possible, I'm only hard guessing here
On the other hand, we could add return types implicitly, as it was proposed
earlier, but I didn't really like this solution.
Return types being added automatically really looks like inference
already, just a simple one, I guess. I'd love it. In all inheritance or
interface implementation scenarios, it seem possible, since the compiler
needs to load the implemented or inherited class code to be able to
compile the current class.
Any good IDE that knows PHP does the job would it also and be able to
detect errors with that.
For a little more details, have a look at my initial message:
https://externals.io/message/112625#112625 Besides, I think
it's better to document the return types explicitly as a declaration, since
they usually help during implementation.
Máté
Thanks for your answer.
Regards,
--
Pierre
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php