> 2010/12/1 Richard Quadling <rquadl...@gmail.com>
>
>> On 1 December 2010 09:22, Stas Malyshev <smalys...@sugarcrm.com> wrote:
>> > Hi!
>> >
>> >> Its not a matter of consistency - Properties, as a cross-language
>> concept
>> >> are not meant to work that way.  You need to think of a property as a
>> set
>> >
>> > Meant by whom? Is there some law of universe that prevents us from
>> > implementing the feature?
>> >
>> >> of two methods that just have a pretty syntax.  Methods cannot be
>> unset,
>> >> and nor should properties be allowed to.  isset() should simply tell
>> us
>> >> whether a property with the specified name is part of the class or
>> not.
>> >
>> > If you need methods, why not use methods? If you mimick object
>> properties,
>> > however, it makes sense to make them work exactly like property,
>> otherwise
>> > you have to explain why they don't work this way.
>> >
>> >> isset() in the way you suggest would just be confusing.  It would
>> allow
>> is
>> >> to say that a property does not exist, when in fact it does exist.
>> This
>> >> is not logical.
>> >
>> > Sorry, from your answer I don't understand - what happens when you
>> call
>> > isset($foo->property) and unset($foo->property)?
>>
>> If we think of properties as this new entity for the language (rather
>> than somehow massaging existing entities to fit a new usage scenario),
>> then
>>
>> isset($instance->property) will always return true for any defined
>> property. Even if the getter would return null. This is new behaviour
>> and can be easily documented. isset() for a property is more like
>> method_exists() than isset() on a variable.
>> With regard to unset($instance->property), from the manual ...

...

> Why change the expected behavior of isset? If a property has not been set
> then isset must return false, and that includes $foo->name = NULL.


Thats simple then, when isset is invoked, call the get method, and if it
returns null then isset() returns false, but otherwise returns true.  That
was likely just a small oversight on Richard's part.

- Dennis


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

Reply via email to