Skip to content

Commit

Permalink
Improve php84 compat
Browse files Browse the repository at this point in the history
  • Loading branch information
flack committed May 13, 2024
1 parent b22c21e commit 598445d
Show file tree
Hide file tree
Showing 76 changed files with 100 additions and 100 deletions.
2 changes: 1 addition & 1 deletion lib/fi/protie/navigation/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class fi_protie_navigation
/**
* Here we initialize the classes and variables needed through the class.
*/
public function __construct(int $id = null)
public function __construct(?int $id = null)
{
$this->_nap = new midcom_helper_nav();
$this->get_node_path();
Expand Down
2 changes: 1 addition & 1 deletion lib/midcom.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static function init(string $environment = 'prod', bool $debug = false) :
* @param string $name The service name as listed in the _service_classes array or null to get midcom_application
* @return midcom_application The midcom application instance
*/
public static function get(string $name = null)
public static function get(?string $name = null)
{
if (!self::$_application) {
self::init();
Expand Down
2 changes: 1 addition & 1 deletion lib/midcom/admin/folder/handler/move.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function _handler_move(Request $request, string $guid, array &$data)
return $this->get_workflow('viewer')->run($request);
}

public function show_tree(midcom_db_topic $folder = null, bool $tree_disabled = false)
public function show_tree(?midcom_db_topic $folder = null, bool $tree_disabled = false)
{
$folder ??= midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ROOTTOPIC);

Expand Down
2 changes: 1 addition & 1 deletion lib/midcom/admin/help/help.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private static function get_documentation_dir(string $component) : string
return midcom::get()->componentloader->path_to_snippetpath($component) . '/documentation/';
}

public static function generate_file_path(string $help_id, string $component, string $language = null) : ?string
public static function generate_file_path(string $help_id, string $component, ?string $language = null) : ?string
{
$language ??= midcom::get()->i18n->get_current_language();

Expand Down
2 changes: 1 addition & 1 deletion lib/midcom/baseclasses/components/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function set_active_leaf($leaf_id)
/**
* Convenience shortcut for adding CSS files
*/
public function add_stylesheet(string $url, string $media = null)
public function add_stylesheet(string $url, ?string $media = null)
{
midcom::get()->head->add_stylesheet($url, $media);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/midcom/baseclasses/components/handler/rest.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ protected function _process_request() : JsonResponse
* sends the response as json
* containing the current response data
*/
private function _send_response(string $message = null) : JsonResponse
private function _send_response(?string $message = null) : JsonResponse
{
// always add status code and message
$this->_response['code'] = $this->_responseStatus;
Expand Down
6 changes: 3 additions & 3 deletions lib/midcom/core/context.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ class midcom_core_context
/**
* Create and prepare a new component context.
*
* @param midcom_db_topic $node Root node of the context
* @param ?midcom_db_topic $node Root node of the context
*/
public function __construct(midcom_db_topic $node = null)
public function __construct(?midcom_db_topic $node = null)
{
$this->_data[MIDCOM_CONTEXT_URI] = $_SERVER['REQUEST_URI'] ?? '';
$this->_data[MIDCOM_CONTEXT_ROOTTOPIC] = $node;
$this->id = self::$counter++;
}

public static function enter(string $url = null, midcom_db_topic $topic = null) : self
public static function enter(?string $url = null, ?midcom_db_topic $topic = null) : self
{
$context = new static($topic);
array_push(self::$stack, $context);
Expand Down
6 changes: 3 additions & 3 deletions lib/midcom/core/dbaobject.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public static function new_query_builder() : midcom_core_querybuilder
* @param string $domain The domain property of the collector instance
* @param mixed $value Value match for the collector instance
*/
public static function new_collector(string $domain = null, $value = null) : midcom_core_collector
public static function new_collector(?string $domain = null, $value = null) : midcom_core_collector
{
return midcom::get()->dbfactory->new_collector(get_called_class(), $domain, $value);
}
Expand Down Expand Up @@ -347,11 +347,11 @@ public function can_user_do(string $privilege, $user = null) : bool
{
return midcom::get()->auth->can_user_do($privilege, $user, $this->__midcom_class_name__);
}
public function require_do(string $privilege, string $message = null)
public function require_do(string $privilege, ?string $message = null)
{
midcom::get()->auth->require_do($privilege, $this, $message);
}
public function require_user_do(string $privilege, string $message = null)
public function require_user_do(string $privilege, ?string $message = null)
{
midcom::get()->auth->require_user_do($privilege, $message, $this->__midcom_class_name__);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/midcom/core/privilege.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public function get_assignee() : ?object
/**
* Checks whether the current assignee is a magic assignee or an object identifier.
*/
public function is_magic_assignee(string $assignee = null) : bool
public function is_magic_assignee(?string $assignee = null) : bool
{
$assignee ??= $this->assignee;
return in_array($assignee, ['SELF', 'EVERYONE', 'USERS', 'ANONYMOUS', 'OWNER']);
Expand Down
2 changes: 1 addition & 1 deletion lib/midcom/db/attachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ private function get_cache_path() : string
return "{$cacheroot}/{$subdir}/{$this->guid}/{$this->name}";
}

public static function get_url(midgard_attachment|midcom_db_attachment|string $attachment, string $name = null) : string
public static function get_url(midgard_attachment|midcom_db_attachment|string $attachment, ?string $name = null) : string
{
if (is_string($attachment)) {
$guid = $attachment;
Expand Down
2 changes: 1 addition & 1 deletion lib/midcom/error/forbidden.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class midcom_error_forbidden extends midcom_error
{
private string $method;

public function __construct(string $message = null, int $code = Response::HTTP_FORBIDDEN, string $method = 'form')
public function __construct(?string $message = null, int $code = Response::HTTP_FORBIDDEN, string $method = 'form')
{
$message ??= midcom::get()->i18n->get_string('access denied', 'midcom');
$this->method = $method;
Expand Down
2 changes: 1 addition & 1 deletion lib/midcom/helper/configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class midcom_helper_configuration
* @param mixed $source Either an associative array or a Midgard object.
* @param string $path Either null or the name of a Parameter domain.
*/
public function __construct($source, string $path = null)
public function __construct($source, ?string $path = null)
{
if ($path !== null) {
$this->_object = $source;
Expand Down
4 changes: 2 additions & 2 deletions lib/midcom/helper/head.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public function add_link_head(array $attributes, bool $prepend = false)
*
* @param string $media The media type(s) for the stylesheet, if any
*/
public function add_stylesheet(string $url, string $media = null)
public function add_stylesheet(string $url, ?string $media = null)
{
$this->add_link_head($this->prepare_stylesheet_attributes($url, $media));
}
Expand All @@ -257,7 +257,7 @@ public function add_stylesheet(string $url, string $media = null)
*
* @param string $media The media type(s) for the stylesheet, if any
*/
public function prepend_stylesheet(string $url, string $media = null)
public function prepend_stylesheet(string $url, ?string $media = null)
{
$this->add_link_head($this->prepare_stylesheet_attributes($url, $media), true);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/midcom/helper/imagepopup/handler/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class midcom_helper_imagepopup_handler_list extends midcom_baseclasses_component
*/
private array $_search_results = [];

public function _handler_list(Request $request, string $handler_id, string $filetype, array &$data, string $guid = null)
public function _handler_list(Request $request, string $handler_id, string $filetype, array &$data, ?string $guid = null)
{
midcom::get()->cache->content->no_cache();
midcom::get()->auth->require_valid_user();
Expand Down
2 changes: 1 addition & 1 deletion lib/midcom/helper/imagepopup/handler/upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
class midcom_helper_imagepopup_handler_upload extends midcom_baseclasses_components_handler
{
public function _handler_upload(Request $request, string $guid = null)
public function _handler_upload(Request $request, ?string $guid = null)
{
// Get the file
$temp = $request->files->get('file');
Expand Down
2 changes: 1 addition & 1 deletion lib/midcom/helper/nav/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ public function find_closest_topic(midcom_core_dbaobject $object) : ?midcom_db_t
* @param int $skip_levels The number of topic levels to skip before starting to work (use this to skip 'Home' links etc.).
* @param string $current_class The class that should be assigned to the currently active element.
*/
public function get_breadcrumb_line(string $separator = ' > ', string $class = null, int $skip_levels = 0, string $current_class = null, array $skip_guids = []) : string
public function get_breadcrumb_line(string $separator = ' > ', ?string $class = null, int $skip_levels = 0, ?string $current_class = null, array $skip_guids = []) : string
{
$breadcrumb_data = $this->get_breadcrumb_data();
$result = '';
Expand Down
6 changes: 3 additions & 3 deletions lib/midcom/helper/reflector/nameresolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct(object $object)
* @param string $name_property property to use as "name", if left to default (null), will be reflected
* @return string value of name property or null on failure
*/
public function get_object_name(string $name_property = null) : ?string
public function get_object_name(?string $name_property = null) : ?string
{
$name_property ??= midcom_helper_reflector::get_name_property($this->_object);
if ( empty($name_property)
Expand All @@ -46,7 +46,7 @@ public function get_object_name(string $name_property = null) : ?string
* @see http://trac.midgard-project.org/ticket/809
* @param string $name_property property to use as "name", if left to default (null), will be reflected
*/
public function name_is_clean(string $name_property = null) : bool
public function name_is_clean(?string $name_property = null) : bool
{
if ($name_copy = $this->get_object_name($name_property)) {
return $name_copy === midcom_helper_misc::urlize($name_copy);
Expand All @@ -61,7 +61,7 @@ public function name_is_clean(string $name_property = null) : bool
* @see http://trac.midgard-project.org/ticket/809
* @param string $name_property property to use as "name", if left to default (null), will be reflected
*/
public function name_is_safe(string $name_property = null) : bool
public function name_is_safe(?string $name_property = null) : bool
{
if ($name_copy = $this->get_object_name($name_property)) {
return $name_copy === rawurlencode($name_copy);
Expand Down
2 changes: 1 addition & 1 deletion lib/midcom/helper/toolbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class midcom_helper_toolbar
* Note that the styles can be changed after construction by updating
* the id_style and class_style members.
*/
public function __construct(string $class_style = 'midcom_toolbar', string $id_style = null)
public function __construct(string $class_style = 'midcom_toolbar', ?string $id_style = null)
{
$this->id_style = $id_style;
$this->class_style = $class_style;
Expand Down
2 changes: 1 addition & 1 deletion lib/midcom/helper/toolbar/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class midcom_helper_toolbar_view extends midcom_helper_toolbar
* @param string $class_style The class style tag for the UL.
* @param string $id_style The id style tag for the UL.
*/
public function __construct(string $class_style = null, string $id_style = null)
public function __construct(?string $class_style = null, ?string $id_style = null)
{
$config = midcom::get()->config;
$class_style = $class_style ?: $config->get('toolbars_view_style_class');
Expand Down
2 changes: 1 addition & 1 deletion lib/midcom/services/auth/backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public function authenticate(string $username, string $password, bool $trusted =
* Creates a login session using the given credentials. It assumes that
* no login has concluded earlier
*/
public function login(string $username, string $password, string $clientip = null, bool $trusted = false) : ?midcom_core_user
public function login(string $username, string $password, ?string $clientip = null, bool $trusted = false) : ?midcom_core_user
{
$user = $this->authenticate($username, $password, $trusted);

Expand Down
14 changes: 7 additions & 7 deletions lib/midcom/services/auth/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public function can_user_do(string $privilege, $user = null, $class = null) : bo
*
* @param string $domain The domain to request sudo for. This is a component name.
*/
public function request_sudo(string $domain = null) : bool
public function request_sudo(?string $domain = null) : bool
{
if (!midcom::get()->config->get('auth_allow_sudo')) {
debug_add("SUDO is not allowed on this website.", MIDCOM_LOG_ERROR);
Expand Down Expand Up @@ -274,7 +274,7 @@ public function is_component_sudo() : bool
*
* It always returns true for administrative users.
*/
public function is_group_member(midcom_core_group|string $group, midcom_core_user $user = null) : bool
public function is_group_member(midcom_core_group|string $group, ?midcom_core_user $user = null) : bool
{
if ($this->is_admin($user)) {
// Administrators always have access.
Expand Down Expand Up @@ -313,7 +313,7 @@ public function is_valid_user() : bool
*
* @param MidgardObject $content_object A Midgard Content Object
*/
public function require_do(string $privilege, object $content_object, string $message = null)
public function require_do(string $privilege, object $content_object, ?string $message = null)
{
if (!$this->can_do($privilege, $content_object)) {
throw $this->access_denied($message, 'privilege %s not granted', $privilege);
Expand All @@ -336,7 +336,7 @@ public function require_do(string $privilege, object $content_object, string $me
*
* @param string $class Optional parameter to set if the check should take type specific permissions into account. The class must be default constructible.
*/
public function require_user_do(string $privilege, string $message = null, string $class = null)
public function require_user_do(string $privilege, ?string $message = null, ?string $class = null)
{
if (!$this->can_user_do($privilege, class: $class)) {
throw $this->access_denied($message, 'privilege %s not granted', $privilege);
Expand Down Expand Up @@ -372,14 +372,14 @@ function require_group_member($group, $message = null)
*
* If the check is successful, the function returns silently.
*/
public function require_admin_user(string $message = null)
public function require_admin_user(?string $message = null)
{
if (!$this->admin && !$this->_component_sudo) {
throw $this->access_denied($message, 'admin level privileges required');
}
}

private function access_denied(?string $message, string $fallback, string $data = null) : midcom_error_forbidden
private function access_denied(?string $message, string $fallback, ?string $data = null) : midcom_error_forbidden
{
if ($message === null) {
$message = midcom::get()->i18n->get_string('access denied: ' . $fallback, 'midcom');
Expand Down Expand Up @@ -544,7 +544,7 @@ public function get_group(string|int|midcom_db_group|midgard_group $id) : ?midco
/**
* This call tells the backend to log in.
*/
public function login(string $username, string $password, string $clientip = null) : bool
public function login(string $username, string $password, ?string $clientip = null) : bool
{
if ($user = $this->backend->login($username, $password, $clientip)) {
$this->set_user($user);
Expand Down
2 changes: 1 addition & 1 deletion lib/midcom/services/cache/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ public function invalidate_all()
/**
* Invalidate all cache objects related to the given GUID.
*/
abstract public function invalidate(string $guid, midcom_core_dbaobject $object = null);
abstract public function invalidate(string $guid, ?midcom_core_dbaobject $object = null);
}
4 changes: 2 additions & 2 deletions lib/midcom/services/cache/module/memcache.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function __construct(midcom_config $config, AdapterInterface $backend)
/**
* {@inheritDoc}
*/
public function invalidate(string $guid, midcom_core_dbaobject $object = null)
public function invalidate(string $guid, ?midcom_core_dbaobject $object = null)
{
foreach ($this->_data_groups as $group) {
if ($group == 'ACL') {
Expand Down Expand Up @@ -89,7 +89,7 @@ public function get(string $data_group, string $key)
* Sets a given key in the cache. If the data group is unknown, a Warning-Level error
* is logged and putting is denied.
*/
public function put(string $data_group, string $key, $data, int $timeout = null)
public function put(string $data_group, string $key, $data, ?int $timeout = null)
{
if (!in_array($data_group, $this->_data_groups)) {
debug_add("Tried to add data to the unknown data group {$data_group}, cannot do that.", MIDCOM_LOG_WARN);
Expand Down
2 changes: 1 addition & 1 deletion lib/midcom/services/cache/module/nap.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class midcom_services_cache_module_nap extends midcom_services_cache_module
/**
* {@inheritDoc}
*/
public function invalidate(string $guid, midcom_core_dbaobject $object = null)
public function invalidate(string $guid, ?midcom_core_dbaobject $object = null)
{
$napobject = $this->get_guid($guid);

Expand Down
2 changes: 1 addition & 1 deletion lib/midcom/services/i18n/formatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function customdate($value, string $pattern)
return $formatter->format($value);
}

public function timeframe($start, $end, string $mode = 'both', string $range_separator = null, bool $fulldate = false) : string
public function timeframe($start, $end, string $mode = 'both', ?string $range_separator = null, bool $fulldate = false) : string
{
$ranger = new Ranger($this->get_locale());
if ($mode !== 'date') {
Expand Down
4 changes: 2 additions & 2 deletions lib/midcom/services/indexer/backend/solr.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private function post(bool $optimize = false)
/**
* {@inheritDoc}
*/
public function query(string $querystring, midcom_services_indexer_filter $filter = null, array $options = []) : array
public function query(string $querystring, ?midcom_services_indexer_filter $filter = null, array $options = []) : array
{
// FIXME: adapt the whole indexer system to fetching enable querying for counts and slices
$query = array_merge($this->config->get_array('indexer_config_options'), $options);
Expand Down Expand Up @@ -143,7 +143,7 @@ public function query(string $querystring, midcom_services_indexer_filter $filte
return $result;
}

private function prepare_request(string $action, string $body = null, string $method = 'GET') : Request
private function prepare_request(string $action, ?string $body = null, string $method = 'GET') : Request
{
$uri = "http://" . $this->config->get('indexer_xmltcp_host');
$uri .= ":" . $this->config->get('indexer_xmltcp_port');
Expand Down
6 changes: 3 additions & 3 deletions lib/midcom/services/metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class midcom_services_metadata
* @param int $context_id The context to retrieve the view metadata for, this
* defaults to the current context.
*/
public function get_view_metadata(int $context_id = null) : ?midcom_helper_metadata
public function get_view_metadata(?int $context_id = null) : ?midcom_helper_metadata
{
$context_id ??= midcom_core_context::get()->id;

Expand Down Expand Up @@ -86,7 +86,7 @@ public function get_page_class() : string
* - unapproved: approvals are enabled for the site but the object is not translated
* - hidden: object is hidden via metadata settings or scheduling
*/
public function get_object_classes(midcom_core_dbaobject $object, string $existing_classes = null) : string
public function get_object_classes(midcom_core_dbaobject $object, ?string $existing_classes = null) : string
{
$css_classes = [];
if ($existing_classes !== null) {
Expand Down Expand Up @@ -303,7 +303,7 @@ public function set_request_metadata(int $lastmodified, ?string $permalinkguid)
* values set with the setter pendant. For ease of use, there is also a key 'permalink'
* which contains a ready-made permalink.
*/
public function get_request_metadata(midcom_core_context $context = null) : array
public function get_request_metadata(?midcom_core_context $context = null) : array
{
$context ??= midcom_core_context::get();
return [
Expand Down
Loading

0 comments on commit 598445d

Please sign in to comment.