From 42ea7f447f39fbc2f79eaaec31f8c10ede59c5d0 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Wed, 1 Oct 2014 11:30:27 +0200 Subject: Many PHPDocs, some unused and dyn declared vars many PHPDocs some unused variables some dynamically declared variables declared --- inc/plugin.php | 45 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 10 deletions(-) (limited to 'inc/plugin.php') diff --git a/inc/plugin.php b/inc/plugin.php index fbfc0325f..8432b21b2 100644 --- a/inc/plugin.php +++ b/inc/plugin.php @@ -48,14 +48,25 @@ class DokuWiki_Plugin { // plugin introspection methods // extract from class name, format = _plugin_[_] + /** + * @return string plugin type + */ function getPluginType() { list($t) = explode('_', get_class($this), 2); return $t; } + + /** + * @return string plugin name + */ function getPluginName() { list($t, $p, $n) = explode('_', get_class($this), 4); return $n; } + + /** + * @return string component name + */ function getPluginComponent() { list($t, $p, $n, $c) = explode('_', get_class($this), 4); return (isset($c)?$c:''); @@ -91,9 +102,11 @@ class DokuWiki_Plugin { } /** - * localFN($id) - * prepends appropriate path for a language dependent filename + * Prepends appropriate path for a language dependent filename * plugin equivalent of localFN() + * + * @param string $id id of localization file + * @return string wiki text */ function localFN($id) { global $conf; @@ -110,9 +123,8 @@ class DokuWiki_Plugin { } /** - * setupLocale() - * reads all the plugins language dependent strings into $this->lang - * this function is automatically called by getLang() + * Reads all the plugins language dependent strings into $this->lang + * this function is automatically called by getLang() */ function setupLocale() { if ($this->localised) return; @@ -196,8 +208,7 @@ class DokuWiki_Plugin { * * @param string $name name of plugin to load * @param bool $msg if a message should be displayed in case the plugin is not available - * - * @return object helper plugin object + * @return DokuWiki_Plugin|null helper plugin object */ function loadHelper($name, $msg = true){ $obj = plugin_load('helper',$name); @@ -211,6 +222,12 @@ class DokuWiki_Plugin { /** * email * standardised function to generate an email link according to obfuscation settings + * + * @param string $email + * @param string $name + * @param string $class + * @param string $more + * @return string html */ function email($email, $name='', $class='', $more='') { if (!$email) return $name; @@ -223,6 +240,13 @@ class DokuWiki_Plugin { /** * external_link * standardised function to generate an external link according to conf settings + * + * @param string $link + * @param string $title + * @param string $class + * @param string $target + * @param string $more + * @return string */ function external_link($link, $title='', $class='', $target='', $more='') { global $conf; @@ -247,8 +271,9 @@ class DokuWiki_Plugin { * Instead use render_text() * * @deprecated 2014-01-22 - * @param $name - * @param $arguments + * + * @param string $name + * @param array $arguments * @return null|string */ function __call($name, $arguments) { @@ -265,7 +290,7 @@ class DokuWiki_Plugin { * output text string through the parser, allows dokuwiki markup to be used * very ineffecient for small pieces of data - try not to use * - * @param string $text wiki markup to parse + * @param string $text wiki markup to parse * @param string $format output format * @return null|string */ -- cgit v1.2.3 From 7e8500eea1e53b1de0e0f70400664afa442cd08d Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Thu, 2 Oct 2014 14:55:24 +0200 Subject: PHPDocs and some improvements --- inc/plugin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'inc/plugin.php') diff --git a/inc/plugin.php b/inc/plugin.php index 8432b21b2..3bab560cb 100644 --- a/inc/plugin.php +++ b/inc/plugin.php @@ -60,7 +60,7 @@ class DokuWiki_Plugin { * @return string plugin name */ function getPluginName() { - list($t, $p, $n) = explode('_', get_class($this), 4); + list(/* $t */, /* $p */, $n) = explode('_', get_class($this), 4); return $n; } @@ -68,7 +68,7 @@ class DokuWiki_Plugin { * @return string component name */ function getPluginComponent() { - list($t, $p, $n, $c) = explode('_', get_class($this), 4); + list(/* $t */, /* $p */, /* $n */, $c) = explode('_', get_class($this), 4); return (isset($c)?$c:''); } -- cgit v1.2.3 From 79e79377626799a77c11aa7849cb9c64305590c8 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 7 Jan 2015 10:47:45 +0100 Subject: Remove error supression for file_exists() In an older version of PHP a file_exists() call would issue a warning when the file did not exist. This was fixed in later PHP releases. Since we require PHP 5.3 now, there's no need to supress any error here anymore. This might even give a minor performance boost. --- inc/plugin.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'inc/plugin.php') diff --git a/inc/plugin.php b/inc/plugin.php index 9d9b2044c..f2ad95e2e 100644 --- a/inc/plugin.php +++ b/inc/plugin.php @@ -33,7 +33,7 @@ class DokuWiki_Plugin { public function getInfo(){ $parts = explode('_', get_class($this)); $info = DOKU_PLUGIN . '/' . $parts[2] . '/plugin.info.txt'; - if(@file_exists($info)) return confToHash($info); + if(file_exists($info)) return confToHash($info); msg( 'getInfo() not implemented in ' . get_class($this) . ' and ' . $info . ' not found.
' . @@ -112,9 +112,9 @@ class DokuWiki_Plugin { global $conf; $plugin = $this->getPluginName(); $file = DOKU_CONF.'plugin_lang/'.$plugin.'/'.$conf['lang'].'/'.$id.'.txt'; - if (!@file_exists($file)){ + if (!file_exists($file)){ $file = DOKU_PLUGIN.$plugin.'/lang/'.$conf['lang'].'/'.$id.'.txt'; - if(!@file_exists($file)){ + if(!file_exists($file)){ //fall back to english $file = DOKU_PLUGIN.$plugin.'/lang/en/'.$id.'.txt'; } @@ -137,7 +137,7 @@ class DokuWiki_Plugin { // don't include once, in case several plugin components require the same language file @include($path . 'en/lang.php'); foreach($config_cascade['lang']['plugin'] as $config_file) { - if(@file_exists($config_file . $this->getPluginName() . '/en/lang.php')) { + if(file_exists($config_file . $this->getPluginName() . '/en/lang.php')) { include($config_file . $this->getPluginName() . '/en/lang.php'); } } @@ -145,7 +145,7 @@ class DokuWiki_Plugin { if($conf['lang'] != 'en') { @include($path . $conf['lang'] . '/lang.php'); foreach($config_cascade['lang']['plugin'] as $config_file) { - if(@file_exists($config_file . $this->getPluginName() . '/' . $conf['lang'] . '/lang.php')) { + if(file_exists($config_file . $this->getPluginName() . '/' . $conf['lang'] . '/lang.php')) { include($config_file . $this->getPluginName() . '/' . $conf['lang'] . '/lang.php'); } } @@ -207,7 +207,7 @@ class DokuWiki_Plugin { $path = DOKU_PLUGIN.$this->getPluginName().'/conf/'; $conf = array(); - if (@file_exists($path.'default.php')) { + if (file_exists($path.'default.php')) { include($path.'default.php'); } -- cgit v1.2.3