Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,9 @@ composer.lock
/phpstan.neon
# PHPStan cache directory
/.phpstan.cache/

# Added by horde-components QC --fix-qc-issues
# Horde installer plugin runtime data
/var/
# Horde installer plugin web-accessible directory
/web/
1 change: 1 addition & 0 deletions .horde.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,4 @@ vendor: horde
quality:
phpstan:
level: 9
keywords: []
19 changes: 10 additions & 9 deletions lib/Horde/Http.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

/**
* Copyright 2007-2017 Horde LLC (http://www.horde.org/)
* Copyright 2007-2026 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (BSD). If you
* did not receive this file, see http://www.horde.org/licenses/bsd.
Expand All @@ -25,16 +26,16 @@ class Horde_Http
/**
* Authentication schemes
*/
const AUTH_ANY = 'ANY';
const AUTH_BASIC = 'BASIC';
const AUTH_DIGEST = 'DIGEST';
const AUTH_NTLM = 'NTLM';
const AUTH_GSSNEGOTIATE = 'GSSNEGOTIATE';
public const AUTH_ANY = 'ANY';
public const AUTH_BASIC = 'BASIC';
public const AUTH_DIGEST = 'DIGEST';
public const AUTH_NTLM = 'NTLM';
public const AUTH_GSSNEGOTIATE = 'GSSNEGOTIATE';

/**
* Proxy types
*/
const PROXY_HTTP = 0;
const PROXY_SOCKS4 = 1;
const PROXY_SOCKS5 = 2;
public const PROXY_HTTP = 0;
public const PROXY_SOCKS4 = 1;
public const PROXY_SOCKS5 = 2;
}
31 changes: 17 additions & 14 deletions lib/Horde/Http/Client.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

/**
* Copyright 2007-2017 Horde LLC (http://www.horde.org/)
* Copyright 2007-2026 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (BSD). If you
* did not receive this file, see http://www.horde.org/licenses/bsd.
Expand Down Expand Up @@ -99,7 +100,7 @@ class Horde_Http_Client
* constructor. See the class properties for available
* settings.
*/
public function __construct($args = array())
public function __construct($args = [])
{
// Set or create request object
if (isset($args['request'])) {
Expand All @@ -124,7 +125,7 @@ public function __construct($args = array())
* @throws Horde_Http_Exception
* @return Horde_Http_Response_Base
*/
public function get($uri = null, $headers = array())
public function get($uri = null, $headers = [])
{
return $this->request('GET', $uri, null, $headers);
}
Expand All @@ -139,7 +140,7 @@ public function get($uri = null, $headers = array())
* @throws Horde_Http_Exception
* @return Horde_Http_Response_Base
*/
public function post($uri = null, $data = null, $headers = array())
public function post($uri = null, $data = null, $headers = [])
{
return $this->request('POST', $uri, $data, $headers);
}
Expand All @@ -154,11 +155,11 @@ public function post($uri = null, $data = null, $headers = array())
* @throws Horde_Http_Exception
* @return Horde_Http_Response_Base
*/
public function put($uri = null, $data = null, $headers = array())
public function put($uri = null, $data = null, $headers = [])
{
if ($this->_httpMethodOverride) {
$headers = array_merge(
array('X-HTTP-Method-Override' => 'PUT'),
['X-HTTP-Method-Override' => 'PUT'],
$headers
);
return $this->post($uri, $data, $headers);
Expand All @@ -176,11 +177,11 @@ public function put($uri = null, $data = null, $headers = array())
* @throws Horde_Http_Exception
* @return Horde_Http_Response_Base
*/
public function delete($uri = null, $headers = array())
public function delete($uri = null, $headers = [])
{
if ($this->_httpMethodOverride) {
$headers = array_merge(
array('X-HTTP-Method-Override' => 'DELETE'),
['X-HTTP-Method-Override' => 'DELETE'],
$headers
);
return $this->post($uri, null, $headers);
Expand All @@ -198,7 +199,7 @@ public function delete($uri = null, $headers = array())
* @throws Horde_Http_Exception
* @return Horde_Http_Response_Base
*/
public function head($uri = null, $headers = array())
public function head($uri = null, $headers = [])
{
return $this->request('HEAD', $uri, null, $headers);
}
Expand All @@ -220,9 +221,11 @@ public function head($uri = null, $headers = array())
* @return Horde_Http_Response_Base
*/
public function request(
$method, $uri = null, $data = null, $headers = array()
)
{
$method,
$uri = null,
$data = null,
$headers = []
) {
if ($method !== null) {
$this->request->method = $method;
}
Expand Down Expand Up @@ -251,7 +254,7 @@ public function request(
*/
public function __get($name)
{
return isset($this->{'_' . $name}) ? $this->{'_' . $name} : null;
return $this->{'_' . $name} ?? null;
}

/**
Expand All @@ -271,7 +274,7 @@ public function __set($name, $value)
}
}

list($object, $objectkey) = explode('.', $name, 2);
[$object, $objectkey] = explode('.', $name, 2);
if ($object == 'request') {
$this->$object->$objectkey = $value;
return true;
Expand Down
7 changes: 3 additions & 4 deletions lib/Horde/Http/Exception.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

/**
* Copyright 2007-2017 Horde LLC (http://www.horde.org/)
* Copyright 2007-2026 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (BSD). If you
* did not receive this file, see http://www.horde.org/licenses/bsd.
Expand All @@ -20,6 +21,4 @@
* @license http://www.horde.org/licenses/bsd BSD
* @package Http
*/
class Horde_Http_Exception extends Horde_Exception_Wrapped
{
}
class Horde_Http_Exception extends Horde_Exception_Wrapped {}
31 changes: 16 additions & 15 deletions lib/Horde/Http/Request/Base.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

/**
* Copyright 2007-2017 Horde LLC (http://www.horde.org/)
* Copyright 2007-2026 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (BSD). If you
* did not receive this file, see http://www.horde.org/licenses/bsd.
Expand Down Expand Up @@ -49,29 +50,29 @@ abstract class Horde_Http_Request_Base
* Request headers
* @var array
*/
protected $_headers = array();
protected $_headers = [];

/**
* @var array
*/
protected $_options = array();
protected $_options = [];

/**
* Constructor
*/
public function __construct($options = array())
public function __construct($options = [])
{
$this->setOptions($options);
}

public function setOptions($options = array())
public function setOptions($options = [])
{
$this->_options = array_merge($this->getDefaultOptions(), $options);
}

public function getDefaultOptions()
{
return array(
return [
'uri' => null,
'method' => 'GET',
'data' => null,
Expand All @@ -88,7 +89,7 @@ public function getDefaultOptions()
'timeout' => 5,
'userAgent' => str_replace(' @' . 'version@', '', 'Horde_Http @version@'),
'verifyPeer' => true,
);
];
}

/**
Expand All @@ -108,11 +109,11 @@ abstract public function send();
public function __get($name)
{
switch ($name) {
case 'headers':
return $this->_headers;
case 'headers':
return $this->_headers;
}

return isset($this->_options[$name]) ? $this->_options[$name] : null;
return $this->_options[$name] ?? null;
}

/**
Expand All @@ -124,9 +125,9 @@ public function __get($name)
public function __set($name, $value)
{
switch ($name) {
case 'headers':
$this->setHeaders($value);
break;
case 'headers':
$this->setHeaders($value);
break;
}

$this->_options[$name] = $value;
Expand All @@ -141,7 +142,7 @@ public function __set($name, $value)
public function setHeaders($headers, $value = null)
{
if (!is_array($headers)) {
$headers = array($headers => $value);
$headers = [$headers => $value];
}

foreach ($headers as $header => $value) {
Expand All @@ -157,6 +158,6 @@ public function setHeaders($headers, $value = null)
*/
public function getHeader($header)
{
return isset($this->_headers[$header]) ? $this->_headers[$header] : null;
return $this->_headers[$header] ?? null;
}
}
17 changes: 9 additions & 8 deletions lib/Horde/Http/Request/Curl.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

/**
* Copyright 2007-2017 Horde LLC (http://www.horde.org/)
* Copyright 2007-2026 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (BSD). If you
* did not receive this file, see http://www.horde.org/licenses/bsd.
Expand Down Expand Up @@ -28,20 +29,20 @@ class Horde_Http_Request_Curl extends Horde_Http_Request_Base
*
* @var array
*/
protected $_httpAuthSchemes = array(
protected $_httpAuthSchemes = [
Horde_Http::AUTH_ANY => CURLAUTH_ANY,
Horde_Http::AUTH_BASIC => CURLAUTH_BASIC,
Horde_Http::AUTH_DIGEST => CURLAUTH_DIGEST,
Horde_Http::AUTH_GSSNEGOTIATE => CURLAUTH_GSSNEGOTIATE,
Horde_Http::AUTH_NTLM => CURLAUTH_NTLM,
);
];

/**
* Constructor
*
* @throws Horde_Http_Exception
*/
public function __construct($args = array())
public function __construct($args = [])
{
if (!extension_loaded('curl')) {
throw new Horde_Http_Exception('The curl extension is not installed. See http://php.net/curl.installation');
Expand All @@ -59,7 +60,7 @@ public function __construct($args = array())
public function send()
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, (string)$this->uri);
curl_setopt($curl, CURLOPT_URL, (string) $this->uri);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $this->method);
Expand Down Expand Up @@ -102,7 +103,7 @@ public function send()
}
if ($this->proxyType == Horde_Http::PROXY_SOCKS5) {
curl_setopt($curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
} else if ($this->proxyType != Horde_Http::PROXY_HTTP) {
} elseif ($this->proxyType != Horde_Http::PROXY_HTTP) {
throw new Horde_Http_Exception(sprintf('Proxy type %s not supported by this request type!', $this->proxyType));
}
}
Expand All @@ -114,7 +115,7 @@ public function send()
}

// Concatenate the headers
$hdr = array();
$hdr = [];
$headers = $this->headers;
if (empty($headers['Expect'])) {
$headers['Expect'] = '';
Expand All @@ -130,7 +131,7 @@ public function send()
throw new Horde_Http_Exception(curl_error($curl), curl_errno($curl));
}
$info = curl_getinfo($curl);
return new Horde_Http_Response_Curl((string)$this->uri, $result, $info);
return new Horde_Http_Response_Curl((string) $this->uri, $result, $info);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion lib/Horde/Http/Request/Factory.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

/**
* Copyright 2007-2017 Horde LLC (http://www.horde.org/)
* Copyright 2007-2026 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (BSD). If you
* did not receive this file, see http://www.horde.org/licenses/bsd.
Expand Down
Loading
Loading