#23684 [NEW]: Final Classes and Const references to Objects
| From: | cunha17 at uol dot com dot br | Date: | Sun, 18 May 2003 19:49:20 +0000 |
| Subject: | #23684 [NEW]: Final Classes and Const references to Objects | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-39900@lists.php.net to get a copy of this message | ||
From: cunha17 at uol dot com dot br
Operating system: Linux
PHP version: 5CVS-2003-05-18 (dev)
PHP Bug Type: Feature/Change Request
Bug description: Final Classes and Const references to Objects
What a work in Zend2 !!! It is getting great, but what about final classes
and 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 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
--
Edit bug report at http://bugs.php.net/?id=23684&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=23684&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=23684&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=23684&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=23684&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=23684&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=23684&r=support
Expected behavior: http://bugs.php.net/fix.php?id=23684&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=23684&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=23684&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=23684&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=23684&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=23684&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=23684&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=23684&r=gnused