More linting!

This commit is contained in:
jgen 2014-04-19 01:36:18 -04:00
parent bdf49b33cb
commit 2da8c19a07
4 changed files with 48 additions and 45 deletions

View File

@ -229,7 +229,7 @@ class MemcacheCache implements CacheEngine {
class APCCache implements CacheEngine { class APCCache implements CacheEngine {
var $hits=0, $misses=0; var $hits=0, $misses=0;
public function __construct($args) {} public function __construct() {}
public function get($key) { public function get($key) {
assert(!is_null($key)); assert(!is_null($key));

View File

@ -10,7 +10,7 @@ require_once "lib/context.php";
/** /**
* Make some data safe for printing into HTML * Make some data safe for printing into HTML
* *
* @retval string * @return string
*/ */
function html_escape($input) { function html_escape($input) {
return htmlentities($input, ENT_QUOTES, "UTF-8"); return htmlentities($input, ENT_QUOTES, "UTF-8");
@ -19,7 +19,7 @@ function html_escape($input) {
/** /**
* Make sure some data is safe to be used in integer context * Make sure some data is safe to be used in integer context
* *
* @retval int * @return int
*/ */
function int_escape($input) { function int_escape($input) {
/* /*
@ -32,7 +32,7 @@ function int_escape($input) {
/** /**
* Make sure some data is safe to be used in URL context * Make sure some data is safe to be used in URL context
* *
* @retval string * @return string
*/ */
function url_escape($input) { function url_escape($input) {
/* /*
@ -66,7 +66,7 @@ function url_escape($input) {
/** /**
* Make sure some data is safe to be used in SQL context * Make sure some data is safe to be used in SQL context
* *
* @retval string * @return string
*/ */
function sql_escape($input) { function sql_escape($input) {
global $database; global $database;
@ -77,7 +77,7 @@ function sql_escape($input) {
/** /**
* Turn all manner of HTML / INI / JS / DB booleans into a PHP one * Turn all manner of HTML / INI / JS / DB booleans into a PHP one
* *
* @retval boolean * @return boolean
*/ */
function bool_escape($input) { function bool_escape($input) {
/* /*
@ -112,7 +112,7 @@ function bool_escape($input) {
* Some functions require a callback function for escaping, * Some functions require a callback function for escaping,
* but we might not want to alter the data * but we might not want to alter the data
* *
* @retval string * @return string
*/ */
function no_escape($input) { function no_escape($input) {
return $input; return $input;
@ -156,7 +156,7 @@ function truncate($string, $limit, $break=" ", $pad="...") {
/** /**
* Turn a human readable filesize into an integer, eg 1KB -> 1024 * Turn a human readable filesize into an integer, eg 1KB -> 1024
* *
* @retval int * @return int
*/ */
function parse_shorthand_int($limit) { function parse_shorthand_int($limit) {
if(is_numeric($limit)) { if(is_numeric($limit)) {
@ -167,8 +167,8 @@ function parse_shorthand_int($limit) {
$value = $m[1]; $value = $m[1];
if (isset($m[2])) { if (isset($m[2])) {
switch(strtolower($m[2])) { switch(strtolower($m[2])) {
case 'g': $value *= 1024; # fallthrough case 'g': $value *= 1024; // fall through
case 'm': $value *= 1024; # fallthrough case 'm': $value *= 1024; // fall through
case 'k': $value *= 1024; break; case 'k': $value *= 1024; break;
default: $value = -1; default: $value = -1;
} }
@ -182,7 +182,7 @@ function parse_shorthand_int($limit) {
/** /**
* Turn an integer into a human readable filesize, eg 1024 -> 1KB * Turn an integer into a human readable filesize, eg 1024 -> 1KB
* *
* @retval string * @return string
*/ */
function to_shorthand_int($int) { function to_shorthand_int($int) {
if($int >= pow(1024, 3)) { if($int >= pow(1024, 3)) {
@ -203,7 +203,7 @@ function to_shorthand_int($int) {
/** /**
* Turn a date into a time, a date, an "X minutes ago...", etc * Turn a date into a time, a date, an "X minutes ago...", etc
* *
* @retval string * @return string
*/ */
function autodate($date, $html=true) { function autodate($date, $html=true) {
$cpu = date('c', strtotime($date)); $cpu = date('c', strtotime($date));
@ -214,7 +214,7 @@ function autodate($date, $html=true) {
/** /**
* Check if a given string is a valid date-time. ( Format: yyyy-mm-dd hh:mm:ss ) * Check if a given string is a valid date-time. ( Format: yyyy-mm-dd hh:mm:ss )
* *
* @retval boolean * @return boolean
*/ */
function isValidDateTime($dateTime) { function isValidDateTime($dateTime) {
if (preg_match("/^(\d{4})-(\d{2})-(\d{2}) ([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/", $dateTime, $matches)) { if (preg_match("/^(\d{4})-(\d{2})-(\d{2}) ([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/", $dateTime, $matches)) {
@ -229,7 +229,7 @@ function isValidDateTime($dateTime) {
/** /**
* Check if a given string is a valid date. ( Format: yyyy-mm-dd ) * Check if a given string is a valid date. ( Format: yyyy-mm-dd )
* *
* @retval boolean * @return boolean
*/ */
function isValidDate($date) { function isValidDate($date) {
if (preg_match("/^(\d{4})-(\d{2})-(\d{2})$/", $date, $matches)) { if (preg_match("/^(\d{4})-(\d{2})-(\d{2})$/", $date, $matches)) {
@ -248,7 +248,7 @@ function isValidDate($date) {
* *
* FIXME: also check that IP ban ext is installed * FIXME: also check that IP ban ext is installed
* *
* @retval string * @return string
*/ */
function show_ip($ip, $ban_reason) { function show_ip($ip, $ban_reason) {
global $user; global $user;
@ -264,7 +264,7 @@ function show_ip($ip, $ban_reason) {
* *
* @param $haystack String to examine. * @param $haystack String to examine.
* @param $needle String to look for. * @param $needle String to look for.
* @retval bool * @return bool
*/ */
function startsWith(/*string*/ $haystack, /*string*/ $needle) { function startsWith(/*string*/ $haystack, /*string*/ $needle) {
$length = strlen($needle); $length = strlen($needle);
@ -276,7 +276,7 @@ function startsWith(/*string*/ $haystack, /*string*/ $needle) {
* *
* @param $haystack String to examine. * @param $haystack String to examine.
* @param $needle String to look for. * @param $needle String to look for.
* @retval bool * @return bool
*/ */
function endsWith(/*string*/ $haystack, /*string*/ $needle) { function endsWith(/*string*/ $haystack, /*string*/ $needle) {
$length = strlen($needle); $length = strlen($needle);
@ -295,7 +295,7 @@ function endsWith(/*string*/ $haystack, /*string*/ $needle) {
* *
* eg make_link("post/list") becomes "/v2/index.php?q=post/list" * eg make_link("post/list") becomes "/v2/index.php?q=post/list"
* *
* @retval string * @return string
*/ */
function make_link($page=null, $query=null) { function make_link($page=null, $query=null) {
global $config; global $config;
@ -331,7 +331,7 @@ function make_link($page=null, $query=null) {
/** /**
* Take the current URL and modify some paramaters * Take the current URL and modify some paramaters
* *
* @retval string * @return string
*/ */
function modify_current_url($changes) { function modify_current_url($changes) {
return modify_url($_SERVER['QUERY_STRING'], $changes); return modify_url($_SERVER['QUERY_STRING'], $changes);
@ -372,7 +372,7 @@ function modify_url($url, $changes) {
/** /**
* Turn a relative link into an absolute one, including hostname * Turn a relative link into an absolute one, including hostname
* *
* @retval string * @return string
*/ */
function make_http(/*string*/ $link) { function make_http(/*string*/ $link) {
if(strpos($link, "ttp://") > 0) return $link; if(strpos($link, "ttp://") > 0) return $link;
@ -639,7 +639,7 @@ function _count_execs($db, $sql, $inputarray) {
/** /**
* Compare two Block objects, used to sort them before being displayed * Compare two Block objects, used to sort them before being displayed
* *
* @retval int * @return int
*/ */
function blockcmp(Block $a, Block $b) { function blockcmp(Block $a, Block $b) {
if($a->position == $b->position) { if($a->position == $b->position) {
@ -653,7 +653,7 @@ function blockcmp(Block $a, Block $b) {
/** /**
* Figure out PHP's internal memory limit * Figure out PHP's internal memory limit
* *
* @retval int * @return int
*/ */
function get_memory_limit() { function get_memory_limit() {
global $config; global $config;
@ -702,7 +702,7 @@ function get_memory_limit() {
* Get the currently active IP, masked to make it not change when the last * Get the currently active IP, masked to make it not change when the last
* octet or two change, for use in session cookies and such * octet or two change, for use in session cookies and such
* *
* @retval string * @return string
*/ */
function get_session_ip(Config $config) { function get_session_ip(Config $config) {
$mask = $config->get_string("session_hash_mask", "255.255.0.0"); $mask = $config->get_string("session_hash_mask", "255.255.0.0");
@ -765,7 +765,7 @@ function flash_message(/*string*/ $text, /*string*/ $type="info") {
* *
* PHP really, really sucks. * PHP really, really sucks.
* *
* @retval string * @return string
*/ */
function get_base_href() { function get_base_href() {
$possible_vars = array('SCRIPT_NAME', 'PHP_SELF', 'PATH_INFO', 'ORIG_PATH_INFO'); $possible_vars = array('SCRIPT_NAME', 'PHP_SELF', 'PATH_INFO', 'ORIG_PATH_INFO');
@ -788,7 +788,7 @@ function get_base_href() {
* A shorthand way to send a TextFormattingEvent and get the * A shorthand way to send a TextFormattingEvent and get the
* results * results
* *
* @retval string * @return string
*/ */
function format_text(/*string*/ $string) { function format_text(/*string*/ $string) {
$tfe = new TextFormattingEvent($string); $tfe = new TextFormattingEvent($string);
@ -1001,7 +1001,7 @@ function get_request_id() {
/** /**
* Remove an item from an array * Remove an item from an array
* *
* @retval array * @return array
*/ */
function array_remove($array, $to_remove) { function array_remove($array, $to_remove) {
$array = array_unique($array); $array = array_unique($array);
@ -1019,7 +1019,7 @@ function array_remove($array, $to_remove) {
* *
* Also removes duplicate values from the array. * Also removes duplicate values from the array.
* *
* @retval array * @return array
*/ */
function array_add($array, $element) { function array_add($array, $element) {
// Could we just use array_push() ? // Could we just use array_push() ?
@ -1032,7 +1032,7 @@ function array_add($array, $element) {
/** /**
* Return the unique elements of an array, case insensitively * Return the unique elements of an array, case insensitively
* *
* @retval array * @return array
*/ */
function array_iunique($array) { function array_iunique($array) {
$ok = array(); $ok = array();
@ -1055,7 +1055,7 @@ function array_iunique($array) {
* *
* from http://uk.php.net/network * from http://uk.php.net/network
* *
* @retval bool * @return bool
*/ */
function ip_in_range($IP, $CIDR) { function ip_in_range($IP, $CIDR) {
list ($net, $mask) = explode("/", $CIDR); list ($net, $mask) = explode("/", $CIDR);
@ -1204,7 +1204,7 @@ $_load_start = microtime(true);
* Collects some debug information (execution time, memory usage, queries, etc) * Collects some debug information (execution time, memory usage, queries, etc)
* and formats it to stick in the footer of the page. * and formats it to stick in the footer of the page.
* *
* @retval String of debug info to add to the page. * @return String of debug info to add to the page.
*/ */
function get_debug_info() { function get_debug_info() {
global $config, $_event_count, $database, $_execs, $_load_start; global $config, $_event_count, $database, $_execs, $_load_start;

View File

@ -374,12 +374,13 @@ YShout.prototype = {
if (!$.browser.safari) return; if (!$.browser.safari) return;
var same = []; var same = [];
for (var i = 0; i < this.p.length; i++) for (var i = 0; i < this.p.length; i++) {
if (this.p[i].adminInfo.ip == ip) if (this.p[i].adminInfo.ip == ip)
same.push(this.p[i]); same.push(this.p[i]);
}
for (var i = 0; i < same.length; i++) {
$('#' + same[i].id).fadeTo(this.animSpeed, .8).fadeTo(this.animSpeed, 1); for (var j = 0; j < same.length; j++) {
$('#' + same[j].id).fadeTo(this.animSpeed, .8).fadeTo(this.animSpeed, 1);
} }
}, },

View File

@ -342,7 +342,7 @@ class Pools extends Extension {
/** /**
* Check if the given user has permission to edit/change the pool. * Check if the given user has permission to edit/change the pool.
* TODO: Should the user variable be global? * TODO: Should the user variable be global?
* @retval bool * @return bool
*/ */
private function have_permission($user, $pool) { private function have_permission($user, $pool) {
// If the pool is public and user is logged OR if the user is admin OR if the pool is owned by the user. // If the pool is public and user is logged OR if the user is admin OR if the pool is owned by the user.
@ -415,12 +415,13 @@ class Pools extends Extension {
throw new PoolCreationException("A pool using this title already exists."); throw new PoolCreationException("A pool using this title already exists.");
} }
$public = $_POST["public"] == "Y" ? "Y" : "N"; $public = $_POST["public"] === "Y" ? "Y" : "N";
$database->execute(" $database->execute("
INSERT INTO pools (user_id, public, title, description, date) INSERT INTO pools (user_id, public, title, description, date)
VALUES (:uid, :public, :title, :desc, now())", VALUES (:uid, :public, :title, :desc, now())",
array("uid"=>$user->id, "public"=>$public, "title"=>$_POST["title"], "desc"=>$_POST["description"])); array("uid"=>$user->id, "public"=>$public, "title"=>$_POST["title"], "desc"=>$_POST["description"]));
$result = array();
$result['poolID'] = $database->get_last_insert_id('pools_id_seq'); $result['poolID'] = $database->get_last_insert_id('pools_id_seq');
log_info("pools", "Pool {$result["poolID"]} created by {$user->name}"); log_info("pools", "Pool {$result["poolID"]} created by {$user->name}");
@ -429,9 +430,9 @@ class Pools extends Extension {
} }
/** /**
* Retrieve information about pools given mulitiple pool IDs. * Retrieve information about pools given multiple pool IDs.
* @param $poolID Array of integers * @param $poolID Array of integers
* @retval 2D Array * @return 2D Array
*/ */
private function get_pool(/*int*/ $poolID) { private function get_pool(/*int*/ $poolID) {
global $database; global $database;
@ -441,7 +442,7 @@ class Pools extends Extension {
/** /**
* Retrieve information about a pool given a pool ID. * Retrieve information about a pool given a pool ID.
* @param $poolID Integer * @param $poolID Integer
* @retval 2D array (with only 1 element in the one dimension) * @return 2D array (with only 1 element in the one dimension)
*/ */
private function get_single_pool(/*int*/ $poolID) { private function get_single_pool(/*int*/ $poolID) {
global $database; global $database;
@ -451,7 +452,7 @@ class Pools extends Extension {
/** /**
* Retrieve information about a pool given a pool title. * Retrieve information about a pool given a pool title.
* @param $poolTitle Integer * @param $poolTitle Integer
* @retval 2D array (with only 1 element in the one dimension) * @return 2D array (with only 1 element in the one dimension)
*/ */
private function get_single_pool_from_title(/*string*/ $poolTitle) { private function get_single_pool_from_title(/*string*/ $poolTitle) {
global $database; global $database;
@ -461,7 +462,7 @@ class Pools extends Extension {
/** /**
* Get all of the pool IDs that an image is in, given an image ID. * Get all of the pool IDs that an image is in, given an image ID.
* @param $imageID Integer * @param $imageID Integer
* @retval 2D array * @return 2D array
*/ */
private function get_pool_id(/*int*/ $imageID) { private function get_pool_id(/*int*/ $imageID) {
global $database; global $database;
@ -581,7 +582,7 @@ class Pools extends Extension {
* @see add_posts() * @see add_posts()
* @param $poolID integer * @param $poolID integer
* @param $imageID integer * @param $imageID integer
* @retval bool * @return bool
*/ */
private function check_post(/*int*/ $poolID, /*int*/ $imageID) { private function check_post(/*int*/ $poolID, /*int*/ $imageID) {
global $database; global $database;
@ -594,7 +595,7 @@ class Pools extends Extension {
* *
* @param $pool Array for the given pool * @param $pool Array for the given pool
* @param $imageID Integer * @param $imageID Integer
* @retval Integer which is the next Image ID or NULL if none. * @return Integer which is the next Image ID or NULL if none.
*/ */
private function get_next_post(/*array*/ $pool, /*int*/ $imageID) { private function get_next_post(/*array*/ $pool, /*int*/ $imageID) {
global $database; global $database;
@ -684,7 +685,7 @@ class Pools extends Extension {
/** /**
* This function gets the current order of images from a given pool. * This function gets the current order of images from a given pool.
* @param $poolID integer * @param $poolID integer
* @retval Array of image objects. * @return Array of image objects.
*/ */
private function edit_posts(/*int*/ $poolID) { private function edit_posts(/*int*/ $poolID) {
global $database; global $database;
@ -750,6 +751,7 @@ class Pools extends Extension {
*/ */
private function add_history(/*int*/ $poolID, $action, $images, $count) { private function add_history(/*int*/ $poolID, $action, $images, $count) {
global $user, $database; global $user, $database;
$database->execute(" $database->execute("
INSERT INTO pool_history (pool_id, user_id, action, images, count, date) INSERT INTO pool_history (pool_id, user_id, action, images, count, date)
VALUES (:pid, :uid, :act, :img, :count, now())", VALUES (:pid, :uid, :act, :img, :count, now())",