Skip to content

Commit

Permalink
PHPDocs and some improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Klap-in committed Oct 2, 2014
1 parent e371095 commit 7e8500e
Show file tree
Hide file tree
Showing 18 changed files with 63 additions and 26 deletions.
4 changes: 3 additions & 1 deletion bin/gittool.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,13 @@ public function cmd_repos() {
* Install extension from the given download URL
*
* @param string $ext
* @return bool
* @return bool|null
*/
private function downloadExtension($ext) {
/** @var helper_plugin_extension_extension $plugin */
$plugin = plugin_load('helper', 'extension_extension');
if(!$ext) die("extension plugin not available, can't continue");

$plugin->setExtension($ext);

$url = $plugin->getDownloadURL();
Expand Down Expand Up @@ -297,6 +298,7 @@ private function getSourceRepo($extension) {
/** @var helper_plugin_extension_extension $ext */
$ext = plugin_load('helper', 'extension_extension');
if(!$ext) die("extension plugin not available, can't continue");

$ext->setExtension($extension);

$repourl = $ext->getSourcerepoURL();
Expand Down
9 changes: 8 additions & 1 deletion inc/Tar.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class Tar {

protected $file = '';
protected $comptype = Tar::COMPRESS_AUTO;
/** @var resource|int */
protected $fh;
protected $memory = '';
protected $closed = true;
Expand Down Expand Up @@ -530,7 +531,7 @@ protected function writeFileHeader($name, $uid, $gid, $perm, $size, $mtime, $typ
* Decode the given tar file header
*
* @param string $block a 512 byte block containign the header data
* @return array|false
* @return false|array
*/
protected function parseHeader($block) {
if(!$block || strlen($block) != 512) return false;
Expand Down Expand Up @@ -633,8 +634,14 @@ public function filetype($file) {
}
}

/**
* Class TarIOException
*/
class TarIOException extends Exception {
}

/**
* Class TarIllegalCompressionException
*/
class TarIllegalCompressionException extends Exception {
}
4 changes: 2 additions & 2 deletions inc/ZipLib.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ function add_dir($name) {
*
* @param string $data
* @param string $name filename
* @param int $compact
* @param bool $compact
* @return bool
*/
function add_File($data, $name, $compact = 1) {
function add_File($data, $name, $compact = true) {
$name = str_replace('\\', '/', $name);
$dtime = dechex($this->DosTime());

Expand Down
2 changes: 1 addition & 1 deletion inc/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ function auth_login($user, $pass, $sticky = false, $silent = false) {
* @author Andreas Gohr <[email protected]>
*
* @param string $token The authentication token
* @return boolean true (or will exit on failure)
* @return boolean|null true (or will exit on failure)
*/
function auth_validateToken($token) {
if(!$token || $token != $_SESSION[DOKU_COOKIE]['auth']['token']) {
Expand Down
2 changes: 1 addition & 1 deletion inc/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -1461,7 +1461,7 @@ function dformat($dt = null, $format = '') {
* @author <ungu at terong dot com>
* @link http://www.php.net/manual/en/function.date.php#54072
*
* @param int $int_date: current date in UNIX timestamp
* @param int $int_date current date in UNIX timestamp
* @return string
*/
function date_iso8601($int_date) {
Expand Down
11 changes: 9 additions & 2 deletions inc/events.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class Doku_Event {

/**
* event constructor
*
* @param string $name
* @param mixed $data
*/
function Doku_Event($name, &$data) {

Expand Down Expand Up @@ -120,14 +123,18 @@ function trigger($action=null, $enablePrevent=true) {
* stop any further processing of the event by event handlers
* this function does not prevent the default action taking place
*/
function stopPropagation() { $this->_continue = false; }
function stopPropagation() {
$this->_continue = false;
}

/**
* preventDefault
*
* prevent the default action taking place
*/
function preventDefault() { $this->_default = false; }
function preventDefault() {
$this->_default = false;
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion inc/parserutils.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
Expand Down
4 changes: 2 additions & 2 deletions inc/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ function getPluginType() {
* @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;
}

/**
* @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:'');
}

Expand Down
4 changes: 2 additions & 2 deletions inc/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -1066,8 +1066,8 @@ function tpl_pagetitle($id = null, $ret = false) {
*
* @author Andreas Gohr <[email protected]>
*
* @param array $tags tags to try
* @param string $alt alternative output if no data was found
* @param array|string $tags tags to try
* @param string $alt alternative output if no data was found
* @param null|string $src the image src, uses global $SRC if not given
* @return string
*/
Expand Down
4 changes: 2 additions & 2 deletions inc/utf8.php
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ function utf8_unhtml($str, $entities=null) {
* Decodes numeric HTML entities to their correct UTF-8 characters
*
* @param $ent string A numeric entity
* @return string
* @return string|false
*/
function utf8_decode_numeric($ent) {
switch ($ent[2]) {
Expand Down Expand Up @@ -657,7 +657,7 @@ function makeutf8($c) {
* Decodes any HTML entity to it's correct UTF-8 char equivalent
*
* @param string $ent An entity
* @return string
* @return string|false
*/
function decode($ent) {
if ($ent[1] == '#') {
Expand Down
5 changes: 5 additions & 0 deletions lib/exe/xmlrpc.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ function dokuwiki_xmlrpc_server(){
$this->IXR_Server();
}

/**
* @param string $methodname
* @param array $args
* @return IXR_Error|mixed
*/
function call($methodname, $args){
try {
$result = $this->remote->call($methodname, $args);
Expand Down
14 changes: 14 additions & 0 deletions lib/plugins/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
*/
class DokuWiki_Admin_Plugin extends DokuWiki_Plugin {

/**
* @param string $language language code
* @return string
*/
function getMenuText($language) {
$menutext = $this->getLang('menu');
if (!$menutext) {
Expand All @@ -23,10 +27,14 @@ function getMenuText($language) {
return $menutext;
}

/**
* @return int
*/
function getMenuSort() {
return 1000;
}


function handle() {
trigger_error('handle() not implemented in '.get_class($this), E_USER_WARNING);
}
Expand All @@ -35,10 +43,16 @@ function html() {
trigger_error('html() not implemented in '.get_class($this), E_USER_WARNING);
}

/**
* @return bool
*/
function forAdminOnly() {
return true;
}

/**
* @return array
*/
function getTOC(){
return array();
}
Expand Down
5 changes: 3 additions & 2 deletions lib/plugins/authplain/_test/escaping.test.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
* @group plugins
*/
class helper_plugin_authplain_escaping_test extends DokuWikiTest {

protected $pluginsEnabled = array('authplain');
/** @var auth_plugin_authplain */
protected $auth;

protected function reloadUsers() {
/* auth caches data loaded from file, but recreated object forces reload */
$this->auth = new auth_plugin_authplain();
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/config/settings/config.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ public function error() { return $this->_error; }
/**
* Returns caution
*
* @return bool|string caution string, otherwise false for invalid caution
* @return false|string caution string, otherwise false for invalid caution
*/
public function caution() {
if (!empty($this->_caution)) {
Expand Down
6 changes: 3 additions & 3 deletions lib/plugins/extension/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ public function handle() {
case 'uninstall':
$extension->setExtension($extname);
$status = $extension->uninstall();
if($status !== true) {
msg($status, -1);
} else {
if($status) {
msg(sprintf($this->getLang('msg_delete_success'), hsc($extension->getDisplayName())), 1);
} else {
msg(sprintf($this->getLang('msg_delete_failed'), hsc($extension->getDisplayName())), -1);
}
break;
case 'enable';
Expand Down
6 changes: 3 additions & 3 deletions lib/plugins/extension/helper/repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function init() {
$request_needed = false;
foreach ($list as $name) {
$cache = new cache('##extension_manager##'.$name, '.repo');
$result = null;

if (!isset($this->loaded_extensions[$name]) && $this->hasAccess() && !$cache->useCache(array('age' => 3600 * 24))) {
$this->loaded_extensions[$name] = true;
$request_data['ext'][] = $name;
Expand Down Expand Up @@ -64,7 +64,7 @@ public function init() {
public function hasAccess() {
if ($this->has_access === null) {
$cache = new cache('##extension_manager###hasAccess', '.repo');
$result = null;

if (!$cache->useCache(array('age' => 3600 * 24, 'purge'=>1))) {
$httpclient = new DokuHTTPClient();
$httpclient->timeout = 5;
Expand All @@ -91,7 +91,7 @@ public function hasAccess() {
*/
public function getData($name) {
$cache = new cache('##extension_manager##'.$name, '.repo');
$result = null;

if (!isset($this->loaded_extensions[$name]) && $this->hasAccess() && !$cache->useCache(array('age' => 3600 * 24))) {
$this->loaded_extensions[$name] = true;
$httpclient = new DokuHTTPClient();
Expand Down
3 changes: 2 additions & 1 deletion lib/plugins/extension/lang/en/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@

$lang['msg_enabled'] = 'Plugin %s enabled';
$lang['msg_disabled'] = 'Plugin %s disabled';
$lang['msg_delete_success'] = 'Extension uninstalled';
$lang['msg_delete_success'] = 'Extension %s uninstalled';
$lang['msg_delete_failed'] = 'Uninstalling Extension %s failed';
$lang['msg_template_install_success'] = 'Template %s installed successfully';
$lang['msg_template_update_success'] = 'Template %s updated successfully';
$lang['msg_plugin_install_success'] = 'Plugin %s installed successfully';
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/extension/lang/nl/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
$lang['status_bundled'] = 'Gebundeld';
$lang['msg_enabled'] = 'Plugin %s ingeschakeld';
$lang['msg_disabled'] = 'Plugin %s uitgeschakeld';
$lang['msg_delete_success'] = 'Uitbreiding gedeinstalleerd';
$lang['msg_delete_success'] = 'Uitbreiding %s gedeinstalleerd';
$lang['msg_template_install_success'] = 'Template %s werd succesvol geïnstalleerd';
$lang['msg_template_update_success'] = 'Template %s werd succesvol geüpdatet';
$lang['msg_plugin_install_success'] = 'Plugin %s werd succesvol geïnstalleerd';
Expand Down

0 comments on commit 7e8500e

Please sign in to comment.