From 47eea6b693bfad804111a692ff772b35d533642f Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Fri, 4 Jun 2021 00:42:47 +0000 Subject: [PATCH] [REF][php8-compat] Fix more instances of where there is a required parameter for a function after an optional one and fix an issue where by a NULL function property is treated as not exisiting in php8 --- CRM/Core/Permission/UnitTests.php | 3 +-- CRM/Core/Reference/OptionValue.php | 2 +- CRM/Utils/Pager.php | 2 +- Civi/Payment/PropertyBag.php | 2 +- tests/phpunit/CRM/Contact/BAO/RelationshipTest.php | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/CRM/Core/Permission/UnitTests.php b/CRM/Core/Permission/UnitTests.php index 24879ab5a3..0143bc352d 100644 --- a/CRM/Core/Permission/UnitTests.php +++ b/CRM/Core/Permission/UnitTests.php @@ -43,9 +43,8 @@ class CRM_Core_Permission_UnitTests extends CRM_Core_Permission_Base { if ($str == CRM_Core_Permission::ALWAYS_ALLOW_PERMISSION) { return TRUE; } - // return the stubbed permission (defaulting to true if the array is missing) - return is_array($this->permissions) ? in_array($str, $this->permissions) : TRUE; + return isset($this->permissions) && is_array($this->permissions) ? in_array($str, $this->permissions) : TRUE; } /** diff --git a/CRM/Core/Reference/OptionValue.php b/CRM/Core/Reference/OptionValue.php index 9908be044b..4641321239 100644 --- a/CRM/Core/Reference/OptionValue.php +++ b/CRM/Core/Reference/OptionValue.php @@ -25,7 +25,7 @@ class CRM_Core_Reference_OptionValue extends CRM_Core_Reference_Basic { * @param string $targetKey * @param null $optionGroupName */ - public function __construct($refTable, $refKey, $targetTable = NULL, $targetKey = 'id', $optionGroupName) { + public function __construct($refTable, $refKey, $targetTable, $targetKey, $optionGroupName) { parent::__construct($refTable, $refKey, $targetTable, $targetKey, NULL); $this->targetOptionGroupName = $optionGroupName; } diff --git a/CRM/Utils/Pager.php b/CRM/Utils/Pager.php index 692daf8547..d0c7a1d557 100644 --- a/CRM/Utils/Pager.php +++ b/CRM/Utils/Pager.php @@ -177,7 +177,7 @@ class CRM_Utils_Pager extends Pager_Sliding { * @return int * new pageId to display to the user */ - public function getPageID($defaultPageId = 1, &$params) { + public function getPageID($defaultPageId, &$params) { // POST has higher priority than GET vars // else if a value is set that has higher priority and finally the GET var $currentPage = $defaultPageId; diff --git a/Civi/Payment/PropertyBag.php b/Civi/Payment/PropertyBag.php index 7a1119aea3..1e9c5988de 100644 --- a/Civi/Payment/PropertyBag.php +++ b/Civi/Payment/PropertyBag.php @@ -296,7 +296,7 @@ class PropertyBag implements \ArrayAccess { * * @return PropertyBag $this object so you can chain set setters. */ - protected function set($prop, $label = 'default', $value) { + protected function set($prop, $label, $value) { $this->props[$label][$prop] = $value; return $this; } diff --git a/tests/phpunit/CRM/Contact/BAO/RelationshipTest.php b/tests/phpunit/CRM/Contact/BAO/RelationshipTest.php index a78e350c5b..fd8329c4a2 100644 --- a/tests/phpunit/CRM/Contact/BAO/RelationshipTest.php +++ b/tests/phpunit/CRM/Contact/BAO/RelationshipTest.php @@ -139,7 +139,7 @@ class CRM_Contact_BAO_RelationshipTest extends CiviUnitTestCase { * * @dataProvider getRelationshipTypeDuplicates */ - public function testRemoveRelationshipTypeDuplicates($relationshipTypeList, $suffix = NULL, $expected, $description) { + public function testRemoveRelationshipTypeDuplicates($relationshipTypeList, $suffix, $expected, $description) { $result = CRM_Contact_BAO_Relationship::removeRelationshipTypeDuplicates($relationshipTypeList, $suffix); $this->assertEquals($expected, $result, "Failure on set '$description'"); } -- 2.25.1