Merge pull request #604 from jgen/scrutinizer-fixes

Some more linting
This commit is contained in:
Shish 2017-03-15 09:42:15 +00:00 committed by GitHub
commit ce5bb30113
9 changed files with 73 additions and 19 deletions

View File

@ -1265,7 +1265,7 @@ function add_image($tmpname, $filename, $tags) {
*
* @param int $orig_width
* @param int $orig_height
* @return int[]
* @return integer[]
*/
function get_thumbnail_size(/*int*/ $orig_width, /*int*/ $orig_height) {
global $config;

View File

@ -432,12 +432,6 @@ function endsWith(/*string*/ $haystack, /*string*/ $needle) {
return (substr($haystack, $start) === $needle);
}
if(!function_exists("mb_strlen")) { // D:
function mb_strlen($str) {return strlen($str);}
function mb_internal_encoding($enc) {}
function mb_strtolower($str) {return strtolower($str);}
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
* HTML Generation *
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@ -1028,6 +1022,11 @@ function transload($url, $mfile) {
}
if (!function_exists('http_parse_headers')) { #http://www.php.net/manual/en/function.http-parse-headers.php#112917
/**
* @param string $raw_headers
* @return string[]
*/
function http_parse_headers ($raw_headers){
$headers = array(); // $headers = [];
@ -1157,10 +1156,40 @@ function log_msg(/*string*/ $section, /*int*/ $priority, /*string*/ $message, $f
}
// More shorthand ways of logging
/**
* @param string $section
* @param string $message
* @param bool|string $flash
* @param array $args
*/
function log_debug( /*string*/ $section, /*string*/ $message, $flash=false, $args=array()) {log_msg($section, SCORE_LOG_DEBUG, $message, $flash, $args);}
/**
* @param string $section
* @param string $message
* @param bool|string $flash
* @param array $args
*/
function log_info( /*string*/ $section, /*string*/ $message, $flash=false, $args=array()) {log_msg($section, SCORE_LOG_INFO, $message, $flash, $args);}
/**
* @param string $section
* @param string $message
* @param bool|string $flash
* @param array $args
*/
function log_warning( /*string*/ $section, /*string*/ $message, $flash=false, $args=array()) {log_msg($section, SCORE_LOG_WARNING, $message, $flash, $args);}
/**
* @param string $section
* @param string $message
* @param bool|string $flash
* @param array $args
*/
function log_error( /*string*/ $section, /*string*/ $message, $flash=false, $args=array()) {log_msg($section, SCORE_LOG_ERROR, $message, $flash, $args);}
/**
* @param string $section
* @param string $message
* @param bool|string $flash
* @param array $args
*/
function log_critical(/*string*/ $section, /*string*/ $message, $flash=false, $args=array()) {log_msg($section, SCORE_LOG_CRITICAL, $message, $flash, $args);}
@ -1191,8 +1220,8 @@ function get_request_id() {
/**
* Remove an item from an array
*
* @param $array
* @param $to_remove
* @param array $array
* @param mixed $to_remove
* @return array
*/
function array_remove($array, $to_remove) {
@ -1211,8 +1240,8 @@ function array_remove($array, $to_remove) {
*
* Also removes duplicate values from the array.
*
* @param $array
* @param $element
* @param array $array
* @param mixed $element
* @return array
*/
function array_add($array, $element) {
@ -1226,7 +1255,7 @@ function array_add($array, $element) {
/**
* Return the unique elements of an array, case insensitively
*
* @param $array
* @param array $array
* @return array
*/
function array_iunique($array) {
@ -1250,8 +1279,8 @@ function array_iunique($array) {
*
* from http://uk.php.net/network
*
* @param $IP
* @param $CIDR
* @param string $IP
* @param string $CIDR
* @return bool
*/
function ip_in_range($IP, $CIDR) {
@ -1390,7 +1419,10 @@ function list_files(/*string*/ $base, $_sub_dir="") {
return $file_list;
}
/**
* @param string $path
* @return string
*/
function path_to_tags($path) {
$matches = array();
if(preg_match("/\d+ - (.*)\.([a-zA-Z]+)/", basename($path), $matches)) {

View File

@ -161,14 +161,14 @@
class SearchTermParseEvent extends Event {
/** @var null|string */
public $term = null;
/** @var null */
/** @var string[] */
public $context = array();
/** @var \Querylet[] */
public $querylets = array();
/**
* @param string|null $term
* @param array $context
* @param string[] $context
*/
public function __construct($term, array $context) {
$this->term = $term;

View File

@ -776,6 +776,9 @@ class OuroborosAPI extends Extension
$page->set_data($response);
}
/**
* @param string $type
*/
private function createItemXML(XMLWriter &$xml, $type, $item)
{
$xml->startElement($type);

View File

@ -242,7 +242,7 @@ class Ratings extends Extension {
}
/**
* @param $context
* @param string[] $context
* @return bool
*/
private function no_rating_query($context) {

View File

@ -45,6 +45,9 @@ class ViewImageTheme extends Themelet {
return "$h_prev | $h_index | $h_next";
}
/**
* @return string
*/
protected function build_navigation(Image $image) {
$h_pin = $this->build_pin($image);
$h_search = "

View File

@ -494,6 +494,10 @@ class Wiki extends Extension {
/**
* callback function to format the diffence-lines with your 'style'
* @param integer $nr1
* @param integer $nr2
* @param string $stat
* @return string
*/
private function formatline( $nr1, $nr2, $stat, &$value ) { #change to $value if problems
if(trim($value) == "") {

View File

@ -63,6 +63,9 @@ abstract class ShimmiePHPUnitTestCase extends \PHPUnit_Framework_TestCase {
$this->assertNotContains($title, $page->title);
}
/**
* @param integer $code
*/
protected function assert_response($code) {
global $page;
$this->assertEquals($code, $page->code);
@ -84,15 +87,24 @@ abstract class ShimmiePHPUnitTestCase extends \PHPUnit_Framework_TestCase {
$this->assertContains($text, $this->page_to_text($section));
}
/**
* @param string $text
*/
protected function assert_no_text($text, $section=null) {
$this->assertNotContains($text, $this->page_to_text($section));
}
/**
* @param string $content
*/
protected function assert_content($content) {
global $page;
$this->assertContains($content, $page->data);
}
/**
* @param string $content
*/
protected function assert_no_content($content) {
global $page;
$this->assertNotContains($content, $page->data);

View File

@ -241,7 +241,7 @@ EOD;
/**
* @param string $link
* @param null|string $desc
* @param string $desc
* @param string[] $pages_matched
* @return null|string
*/