Przeglądaj źródła

Use array_replace instead of manually looping through items

Jordi Boggiano 12 lat temu
rodzic
commit
b33357d16b
1 zmienionych plików z 1 dodań i 6 usunięć
  1. 1 6
      src/Monolog/ErrorHandler.php

+ 1 - 6
src/Monolog/ErrorHandler.php

@@ -81,12 +81,7 @@ class ErrorHandler
     public function registerErrorHandler(array $levelMap = array(), $callPrevious = true, $errorTypes = -1)
     {
         $prev = set_error_handler(array($this, 'handleError'), $errorTypes);
-        $this->errorLevelMap = $this->defaultErrorLevelMap();
-        // merging the map into the defaults by hand because array_merge
-        // trips up on numeric keys
-        foreach ($levelMap as $key => $val) {
-            $this->errorLevelMap[$key] = $val;
-        }
+        $this->errorLevelMap = array_replace($this->defaultErrorLevelMap(), $levelMap);
         if ($callPrevious) {
             $this->previousErrorHandler = $prev ?: true;
         }