[ https://issues.apache.org/jira/browse/LOG4PHP-178?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13284336#comment-13284336 ]
Vladimir Gorej commented on LOG4PHP-178: ---------------------------------------- You can overcome this problem by defining the signature of the method as follows: public function setLevel(LoggerLevel $level = null) This way, seLevel method can only accept LoggerLevel instance or null > Avoid usage errors by adding Type Hints > --------------------------------------- > > Key: LOG4PHP-178 > URL: https://issues.apache.org/jira/browse/LOG4PHP-178 > Project: Log4php > Issue Type: Improvement > Affects Versions: 2.2.1 > Reporter: Christian Hammers > Assignee: Ivan Habunek > Priority: Minor > Labels: patch > > It's tempting to write: > $this->log = Logger::getRootLogger(); > $this->log->setLevel(LoggerLevel::WARN); > which at first succeedes but throws an exception when first using this Logger. > It would be more obvious to the user when he gets an immediate compiler error > due to type hints. > --- Logger.php.orig 2012-05-25 16:55:35.000000000 +0200 > > +++ Logger.php 2012-05-25 17:02:04.000000000 +0200 > > @@ -376,9 +376,11 @@ > > /** > > * Set the Logger level. > * > + * Use LoggerLevel::getLevelWarn() etc. to get a LoggerLevel object. > + * > * @param LoggerLevel $level the level to set > */ > - public function setLevel($level) { > + public function setLevel(LoggerLevel $level) { > $this->level = $level; > } > -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira