No, I don’t expect all objects to have the same properties.
So, today I learned that `$foo = 1; isset($foo->bar);` doesn’t throw an error 
about a non-object. However, property_exists *does* throw errors in that 
situation, as does get_object_vars() - two situations where you *can* pass any 
object, so long as it is an object.

Like I said, the functionality is possible without it. But what functionality 
was impossible without int/float/string type hints? They just make it much 
clearer, with less repeated boiler plate, what arguments you can actually 
accept.


Cheers

Stephen


> On 24 Oct 2016, at 12:05, Stanislav Malyshev <smalys...@gmail.com> wrote:
> 
> Hi!
> 
>> In the same way that Iterable type hint allows you to safely do a
>> foreach on an argument, object allows you to safely use property
>> accessor syntax (i.e. ->). For me it would be most useful in lower
>> level utility classes.
> 
> Not sure I get this point. How you can safely use -> if you have no idea
> what object you've got? You certainly don't expect every object to have
> the same properties?
> 
> -- 
> Stas Malyshev
> smalys...@gmail.com
> 


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

Reply via email to