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
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,23 @@ run-tests.log

.phpunit.cache/
composer.lock

# Added by horde-components QC --fix-qc-issues
# Build artifacts directory
/build/
# PHPStorm IDE settings
/.idea/
# VSCode IDE settings
/.vscode/
# Claude Code CLI cache and state
/.claude/
# Cline extension data
/.cline/
# PHP CS Fixer cache file
/.php-cs-fixer.cache
# PHPUnit result cache
/.phpunit.result.cache
# PHPStan local configuration
/phpstan.neon
# PHPStan cache directory
/.phpstan.cache/
9 changes: 7 additions & 2 deletions .horde.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ license:
uri: http://www.horde.org/licenses/lgpl21
dependencies:
required:
php: ^7.4 || ^8
php: ^8
composer:
horde/core: ^3
horde/dav: ^2
Expand All @@ -59,4 +59,9 @@ dependencies:
dev:
composer:
horde/activesync: ^3
horde/test: ^3
horde/http: ^3
keywords:
- soap
- jsonrpc
- activesync
vendor: horde
8 changes: 5 additions & 3 deletions doc/Horde/Rpc/examples/soap.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @package Rpc
*/
Expand All @@ -12,7 +13,7 @@
$rpc_method = 'calendar.listCalendars';

// SOAP options, usually username and password
$rpc_options = array(
$rpc_options = [
'login' => '',
'password' => '',
'namespace' => 'urn:horde',
Expand All @@ -23,13 +24,14 @@
'uri' => 'urn:horde',
'exceptions' => true,
'trace' => true,
);
];

$soap = new SoapClient(null, $rpc_options);
$result = Horde_Rpc::request(
'soap',
$GLOBALS['rpc_endpoint'],
$GLOBALS['rpc_method'],
$soap,
array());
[]
);
var_dump($result);
8 changes: 5 additions & 3 deletions doc/Horde/Rpc/examples/xmlrpc.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @package Rpc
*/
Expand All @@ -12,17 +13,18 @@
$rpc_method = 'calendar.listCalendars';

// XML-RPC options, usually username and password
$rpc_options = array(
$rpc_options = [
'request.username' => '',
'request.password' => '',
);
];

$http_client = new Horde_Http_Client($rpc_options);
$result = Horde_Rpc::request(
'xmlrpc',
$GLOBALS['rpc_endpoint'],
$GLOBALS['rpc_method'],
$GLOBALS['http_client'],
array());
[]
);

var_dump($result);
27 changes: 16 additions & 11 deletions lib/Horde/Rpc.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

/**
* Copyright 2002-2017 Horde LLC (http://www.horde.org/)
* Copyright 2002-2026 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
Expand Down Expand Up @@ -36,7 +37,7 @@ class Horde_Rpc
*
* @var array
*/
protected $_params = array();
protected $_params = [];

/**
* Do we need an authenticated user?
Expand Down Expand Up @@ -74,15 +75,15 @@ class Horde_Rpc
* @param array $params A hash containing any additional configuration or
* connection parameters a subclass might need.
*/
public function __construct($request, $params = array())
public function __construct($request, $params = [])
{
// Create a stub if we don't have a useable logger.
if (isset($params['logger'])
&& is_callable(array($params['logger'], 'log'))) {
&& is_callable([$params['logger'], 'log'])) {
$this->_logger = $params['logger'];
unset($params['logger']);
} else {
$this->_logger = new Horde_Support_Stub;
$this->_logger = new Horde_Support_Stub();
}

$this->_params = $params;
Expand Down Expand Up @@ -125,12 +126,12 @@ public function authorize()
$hash = str_replace('Basic ', '', $serverVars['Authorization']);
$hash = base64_decode($hash);
if (strpos($hash, ':') !== false) {
list($user, $pass) = explode(':', $hash, 2);
[$user, $pass] = explode(':', $hash, 2);
}
}

if (!isset($user)
|| !$auth->authenticate($user, array('password' => $pass))) {
|| !$auth->authenticate($user, ['password' => $pass])) {
if ($this->_requestMissingAuthorization) {
header('WWW-Authenticate: Basic realm="Horde RPC"');
}
Expand Down Expand Up @@ -222,13 +223,17 @@ public function sendOutput($output)
* @return mixed The returned result from the method
* @throws Horde_Rpc_Exception
*/
public static function request($driver, $url, $method, $client,
$params = null)
{
public static function request(
$driver,
$url,
$method,
$client,
$params = null
) {
$driver = Horde_String::ucfirst(basename($driver));
$class = 'Horde_Rpc_' . $driver;
if (class_exists($class)) {
return call_user_func(array($class, 'request'), $url, $method, $client, $params);
return call_user_func([$class, 'request'], $url, $method, $client, $params);
} else {
throw new Horde_Rpc_Exception('Class definition of ' . $class . ' not found.');
}
Expand Down
Loading
Loading