From ac56ae413557048da3cac2faf74c0bdeac9c81d2 Mon Sep 17 00:00:00 2001 From: flack Date: Sun, 1 Dec 2024 13:25:10 +0100 Subject: [PATCH] Fix php84 deprecations --- lib/midcom/core/privilege.php | 4 ++-- lib/midcom/services/cache/module/content.php | 4 ++-- lib/midcom/services/i18n/formatter.php | 6 +++--- lib/midcom/services/i18n/l10n.php | 2 +- lib/midcom/services/indexer/client.php | 2 +- lib/midcom/services/indexer/main.php | 4 ++-- lib/midcom/services/rcs/handler.php | 2 +- lib/midgard/admin/asgard/handler/preferences.php | 2 +- lib/net/nemein/tag/handler.php | 2 +- lib/org/openpsa/calendar/event/member.php | 4 ++-- lib/org/openpsa/expenses/handler/index.php | 4 ++-- lib/org/openpsa/invoices/handler/list.php | 2 +- lib/org/openpsa/invoices/invoice/pdf.php | 4 ++-- lib/org/openpsa/invoices/scheduler.php | 4 ++-- lib/org/openpsa/mypage/workingon.php | 2 +- src/midcom/datamanager/controller.php | 2 +- src/midcom/grid/provider.php | 2 +- 17 files changed, 26 insertions(+), 26 deletions(-) diff --git a/lib/midcom/core/privilege.php b/lib/midcom/core/privilege.php index 963b3eae4..e5032f170 100644 --- a/lib/midcom/core/privilege.php +++ b/lib/midcom/core/privilege.php @@ -75,7 +75,7 @@ class midcom_core_privilege * The Default constructor creates an empty privilege, if you specify * another privilege object in the constructor, a copy is constructed. */ - public function __construct(midcom_core_privilege_db|array|string $src = null) + public function __construct(midcom_core_privilege_db|array|string|null $src = null) { if (is_array($src)) { // Store given values to our privilege array @@ -444,7 +444,7 @@ public static function get_privilege(midcom_core_dbaobject $object, string $name return new midcom_core_privilege($result[0]); } - private function _load(midcom_core_privilege_db|string $src = null) + private function _load(midcom_core_privilege_db|string|null $src = null) { if ($src instanceof midcom_core_privilege_db) { // Got a privilege object as argument, use that diff --git a/lib/midcom/services/cache/module/content.php b/lib/midcom/services/cache/module/content.php index 9ef3152ec..055888c5c 100644 --- a/lib/midcom/services/cache/module/content.php +++ b/lib/midcom/services/cache/module/content.php @@ -361,7 +361,7 @@ private function get_strategy(string $name) : string * * @see uncached() */ - public function no_cache(Response $response = null) + public function no_cache(?Response $response = null) { $settings = 'no-store, no-cache, must-revalidate'; // PONDER: Send expires header (set to long time in past) as well ?? @@ -451,7 +451,7 @@ public function register_sent_header(string $header) * * {@inheritDoc} */ - public function invalidate(string $guid, midcom_core_dbaobject $object = null) + public function invalidate(string $guid, ?midcom_core_dbaobject $object = null) { $guidmap = $this->backend->getItem($guid); if (!$guidmap->isHit()) { diff --git a/lib/midcom/services/i18n/formatter.php b/lib/midcom/services/i18n/formatter.php index 4b9b508b7..ce23475c0 100644 --- a/lib/midcom/services/i18n/formatter.php +++ b/lib/midcom/services/i18n/formatter.php @@ -31,17 +31,17 @@ public function number(int|float $value, int $precision = 2) return $formatter->format($value); } - public function date(int|string|DateTimeInterface $value = null, int|string $dateformat = 'medium') + public function date(int|string|null|DateTimeInterface $value = null, int|string $dateformat = 'medium') { return $this->datetime($value, $dateformat, IntlDateFormatter::NONE); } - public function time(int|string|DateTimeInterface $value = null, int|string $timeformat = 'short') + public function time(int|string|null|DateTimeInterface $value = null, int|string $timeformat = 'short') { return $this->datetime($value, IntlDateFormatter::NONE, $timeformat); } - public function datetime(int|string|DateTimeInterface $value = null, int|string $dateformat = 'medium', int|string $timeformat = 'short') + public function datetime(int|string|null|DateTimeInterface $value = null, int|string $dateformat = 'medium', int|string $timeformat = 'short') { $value ??= time(); $formatter = new IntlDateFormatter($this->get_locale(), $this->constant($dateformat), $this->constant($timeformat)); diff --git a/lib/midcom/services/i18n/l10n.php b/lib/midcom/services/i18n/l10n.php index 2d63eacc8..8362bd8a0 100644 --- a/lib/midcom/services/i18n/l10n.php +++ b/lib/midcom/services/i18n/l10n.php @@ -252,7 +252,7 @@ public function get_formatter() : midcom_services_i18n_formatter * * @param string $language The language to search in. */ - function string_exists(string $string, string $language = null) : bool + function string_exists(string $string, ?string $language = null) : bool { $language ??= $this->_language; $this->_check_for_language($language); diff --git a/lib/midcom/services/indexer/client.php b/lib/midcom/services/indexer/client.php index 57920e96b..29e78702a 100644 --- a/lib/midcom/services/indexer/client.php +++ b/lib/midcom/services/indexer/client.php @@ -41,7 +41,7 @@ abstract class midcom_services_indexer_client /** * @param midcom_db_topic $topic The current topic */ - public function __construct($topic, midcom_services_indexer $indexer = null) + public function __construct($topic, ?midcom_services_indexer $indexer = null) { $this->_topic = $topic; $this->_l10n = midcom::get()->i18n->get_l10n($topic->component); diff --git a/lib/midcom/services/indexer/main.php b/lib/midcom/services/indexer/main.php index 279364406..2d775b96e 100644 --- a/lib/midcom/services/indexer/main.php +++ b/lib/midcom/services/indexer/main.php @@ -35,7 +35,7 @@ class midcom_services_indexer implements EventSubscriberInterface /** * Initialization */ - public function __construct(midcom_services_indexer_backend $backend = null) + public function __construct(?midcom_services_indexer_backend $backend = null) { $this->_backend = $backend; $this->_disabled = $this->_backend === null; @@ -163,7 +163,7 @@ public function delete_all(string $constraint = '') : bool * @return midcom_services_indexer_document[] An array of documents matching the query * @todo Refactor into multiple methods */ - public function query(string $query, midcom_services_indexer_filter $filter = null, array $options = []) : array + public function query(string $query, ?midcom_services_indexer_filter $filter = null, array $options = []) : array { $result = []; if ($this->_disabled) { diff --git a/lib/midcom/services/rcs/handler.php b/lib/midcom/services/rcs/handler.php index 0ee42fa87..6b6449926 100644 --- a/lib/midcom/services/rcs/handler.php +++ b/lib/midcom/services/rcs/handler.php @@ -57,7 +57,7 @@ private function prepare_backend(string $guid) /** * Prepare version control toolbar */ - private function rcs_toolbar(array $revision, array $revision2 = null) + private function rcs_toolbar(array $revision, ?array $revision2 = null) { $this->add_stylesheet(MIDCOM_STATIC_URL . "/midcom.services.rcs/rcs.css"); $prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX) . $this->url_prefix; diff --git a/lib/midgard/admin/asgard/handler/preferences.php b/lib/midgard/admin/asgard/handler/preferences.php index 749649e17..6368d4867 100644 --- a/lib/midgard/admin/asgard/handler/preferences.php +++ b/lib/midgard/admin/asgard/handler/preferences.php @@ -44,7 +44,7 @@ private function _process_request_data(array &$data) * * @param string $guid The person GUID */ - public function _handler_preferences(Request $request, array &$data, string $guid = null) + public function _handler_preferences(Request $request, array &$data, ?string $guid = null) { midcom::get()->auth->require_valid_user(); diff --git a/lib/net/nemein/tag/handler.php b/lib/net/nemein/tag/handler.php index 0feee3af3..036a42de2 100644 --- a/lib/net/nemein/tag/handler.php +++ b/lib/net/nemein/tag/handler.php @@ -23,7 +23,7 @@ class net_nemein_tag_handler * @param array $tags List of tags and urls, tag is key, url is value * @todo Set the link->navorder property */ - public static function tag_object($object, array $tags, string $component = null) : bool + public static function tag_object($object, array $tags, ?string $component = null) : bool { $component ??= midcom_core_context::get()->get_key(MIDCOM_CONTEXT_COMPONENT); $existing_tags = self::get_object_tags($object); diff --git a/lib/org/openpsa/calendar/event/member.php b/lib/org/openpsa/calendar/event/member.php index 13491aaf7..3a96f1b4d 100644 --- a/lib/org/openpsa/calendar/event/member.php +++ b/lib/org/openpsa/calendar/event/member.php @@ -55,7 +55,7 @@ public function get_label() : string return sprintf(midcom::get()->i18n->get_string('%s in %s', 'midcom'), $person->name, $event->title); } - public function notify(string $type, org_openpsa_calendar_event_dba $event = null, string $nl = "\n") + public function notify(string $type, ?org_openpsa_calendar_event_dba $event = null, string $nl = "\n") { $recipient = $this->get_person_obj(); @@ -221,7 +221,7 @@ public static function find_free_times($amount, midcom_db_person $person, $start return $slots; } - private static function _create_slot(int $start, int $end, ?org_openpsa_calendar_event_dba $previous, org_openpsa_calendar_event_dba $next = null) : array + private static function _create_slot(int $start, int $end, ?org_openpsa_calendar_event_dba $previous, ?org_openpsa_calendar_event_dba $next = null) : array { return [ 'start' => $start, diff --git a/lib/org/openpsa/expenses/handler/index.php b/lib/org/openpsa/expenses/handler/index.php index 6a784db31..6560591db 100644 --- a/lib/org/openpsa/expenses/handler/index.php +++ b/lib/org/openpsa/expenses/handler/index.php @@ -42,7 +42,7 @@ private function prepare_dates(?string $requested_time, array &$data) /** * The handler for the index view. */ - public function _handler_index(Request $request, array &$data, string $timestamp = null) + public function _handler_index(Request $request, array &$data, ?string $timestamp = null) { $this->prepare_dates($timestamp, $data); @@ -142,7 +142,7 @@ private function _get_sorted_reports(midcom_core_collector $hours_mc) : array return array_values($reports); } - private function _get_list_link(string $label, string $date = null, string $task_guid = null, $person_id = null) : string + private function _get_list_link(string $label, ?string $date = null, ?string $task_guid = null, $person_id = null) : string { if ($task_guid !== null) { $url = $this->router->generate('list_hours_task', ['guid' => $task_guid]); diff --git a/lib/org/openpsa/invoices/handler/list.php b/lib/org/openpsa/invoices/handler/list.php index f8d81ec0e..ff9343047 100644 --- a/lib/org/openpsa/invoices/handler/list.php +++ b/lib/org/openpsa/invoices/handler/list.php @@ -39,7 +39,7 @@ public function _on_initialize() midcom::get()->uimessages->add_head_elements(); } - public function get_qb(string $field = null, string $direction = 'ASC', array $search = []) : midcom_core_query + public function get_qb(?string $field = null, string $direction = 'ASC', array $search = []) : midcom_core_query { $qb = org_openpsa_invoices_invoice_dba::new_collector(); if ($field !== null) { diff --git a/lib/org/openpsa/invoices/invoice/pdf.php b/lib/org/openpsa/invoices/invoice/pdf.php index 9f77b3b1a..98b323ae5 100644 --- a/lib/org/openpsa/invoices/invoice/pdf.php +++ b/lib/org/openpsa/invoices/invoice/pdf.php @@ -21,7 +21,7 @@ public function __construct(org_openpsa_invoices_invoice_dba $invoice) $this->invoice = $invoice; } - public function get_attachment(bool $autocreate = false, string $kind = null) : ?midcom_db_attachment + public function get_attachment(bool $autocreate = false, ?string $kind = null) : ?midcom_db_attachment { if ($kind == 'reminder') { $pdf_files = blobs::get_attachments($this->invoice, "pdf_file_reminder"); @@ -67,7 +67,7 @@ public function get_button_options(string $kind = 'invoice') : array ]; } - public function render_and_attach(string $kind = null) : midcom_db_attachment + public function render_and_attach(?string $kind = null) : midcom_db_attachment { if ($kind == null) { $client_class = midcom_baseclasses_components_configuration::get('org.openpsa.invoices', 'config')->get('invoice_pdfbuilder_class'); diff --git a/lib/org/openpsa/invoices/scheduler.php b/lib/org/openpsa/invoices/scheduler.php index 5e793e2ab..c705ce621 100644 --- a/lib/org/openpsa/invoices/scheduler.php +++ b/lib/org/openpsa/invoices/scheduler.php @@ -211,7 +211,7 @@ private function render_task_info(string $label, array $tasks) : string /** * @todo Check if we already have an open task for this delivery? */ - public function create_task(int $start, int $end, string $title, org_openpsa_projects_task_dba $source_task = null) : org_openpsa_projects_task_dba + public function create_task(int $start, int $end, string $title, ?org_openpsa_projects_task_dba $source_task = null) : org_openpsa_projects_task_dba { // Create the task $task = new org_openpsa_projects_task_dba(); @@ -263,7 +263,7 @@ public function create_task(int $start, int $end, string $title, org_openpsa_pro * @param integer $months The maximum number of months to look forward * @param integer $start The timestamp from which to begin */ - public function calculate_cycles(int $months = null, int $start = null) : int + public function calculate_cycles(?int $months = null, ?int $start = null) : int { $start ??= time(); $cycles = 0; diff --git a/lib/org/openpsa/mypage/workingon.php b/lib/org/openpsa/mypage/workingon.php index 212e0e48a..db1f500c9 100644 --- a/lib/org/openpsa/mypage/workingon.php +++ b/lib/org/openpsa/mypage/workingon.php @@ -48,7 +48,7 @@ class org_openpsa_mypage_workingon /** * @param midcom_db_person $person Person to handle "now working on" for. By default current user */ - public function __construct(midcom_db_person $person = null) + public function __construct(?midcom_db_person $person = null) { $this->person = $person ?? midcom::get()->auth->user->get_storage(); diff --git a/src/midcom/datamanager/controller.php b/src/midcom/datamanager/controller.php index fb689a85b..79820822b 100644 --- a/src/midcom/datamanager/controller.php +++ b/src/midcom/datamanager/controller.php @@ -30,7 +30,7 @@ class controller private datamanager $dm; - public function __construct(datamanager $dm, string $name = null) + public function __construct(datamanager $dm, ?string $name = null) { $this->dm = $dm; $this->form = $dm->get_form($name); diff --git a/src/midcom/grid/provider.php b/src/midcom/grid/provider.php index be2306afa..180054f85 100644 --- a/src/midcom/grid/provider.php +++ b/src/midcom/grid/provider.php @@ -103,7 +103,7 @@ public function set_grid(grid $grid) $this->_datatype = $grid->get_option('datatype'); } - public function get_grid(string $identifier = null) : grid + public function get_grid(?string $identifier = null) : grid { if (null !== $identifier) { $this->_grid = new grid($identifier, $this->_datatype);