filebackend: Remove private handleWarning in favour of local closure
authorTimo Tijhof <krinklemail@gmail.com>
Fri, 23 Aug 2019 13:15:33 +0000 (14:15 +0100)
committerKrinkle <krinklemail@gmail.com>
Fri, 23 Aug 2019 20:37:45 +0000 (20:37 +0000)
This is a pattern from before PHP 5.3, which we no longer need.

Change-Id: I886d1ded25ffe1ee12b6a3f8d48c04aa7dd2ef51

includes/libs/filebackend/FSFileBackend.php

index e6a49c7..c05dc28 100644 (file)
@@ -795,8 +795,16 @@ class FSFileBackend extends FileBackendStore {
         * Listen for E_WARNING errors and track whether any happen
         */
        protected function trapWarnings() {
-               $this->hadWarningErrors[] = false; // push to stack
-               set_error_handler( [ $this, 'handleWarning' ], E_WARNING );
+               // push to stack
+               $this->hadWarningErrors[] = false;
+               set_error_handler( function ( $errno, $errstr ) {
+                       // more detailed error logging
+                       $this->logger->error( $errstr );
+                       $this->hadWarningErrors[count( $this->hadWarningErrors ) - 1] = true;
+
+                       // suppress from PHP handler
+                       return true;
+               }, E_WARNING );
        }
 
        /**
@@ -805,20 +813,9 @@ class FSFileBackend extends FileBackendStore {
         * @return bool
         */
        protected function untrapWarnings() {
-               restore_error_handler(); // restore previous handler
-               return array_pop( $this->hadWarningErrors ); // pop from stack
-       }
-
-       /**
-        * @param int $errno
-        * @param string $errstr
-        * @return bool
-        * @private
-        */
-       public function handleWarning( $errno, $errstr ) {
-               $this->logger->error( $errstr ); // more detailed error logging
-               $this->hadWarningErrors[count( $this->hadWarningErrors ) - 1] = true;
-
-               return true; // suppress from PHP handler
+               // restore previous handler
+               restore_error_handler();
+               // pop from stack
+               return array_pop( $this->hadWarningErrors );
        }
 }