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/parserutils.php | 49 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 6 deletions(-) (limited to 'inc/parserutils.php') diff --git a/inc/parserutils.php b/inc/parserutils.php index 9c2a0b570..791033e63 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -55,6 +55,11 @@ define('METADATA_RENDER_UNLIMITED', 4); * wasn't found * * @author Andreas Gohr + * + * @param string $id page id + * @param string|int $rev revision timestamp or empty string + * @param bool $excuse + * @return null|string */ function p_wiki_xhtml($id, $rev='', $excuse=true){ $file = wikiFN($id,$rev); @@ -89,6 +94,9 @@ function p_wiki_xhtml($id, $rev='', $excuse=true){ * Returns the specified local text in parsed format * * @author Andreas Gohr + * + * @param string $id page id + * @return null|string */ function p_locale_xhtml($id){ //fetch parsed locale @@ -101,6 +109,11 @@ function p_locale_xhtml($id){ * * @author Andreas Gohr * @author Chris Smith + * + * @param string $file filename, path to file + * @param string $format + * @param string $id page id + * @return null|string */ function p_cached_output($file, $format='xhtml', $id='') { global $conf; @@ -129,6 +142,11 @@ function p_cached_output($file, $format='xhtml', $id='') { * Uses and creates a serialized cache file * * @author Andreas Gohr + * + * @param string $file filename, path to file + * @param bool $cacheonly + * @param string $id page id + * @return array|null */ function p_cached_instructions($file,$cacheonly=false,$id='') { static $run = null; @@ -157,7 +175,8 @@ function p_cached_instructions($file,$cacheonly=false,$id='') { * * @author Harry Fuecks * @author Andreas Gohr - * @param string $text raw wiki syntax text + * + * @param string $text raw wiki syntax text * @return array a list of instruction arrays */ function p_get_instructions($text){ @@ -185,9 +204,9 @@ function p_get_instructions($text){ /** * returns the metadata of a page * - * @param string $id The id of the page the metadata should be returned from - * @param string $key The key of the metdata value that shall be read (by default everything) - separate hierarchies by " " like "date created" - * @param int $render If the page should be rendererd - possible values: + * @param string $id The id of the page the metadata should be returned from + * @param string $key The key of the metdata value that shall be read (by default everything) - separate hierarchies by " " like "date created" + * @param int $render If the page should be rendererd - possible values: * METADATA_DONT_RENDER, METADATA_RENDER_USING_SIMPLE_CACHE, METADATA_RENDER_USING_CACHE * METADATA_RENDER_UNLIMITED (also combined with the previous two options), * default: METADATA_RENDER_USING_CACHE @@ -360,6 +379,9 @@ function p_set_metadata($id, $data, $render=false, $persistent=true){ * used on page deletion * * @author Michael Klier + * + * @param string $id page id + * @return bool success / fail */ function p_purge_metadata($id) { $meta = p_read_metadata($id); @@ -423,6 +445,10 @@ function p_save_metadata($id, $meta) { * renders the metadata of a page * * @author Esther Brunner + * + * @param string $id page id + * @param array $orig the original metadata + * @return array|null array('current'=> array,'persistent'=> array); */ function p_render_metadata($id, $orig){ // make sure the correct ID is in global ID @@ -477,6 +503,8 @@ function p_render_metadata($id, $orig){ * returns all available parser syntax modes in correct order * * @author Andreas Gohr + * + * @return array[] with for each plugin the array('sort' => sortnumber, 'mode' => mode string, 'obj' => plugin object) */ function p_get_parsermodes(){ global $conf; @@ -569,6 +597,10 @@ function p_get_parsermodes(){ * Callback function for usort * * @author Andreas Gohr + * + * @param array $a + * @param array $b + * @return int $a is lower/equal/higher than $b */ function p_sort_modes($a, $b){ if($a['sort'] == $b['sort']) return 0; @@ -582,6 +614,11 @@ function p_sort_modes($a, $b){ * * @author Harry Fuecks * @author Andreas Gohr + * + * @param string $mode + * @param array $instructions + * @param array $info returns render info like enabled toc and cache + * @return null|string rendered output */ function p_render($mode,$instructions,&$info){ if(is_null($instructions)) return ''; @@ -673,8 +710,8 @@ function p_get_renderer($mode) { * METADATA_RENDER_USING_SIMPLE_CACHE, * METADATA_RENDER_USING_CACHE, * METADATA_RENDER_UNLIMITED - * * @return string|null The first heading + * * @author Andreas Gohr * @author Michael Hamann */ @@ -688,8 +725,8 @@ function p_get_first_heading($id, $render=METADATA_RENDER_USING_SIMPLE_CACHE){ * @param string $code source code to be highlighted * @param string $language language to provide highlighting * @param string $wrapper html element to wrap the returned highlighted text - * * @return string xhtml code + * * @author Christopher Smith * @author Andreas Gohr */ -- cgit v1.2.3 From e3710957c6b7e12293805a15d0624be7c7054092 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Wed, 1 Oct 2014 17:05:40 +0200 Subject: more phpdocs and minor check --- inc/parserutils.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'inc/parserutils.php') diff --git a/inc/parserutils.php b/inc/parserutils.php index 791033e63..ef62c8e49 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -616,12 +616,13 @@ function p_sort_modes($a, $b){ * @author Andreas Gohr * * @param string $mode - * @param array $instructions + * @param array|null|false $instructions * @param array $info returns render info like enabled toc and cache * @return null|string rendered output */ function p_render($mode,$instructions,&$info){ if(is_null($instructions)) return ''; + if($instructions === false) return ''; $Renderer = p_get_renderer($mode); if (is_null($Renderer)) return null; -- 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/parserutils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/parserutils.php') diff --git a/inc/parserutils.php b/inc/parserutils.php index ef62c8e49..4371f1928 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -655,7 +655,7 @@ function p_render($mode,$instructions,&$info){ * Figure out the correct renderer class to use for $mode, * instantiate and return it * - * @param $mode string Mode of the renderer to get + * @param string $mode Mode of the renderer to get * @return null|Doku_Renderer The renderer * * @author Christopher Smith -- 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/parserutils.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'inc/parserutils.php') diff --git a/inc/parserutils.php b/inc/parserutils.php index 3ef8138a7..17c331ef5 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -71,13 +71,13 @@ function p_wiki_xhtml($id, $rev='', $excuse=true,$date_at=''){ $ID = $id; if($rev || $date_at){ - if(@file_exists($file)){ + if(file_exists($file)){ $ret = p_render('xhtml',p_get_instructions(io_readWikiPage($file,$id,$rev)),$info,$date_at); //no caching on old revisions }elseif($excuse){ $ret = p_locale_xhtml('norev'); } }else{ - if(@file_exists($file)){ + if(file_exists($file)){ $ret = p_cached_output($file,'xhtml',$id); }elseif($excuse){ $ret = p_locale_xhtml('newpage'); @@ -156,7 +156,7 @@ function p_cached_instructions($file,$cacheonly=false,$id='') { if ($cacheonly || $cache->useCache() || (isset($run[$file]) && !defined('DOKU_UNITTEST'))) { return $cache->retrieveCache(); - } else if (@file_exists($file)) { + } else if (file_exists($file)) { // no cache - do some work $ins = p_get_instructions(io_readWikiPage($file,$id)); if ($cache->storeCache($ins)) { @@ -248,7 +248,7 @@ function p_get_metadata($id, $key='', $render=METADATA_RENDER_USING_CACHE){ if ($render & METADATA_RENDER_USING_SIMPLE_CACHE) { $pagefn = wikiFN($id); $metafn = metaFN($id, '.meta'); - if (!@file_exists($metafn) || @filemtime($pagefn) > @filemtime($cachefile->cache)) { + if (!file_exists($metafn) || @filemtime($pagefn) > @filemtime($cachefile->cache)) { $do_render = true; } } elseif (!$cachefile->useCache()){ @@ -414,7 +414,7 @@ function p_read_metadata($id,$cache=false) { if (isset($cache_metadata[(string)$id])) return $cache_metadata[(string)$id]; $file = metaFN($id, '.meta'); - $meta = @file_exists($file) ? unserialize(io_readFile($file, false)) : array('current'=>array(),'persistent'=>array()); + $meta = file_exists($file) ? unserialize(io_readFile($file, false)) : array('current'=>array(),'persistent'=>array()); if ($cache) { $cache_metadata[(string)$id] = $meta; -- cgit v1.2.3 From 41d51802a4f1d52aced2f2960bc919c9739cf775 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 15 May 2015 16:26:00 +0200 Subject: switched geshi higlighter to composer based repository --- inc/parserutils.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'inc/parserutils.php') diff --git a/inc/parserutils.php b/inc/parserutils.php index 17c331ef5..8650f974f 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -746,14 +746,13 @@ function p_xhtml_cached_geshi($code, $language, $wrapper='pre') { $cache = getCacheName($language.$code,".code"); $ctime = @filemtime($cache); if($ctime && !$INPUT->bool('purge') && - $ctime > filemtime(DOKU_INC.'inc/geshi.php') && // geshi changed - $ctime > @filemtime(DOKU_INC.'inc/geshi/'.$language.'.php') && // language syntax definition changed + $ctime > filemtime(DOKU_INC.'vendor/composer/installed.json') && // libraries changed $ctime > filemtime(reset($config_cascade['main']['default']))){ // dokuwiki changed $highlighted_code = io_readFile($cache, false); } else { - $geshi = new GeSHi($code, $language, DOKU_INC . 'inc/geshi'); + $geshi = new GeSHi($code, $language); $geshi->set_encoding('utf-8'); $geshi->enable_classes(); $geshi->set_header_type(GESHI_HEADER_PRE); -- cgit v1.2.3 From 7de86af9758e71d251fad91063035a459d83d2eb Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Tue, 30 Jun 2015 23:07:10 +0200 Subject: phpdocs, reformatting --- inc/parserutils.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'inc/parserutils.php') diff --git a/inc/parserutils.php b/inc/parserutils.php index 8650f974f..5b96d39fe 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -121,15 +121,21 @@ function p_cached_output($file, $format='xhtml', $id='') { $cache = new cache_renderer($id, $file, $format); if ($cache->useCache()) { $parsed = $cache->retrieveCache(false); - if($conf['allowdebug'] && $format=='xhtml') $parsed .= "\n\n"; + if($conf['allowdebug'] && $format=='xhtml') { + $parsed .= "\n\n"; + } } else { $parsed = p_render($format, p_cached_instructions($file,false,$id), $info); if ($info['cache'] && $cache->storeCache($parsed)) { // storeCache() attempts to save cachefile - if($conf['allowdebug'] && $format=='xhtml') $parsed .= "\n\n"; + if($conf['allowdebug'] && $format=='xhtml') { + $parsed .= "\n\n"; + } }else{ $cache->removeCache(); //try to delete cachefile - if($conf['allowdebug'] && $format=='xhtml') $parsed .= "\n\n"; + if($conf['allowdebug'] && $format=='xhtml') { + $parsed .= "\n\n"; + } } } @@ -616,8 +622,9 @@ function p_sort_modes($a, $b){ * @author Andreas Gohr * * @param string $mode - * @param array|null|false $instructions - * @param array $info returns render info like enabled toc and cache + * @param array|null|false $instructions + * @param array $info returns render info like enabled toc and cache + * @param string $date_at * @return null|string rendered output */ function p_render($mode,$instructions,&$info,$date_at=''){ @@ -632,7 +639,7 @@ function p_render($mode,$instructions,&$info,$date_at=''){ if($date_at) { $Renderer->date_at = $date_at; } - + $Renderer->smileys = getSmileys(); $Renderer->entities = getEntities(); $Renderer->acronyms = getAcronyms(); -- cgit v1.2.3