From 59bc3b48fdffb76ee65a4b630be3ffa1f6c20c80 Mon Sep 17 00:00:00 2001
From: Gerrit Uitslag <klapinklapin@gmail.com>
Date: Mon, 29 Sep 2014 21:45:27 +0200
Subject: [PATCH] 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 <andi@splitbrain.org>
      */
     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 '</pre>';
 
     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 <pshns@ukr.net>
  */
-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 <pshns@ukr.net>
- * @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 <hfuecks@gmail.com>
-     * @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 <audio> tag
      * @return string
      */
-    function _audio($src, $atts = null) {
+    function _audio($src, $atts = array()) {
         $files = array();
         $isExternal = media_isexternal($src);
 
diff --git a/inc/plugincontroller.class.php b/inc/plugincontroller.class.php
index 999f32937..86c10585e 100644
--- a/inc/plugincontroller.class.php
+++ b/inc/plugincontroller.class.php
@@ -73,7 +73,7 @@ class Doku_Plugin_Controller {
         //we keep all loaded plugins available in global scope for reuse
         global $DOKU_PLUGINS;
 
-        list($plugin,$component) = $this->_splitName($name);
+        list($plugin, /* $component */) = $this->_splitName($name);
 
         // check if disabled
         if(!$disabled && $this->isdisabled($plugin)){
diff --git a/inc/remote.php b/inc/remote.php
index e27aa74f8..a21ef1e25 100644
--- a/inc/remote.php
+++ b/inc/remote.php
@@ -85,7 +85,7 @@ class RemoteAPI {
         if ($args === null) {
             $args = array();
         }
-        list($type, $pluginName, $call) = explode('.', $method, 3);
+        list($type, $pluginName, /* $call */) = explode('.', $method, 3);
         if ($type === 'plugin') {
             return $this->callPlugin($pluginName, $method, $args);
         }
diff --git a/inc/search.php b/inc/search.php
index 5489dc2c0..79d930149 100644
--- a/inc/search.php
+++ b/inc/search.php
@@ -258,6 +258,7 @@ function search_allpages(&$data,$base,$file,$type,$lvl,$opts){
     //only search txt files
     if(substr($file,-4) != '.txt') return true;
 
+    $item = array();
     $item['id']   = pathID($file);
     if(!$opts['skipacl'] && auth_quickaclcheck($item['id']) < AUTH_READ){
         return false;
diff --git a/inc/subscription.php b/inc/subscription.php
index dbbcbe16a..bad98cf6c 100644
--- a/inc/subscription.php
+++ b/inc/subscription.php
@@ -454,7 +454,7 @@ class Subscription {
         global $conf;
 
         $file = mediaFN($id);
-        list($mime, $ext) = mimetype($id);
+        list($mime, /* $ext */) = mimetype($id);
 
         $trep = array(
             'MIME'  => $mime,
diff --git a/inc/template.php b/inc/template.php
index 667e3db1c..49f6986fd 100644
--- a/inc/template.php
+++ b/inc/template.php
@@ -759,7 +759,6 @@ function tpl_get_action($type) {
             break;
         default:
             return '[unknown %s type]';
-            break;
     }
     return compact('accesskey', 'type', 'id', 'method', 'params', 'nofollow', 'replacement');
 }
diff --git a/lib/exe/indexer.php b/lib/exe/indexer.php
index d0a5e0463..89c4b7cd0 100644
--- a/lib/exe/indexer.php
+++ b/lib/exe/indexer.php
@@ -84,7 +84,7 @@ function runTrimRecentChanges($media_changes = false) {
             io_saveFile($fn.'_tmp', '');          // presave tmp as 2nd lock
             $trim_time = time() - $conf['recent_days']*86400;
             $out_lines = array();
-
+            $old_lines = array();
             for ($i=0; $i<count($lines); $i++) {
                 $log = parseChangelogLine($lines[$i]);
                 if ($log === false) continue;                      // discard junk
diff --git a/lib/plugins/acl/admin.php b/lib/plugins/acl/admin.php
index ebb097a04..814bbfe9c 100644
--- a/lib/plugins/acl/admin.php
+++ b/lib/plugins/acl/admin.php
@@ -762,6 +762,8 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin {
      */
     function _html_select(){
         $inlist = false;
+        $usel = '';
+        $gsel = '';
 
         if($this->who &&
            !in_array($this->who,$this->usersgroups) &&
@@ -770,11 +772,9 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin {
             if($this->who{0} == '@'){
                 $gsel = ' selected="selected"';
             }else{
-                $usel   = ' selected="selected"';
+                $usel = ' selected="selected"';
             }
         }else{
-            $usel = '';
-            $gsel = '';
             $inlist = true;
         }
 
diff --git a/lib/plugins/acl/remote.php b/lib/plugins/acl/remote.php
index 6d5201cf6..2fdc697db 100644
--- a/lib/plugins/acl/remote.php
+++ b/lib/plugins/acl/remote.php
@@ -18,11 +18,13 @@ class remote_plugin_acl extends DokuWiki_Remote_Plugin {
     }
 
     function addAcl($scope, $user, $level){
+        /** @var admin_plugin_acl $apa */
         $apa = plugin_load('admin', 'acl');
         return $apa->_acl_add($scope, $user, $level);
     }
 
     function delAcl($scope, $user){
+        /** @var admin_plugin_acl $apa */
         $apa = plugin_load('admin', 'acl');
         return $apa->_acl_del($scope, $user);
     }
diff --git a/lib/plugins/auth.php b/lib/plugins/auth.php
index b38b591a3..0d6ea2fa3 100644
--- a/lib/plugins/auth.php
+++ b/lib/plugins/auth.php
@@ -124,8 +124,11 @@ class DokuWiki_Auth_Plugin extends DokuWiki_Plugin {
             'modify' => 'modifyUser',
             'delete' => 'deleteUsers'
         );
-        if(empty($validTypes[$type]))
+        if(empty($validTypes[$type])) {
             return false;
+        }
+
+        $result = false;
         $eventdata = array('type' => $type, 'params' => $params, 'modification_result' => null);
         $evt       = new Doku_Event('AUTH_USER_CHANGE', $eventdata);
         if($evt->advise_before(true)) {
diff --git a/lib/plugins/authad/adLDAP/adLDAP.php b/lib/plugins/authad/adLDAP/adLDAP.php
index c1f92abe2..5563e4fe9 100644
--- a/lib/plugins/authad/adLDAP/adLDAP.php
+++ b/lib/plugins/authad/adLDAP/adLDAP.php
@@ -947,5 +947,3 @@ class adLDAP {
 * }
 */
 class adLDAPException extends Exception {}
-
-?>
\ No newline at end of file
diff --git a/lib/plugins/authad/auth.php b/lib/plugins/authad/auth.php
index a3119dda6..65f0b1647 100644
--- a/lib/plugins/authad/auth.php
+++ b/lib/plugins/authad/auth.php
@@ -203,6 +203,7 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin {
         }
 
         //general user info
+        $info = array();
         $info['name'] = $result[0]['displayname'][0];
         $info['mail'] = $result[0]['mail'][0];
         $info['uid']  = $result[0]['samaccountname'][0];
diff --git a/lib/plugins/authldap/auth.php b/lib/plugins/authldap/auth.php
index a94c7a357..fd4729331 100644
--- a/lib/plugins/authldap/auth.php
+++ b/lib/plugins/authldap/auth.php
@@ -181,6 +181,7 @@ class auth_plugin_authldap extends DokuWiki_Auth_Plugin {
             }
         }
 
+        $info = array();
         $info['user']   = $user;
         $info['server'] = $this->getConf('server');
 
diff --git a/lib/plugins/authmysql/auth.php b/lib/plugins/authmysql/auth.php
index 176eac679..0605a3bf1 100644
--- a/lib/plugins/authmysql/auth.php
+++ b/lib/plugins/authmysql/auth.php
@@ -366,7 +366,7 @@ class auth_plugin_authmysql extends DokuWiki_Auth_Plugin {
      *
      * @param  int          $first  index of first user to be returned
      * @param  int          $limit  max number of users to be returned
-     * @param  array|string $filter array of field/pattern pairs
+     * @param  array $filter array of field/pattern pairs
      * @return  array userinfo (refer getUserData for internal userinfo details)
      */
     public function retrieveUsers($first = 0, $limit = 0, $filter = array()) {
diff --git a/lib/plugins/config/settings/config.class.php b/lib/plugins/config/settings/config.class.php
index 8dae23110..30e7a2133 100644
--- a/lib/plugins/config/settings/config.class.php
+++ b/lib/plugins/config/settings/config.class.php
@@ -775,6 +775,7 @@ if (!class_exists('setting_email')) {
          * update setting with user provided value $input
          * if value fails error check, save it
          *
+         * @param mixed $input
          * @return boolean true if changed, false otherwise (incl. on error)
          */
         function update($input) {
@@ -925,6 +926,7 @@ if (!class_exists('setting_onoff')) {
 if (!class_exists('setting_multichoice')) {
     class setting_multichoice extends setting_string {
         var $_choices = array();
+        var $lang; //some custom language strings are stored in setting
 
         function html(&$plugin, $echo = false) {
             $value = '';
@@ -1125,7 +1127,7 @@ if (!class_exists('setting_multicheckbox')) {
             // handle any remaining values
             $other = join(',',$value);
 
-            $class = (count($default == count($value)) && (count($value) == count(array_intersect($value,$default)))) ?
+            $class = ((count($default) == count($value)) && (count($value) == count(array_intersect($value,$default)))) ?
                             " selectiondefault" : "";
 
             $input .= '<div class="other'.$class.'">'."\n";
diff --git a/lib/plugins/config/settings/extra.class.php b/lib/plugins/config/settings/extra.class.php
index 83de802a3..02171fb77 100644
--- a/lib/plugins/config/settings/extra.class.php
+++ b/lib/plugins/config/settings/extra.class.php
@@ -122,7 +122,7 @@ if (!class_exists('setting_disableactions')) {
 
             // make some language adjustments (there must be a better way)
             // transfer some DokuWiki language strings to the plugin
-            if (!$plugin->localised) $this->setupLocale();
+            if (!$plugin->localised) $plugin->setupLocale();
             $plugin->lang[$this->_key.'_revisions'] = $lang['btn_revs'];
 
             foreach ($this->_choices as $choice)
@@ -159,7 +159,7 @@ if (!class_exists('setting_license')) {
 
             foreach($license as $key => $data){
                 $this->_choices[] = $key;
-                $this->lang[$this->_key.'_o_'.$key] = $data['name'];
+                $this->lang[$this->_key.'_o_'.$key] = $data['name']; // stored in setting
             }
 
             parent::initialize($default,$local,$protected);
@@ -171,6 +171,7 @@ if (!class_exists('setting_license')) {
 if (!class_exists('setting_renderer')) {
     class setting_renderer extends setting_multichoice {
         var $_prompts = array();
+        var $_format = null;
 
         function initialize($default,$local,$protected) {
             $format = $this->_format;
@@ -192,7 +193,7 @@ if (!class_exists('setting_renderer')) {
 
             // make some language adjustments (there must be a better way)
             // transfer some plugin names to the config plugin
-            if (!$plugin->localised) $this->setupLocale();
+            if (!$plugin->localised) $plugin->setupLocale();
 
             foreach ($this->_choices as $choice) {
                 if (!isset($plugin->lang[$this->_key.'_o_'.$choice])) {
diff --git a/lib/plugins/info/syntax.php b/lib/plugins/info/syntax.php
index 3e3f6b733..fc0e1af9d 100644
--- a/lib/plugins/info/syntax.php
+++ b/lib/plugins/info/syntax.php
@@ -104,7 +104,7 @@ class syntax_plugin_info extends DokuWiki_Syntax_Plugin {
      *
      * uses some of the original renderer methods
      */
-    function _plugins_xhtml($type, Doku_Renderer &$renderer){
+    function _plugins_xhtml($type, Doku_Renderer_xhtml $renderer){
         global $lang;
         $renderer->doc .= '<ul>';
 
@@ -142,7 +142,7 @@ class syntax_plugin_info extends DokuWiki_Syntax_Plugin {
      *
      * uses some of the original renderer methods
      */
-    function _helpermethods_xhtml(Doku_Renderer &$renderer){
+    function _helpermethods_xhtml(Doku_Renderer_xhtml $renderer){
         $plugins = plugin_list('helper');
         foreach($plugins as $p){
             if (!$po = plugin_load('helper',$p)) continue;
@@ -249,12 +249,17 @@ class syntax_plugin_info extends DokuWiki_Syntax_Plugin {
 
     /**
      * Adds a TOC item
+     *
+     * @param string $text
+     * @param int $level
+     * @param Doku_Renderer_xhtml $renderer
+     * @return string
      */
-    function _addToTOC($text, $level, Doku_Renderer &$renderer){
+    protected function _addToTOC($text, $level, Doku_Renderer_xhtml $renderer){
         global $conf;
 
+        $hid = '';
         if (($level >= $conf['toptoclevel']) && ($level <= $conf['maxtoclevel'])){
-            /** @var $renderer Doku_Renderer_xhtml */
             $hid  = $renderer->_headerToLink($text, true);
             $renderer->toc[] = array(
                 'hid'   => $hid,
diff --git a/lib/plugins/usermanager/admin.php b/lib/plugins/usermanager/admin.php
index b67d91b36..c568469a7 100644
--- a/lib/plugins/usermanager/admin.php
+++ b/lib/plugins/usermanager/admin.php
@@ -738,6 +738,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin {
         global $auth;
         global $INPUT;
 
+        $user = array();
         $user[0] = ($clean) ? $auth->cleanUser($INPUT->str('userid')) : $INPUT->str('userid');
         $user[1] = $INPUT->str('userpass');
         $user[2] = $INPUT->str('username');
@@ -764,7 +765,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin {
         $this->_filter = array();
 
         if ($op == 'new') {
-            list($user,$pass,$name,$mail,$grps) = $this->_retrieveUser(false);
+            list($user,/* $pass */,$name,$mail,$grps) = $this->_retrieveUser(false);
 
             if (!empty($user)) $this->_filter['user'] = $user;
             if (!empty($name)) $this->_filter['name'] = $name;
@@ -816,6 +817,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin {
 
         $disabled = 'disabled="disabled"';
 
+        $buttons = array();
         $buttons['start'] = $buttons['prev'] = ($this->_start == 0) ? $disabled : '';
 
         if ($this->_user_total == -1) {
@@ -951,7 +953,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin {
         $INPUT->set('usergroups', $candidate[4]);
 
         $cleaned = $this->_retrieveUser();
-        list($user,$pass,$name,$mail,$grps) = $cleaned;
+        list($user,/* $pass */,$name,$mail,/* $grps */) = $cleaned;
         if (empty($user)) {
             $error = $this->lang['import_error_baduserid'];
             return false;
-- 
GitLab