Hi!
Since we now allow defining return value types for functions, one can
also create definition for magic functions that make no sense, such as
__toString() : float or __isset() : Closure. I think we should restrict
such definitions - either to types that makes sense or in case of
methods that aren't supposed to return anything useful, completely. We
already do this for ctors, dtors and __clone but not consistently for
other magics. Also some values for parameter types make no sense.
I've created a bug https://bugs.php.net/bug.php?id=69718 to track this.
Not sure if this really needs an RFC.
Stas Malyshev
smalyshev@gmail.com
Hi!
Since we now allow defining return value types for functions, one can
also create definition for magic functions that make no sense, such as
__toString() : float or __isset() : Closure. I think we should restrict
such definitions - either to types that makes sense or in case of
methods that aren't supposed to return anything useful, completely. We
already do this for ctors, dtors and __clone but not consistently for
other magics. Also some values for parameter types make no sense.
My original patch for return types did not allow return types for
ctors, dtors, and __clone. It seems you did not preserve this? In any
case no RFC is needed because this was outlined in the RFC:
https://wiki.php.net/rfc/return_types#methods_which_cannot_declare_return_types
The only one that should allow anything for now is __toString which
would be permitted to declare a return type of string.
Hi!
Since we now allow defining return value types for functions, one can
also create definition for magic functions that make no sense, such as
__toString() : float or __isset() : Closure. I think we should restrict
such definitions - either to types that makes sense or in case of
methods that aren't supposed to return anything useful, completely. We
already do this for ctors, dtors and __clone but not consistently for
other magics. Also some values for parameter types make no sense.My original patch for return types did not allow return types for
ctors, dtors, and __clone. It seems you did not preserve this? In any
case no RFC is needed because this was outlined in the RFC:
https://wiki.php.net/rfc/return_types#methods_which_cannot_declare_return_typesThe only one that should allow anything for now is __toString which
would be permitted to declare a return type of string.
My apologies; I misread Dmitry's original statement. Disregard my message.
Hi!
Since we now allow defining return value types for functions, one can
also create definition for magic functions that make no sense, such as
__toString() : float or __isset() : Closure. I think we should restrict
such definitions - either to types that makes sense or in case of
methods that aren't supposed to return anything useful, completely. We
already do this for ctors, dtors and __clone but not consistently for
other magics. Also some values for parameter types make no sense.My original patch for return types did not allow return types for
ctors, dtors, and __clone. It seems you did not preserve this? In any
case no RFC is needed because this was outlined in the RFC:
https://wiki.php.net/rfc/return_types#methods_which_cannot_declare_return_typesThe only one that should allow anything for now is __toString which
would be permitted to declare a return type of string.My apologies; I misread Dmitry's original statement. Disregard my message.
s/Dmitry/Stas/; seems I shouldn't post anything today; sorry for all
the mistakes and noise.