Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: strnatcasecmp(): Passing null to parameter #1 ($string1) of type string is deprecated #21413

Merged
merged 3 commits into from Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion core/Category/CategoryList.php
Expand Up @@ -39,6 +39,10 @@ public function getCategories()
return $this->categories;
}

/**
* @param string|null $categoryId
* @return bool
*/
public function hasCategory($categoryId)
{
return isset($this->categories[$categoryId]);
Expand All @@ -47,14 +51,16 @@ public function hasCategory($categoryId)
/**
* Get the category having the given id, if possible.
*
* @param string $categoryId
* @param string|null $categoryId
* @return Category|null
*/
public function getCategory($categoryId)
{
if ($this->hasCategory($categoryId)) {
return $this->categories[$categoryId];
}

return null;
}

/**
Expand Down
8 changes: 4 additions & 4 deletions core/Plugin/Report.php
Expand Up @@ -82,14 +82,14 @@ class Report

/**
* The translation key of the category the report belongs to.
* @var string
* @var string|null
* @api
*/
protected $categoryId;

/**
* The translation key of the subcategory the report belongs to.
* @var string
* @var string|null
* @api
*/
protected $subcategoryId;
Expand Down Expand Up @@ -805,7 +805,7 @@ public function getParameters()

/**
* Get the translated name of the category the report belongs to.
* @return string
* @return string|null
* @ignore
*/
public function getCategoryId()
Expand All @@ -815,7 +815,7 @@ public function getCategoryId()

/**
* Get the translated name of the subcategory the report belongs to.
* @return string
* @return string|null
* @ignore
*/
public function getSubcategoryId()
Expand Down
12 changes: 11 additions & 1 deletion core/Plugin/ReportsProvider.php
Expand Up @@ -198,6 +198,16 @@ private function sort($a, $b)
return $result;
}

/**
* @param string|null $catIdA
* @param string|null $subcatIdA
* @param int $orderA
* @param string|null $catIdB
* @param string|null $subcatIdB
* @param int $orderB
*
* @return int
*/
public function compareCategories($catIdA, $subcatIdA, $orderA, $catIdB, $subcatIdB, $orderB)
{
if (!isset($this->categoryList)) {
Expand Down Expand Up @@ -257,7 +267,7 @@ public function compareCategories($catIdA, $subcatIdA, $orderA, $catIdB, $subcat
return $orderA < $orderB ? -1 : 1;
}

return strnatcasecmp($catIdA, $catIdB);
return strnatcasecmp($catIdA ?? '', $catIdB ?? '');
}

/**
Expand Down