Uploaded image for project: 'Log4php'
  1. Log4php
  2. LOG4PHP-178

Avoid usage errors by adding Type Hints

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.2.1
    • 2.3.0
    • None

    Description

      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; }

      Attachments

        Activity

          People

            juice Ivan Habunek
            lathspell Christian Brunotte
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: