From 59bc3b48fdffb76ee65a4b630be3ffa1f6c20c80 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Mon, 29 Sep 2014 21:45:27 +0200 Subject: more scrutinizer issue improvements --- inc/IXR_Library.php | 3 ++- inc/JpegMeta.php | 10 ++++---- inc/Mailer.class.php | 10 ++++---- inc/RemoteAPICore.php | 1 + inc/Tar.class.php | 1 + inc/ZipLib.class.php | 7 ++++-- inc/actions.php | 1 - inc/auth.php | 1 + inc/common.php | 3 +++ inc/fulltext.php | 1 + inc/html.php | 1 + inc/infoutils.php | 3 ++- inc/media.php | 34 ++++++++++++++++------------ inc/parser/lexer.php | 25 ++++++++++++-------- inc/parser/metadata.php | 14 ++++++------ inc/parser/xhtml.php | 7 ++++-- inc/plugincontroller.class.php | 2 +- inc/remote.php | 2 +- inc/search.php | 1 + inc/subscription.php | 2 +- inc/template.php | 1 - lib/exe/indexer.php | 2 +- lib/plugins/acl/admin.php | 6 ++--- lib/plugins/acl/remote.php | 2 ++ lib/plugins/auth.php | 5 +++- lib/plugins/authad/adLDAP/adLDAP.php | 2 -- lib/plugins/authad/auth.php | 1 + lib/plugins/authldap/auth.php | 1 + lib/plugins/authmysql/auth.php | 2 +- lib/plugins/config/settings/config.class.php | 4 +++- lib/plugins/config/settings/extra.class.php | 7 +++--- lib/plugins/info/syntax.php | 13 +++++++---- lib/plugins/usermanager/admin.php | 6 +++-- 33 files changed, 110 insertions(+), 71 deletions(-) diff --git a/inc/IXR_Library.php b/inc/IXR_Library.php index 979dc4d16..2becf4a54 100644 --- a/inc/IXR_Library.php +++ b/inc/IXR_Library.php @@ -15,6 +15,7 @@ class IXR_Value { + /** @var IXR_Value[]|IXR_Date|IXR_Base64|int|bool|double|string */ var $data; var $type; function IXR_Value ($data, $type = false) { @@ -177,7 +178,7 @@ class IXR_Message { return true; } function tag_open($parser, $tag, $attr) { - $this->currentTag = $tag; + $this->_currentTag = $tag; $this->_currentTagContents = ''; switch($tag) { case 'methodCall': diff --git a/inc/JpegMeta.php b/inc/JpegMeta.php index a35ec3ed0..3b6c6694c 100644 --- a/inc/JpegMeta.php +++ b/inc/JpegMeta.php @@ -42,6 +42,7 @@ class JpegMeta { var $_fileName; var $_fp = null; + var $_fpout = null; var $_type = 'unknown'; var $_markers; @@ -527,12 +528,12 @@ class JpegMeta { /** * Get the image's title, tries various fields * - * @param int $max maximum number chars (keeps words) + * @param int $max maximum number chars (keeps words) + * @return bool|mixed|string + * * @author Andreas Gohr */ function getTitle($max=80){ - $cap = ''; - // try various fields $cap = $this->getField(array('Iptc.Headline', 'Iptc.Caption', @@ -560,6 +561,7 @@ class JpegMeta { $this->_parseAll(); if ($this->_markers == null) { if (@isset($this->_info['file']['UnixTime'])) { + $dates = array(); $dates['FileModified'] = $this->_info['file']['UnixTime']; $dates['Time'] = $this->_info['file']['UnixTime']; $dates['TimeSource'] = 'FileModified'; @@ -1334,7 +1336,6 @@ class JpegMeta { return false; } - $pos = 0; $this->_info['jfif'] = array(); $vmaj = $this->_getByte($data, 5); @@ -1420,7 +1421,6 @@ class JpegMeta { break; default: return false; - break; } $this->_info['sof']['Format'] = $format; diff --git a/inc/Mailer.class.php b/inc/Mailer.class.php index e90b45f99..fb9ed460c 100644 --- a/inc/Mailer.class.php +++ b/inc/Mailer.class.php @@ -130,7 +130,7 @@ class Mailer { * If an empy value is passed, the header is removed * * @param string $header the header name (no trailing colon!) - * @param string $value the value of the header + * @param string|string[] $value the value of the header * @param bool $clean remove all non-ASCII chars and line feeds? */ public function setHeader($header, $value, $clean = true) { @@ -177,7 +177,7 @@ class Mailer { * @param string $text plain text body * @param array $textrep replacements to apply on the text part * @param array $htmlrep replacements to apply on the HTML part, leave null to use $textrep - * @param array $html the HTML body, leave null to create it from $text + * @param string $html the HTML body, leave null to create it from $text * @param bool $wrap wrap the HTML in the default header/Footer */ public function setBody($text, $textrep = null, $htmlrep = null, $html = null, $wrap = true) { @@ -283,7 +283,7 @@ class Mailer { * Add the To: recipients * * @see cleanAddress - * @param string|array $address Multiple adresses separated by commas or as array + * @param string|string[] $address Multiple adresses separated by commas or as array */ public function to($address) { $this->setHeader('To', $address, false); @@ -293,7 +293,7 @@ class Mailer { * Add the Cc: recipients * * @see cleanAddress - * @param string|array $address Multiple adresses separated by commas or as array + * @param string|string[] $address Multiple adresses separated by commas or as array */ public function cc($address) { $this->setHeader('Cc', $address, false); @@ -303,7 +303,7 @@ class Mailer { * Add the Bcc: recipients * * @see cleanAddress - * @param string|array $address Multiple adresses separated by commas or as array + * @param string|string[] $address Multiple adresses separated by commas or as array */ public function bcc($address) { $this->setHeader('Bcc', $address, false); diff --git a/inc/RemoteAPICore.php b/inc/RemoteAPICore.php index ffa03ee93..8c7a0e846 100644 --- a/inc/RemoteAPICore.php +++ b/inc/RemoteAPICore.php @@ -681,6 +681,7 @@ class RemoteAPICore { $pagelog->setChunkSize(1024); $info = $pagelog->getRevisionInfo($time); if(!empty($info)) { + $data = array(); $data['user'] = $info['user']; $data['ip'] = $info['ip']; $data['type'] = $info['type']; diff --git a/inc/Tar.class.php b/inc/Tar.class.php index 903f7f35c..8c7d33fc1 100644 --- a/inc/Tar.class.php +++ b/inc/Tar.class.php @@ -536,6 +536,7 @@ class Tar { $header = @unpack("a100filename/a8perm/a8uid/a8gid/a12size/a12mtime/a8checksum/a1typeflag/a100link/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor/a155prefix", $block); if(!$header) return false; + $return = array(); $return['checksum'] = OctDec(trim($header['checksum'])); if($return['checksum'] != $chks) return false; diff --git a/inc/ZipLib.class.php b/inc/ZipLib.class.php index 918d38579..cec518b05 100644 --- a/inc/ZipLib.class.php +++ b/inc/ZipLib.class.php @@ -24,10 +24,12 @@ class ZipLib { @rewind($zip); @fseek($zip, $centd['offset']); + $ret = array(); for ($i=0; $i<$centd['entries']; $i++) { $header = $this->ReadCentralFileHeaders($zip); $header['index'] = $i; + $info = array(); $info['filename'] = $header['filename']; $info['stored_filename'] = $header['stored_filename']; $info['size'] = $header['size']; @@ -48,6 +50,7 @@ class ZipLib { function Add($files,$compact) { if(!is_array($files[0])) $files=Array($files); + $ret = array(); for($i=0;$files[$i];$i++){ $fn = $files[$i]; if(!in_Array(dirname($fn[0]),$this->dirs)) @@ -189,7 +192,6 @@ class ZipLib { */ function Extract ( $zn, $to, $index = Array(-1) ) { if(!@is_dir($to)) $this->_mkdir($to); - $ok = 0; $zip = @fopen($zn,'rb'); if(!$zip) return(-1); $cdir = $this->ReadCentralDir($zip,$zn); @@ -203,6 +205,7 @@ class ZipLib { return(-1); } + $stat = array(); for ($i=0; $i<$cdir['entries']; $i++) { @fseek($zip, $pos_entry); $header = $this->ReadCentralFileHeaders($zip); @@ -320,6 +323,7 @@ class ZipLib { $data=unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', fread($zip, 18)); + $centd = array(); if ($data['comment_size'] != 0){ $centd['comment'] = fread($zip, $data['comment_size']); } else { @@ -421,7 +425,6 @@ class ZipLib { function ExtractStr($zn, $name) { - $ok = 0; $zip = @fopen($zn,'rb'); if(!$zip) return(null); $cdir = $this->ReadCentralDir($zip,$zn); diff --git a/inc/actions.php b/inc/actions.php index 2b819a0d6..5cf63a6ca 100644 --- a/inc/actions.php +++ b/inc/actions.php @@ -600,7 +600,6 @@ function act_export($act){ $pre = ''; $post = ''; - $output = ''; $headers = array(); // search engines: never cache exported docs! (Google only currently) diff --git a/inc/auth.php b/inc/auth.php index e938830ef..dc2b6cad8 100644 --- a/inc/auth.php +++ b/inc/auth.php @@ -1129,6 +1129,7 @@ function auth_deleteprofile(){ } } + $deleted = array(); $deleted[] = $INPUT->server->str('REMOTE_USER'); if($auth->triggerUserMod('delete', array($deleted))) { // force and immediate logout including removing the sticky cookie diff --git a/inc/common.php b/inc/common.php index 95ea4e72d..91a068bb0 100644 --- a/inc/common.php +++ b/inc/common.php @@ -120,6 +120,7 @@ function basicinfo($id, $htmlClient=true){ global $INPUT; // set info about manager/admin status. + $info = array(); $info['isadmin'] = false; $info['ismanager'] = false; if($INPUT->server->has('REMOTE_USER')) { @@ -685,6 +686,7 @@ function checkwordblock($text = '') { } if(count($re) && preg_match('#('.join('|', $re).')#si', $text, $matches)) { // prepare event data + $data = array(); $data['matches'] = $matches; $data['userinfo']['ip'] = $INPUT->server->str('REMOTE_ADDR'); if($INPUT->server->str('REMOTE_USER')) { @@ -1119,6 +1121,7 @@ function rawWikiSlices($range, $id, $rev = '') { $from = !$from ? 0 : ($from - 1); $to = !$to ? strlen($text) : ($to - 1); + $slices = array(); $slices[0] = substr($text, 0, $from); $slices[1] = substr($text, $from, $to - $from); $slices[2] = substr($text, $to); diff --git a/inc/fulltext.php b/inc/fulltext.php index aaef090e1..c1dc16e47 100644 --- a/inc/fulltext.php +++ b/inc/fulltext.php @@ -23,6 +23,7 @@ if(!defined('FT_SNIPPET_NUMBER')) define('FT_SNIPPET_NUMBER',15); */ function ft_pageSearch($query,&$highlight){ + $data = array(); $data['query'] = $query; $data['highlight'] =& $highlight; diff --git a/inc/html.php b/inc/html.php index dd4a3d8da..ce6360175 100644 --- a/inc/html.php +++ b/inc/html.php @@ -1902,6 +1902,7 @@ function html_debug(){ print ''; if (function_exists('apache_get_version')) { + $apache = array(); $apache['version'] = apache_get_version(); if (function_exists('apache_get_modules')) { diff --git a/inc/infoutils.php b/inc/infoutils.php index f9ba11560..9c297a28d 100644 --- a/inc/infoutils.php +++ b/inc/infoutils.php @@ -296,6 +296,7 @@ define('MSG_ADMINS_ONLY',4); */ function msg($message,$lvl=0,$line='',$file='',$allow=MSG_PUBLIC){ global $MSG, $MSG_shown; + $errors = array(); $errors[-1] = 'error'; $errors[0] = 'info'; $errors[1] = 'success'; @@ -452,7 +453,7 @@ function dbg_backtrace(){ }elseif(is_array($arg)){ $params[] = '[Array]'; }elseif(is_null($arg)){ - $param[] = '[NULL]'; + $params[] = '[NULL]'; }else{ $params[] = (string) '"'.$arg.'"'; } diff --git a/inc/media.php b/inc/media.php index 2b802a0ae..7770d3cc9 100644 --- a/inc/media.php +++ b/inc/media.php @@ -231,6 +231,7 @@ function media_delete($id,$auth){ $file = mediaFN($id); // trigger an event - MEDIA_DELETE_FILE + $data = array(); $data['id'] = $id; $data['name'] = utf8_basename($file); $data['path'] = $file; @@ -439,6 +440,7 @@ function media_save($file, $id, $ow, $auth, $move) { } // prepare event data + $data = array(); $data[0] = $file['name']; $data[1] = $fn; $data[2] = $id; @@ -910,11 +912,11 @@ function media_tab_history($image, $ns, $auth=null) { * * @param string $image media id * @param int $auth permission level - * @param int|bool $rev + * @param int|string $rev revision timestamp or empty string * @param JpegMeta|bool $meta * @author Kate Arzamastseva */ -function media_preview($image, $auth, $rev=false, $meta=false) { +function media_preview($image, $auth, $rev='', $meta=false) { $size = media_image_preview_size($image, $rev, $meta); @@ -999,11 +1001,11 @@ function media_preview_buttons($image, $auth, $rev='') { * Returns image width and height for mediamanager preview panel * * @author Kate Arzamastseva - * @param string $image - * @param int|string $rev - * @param JpegMeta $meta - * @param int $size - * @return array + * @param string $image + * @param int|string $rev + * @param JpegMeta|bool $meta + * @param int $size + * @return array|bool */ function media_image_preview_size($image, $rev, $meta, $size = 500) { if (!preg_match("/\.(jpe?g|gif|png)$/", $image) || !file_exists(mediaFN($image, $rev))) return false; @@ -1158,6 +1160,7 @@ function media_diff($image, $ns, $auth, $fromajax = false) { } // prepare event data + $data = array(); $data[0] = $image; $data[1] = $l_rev; $data[2] = $r_rev; @@ -1397,13 +1400,12 @@ function media_searchlist($query,$ns,$auth=null,$fullscreen=false,$sort='natural global $lang; $ns = cleanID($ns); - + $evdata = array( + 'ns' => $ns, + 'data' => array(), + 'query' => $query + ); if ($query) { - $evdata = array( - 'ns' => $ns, - 'data' => array(), - 'query' => $query - ); $evt = new Doku_Event('MEDIA_SEARCH', $evdata); if ($evt->advise_before()) { $dir = utf8_encodeFN(str_replace(':','/',$evdata['ns'])); @@ -2169,6 +2171,7 @@ function media_resize_imageGD($ext,$from,$from_w,$from_h,$to,$to_w,$to_h,$ofs_x= } // create an image of the given filetype + $image = false; if ($ext == 'jpg' || $ext == 'jpeg'){ if(!function_exists("imagecreatefromjpeg")) return false; $image = @imagecreatefromjpeg($from); @@ -2182,6 +2185,7 @@ function media_resize_imageGD($ext,$from,$from_w,$from_h,$to,$to_w,$to_h,$ofs_x= } if(!$image) return false; + $newimg = false; if(($conf['gdlib']>1) && function_exists("imagecreatetruecolor") && $ext != 'gif'){ $newimg = @imagecreatetruecolor ($to_w, $to_h); } @@ -2266,14 +2270,14 @@ function media_resize_imageGD($ext,$from,$from_w,$from_h,$to,$to_w,$to_h,$ofs_x= function media_alternativefiles($src, $exts){ $files = array(); - list($srcExt, $srcMime) = mimetype($src); + list($srcExt, /* $srcMime */) = mimetype($src); $filebase = substr($src, 0, -1 * (strlen($srcExt)+1)); foreach($exts as $ext) { $fileid = $filebase.'.'.$ext; $file = mediaFN($fileid); if(file_exists($file)) { - list($fileExt, $fileMime) = mimetype($file); + list(/* $fileExt */, $fileMime) = mimetype($file); $files[$fileMime] = $fileid; } } diff --git a/inc/parser/lexer.php b/inc/parser/lexer.php index 2e84eca7c..b46a5f505 100644 --- a/inc/parser/lexer.php +++ b/inc/parser/lexer.php @@ -56,12 +56,12 @@ class Doku_LexerParallelRegex { /** * Adds a pattern with an optional label. * - * @param mixed $pattern Perl style regex. Must be UTF-8 + * @param mixed $pattern Perl style regex. Must be UTF-8 * encoded. If its a string, the (, ) * lose their meaning unless they * form part of a lookahead or * lookbehind assertation. - * @param string $label Label of regex to be returned + * @param bool|string $label Label of regex to be returned * on a match. Label must be ASCII * @access public */ @@ -151,7 +151,8 @@ class Doku_LexerParallelRegex { * "or" operator. Caches the regex. * Will automatically escape (, ) and / tokens. * - * @param array $patterns List of patterns in order. + * @internal array $_patterns List of patterns in order. + * @return null|string * @access private */ function _getCompoundedRegex() { @@ -297,6 +298,7 @@ class Doku_Lexer { */ function Doku_Lexer(&$parser, $start = "accept", $case = false) { $this->_case = $case; + /** @var Doku_LexerParallelRegex[] _regexes */ $this->_regexes = array(); $this->_parser = &$parser; $this->_mode = new Doku_LexerStateStack($start); @@ -425,11 +427,13 @@ class Doku_Lexer { * Sends the matched token and any leading unmatched * text to the parser changing the lexer to a new * mode if one is listed. - * @param string $unmatched Unmatched leading portion. - * @param string $matched Actual token match. - * @param string $mode Mode after match. A boolean + * @param string $unmatched Unmatched leading portion. + * @param string $matched Actual token match. + * @param bool|string $mode Mode after match. A boolean * false mode causes no change. - * @param int $pos Current byte index location in raw doc + * @param int $initialPos + * @param int $matchPos + * Current byte index location in raw doc * thats being parsed * @return boolean False if there was any error * from the parser. @@ -498,11 +502,12 @@ class Doku_Lexer { * Calls the parser method named after the current * mode. Empty content will be ignored. The lexer * has a parser handler for each mode in the lexer. - * @param string $content Text parsed. - * @param boolean $is_match Token is recognised rather + * @param string $content Text parsed. + * @param boolean $is_match Token is recognised rather * than unparsed data. - * @param int $pos Current byte index location in raw doc + * @param int $pos Current byte index location in raw doc * thats being parsed + * @return bool * @access private */ function _invokeParser($content, $is_match, $pos) { diff --git a/inc/parser/metadata.php b/inc/parser/metadata.php index 4619c24ce..3fc5d1c9a 100644 --- a/inc/parser/metadata.php +++ b/inc/parser/metadata.php @@ -421,8 +421,8 @@ class Doku_Renderer_metadata extends Doku_Renderer { /** * keep track of internal links in $this->meta['relation']['references'] * - * @param string $id page ID to link to. eg. 'wiki:syntax' - * @param string|array $name name for the link, array for media file + * @param string $id page ID to link to. eg. 'wiki:syntax' + * @param string|array|null $name name for the link, array for media file */ function internallink($id, $name = null) { global $ID; @@ -458,8 +458,8 @@ class Doku_Renderer_metadata extends Doku_Renderer { /** * Render an external link * - * @param string $url full URL with scheme - * @param string|array $name name for the link, array for media file + * @param string $url full URL with scheme + * @param string|array|null $name name for the link, array for media file */ function externallink($url, $name = null) { if(is_array($name)) { @@ -628,9 +628,9 @@ class Doku_Renderer_metadata extends Doku_Renderer { * Construct a title and handle images in titles * * @author Harry Fuecks - * @param string|array $title either string title or media array - * @param string $default default title if nothing else is found - * @param null|string $id linked page id (used to extract title from first heading) + * @param string|array|null $title either string title or media array + * @param string $default default title if nothing else is found + * @param null|string $id linked page id (used to extract title from first heading) * @return string title text */ function _getLinkTitle($title, $default, $id = null) { diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index cd4b3d6e5..aa09058df 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -820,6 +820,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { // now first resolve and clean up the $id resolve_pageid(getNS($ID), $id, $exists); + $link = array(); $name = $this->_getLinkTitle($name, $default, $isImage, $id, $linktype); if(!$isImage) { if($exists) { @@ -904,6 +905,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { } //prepare for formating + $link = array(); $link['target'] = $conf['target']['extern']; $link['style'] = ''; $link['pre'] = ''; @@ -981,6 +983,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { global $conf; //simple setup + $link = array(); $link['target'] = $conf['target']['windows']; $link['pre'] = ''; $link['suf'] = ''; @@ -1656,7 +1659,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { // prepare alternative formats $extensions = array('webm', 'ogv', 'mp4'); $files = media_alternativefiles($src, $extensions); - $poster = media_alternativefiles($src, array('jpg', 'png'), true); + $poster = media_alternativefiles($src, array('jpg', 'png')); if(!empty($poster)) { $posterUrl = ml(reset($poster), '', true, '&'); } @@ -1700,7 +1703,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { * @param array $atts - additional attributes for the