Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
visibility fixes
First start at declaring visibilites for methods and properties. Still
missing: the parser/renderer stuff and the plugins
  • Loading branch information
splitbrain committed Apr 27, 2018
1 parent 64159a6 commit aba86f3
Show file tree
Hide file tree
Showing 12 changed files with 102 additions and 103 deletions.
11 changes: 7 additions & 4 deletions _test/tests/inc/httpclient_http.test.php
Expand Up @@ -301,6 +301,9 @@ function test_wikimatrix(){
$this->assertTrue($data !== false, $http->errorInfo());
}

/**
* @throws ReflectionException
*/
function test_postencode(){
$http = new HTTPMockClient();

Expand All @@ -312,7 +315,7 @@ function test_postencode(){
);
$this->assertEquals(
'%C3%B6%C3%A4%3F=%C3%B6%C3%A4%3F&foo=bang',
$http->_postEncode($data),
$this->callInaccessibleMethod($http, '_postEncode', [$data]),
'simple'
);

Expand All @@ -323,7 +326,7 @@ function test_postencode(){
);
$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'
);

Expand All @@ -334,7 +337,7 @@ function test_postencode(){
);
$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'
);

Expand All @@ -346,7 +349,7 @@ function test_postencode(){
);
$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'
);
}
Expand Down
19 changes: 7 additions & 12 deletions inc/FeedParser.php
Expand Up @@ -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');
Expand All @@ -24,7 +24,7 @@ function __construct(){
*
* @param string $url
*/
function feed_url($url){
public function feed_url($url){
$this->set_feed_url($url);
}
}
Expand All @@ -35,12 +35,7 @@ function feed_url($url){
* 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 */

/**
Expand All @@ -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);
Expand All @@ -65,17 +60,17 @@ function __construct($url, $timeout=10, $redirects=5,
}

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

Expand Down
2 changes: 1 addition & 1 deletion inc/Form/ButtonElement.php
Expand Up @@ -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;
}
Expand Down
98 changes: 49 additions & 49 deletions inc/HTTPClient.php
Expand Up @@ -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();
Expand Down Expand Up @@ -105,7 +105,7 @@ function __construct(){
*
* @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;
Expand All @@ -127,7 +127,7 @@ function get($url,$sloppy304=false){
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function dget($url,$data,$sloppy304=false){
public function dget($url,$data,$sloppy304=false){
if(strpos($url,'?')){
$url .= '&';
}else{
Expand All @@ -147,7 +147,7 @@ function dget($url,$data,$sloppy304=false){
* @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;
Expand All @@ -170,7 +170,7 @@ function post($url,$data){
* @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;
Expand Down Expand Up @@ -517,7 +517,7 @@ function sendRequest($url,$data='',$method='GET'){
* @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;
Expand Down Expand Up @@ -579,7 +579,7 @@ function _ssltunnel(&$socket, &$requesturl){
*
* @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;
Expand Down Expand Up @@ -624,7 +624,7 @@ function _sendData($socket, $data, $message) {
*
* @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;
Expand Down Expand Up @@ -674,7 +674,7 @@ function _readData($socket, $nbytes, $message, $ignore_eof = false) {
*
* @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;
Expand Down Expand Up @@ -710,7 +710,7 @@ function _readLine($socket, $message) {
* @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);
Expand All @@ -725,7 +725,7 @@ function _debug($info,$var=null){
* @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();
Expand All @@ -742,7 +742,7 @@ function _debug_html($info, $var=null){
* @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";
Expand All @@ -753,7 +753,7 @@ function _debug_text($info, $var=null){
*
* @return float
*/
static function _time(){
protected static function _time(){
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
Expand All @@ -768,7 +768,7 @@ static function _time(){
* @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)
Expand Down Expand Up @@ -799,7 +799,7 @@ function _parseHeaders($string){
* @param array $headers
* @return string
*/
function _buildHeaders($headers){
protected function _buildHeaders($headers){
$string = '';
foreach($headers as $key => $value){
if($value === '') continue;
Expand All @@ -815,7 +815,7 @@ function _buildHeaders($headers){
*
* @return string
*/
function _getCookies(){
protected function _getCookies(){
$headers = '';
foreach ($this->cookies as $key => $val){
$headers .= "$key=$val; ";
Expand All @@ -833,7 +833,7 @@ function _getCookies(){
* @param array $data
* @return string
*/
function _postEncode($data){
protected function _postEncode($data){
return http_build_query($data,'','&');
}

Expand All @@ -846,7 +846,7 @@ function _postEncode($data){
* @param array $data
* @return string
*/
function _postMultipartEncode($data){
protected function _postMultipartEncode($data){
$boundary = '--'.$this->boundary;
$out = '';
foreach($data as $key => $val){
Expand Down Expand Up @@ -877,7 +877,7 @@ function _postMultipartEncode($data){
* @param string $port
* @return string unique identifier
*/
function _uniqueConnectionId($server, $port) {
protected function _uniqueConnectionId($server, $port) {
return "$server:$port";
}
}
Expand All @@ -895,7 +895,7 @@ class DokuHTTPClient extends HTTPClient {
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function __construct(){
public function __construct(){
global $conf;

// call parent constructor
Expand Down Expand Up @@ -936,7 +936,7 @@ function __construct(){
* @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);
Expand Down

0 comments on commit aba86f3

Please sign in to comment.