|
From: <var...@us...> - 2023-07-14 10:33:07
|
Revision: 11051
http://sourceforge.net/p/phpwiki/code/11051
Author: vargenau
Date: 2023-07-14 10:33:04 +0000 (Fri, 14 Jul 2023)
Log Message:
-----------
lib/wikilens: PHP 7: add types for function arguments and return
Modified Paths:
--------------
trunk/lib/wikilens/Buddy.php
trunk/lib/wikilens/CustomPrefs.php
trunk/lib/wikilens/PageListColumns.php
trunk/lib/wikilens/RatingsDb.php
trunk/lib/wikilens/RatingsUser.php
trunk/lib/wikilens/Utils.php
Modified: trunk/lib/wikilens/Buddy.php
===================================================================
--- trunk/lib/wikilens/Buddy.php 2023-07-14 10:03:49 UTC (rev 11050)
+++ trunk/lib/wikilens/Buddy.php 2023-07-14 10:33:04 UTC (rev 11051)
@@ -48,7 +48,7 @@
addPageTextData($user, $dbi, $buddy, $START_DELIM, $DELIM);
}
-function getBuddies($fromUser, $dbi, $thePage = "")
+function getBuddies($fromUser, $dbi, $thePage = ""): array
{
$START_DELIM = $thePage . _("Buddies:");
$DELIM = ",";
@@ -88,7 +88,7 @@
return $result;
}
-function CoAgreement($dbi, $page, $users, $active_userid)
+function CoAgreement($dbi, $page, $users, $active_userid): int
{
//Returns a "yes" 1, "no" -1, or "unsure" 0 for whether
//the group agrees on the page based on their ratings
Modified: trunk/lib/wikilens/CustomPrefs.php
===================================================================
--- trunk/lib/wikilens/CustomPrefs.php 2023-07-14 10:03:49 UTC (rev 11050)
+++ trunk/lib/wikilens/CustomPrefs.php 2023-07-14 10:33:04 UTC (rev 11051)
@@ -35,7 +35,7 @@
class _UserPreference_recengine // recommendation engine method
extends _UserPreference
{
- public $valid_values = array('php', 'mysuggest', 'mymovielens', 'mycluto');
+ public array $valid_values = array('php', 'mysuggest', 'mymovielens', 'mycluto');
public $default_value = 'php';
public function sanify($value)
@@ -51,7 +51,7 @@
class _UserPreference_recalgo // recommendation engine algorithm
extends _UserPreference
{
- public $valid_values = array(
+ public array $valid_values = array(
'itemCos', // Item-based Top-N recommendation algorithm with cosine-based similarity function
'itemProb', // Item-based Top-N recommendation algorithm with probability-based similarity function.
// This algorithms tends to outperform the rest.
Modified: trunk/lib/wikilens/PageListColumns.php
===================================================================
--- trunk/lib/wikilens/PageListColumns.php 2023-07-14 10:03:49 UTC (rev 11050)
+++ trunk/lib/wikilens/PageListColumns.php 2023-07-14 10:33:04 UTC (rev 11051)
@@ -206,7 +206,7 @@
return ($rating ? $rating : "-");
}
- public function hasNoRatings($pages)
+ public function hasNoRatings($pages): bool
{
$total = 0;
$use = & $this->_user;
@@ -346,7 +346,7 @@
class _PageList_Column_top3recs extends _PageList_Column_custom
{
- public $_active_ratings_user;
+ public RatingsUser $_active_ratings_user;
public $_users;
public function __construct($params)
Modified: trunk/lib/wikilens/RatingsDb.php
===================================================================
--- trunk/lib/wikilens/RatingsDb.php 2023-07-14 10:03:49 UTC (rev 11050)
+++ trunk/lib/wikilens/RatingsDb.php 2023-07-14 10:33:04 UTC (rev 11051)
@@ -293,7 +293,7 @@
*
* @return true upon success
*/
- public function delete_rating($rater, $ratee, $dimension)
+ public function delete_rating($rater, $ratee, $dimension): bool
{
if (RATING_STORAGE == 'SQL') {
$this->sql_delete_rating($rater, $ratee, $dimension);
@@ -314,7 +314,7 @@
*
* @return true upon success
*/
- public function rate($rater, $ratee, $rateeversion, $dimension, $rating)
+ public function rate($rater, $ratee, $rateeversion, $dimension, $rating): bool
{
if (RATING_STORAGE == 'SQL') {
$page = $this->_dbi->getPage($pagename);
@@ -539,7 +539,7 @@
$rater = null,
$ratee = null,
$orderby = null,
- $pageinfo = "ratee"
+ string $pageinfo = "ratee"
)
{
if (is_null($dimension)) {
@@ -656,7 +656,7 @@
*
* @return true upon success
*/
- public function sql_delete_rating($rater, $ratee, $dimension)
+ public function sql_delete_rating($rater, $ratee, $dimension): bool
{
//$dbh = &$this->_dbi;
$dbi = &$this->_sqlbackend;
@@ -686,7 +686,7 @@
*
* @return true upon success
*/
- public function sql_rate($rater, $ratee, $rateeversion, $dimension, $rating)
+ public function sql_rate($rater, $ratee, $rateeversion, $dimension, $rating): bool
{
$dbi = &$this->_sqlbackend;
extract($dbi->_table_names);
Modified: trunk/lib/wikilens/RatingsUser.php
===================================================================
--- trunk/lib/wikilens/RatingsUser.php 2023-07-14 10:03:49 UTC (rev 11050)
+++ trunk/lib/wikilens/RatingsUser.php 2023-07-14 10:33:04 UTC (rev 11051)
@@ -54,11 +54,11 @@
class RatingsUser
{
public $_userid;
- public $_ratings_loaded;
- public $_ratings;
- public $_num_ratings;
- public $_mean_ratings;
- public $_pearson_sims;
+ public bool $_ratings_loaded;
+ public array $_ratings;
+ public int $_num_ratings;
+ public array $_mean_ratings;
+ public array $_pearson_sims;
public function __construct($userid)
{
@@ -96,7 +96,7 @@
*
* @return bool True if $user can view this user's ratings, false otherwise
*/
- public function allow_view_ratings($user)
+ public function allow_view_ratings($user): bool
{
return true;
}
@@ -106,7 +106,7 @@
*
* @return array Assoc. array [page_name][dimension] = _UserRating object
*/
- public function get_ratings()
+ public function get_ratings(): array
{
$this->_load_ratings();
return $this->_ratings;
@@ -148,7 +148,7 @@
// ephemeral and doesn't particularly care about the ratings count or any
// other features that these methods might provide down the road)
- public function has_rated($pagename, $dimension = null)
+ public function has_rated($pagename, $dimension = null): bool
{
// XXX: does this really want to do a full ratings load? (scalability?)
$this->_load_ratings();
@@ -380,22 +380,22 @@
$this->rating = (float)$rating;
}
- public function get_rater()
+ public function get_rater(): string
{
return $this->rater;
}
- public function get_ratee()
+ public function get_ratee(): string
{
return $this->ratee;
}
- public function get_rating()
+ public function get_rating(): float
{
return $this->rating;
}
- public function get_dimension()
+ public function get_dimension(): int
{
return $this->dimension;
}
Modified: trunk/lib/wikilens/Utils.php
===================================================================
--- trunk/lib/wikilens/Utils.php 2023-07-14 10:03:49 UTC (rev 11050)
+++ trunk/lib/wikilens/Utils.php 2023-07-14 10:33:04 UTC (rev 11051)
@@ -101,7 +101,7 @@
return $retArray;
}
-function notEmptyName($var)
+function notEmptyName($var): bool
{
return $var != "";
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|