Skip to content

Commit

Permalink
Fix php84 deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
flack committed Dec 1, 2024
1 parent 9e637f3 commit ac56ae4
Show file tree
Hide file tree
Showing 17 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions lib/midcom/core/privilege.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/midcom/services/cache/module/content.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ??
Expand Down Expand Up @@ -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()) {
Expand Down
6 changes: 3 additions & 3 deletions lib/midcom/services/i18n/formatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion lib/midcom/services/i18n/l10n.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lib/midcom/services/indexer/client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions lib/midcom/services/indexer/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion lib/midcom/services/rcs/handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/midgard/admin/asgard/handler/preferences.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion lib/net/nemein/tag/handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions lib/org/openpsa/calendar/event/member.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions lib/org/openpsa/expenses/handler/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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]);
Expand Down
2 changes: 1 addition & 1 deletion lib/org/openpsa/invoices/handler/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions lib/org/openpsa/invoices/invoice/pdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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');
Expand Down
4 changes: 2 additions & 2 deletions lib/org/openpsa/invoices/scheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/org/openpsa/mypage/workingon.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion src/midcom/datamanager/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/midcom/grid/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ac56ae4

Please sign in to comment.