Skip to content

Commit 27b344e

Browse files
committed
Fix params and return types
1 parent 4d3c2a9 commit 27b344e

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

main/inc/lib/course_home.lib.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -721,10 +721,10 @@ public static function get_tools_category($course_tool_category, $courseId = 0,
721721
}
722722
break;
723723
case 'lp_category.gif':
724-
$lpCategory = self::getPublishedLpCategoryFromLink($temp_row['link']);
725724
if ($showInvisibleLpsForStudents) {
726725
$add = true;
727726
} else {
727+
$lpCategory = self::getPublishedLpCategoryFromLink($temp_row['link']);
728728
$add = learnpath::categoryIsVisibleForStudent($lpCategory, $user);
729729
}
730730

@@ -1384,18 +1384,19 @@ public static function getPublishedLpIdFromLink($link)
13841384

13851385
/**
13861386
* Get published learning path category from link inside course home.
1387-
*
1388-
* @param string $link
1389-
*
1390-
* @return CLpCategory
13911387
*/
1392-
public static function getPublishedLpCategoryFromLink($link)
1388+
public static function getPublishedLpCategoryFromLink(string $link): ?CLpCategory
13931389
{
13941390
$query = parse_url($link, PHP_URL_QUERY);
13951391
parse_str($query, $params);
13961392
$id = isset($params['id']) ? (int) $params['id'] : 0;
1393+
1394+
if (empty($id)) {
1395+
return null;
1396+
}
1397+
13971398
$em = Database::getManager();
1398-
/** @var CLpCategory $category */
1399+
/** @var ?CLpCategory $category */
13991400
$category = $em->find('ChamiloCourseBundle:CLpCategory', $id);
14001401

14011402
return $category;

main/lp/learnpath.class.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4860,17 +4860,19 @@ public static function toggleCategoryPublish($id, $setVisibility = 1)
48604860
/**
48614861
* Check if the learnpath category is visible for a user.
48624862
*
4863-
* @param int
4864-
* @param int
4863+
* @param CLpCategory|null $category
4864+
* @param User $user
4865+
* @param int $courseId
4866+
* @param int $sessionId
48654867
*
48664868
* @return bool
48674869
*/
48684870
public static function categoryIsVisibleForStudent(
4869-
CLpCategory $category,
4871+
?CLpCategory $category,
48704872
User $user,
48714873
$courseId = 0,
48724874
$sessionId = 0
4873-
) {
4875+
): bool {
48744876
if (empty($category)) {
48754877
return false;
48764878
}
@@ -4899,7 +4901,7 @@ public static function categoryIsVisibleForStudent(
48994901

49004902
$subscriptionSettings = self::getSubscriptionSettings();
49014903

4902-
if ($subscriptionSettings['allow_add_users_to_lp_category'] == false) {
4904+
if (!$subscriptionSettings['allow_add_users_to_lp_category']) {
49034905
return true;
49044906
}
49054907

@@ -4951,9 +4953,8 @@ public static function categoryIsVisibleForStudent(
49514953
}
49524954
}
49534955
}
4954-
$response = $noGroupSubscribed && $noUserSubscribed;
49554956

4956-
return $response;
4957+
return $noGroupSubscribed && $noUserSubscribed;
49574958
}
49584959

49594960
/**
@@ -12959,10 +12960,8 @@ public static function getCategorySessionId($id)
1295912960

1296012961
/**
1296112962
* @param int $id
12962-
*
12963-
* @return CLpCategory
1296412963
*/
12965-
public static function getCategory($id)
12964+
public static function getCategory($id): ?CLpCategory
1296612965
{
1296712966
$id = (int) $id;
1296812967
$em = Database::getManager();

0 commit comments

Comments
 (0)