Re: Clarification on the Enum language structure

From: Date: Mon, 14 Feb 2011 15:45:03 +0000
Subject: Re: Clarification on the Enum language structure
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-51447@lists.php.net to get a copy of this message
Jarrod Nettles wrote:
So, my proposed syntax would look something more like this.
I think also and was wondering about the current rfc for a few weeks. Im not a core developer but I want to outline what i would expect as php framework developer.
namespace System\Logs {
                 enum Levels{
                                 DEBUG,
                                 INFO,
                                 WARNING,
                                 ERROR
                 };
}
Yes, after that I would expect a new type "Levels" and the possibility to do something like this: $log = new Levels; $log = WARNING; or $log = new Levels(WARNING); Like the current rfc i think, therefore we need the corresponding constants to be defined by defining the Levels type. Furthermore we should have the appropriate type hints for function/method calls. Assuming, we have a method like this public function setLogLevel (Levels $logLevel) {
    $this->logLevel = $logLevel;
} i would like to call them by delivering $log as a parameter $someLogginObject->setLogLevel($log) and get an error in the case the type of $log is not Levels. What do you think about a viable approach to implement a enum language structure. The current rfc seams not very useful for me. Thanks! Thomas Gutbier Web Developer Hannover, Germany

« previous php.internals (#51447) next »