On 07/12/2015 05:12 PM, Rasmus Lerdorf wrote:
> On 07/12/2015 12:37 PM, Larry Garfield wrote:
>> I don't know why we're even talking about IDEs here.  IDE
>> auto-completion isn't the point, anymore than it was the point for
>> scalar type hints or return type hints.  It's about the language doing
>> type checking for you and static analysis, so that the language can find
>> bugs for you. Eg:
>>
>> class Foo {
>>   public Bar $bar;
>> }
>>
>> $f = new Foo();
>> $f->bar = new Baz(); // This line is clearly wrong and the compiler can 
>> check it for you

By the way, I forgot to add that you can't possibly say that this line
is clearly wrong without knowing what Baz is and you didn't define Baz.
So the only thing clearly wrong with that line is that the Baz class
doesn't exist which has nothing to do with the property type.

If you have:

    class Bar { }
    class Baz extends Bar { }

Then that line is perfectly valid since Baz is an instance of Bar which
would meet the type criteria provided. And this also shows that the
compiler can't actually check that necessarily. We don't know whether
Baz is an instance of Bar at compile-time.

-Rasmus

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to