Re: Class Properties in Interfaces?

From: Date: Tue, 29 Apr 2008 18:33:21 +0000
Subject: Re: Class Properties in Interfaces?
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-37365@lists.php.net to get a copy of this message
Hi Stas, hi everbody, Am Dienstag, den 29.04.2008, 10:22 -0700 schrieb Stanislav Malyshev: [...] > In any case, whenever you want to write $foo->bar, just write > $foo->getBar() and $foo->setBar(), and it'd work :) I think the issue is, that PHP does not have defined properties with attached validation (yes, I know about __get()/__set()). Now we just have plain properties that may contain everything. If we would have something like this: class Clazz { public $property { function get() { return $this->property; } function set($property) { $this->property = (int)$property; } } } In this case it, maybe it would make sense to allow definitions of properties in interfaces. For example the following could require a property to be read only: class Clazz { public $property { function get(); } } An interface defines a halfway strict API. Allowing the current properties in interfaces would not add any sensible functionality because it would not define the API better. cu, Lars

Attachment: [application/pgp-signature] Dies ist ein digital signierter Nachrichtenteil signature.asc
« previous php.internals (#37365) next »