diff options
author | Andreas Gohr <andi@splitbrain.org> | 2018-04-27 20:02:24 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2018-04-27 20:02:24 +0200 |
commit | aba86f383f2a5af0340d1bc69cf4f6853b03bf77 (patch) | |
tree | 6ff2f6838633b645bbe18c534bded3ab75d2da5e | |
parent | 64159a61e94d0ce680071c8890e144982c3a8cbe (diff) | |
download | dokuwiki-aba86f383f2a5af0340d1bc69cf4f6853b03bf77.tar.gz dokuwiki-aba86f383f2a5af0340d1bc69cf4f6853b03bf77.zip |
visibility fixes
First start at declaring visibilites for methods and properties. Still
missing: the parser/renderer stuff and the plugins
-rw-r--r-- | _test/tests/inc/httpclient_http.test.php | 11 | ||||
-rw-r--r-- | inc/FeedParser.php | 19 | ||||
-rw-r--r-- | inc/Form/ButtonElement.php | 2 | ||||
-rw-r--r-- | inc/HTTPClient.php | 98 | ||||
-rw-r--r-- | inc/Input.class.php | 15 | ||||
-rw-r--r-- | inc/PassHash.class.php | 2 | ||||
-rw-r--r-- | inc/RemoteAPICore.php | 2 | ||||
-rw-r--r-- | inc/changelog.php | 2 | ||||
-rw-r--r-- | inc/events.php | 16 | ||||
-rw-r--r-- | inc/form.php | 28 | ||||
-rw-r--r-- | inc/subscription.php | 4 | ||||
-rw-r--r-- | inc/utf8.php | 6 |
12 files changed, 102 insertions, 103 deletions
diff --git a/_test/tests/inc/httpclient_http.test.php b/_test/tests/inc/httpclient_http.test.php index 6cc783b2b..4a6c32f13 100644 --- a/_test/tests/inc/httpclient_http.test.php +++ b/_test/tests/inc/httpclient_http.test.php @@ -301,6 +301,9 @@ class httpclient_http_test extends DokuWikiTest { $this->assertTrue($data !== false, $http->errorInfo()); } + /** + * @throws ReflectionException + */ function test_postencode(){ $http = new HTTPMockClient(); @@ -312,7 +315,7 @@ class httpclient_http_test extends DokuWikiTest { ); $this->assertEquals( '%C3%B6%C3%A4%3F=%C3%B6%C3%A4%3F&foo=bang', - $http->_postEncode($data), + $this->callInaccessibleMethod($http, '_postEncode', [$data]), 'simple' ); @@ -323,7 +326,7 @@ class httpclient_http_test extends DokuWikiTest { ); $this->assertEquals( 'foo=bang&%C3%A4rr%5B0%5D=%C3%B6&%C3%A4rr%5B1%5D=b&%C3%A4rr%5B2%5D=c', - $http->_postEncode($data), + $this->callInaccessibleMethod($http, '_postEncode', [$data]), 'onelevelnum' ); @@ -334,7 +337,7 @@ class httpclient_http_test extends DokuWikiTest { ); $this->assertEquals( 'foo=bang&%C3%A4rr%5B%C3%B6%5D=%C3%A4&%C3%A4rr%5Bb%5D=c', - $http->_postEncode($data), + $this->callInaccessibleMethod($http, '_postEncode', [$data]), 'onelevelassoc' ); @@ -346,7 +349,7 @@ class httpclient_http_test extends DokuWikiTest { ); $this->assertEquals( 'foo=bang&%C3%A4rr%5B%C3%B6%5D=%C3%A4&%C3%A4rr%5B%C3%A4%5D%5B%C3%B6%5D=%C3%A4', - $http->_postEncode($data), + $this->callInaccessibleMethod($http, '_postEncode', [$data]), 'twolevelassoc' ); } diff --git a/inc/FeedParser.php b/inc/FeedParser.php index a0316cacf..9b9db6f1b 100644 --- a/inc/FeedParser.php +++ b/inc/FeedParser.php @@ -13,7 +13,7 @@ class FeedParser extends SimplePie { /** * Constructor. Set some defaults */ - function __construct(){ + public function __construct(){ parent::__construct(); $this->enable_cache(false); $this->set_file_class('FeedParser_File'); @@ -24,7 +24,7 @@ class FeedParser extends SimplePie { * * @param string $url */ - function feed_url($url){ + public function feed_url($url){ $this->set_feed_url($url); } } @@ -35,12 +35,7 @@ class FeedParser extends SimplePie { * Replaces SimplePie's own class */ class FeedParser_File extends SimplePie_File { - var $http; - var $useragent; - var $success = true; - var $headers = array(); - var $body; - var $error; + protected $http; /** @noinspection PhpMissingParentConstructorInspection */ /** @@ -50,7 +45,7 @@ class FeedParser_File extends SimplePie_File { * * @inheritdoc */ - function __construct($url, $timeout=10, $redirects=5, + public function __construct($url, $timeout=10, $redirects=5, $headers=null, $useragent=null, $force_fsockopen=false, $curl_options = array()) { $this->http = new DokuHTTPClient(); $this->success = $this->http->sendRequest($url); @@ -65,17 +60,17 @@ class FeedParser_File extends SimplePie_File { } /** @inheritdoc */ - function headers(){ + public function headers(){ return $this->headers; } /** @inheritdoc */ - function body(){ + public function body(){ return $this->body; } /** @inheritdoc */ - function close(){ + public function close(){ return true; } diff --git a/inc/Form/ButtonElement.php b/inc/Form/ButtonElement.php index e2afe9c97..4f585f0c1 100644 --- a/inc/Form/ButtonElement.php +++ b/inc/Form/ButtonElement.php @@ -17,7 +17,7 @@ class ButtonElement extends Element { * @param string $name * @param string $content HTML content of the button. You have to escape it yourself. */ - function __construct($name, $content = '') { + public function __construct($name, $content = '') { parent::__construct('button', array('name' => $name, 'value' => 1)); $this->content = $content; } diff --git a/inc/HTTPClient.php b/inc/HTTPClient.php index 42fca91d8..1659392ce 100644 --- a/inc/HTTPClient.php +++ b/inc/HTTPClient.php @@ -28,53 +28,53 @@ class HTTPClientException extends Exception { } */ class HTTPClient { //set these if you like - var $agent; // User agent - var $http; // HTTP version defaults to 1.0 - var $timeout; // read timeout (seconds) - var $cookies; - var $referer; - var $max_redirect; - var $max_bodysize; - var $max_bodysize_abort = true; // if set, abort if the response body is bigger than max_bodysize - var $header_regexp; // if set this RE must match against the headers, else abort - var $headers; - var $debug; - var $start = 0.0; // for timings - var $keep_alive = true; // keep alive rocks + public $agent; // User agent + public $http; // HTTP version defaults to 1.0 + public $timeout; // read timeout (seconds) + public $cookies; + public $referer; + public $max_redirect; + public $max_bodysize; + public $max_bodysize_abort = true; // if set, abort if the response body is bigger than max_bodysize + public $header_regexp; // if set this RE must match against the headers, else abort + public $headers; + public $debug; + public $start = 0.0; // for timings + public $keep_alive = true; // keep alive rocks // don't set these, read on error - var $error; - var $redirect_count; + public $error; + public $redirect_count; // read these after a successful request - var $status; - var $resp_body; - var $resp_headers; + public $status; + public $resp_body; + public $resp_headers; // set these to do basic authentication - var $user; - var $pass; + public $user; + public $pass; // set these if you need to use a proxy - var $proxy_host; - var $proxy_port; - var $proxy_user; - var $proxy_pass; - var $proxy_ssl; //boolean set to true if your proxy needs SSL - var $proxy_except; // regexp of URLs to exclude from proxy + public $proxy_host; + public $proxy_port; + public $proxy_user; + public $proxy_pass; + public $proxy_ssl; //boolean set to true if your proxy needs SSL + public $proxy_except; // regexp of URLs to exclude from proxy // list of kept alive connections - static $connections = array(); + protected static $connections = array(); // what we use as boundary on multipart/form-data posts - var $boundary = '---DokuWikiHTTPClient--4523452351'; + protected $boundary = '---DokuWikiHTTPClient--4523452351'; /** * Constructor. * * @author Andreas Gohr <andi@splitbrain.org> */ - function __construct(){ + public function __construct(){ $this->agent = 'Mozilla/4.0 (compatible; DokuWiki HTTP Client; '.PHP_OS.')'; $this->timeout = 15; $this->cookies = array(); @@ -105,7 +105,7 @@ class HTTPClient { * * @author Andreas Gohr <andi@splitbrain.org> */ - function get($url,$sloppy304=false){ + public function get($url,$sloppy304=false){ if(!$this->sendRequest($url)) return false; if($this->status == 304 && $sloppy304) return $this->resp_body; if($this->status < 200 || $this->status > 206) return false; @@ -127,7 +127,7 @@ class HTTPClient { * * @author Andreas Gohr <andi@splitbrain.org> */ - function dget($url,$data,$sloppy304=false){ + public function dget($url,$data,$sloppy304=false){ if(strpos($url,'?')){ $url .= '&'; }else{ @@ -147,7 +147,7 @@ class HTTPClient { * @return false|string response body, false on error * @author Andreas Gohr <andi@splitbrain.org> */ - function post($url,$data){ + public function post($url,$data){ if(!$this->sendRequest($url,$data,'POST')) return false; if($this->status < 200 || $this->status > 206) return false; return $this->resp_body; @@ -170,7 +170,7 @@ class HTTPClient { * @author Andreas Goetz <cpuidle@gmx.de> * @author Andreas Gohr <andi@splitbrain.org> */ - function sendRequest($url,$data='',$method='GET'){ + public function sendRequest($url,$data='',$method='GET'){ $this->start = $this->_time(); $this->error = ''; $this->status = 0; @@ -517,7 +517,7 @@ class HTTPClient { * @throws HTTPClientException when a tunnel is needed but could not be established * @return bool true if a tunnel was established */ - function _ssltunnel(&$socket, &$requesturl){ + protected function _ssltunnel(&$socket, &$requesturl){ if(!$this->proxy_host) return false; $requestinfo = parse_url($requesturl); if($requestinfo['scheme'] != 'https') return false; @@ -579,7 +579,7 @@ class HTTPClient { * * @author Tom N Harris <tnharris@whoopdedo.org> */ - function _sendData($socket, $data, $message) { + protected function _sendData($socket, $data, $message) { // send request $towrite = strlen($data); $written = 0; @@ -624,7 +624,7 @@ class HTTPClient { * * @author Tom N Harris <tnharris@whoopdedo.org> */ - function _readData($socket, $nbytes, $message, $ignore_eof = false) { + protected function _readData($socket, $nbytes, $message, $ignore_eof = false) { $r_data = ''; // Does not return immediately so timeout and eof can be checked if ($nbytes < 0) $nbytes = 0; @@ -674,7 +674,7 @@ class HTTPClient { * * @author Tom N Harris <tnharris@whoopdedo.org> */ - function _readLine($socket, $message) { + protected function _readLine($socket, $message) { $r_data = ''; do { $time_used = $this->_time() - $this->start; @@ -710,7 +710,7 @@ class HTTPClient { * @param string $info * @param mixed $var */ - function _debug($info,$var=null){ + protected function _debug($info,$var=null){ if(!$this->debug) return; if(php_sapi_name() == 'cli'){ $this->_debug_text($info, $var); @@ -725,7 +725,7 @@ class HTTPClient { * @param string $info * @param mixed $var */ - function _debug_html($info, $var=null){ + protected function _debug_html($info, $var=null){ print '<b>'.$info.'</b> '.($this->_time() - $this->start).'s<br />'; if(!is_null($var)){ ob_start(); @@ -742,7 +742,7 @@ class HTTPClient { * @param string $info * @param mixed $var */ - function _debug_text($info, $var=null){ + protected function _debug_text($info, $var=null){ print '*'.$info.'* '.($this->_time() - $this->start)."s\n"; if(!is_null($var)) print_r($var); print "\n-----------------------------------------------\n"; @@ -753,7 +753,7 @@ class HTTPClient { * * @return float */ - static function _time(){ + protected static function _time(){ list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); } @@ -768,7 +768,7 @@ class HTTPClient { * @param string $string * @return array */ - function _parseHeaders($string){ + protected function _parseHeaders($string){ $headers = array(); $lines = explode("\n",$string); array_shift($lines); //skip first line (status) @@ -799,7 +799,7 @@ class HTTPClient { * @param array $headers * @return string */ - function _buildHeaders($headers){ + protected function _buildHeaders($headers){ $string = ''; foreach($headers as $key => $value){ if($value === '') continue; @@ -815,7 +815,7 @@ class HTTPClient { * * @return string */ - function _getCookies(){ + protected function _getCookies(){ $headers = ''; foreach ($this->cookies as $key => $val){ $headers .= "$key=$val; "; @@ -833,7 +833,7 @@ class HTTPClient { * @param array $data * @return string */ - function _postEncode($data){ + protected function _postEncode($data){ return http_build_query($data,'','&'); } @@ -846,7 +846,7 @@ class HTTPClient { * @param array $data * @return string */ - function _postMultipartEncode($data){ + protected function _postMultipartEncode($data){ $boundary = '--'.$this->boundary; $out = ''; foreach($data as $key => $val){ @@ -877,7 +877,7 @@ class HTTPClient { * @param string $port * @return string unique identifier */ - function _uniqueConnectionId($server, $port) { + protected function _uniqueConnectionId($server, $port) { return "$server:$port"; } } @@ -895,7 +895,7 @@ class DokuHTTPClient extends HTTPClient { * * @author Andreas Gohr <andi@splitbrain.org> */ - function __construct(){ + public function __construct(){ global $conf; // call parent constructor @@ -936,7 +936,7 @@ class DokuHTTPClient extends HTTPClient { * @param string $method * @return bool */ - function sendRequest($url,$data='',$method='GET'){ + public function sendRequest($url,$data='',$method='GET'){ $httpdata = array('url' => $url, 'data' => $data, 'method' => $method); diff --git a/inc/Input.class.php b/inc/Input.class.php index 199994d8d..2a6f35de4 100644 --- a/inc/Input.class.php +++ b/inc/Input.class.php @@ -28,7 +28,7 @@ class Input { /** * Intilizes the Input class and it subcomponents */ - function __construct() { + public function __construct() { $this->access = &$_REQUEST; $this->post = new PostInput(); $this->get = new GetInput(); @@ -273,12 +273,13 @@ class Input { * Internal class used for $_POST access in Input class */ class PostInput extends Input { + protected $access; - /** + /** @noinspection PhpMissingParentConstructorInspection * Initialize the $access array, remove subclass members */ - function __construct() { + public function __construct() { $this->access = &$_POST; } @@ -300,10 +301,10 @@ class PostInput extends Input { class GetInput extends Input { protected $access; - /** + /** @noinspection PhpMissingParentConstructorInspection * Initialize the $access array, remove subclass members */ - function __construct() { + public function __construct() { $this->access = &$_GET; } @@ -325,10 +326,10 @@ class GetInput extends Input { class ServerInput extends Input { protected $access; - /** + /** @noinspection PhpMissingParentConstructorInspection * Initialize the $access array, remove subclass members */ - function __construct() { + public function __construct() { $this->access = &$_SERVER; } diff --git a/inc/PassHash.class.php b/inc/PassHash.class.php index 3d03c1e05..1e66c2827 100644 --- a/inc/PassHash.class.php +++ b/inc/PassHash.class.php @@ -21,7 +21,7 @@ class PassHash { * @param string $hash Hash to compare against * @return bool */ - function verify_hash($clear, $hash) { + public function verify_hash($clear, $hash) { $method = ''; $salt = ''; $magic = ''; diff --git a/inc/RemoteAPICore.php b/inc/RemoteAPICore.php index cda2ef551..b80aec399 100644 --- a/inc/RemoteAPICore.php +++ b/inc/RemoteAPICore.php @@ -425,7 +425,7 @@ class RemoteAPICore { * @param string $id page id * @return array */ - function listBackLinks($id){ + public function listBackLinks($id){ return ft_backlinks($this->resolvePageId($id)); } diff --git a/inc/changelog.php b/inc/changelog.php index c82b7d7d9..1981a7d8f 100644 --- a/inc/changelog.php +++ b/inc/changelog.php @@ -894,7 +894,7 @@ abstract class ChangeLog { * @param number $date_at timestamp * @return string revision ('' for current) */ - function getLastRevisionAt($date_at){ + public function getLastRevisionAt($date_at){ //requested date_at(timestamp) younger or equal then modified_time($this->id) => load current if(file_exists($this->getFilename()) && $date_at >= @filemtime($this->getFilename())) { return ''; diff --git a/inc/events.php b/inc/events.php index 4a72318f6..83e6794eb 100644 --- a/inc/events.php +++ b/inc/events.php @@ -29,7 +29,7 @@ class Doku_Event { * @param string $name * @param mixed $data */ - function __construct($name, &$data) { + public function __construct($name, &$data) { $this->name = $name; $this->data =& $data; @@ -39,7 +39,7 @@ class Doku_Event { /** * @return string */ - function __toString() { + public function __toString() { return $this->name; } @@ -61,7 +61,7 @@ class Doku_Event { * @param bool $enablePreventDefault * @return bool results of processing the event, usually $this->_default */ - function advise_before($enablePreventDefault=true) { + public function advise_before($enablePreventDefault=true) { global $EVENT_HANDLER; $this->canPreventDefault = $enablePreventDefault; @@ -70,7 +70,7 @@ class Doku_Event { return (!$enablePreventDefault || $this->_default); } - function advise_after() { + public function advise_after() { global $EVENT_HANDLER; $this->_continue = true; @@ -92,7 +92,7 @@ class Doku_Event { * or the results of the default action (as modified by <event>_after handlers) * or NULL no action took place and no handler modified the value */ - function trigger($action=null, $enablePrevent=true) { + public function trigger($action=null, $enablePrevent=true) { if (!is_callable($action)) { $enablePrevent = false; @@ -173,7 +173,7 @@ class Doku_Event_Handler { * constructor, loads all action plugins and calls their register() method giving them * an opportunity to register any hooks they require */ - function __construct() { + public function __construct() { // load action plugins /** @var DokuWiki_Action_Plugin $plugin */ @@ -200,7 +200,7 @@ class Doku_Event_Handler { * @param mixed $param data passed to the event handler * @param int $seq sequence number for ordering hook execution (ascending) */ - function register_hook($event, $advise, $obj, $method, $param=null, $seq=0) { + public function register_hook($event, $advise, $obj, $method, $param=null, $seq=0) { $seq = (int)$seq; $doSort = !isset($this->_hooks[$event.'_'.$advise][$seq]); $this->_hooks[$event.'_'.$advise][$seq][] = array($obj, $method, $param); @@ -216,7 +216,7 @@ class Doku_Event_Handler { * @param Doku_Event $event * @param string $advise BEFORE or AFTER */ - function process_event($event,$advise='') { + public function process_event($event,$advise='') { $evt_name = $event->name . ($advise ? '_'.$advise : '_BEFORE'); diff --git a/inc/form.php b/inc/form.php index 0e8100e20..ddf0732d0 100644 --- a/inc/form.php +++ b/inc/form.php @@ -53,7 +53,7 @@ class Doku_Form { * * @author Tom N Harris <tnharris@whoopdedo.org> */ - function __construct($params, $action=false, $method=false, $enctype=false) { + public function __construct($params, $action=false, $method=false, $enctype=false) { if(!is_array($params)) { $this->params = array('id' => $params); if ($action !== false) $this->params['action'] = $action; @@ -86,7 +86,7 @@ class Doku_Form { * * @author Tom N Harris <tnharris@whoopdedo.org> */ - function startFieldset($legend) { + public function startFieldset($legend) { if ($this->_infieldset) { $this->addElement(array('_elem'=>'closefieldset')); } @@ -99,7 +99,7 @@ class Doku_Form { * * @author Tom N Harris <tnharris@whoopdedo.org> */ - function endFieldset() { + public function endFieldset() { if ($this->_infieldset) { $this->addElement(array('_elem'=>'closefieldset')); } @@ -118,7 +118,7 @@ class Doku_Form { * * @author Tom N Harris <tnharris@whoopdedo.org> */ - function addHidden($name, $value) { + public function addHidden($name, $value) { if (is_null($value)) unset($this->_hidden[$name]); else @@ -136,7 +136,7 @@ class Doku_Form { * * @author Tom N Harris <tnharris@whoopdedo.org> */ - function addElement($elem) { + public function addElement($elem) { $this->_content[] = $elem; } @@ -150,7 +150,7 @@ class Doku_Form { * * @author Tom N Harris <tnharris@whoopdedo.org> */ - function insertElement($pos, $elem) { + public function insertElement($pos, $elem) { array_splice($this->_content, $pos, 0, array($elem)); } @@ -164,7 +164,7 @@ class Doku_Form { * * @author Tom N Harris <tnharris@whoopdedo.org> */ - function replaceElement($pos, $elem) { + public function replaceElement($pos, $elem) { $rep = array(); if (!is_null($elem)) $rep[] = $elem; array_splice($this->_content, $pos, 1, $rep); @@ -180,7 +180,7 @@ class Doku_Form { * * @author Tom N Harris <tnharris@whoopdedo.org> */ - function findElementByType($type) { + public function findElementByType($type) { foreach ($this->_content as $pos=>$elem) { if (is_array($elem) && $elem['_elem'] == $type) return $pos; @@ -198,7 +198,7 @@ class Doku_Form { * * @author Tom N Harris <tnharris@whoopdedo.org> */ - function findElementById($id) { + public function findElementById($id) { foreach ($this->_content as $pos=>$elem) { if (is_array($elem) && isset($elem['id']) && $elem['id'] == $id) return $pos; @@ -217,7 +217,7 @@ class Doku_Form { * * @author Tom N Harris <tnharris@whoopdedo.org> */ - function findElementByAttribute($name, $value) { + public function findElementByAttribute($name, $value) { foreach ($this->_content as $pos=>$elem) { if (is_array($elem) && isset($elem[$name]) && $elem[$name] == $value) return $pos; @@ -237,7 +237,7 @@ class Doku_Form { * * @author Tom N Harris <tnharris@whoopdedo.org> */ - function &getElementAt($pos) { + public function &getElementAt($pos) { if ($pos < 0) $pos = count($this->_content) + $pos; if ($pos < 0) $pos = 0; if ($pos >= count($this->_content)) $pos = count($this->_content) - 1; @@ -254,7 +254,7 @@ class Doku_Form { * * @return string html of the form */ - function getForm() { + public function getForm() { global $lang; $form = ''; $this->params['accept-charset'] = $lang['encoding']; @@ -284,7 +284,7 @@ class Doku_Form { * * wraps around getForm() */ - function printForm(){ + public function printForm(){ echo $this->getForm(); } @@ -300,7 +300,7 @@ class Doku_Form { * @author Adrian Lang <lang@cosmocode.de> */ - function addRadioSet($name, $entries) { + public function addRadioSet($name, $entries) { global $INPUT; $value = (array_key_exists($INPUT->post->str($name), $entries)) ? $INPUT->str($name) : key($entries); diff --git a/inc/subscription.php b/inc/subscription.php index 74bec656d..3dbebcbf5 100644 --- a/inc/subscription.php +++ b/inc/subscription.php @@ -249,10 +249,10 @@ class Subscription { * * @param string $id Page ID, defaults to global $ID * @param string $user User, defaults to $_SERVER['REMOTE_USER'] - * @return array + * @return array|false * @author Adrian Lang <lang@cosmocode.de> */ - function user_subscription($id = '', $user = '') { + public function user_subscription($id = '', $user = '') { if(!$this->isenabled()) return false; global $ID; diff --git a/inc/utf8.php b/inc/utf8.php index e91319ca0..3c8106599 100644 --- a/inc/utf8.php +++ b/inc/utf8.php @@ -649,7 +649,7 @@ if(!class_exists('utf8_entity_decoder')){ /** * Initializes the decoding tables */ - function __construct() { + public function __construct() { $table = get_html_translation_table(HTML_ENTITIES); $table = array_flip($table); $this->table = array_map(array(&$this,'makeutf8'), $table); @@ -661,7 +661,7 @@ if(!class_exists('utf8_entity_decoder')){ * @param string $c * @return string|false */ - function makeutf8($c) { + public function makeutf8($c) { return unicode_to_utf8(array(ord($c))); } @@ -671,7 +671,7 @@ if(!class_exists('utf8_entity_decoder')){ * @param string $ent An entity * @return string|false */ - function decode($ent) { + public function decode($ent) { if ($ent[1] == '#') { return utf8_decode_numeric($ent); } elseif (array_key_exists($ent[0],$this->table)) { |