From 142c67f9d5a82bc7f5991b121327100b417e6754 Mon Sep 17 00:00:00 2001 From: argiepiano Date: Tue, 29 Jul 2025 09:10:59 -0600 Subject: [PATCH] Issue #248. Fix nullables for PHP 8.4 Fixes #248 --- includes/rules.core.inc | 6 +++--- includes/rules.plugins.inc | 6 +++--- rules.module | 4 ++-- ui/ui.core.inc | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/includes/rules.core.inc b/includes/rules.core.inc index 7140b29..5f22390 100644 --- a/includes/rules.core.inc +++ b/includes/rules.core.inc @@ -178,7 +178,7 @@ class RulesEntityController extends EntityPlusControllerExportable { return $config; } - public function save($rules_config, DatabaseTransaction $transaction = NULL) { + public function save($rules_config, ?DatabaseTransaction $transaction = NULL) { $transaction = isset($transaction) ? $transaction : db_transaction(); // Load the stored entity, if any. @@ -296,7 +296,7 @@ class RulesEntityController extends EntityPlusControllerExportable { * * @see EntityAPIControllerExportable::delete() */ - public function delete($ids, DatabaseTransaction $transaction = NULL) { + public function delete($ids, ?DatabaseTransaction $transaction = NULL) { $transaction = isset($transaction) ? $transaction : db_transaction(); // Use entity-load as ids may be the names as well as the ids. $configs = $ids ? entity_load('rules_config', $ids) : array(); @@ -1745,7 +1745,7 @@ abstract class RulesAbstractPlugin extends RulesPlugin { /** * Execute the configured execution callback and log that. */ - abstract protected function executeCallback(array $args, RulesState $state = NULL); + abstract protected function executeCallback(array $args, ?RulesState $state = NULL); public function evaluate(RulesState $state) { $this->processSettings(); diff --git a/includes/rules.plugins.inc b/includes/rules.plugins.inc index 790195b..25864bb 100644 --- a/includes/rules.plugins.inc +++ b/includes/rules.plugins.inc @@ -17,7 +17,7 @@ class RulesAction extends RulesAbstractPlugin implements RulesActionInterface { /** * Execute the callback and update/save data as specified by the action. */ - protected function executeCallback(array $args, RulesState $state = NULL) { + protected function executeCallback(array $args, ?RulesState $state = NULL) { rules_log('Evaluating the action %name.', array( '%name' => $this->label($this->elementName), ), RulesLog::INFO, $this); @@ -107,7 +107,7 @@ class RulesCondition extends RulesAbstractPlugin implements RulesConditionInterf return $this->negate; } - protected function executeCallback(array $args, RulesState $state = NULL) { + protected function executeCallback(array $args, ?RulesState $state = NULL) { $return = (bool) $this->__call('execute', empty($this->info['named parameter']) ? $args : array($args)); $return = $this->negate ? !$return : $return; rules_log('The condition %name evaluated to %bool', array( @@ -416,7 +416,7 @@ class RulesReactionRule extends Rule implements RulesTriggerableInterface { /** * Implements RulesTriggerableInterface::event(). */ - public function event($event_name, array $settings = NULL) { + public function event($event_name, ?array $settings = NULL) { // Process any settings and determine the configured event's name. if ($settings) { $handler = rules_get_event_handler($event_name, $settings); diff --git a/rules.module b/rules.module index ada1ce5..581ae0b 100644 --- a/rules.module +++ b/rules.module @@ -216,7 +216,7 @@ function rules_action_set($variables = array(), $provides = array()) { * (optional) This may be used to denote the beginning (TRUE) or the end * (FALSE) of a new execution scope. */ -function rules_log($msg, $args = array(), $priority = RulesLog::INFO, RulesPlugin $element = NULL, $scope = NULL) { +function rules_log($msg, $args = array(), $priority = RulesLog::INFO, ?RulesPlugin $element = NULL, $scope = NULL) { static $logger, $settings; // Statically cache the variable settings as this is called very often. @@ -711,7 +711,7 @@ function rules_get_event_base_name($event_name) { * @return RulesEventHandlerInterface * The event handler. */ -function rules_get_event_handler($event_name, array $settings = NULL) { +function rules_get_event_handler($event_name, ?array $settings = NULL) { $event_name = rules_get_event_base_name($event_name); $event_info = rules_get_event_info($event_name); $class = !empty($event_info['class']) ? $event_info['class'] : 'RulesEventDefaultHandler'; diff --git a/ui/ui.core.inc b/ui/ui.core.inc index 02aedfb..78c8ff1 100644 --- a/ui/ui.core.inc +++ b/ui/ui.core.inc @@ -862,7 +862,7 @@ class RulesPluginUI extends FacesExtender implements RulesPluginUIInterface { * Generates a path using the given operation for the element with the given * id of the configuration with the given name. */ - public static function path($name, $op = NULL, RulesPlugin $element = NULL, $parameter = FALSE) { + public static function path($name, $op = NULL, ?RulesPlugin $element = NULL, $parameter = FALSE) { $element_id = isset($element) ? $element->elementId() : FALSE; if (isset(self::$basePath)) { $base_path = self::$basePath;