Skip to content
This repository was archived by the owner on Feb 19, 2025. It is now read-only.

Commit d995cd7

Browse files
committed
Use phpDoc type hints compatible with apereo/phpcas methods
1 parent 727704f commit d995cd7

File tree

2 files changed

+92
-14
lines changed

2 files changed

+92
-14
lines changed

src/Subfission/Cas/PhpCasProxy.php

+65-14
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Subfission\Cas;
44

5+
use CAS_ServiceBaseUrl_Interface;
56
use phpCAS;
67
use Psr\Log\LoggerInterface;
78

@@ -67,26 +68,76 @@ public function setLogger(LoggerInterface $logger = null): void
6768
phpCAS::setLogger($logger);
6869
}
6970

71+
/**
72+
* phpCAS client initializer.
73+
*
74+
* @param string $server_version the version of the CAS server
75+
* @param string $server_hostname the hostname of the CAS server
76+
* @param int $server_port the port the CAS server is running on
77+
* @param string $server_uri the URI the CAS server is responding on
78+
* @param string|string[]|CAS_ServiceBaseUrl_Interface
79+
* $service_base_url the base URL (protocol, host and the
80+
* optional port) of the CAS client; pass
81+
* in an array to use auto discovery with
82+
* an allowlist; pass in
83+
* CAS_ServiceBaseUrl_Interface for custom
84+
* behavior. Added in 1.6.0. Similar to
85+
* serverName config in other CAS clients.
86+
* @param bool $changeSessionID Allow phpCAS to change the session_id
87+
* (Single Sign Out/handleLogoutRequests
88+
* is based on that change)
89+
* @param \SessionHandlerInterface $sessionHandler the session handler
90+
*
91+
* @return void a newly created CAS_Client object
92+
* @note Only one of the phpCAS::client() and phpCAS::proxy functions should be
93+
* called, only once, and before all other methods (except phpCAS::getVersion()
94+
* and phpCAS::setDebug()).
95+
*/
7096
public function client(
71-
string $server_version,
72-
string $server_hostname,
73-
int $server_port,
74-
string $server_uri,
75-
string $service_base_url,
76-
bool $changeSessionID = true,
77-
\SessionHandlerInterface $sessionHandler = null
97+
$server_version,
98+
$server_hostname,
99+
$server_port,
100+
$server_uri,
101+
$service_base_url,
102+
$changeSessionID = true,
103+
$sessionHandler = null
78104
): void {
79105
phpCAS::client($server_version, $server_hostname, $server_port, $server_uri, $service_base_url, $changeSessionID, $sessionHandler);
80106
}
81107

108+
/**
109+
* phpCAS proxy initializer.
110+
*
111+
* @param string $server_version the version of the CAS server
112+
* @param string $server_hostname the hostname of the CAS server
113+
* @param string $server_port the port the CAS server is running on
114+
* @param string $server_uri the URI the CAS server is responding on
115+
* @param string|string[]|CAS_ServiceBaseUrl_Interface
116+
* $service_base_url the base URL (protocol, host and the
117+
* optional port) of the CAS client; pass
118+
* in an array to use auto discovery with
119+
* an allowlist; pass in
120+
* CAS_ServiceBaseUrl_Interface for custom
121+
* behavior. Added in 1.6.0. Similar to
122+
* serverName config in other CAS clients.
123+
* @param bool $changeSessionID Allow phpCAS to change the session_id
124+
* (Single Sign Out/handleLogoutRequests
125+
* is based on that change)
126+
* @param \SessionHandlerInterface $sessionHandler the session handler
127+
*
128+
* @return void a newly created CAS_Client object
129+
* @note Only one of the phpCAS::client() and phpCAS::proxy functions should be
130+
* called, only once, and before all other methods (except phpCAS::getVersion()
131+
* and phpCAS::setDebug()).
132+
*/
82133
public function proxy(
83-
string $server_version,
84-
string $server_hostname,
85-
int $server_port,
86-
string $server_uri,
87-
string $service_base_url,
88-
bool $changeSessionID = true,
89-
\SessionHandlerInterface $sessionHandler = null
134+
$server_version,
135+
$server_hostname,
136+
$server_port,
137+
$server_uri,
138+
$service_base_url,
139+
$changeSessionID = true,
140+
$sessionHandler = null
90141
): void {
91142
phpCAS::proxy($server_version, $server_hostname, $server_port, $server_uri, $service_base_url, $changeSessionID, $sessionHandler);
92143
}

tests/CasManagerTest.php

+27
Original file line numberDiff line numberDiff line change
@@ -570,4 +570,31 @@ private function makeCasManager(array $config = []): CasManager
570570
{
571571
return new CasManager($config, $this->casProxy, $this->sessionProxy, $this->logoutStrategy);
572572
}
573+
574+
public function testConfiguresCasWithServiceBaseArray(): void
575+
{
576+
$config = [
577+
'cas_enable_saml' => false,
578+
'cas_hostname' => $this->faker->domainName(),
579+
'cas_port' => $this->faker->numberBetween(1, 1024),
580+
'cas_uri' => $this->faker->url(),
581+
'cas_client_service' => [$this->faker->url(), $this->faker->url()],
582+
'cas_control_session' => $this->faker->boolean(),
583+
];
584+
585+
$this->casProxy->expects($this->once())->method('serverTypeCas')
586+
->willReturnArgument(0);
587+
588+
$this->casProxy->expects($this->once())->method('client')
589+
->with(
590+
$this->anything(),
591+
$this->equalTo($config['cas_hostname']),
592+
$this->equalTo($config['cas_port']),
593+
$this->equalTo($config['cas_uri']),
594+
$this->equalTo($config['cas_client_service']),
595+
$this->equalTo($config['cas_control_session'])
596+
);
597+
598+
$this->makeCasManager($config);
599+
}
573600
}

0 commit comments

Comments
 (0)