final classes and const references to objects

From: Date: Fri, 09 May 2003 17:17:45 +0000
Subject: final classes and const references to objects
Groups: php.internals 
Request: Send a blank email to internals+get-1411@lists.php.net to get a copy of this message
What a work in Zend2 !!! It is getting great, but about object constants in class definition? I need to do something like this: class EnumException extends Exception{ } final class Car { //private const _ferrari = 0; const _porsche = 1; const _corvette = 2; //private const _last_value = 2; //public const ferrari = new Car(_ferrari); const porsche = new Car(_porsche); const corvette = new Car(_corvette); private $value; protected function __construct($value) { if (($value < 0) || ($value > _last_value)) { throw new EnumException(); } $this->value = $value; } public function value() { return $this->value; } } Everything works fine, except the final keyword for the class and the const initialization with an object. I think final classes would be a good approach in assuring that a class will not be modified(inherited). Why can´t objects be assigned to constants ? Is there another way of doing this in Zend2 ? Thanx, Cristiano Duarte

« previous php.internals (#1411) next »