On 16 July 2018 at 09:43, Rowan Collins <rowan.coll...@gmail.com> wrote:

> There's no contradiction here; throwing an error when a
> property is *read* is not the same as enforcing that it always has a valid 
> value.

That's true, but claiming the RFC just 'trusts' the users to
initialise them is a miss-representation of the RFC to me. The RFC
catches the mistake if the programmer fails to initialise the variable
then reads from it.

> If not, the object created would not be fully initialised,

This is always going to be the case, unless you're proposing to
deprecate ReflectionClass::newInstanceWithoutConstructor .... which is
going to break a huge number of applications.

tbh, I really don't see a real problem that needs to be fixed. For me
it is the equivalent of this:

function foo() : int {
   return "five";
}

This gives an error when the code is run, not when the code is
compiled, despite it being a 'detectable' error. In most compiled
languages, this error would be detected at the compilation step. In
'dynamic' languages it is detected at run-time.

The same is true for classes with typed properties. Yes, if you make a
mistake and forget to set a typed property before using an object
there will be an error.

That would only be a problem in production if you don't run that code
at all in development or in test....which is true of many, many
things.

cheers
Dan

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to