Hi Clint,

In order to achieve read-only and write-only, we could do something
similar to this:

/* Explicitly read-only, sub-classes may redefine the getter but may
not define a setter */
public $Hours {
    get() { ... }
    final private set() {}
}

This would make the additional keyword superfluous. It's very similar
to what is currently done in Singleton classes that usually have
private constructors.

Second, I'd like to throw in the idea of array accessors. I mentioned
this before, but did not get any response.

public $Addresses {
    offsetSet($offset, $value) { ... }
    offsetGet() { ... }
    offsetUnset($offset) { ... }
    offsetExists($offset) { ... }
}

The reasoning for this feature is that in object-oriented design you
have to process logic when establishing bidirectional associations
between objects. For example, adding an Address to a Contact instance
would require Address::$Contact to be set as well if the association
is bidirectional.

public $Addresses {
    offsetSet($offset, $address) {
        $address->Contact = $this;
    }
}

$contact->Addresses[] = new Address();

What do you think about supporting this?

Cheers,
Bernhard

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

Reply via email to