Hello, I would like to correct myself (credits to Marco Pivetta for informing me) regarding union types. While we still wouldn't be able to declare a type alias as `callable` and then use it in properties, technically speaking `string|array|object` would allow to pass callables. As such, my point about union types is invalid.
Best regards, Benas Seliuginas ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On Wednesday, April 22, 2020 7:56 PM, moliata <moli...@protonmail.com> wrote: > Hello, > > thank you for your opinion. In response to you mentioning that fixing this > problem would be a huge amount of work, I would like to reiterate the idea of > simply ignoring context-dependent problems for the time being. In fact, we can > observe this behavior in parameter/return type hints already. As such, it > doesn't make sense to make just property type hints a special case/exception. > > Moreover, I oversaw Sara Golemon's comment in the `mixed pseudo type` RFC that > she would like to use type aliasing and union types instead, at least in the > long run. The problem that comes up with this approach is that even if we did > something like this: > `use mixed as string|int|...|callable;` > ...we couldn't apply this `mixed` type alias to properties as callable type is > not allowed to be used with them. > > Best regards, > Benas Seliuginas > > ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ > On Wednesday, April 22, 2020 5:29 PM, Dan Ackroyd dan...@basereality.com > wrote: > > > On Tue, 21 Apr 2020 at 14:08, moliata moli...@protonmail.com wrote: > > > > > > > > > > I wanted to ignite a friendly discussion whether > > > PHP should allow typed callable properties. > > > > IMO no. > > Trying to fix the problems with callables would be a huge amount of > > work, and not actually give that much benefit. Even just documenting > > the problems with callables* is a non-trivial amount of work, and I > > suspect there are many horrors lurking with the SPL code related to > > them. > > > > > I believe we should look into... > > > > I'm pretty sure that choosing a different problem to solve that: > > > > - would be easier to solve. > > > > - provide more benefit in the long term. > > > > - not require breaking a lot of userland + internal code immediately, > > but instead allow for migration over a longer period. > > My thoughts on adding 'function types' are here: > > https://github.com/Danack/FunctionTypes/blob/master/function_type_rfc.md > > There's still more than a couple of known problems that need to be > > worked through, as well as probably unknown problems lurking. As email > > is not a good format for carrying out discussions, if people want to > > take part in that discussion, doing it in that repo would be better > > imo. > > Assuming the problems remaining can be addressed, that would give us a > > more useful feature, and the existing 'callables' can be slowly > > deprecated and maybe removed from PHP in the distant future. > > cheers > > Dan > > Ack > > *[problems with callables] - > > https://wiki.php.net/rfc/consistent_callables > > -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php