On Wed, 6 Feb 2019 at 12:38, Benjamin Morel <benjamin.mo...@gmail.com> wrote:
> While playing with typed properties, something that annoys me a lot, in the > context of a data mapper, is not to be able to use isset() to check whether > an object's property is initialized. > This sounds like a reasonable problem to raise... > Would it be possible to introduce another isset() operator, that would > return true for NULL values? > ...but this sounds like the wrong solution. The distinction you need has nothing to do with nulls, it has to do with the very specific case of "this property currently violates its contract and I want to treat that as something other than an error". I personally still think that unset() should raise an error for typed properties, but apparently there are cunning hacks that it makes possible; as such, 99% of PHP developers should never need to detect this state. It therefore makes more sense to me to have this as a specific API relating to typed properties; if it can be done faster outside the reflection class, it could be in the form of a new function like property_is_initialized($object, $propertyName); this would be an extension of property_exists, that handles the edge case of "declared with a type and then explicitly unset". Regards, -- Rowan Collins [IMSoP]