From 446dcf1ccdcdd8f7c9a0d59a7ba0b9a354dd705f Mon Sep 17 00:00:00 2001 From: Jessica Clarke Date: Mon, 11 Jan 2021 02:02:16 +0000 Subject: [PATCH] Fix error handler on PHP 8 Summary: PHP 7.2.0 deprecated the 5th parameter and PHP 8 removed it, so stop using it and provide a default value to avoid erroring with: ``` Too few arguments to function PhutilErrorHandler::handleError(), 4 passed and exactly 5 expected ``` Test Plan: Used to create this revision with PHP 8 on macOS Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: Korvin Maniphest Tasks: T13588 Differential Revision: https://secure.phabricator.com/D21498 --- src/error/PhutilErrorHandler.php | 5 ++--- src/error/PhutilErrorTrap.php | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/error/PhutilErrorHandler.php b/src/error/PhutilErrorHandler.php index deb6ee16..95af88b6 100644 --- a/src/error/PhutilErrorHandler.php +++ b/src/error/PhutilErrorHandler.php @@ -180,10 +180,10 @@ final class PhutilErrorHandler extends Phobject { * @return void * @task internal */ - public static function handleError($num, $str, $file, $line, $ctx) { + public static function handleError($num, $str, $file, $line, $ctx = null) { foreach (self::$traps as $trap) { - $trap->addError($num, $str, $file, $line, $ctx); + $trap->addError($num, $str, $file, $line); } if ((error_reporting() & $num) == 0) { @@ -214,7 +214,6 @@ final class PhutilErrorHandler extends Phobject { array( 'file' => $file, 'line' => $line, - 'context' => $ctx, 'error_code' => $num, 'trace' => $trace, )); diff --git a/src/error/PhutilErrorTrap.php b/src/error/PhutilErrorTrap.php index 94d291d0..252a37f9 100644 --- a/src/error/PhutilErrorTrap.php +++ b/src/error/PhutilErrorTrap.php @@ -41,13 +41,12 @@ final class PhutilErrorTrap extends Phobject { private $destroyed; private $errors = array(); - public function addError($num, $str, $file, $line, $ctx) { + public function addError($num, $str, $file, $line) { $this->errors[] = array( 'num' => $num, 'str' => $str, 'file' => $file, 'line' => $line, - 'ctx' => $ctx, ); return $this; }