Skip to content

Commit 6a768b7

Browse files
committed
Adjust parameter declaration. PHP 8.4 deprecates nullable declarations
1 parent cace752 commit 6a768b7

9 files changed

+67
-67
lines changed

src/Saml2/Auth.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ class Auth
171171
* @throws Exception
172172
* @throws Error
173173
*/
174-
public function __construct(?array $settings = null, bool $spValidationOnly = false)
174+
public function __construct(array|null $settings, bool $spValidationOnly = false)
175175
{
176176
$this->_settings = new Settings($settings, $spValidationOnly);
177177
}
@@ -224,7 +224,7 @@ public function setSchemasPath($path)
224224
* @throws Error
225225
* @throws ValidationError
226226
*/
227-
public function processResponse($requestId = null)
227+
public function processResponse(string|null $requestId)
228228
{
229229
$this->_errors = array();
230230
$this->_lastError = $this->_lastErrorException = null;
@@ -274,7 +274,7 @@ public function processResponse($requestId = null)
274274
*
275275
* @throws Error
276276
*/
277-
public function processSLO($keepLocalSession = false, $requestId = null, $retrieveParametersFromServer = false, $cbDeleteSession = null, $stay = false)
277+
public function processSLO($keepLocalSession = false, string|null $requestId, $retrieveParametersFromServer = false, callable|null $cbDeleteSession, $stay = false)
278278
{
279279
$this->_errors = array();
280280
$this->_lastError = $this->_lastErrorException = null;
@@ -539,7 +539,7 @@ public function getAttributeWithFriendlyName($friendlyName)
539539
*
540540
* @throws Error
541541
*/
542-
public function login($returnTo = null, array $parameters = array(), $forceAuthn = false, $isPassive = false, $stay = false, $setNameIdPolicy = true, $nameIdValueReq = null)
542+
public function login(string|null $returnTo, array $parameters = array(), $forceAuthn = false, $isPassive = false, $stay = false, $setNameIdPolicy = true, string|null $nameIdValueReq)
543543
{
544544
$authnRequest = $this->buildAuthnRequest($this->_settings, $forceAuthn, $isPassive, $setNameIdPolicy, $nameIdValueReq);
545545

@@ -580,7 +580,7 @@ public function login($returnTo = null, array $parameters = array(), $forceAuthn
580580
*
581581
* @throws Error
582582
*/
583-
public function logout($returnTo = null, array $parameters = array(), $nameId = null, $sessionIndex = null, $stay = false, $nameIdFormat = null, $nameIdNameQualifier = null, $nameIdSPNameQualifier = null)
583+
public function logout(string|null $returnTo, array $parameters = array(), string|null $nameId, string|null $sessionIndex, $stay = false, string|null $nameIdFormat, string|null $nameIdNameQualifier, string|null $nameIdSPNameQualifier)
584584
{
585585
$sloUrl = $this->getSLOurl();
586586
if (empty($sloUrl)) {
@@ -673,7 +673,7 @@ public function getLastRequestID()
673673
*
674674
* @return AuthnRequest The AuthnRequest object
675675
*/
676-
public function buildAuthnRequest(Settings $settings, $forceAuthn, $isPassive, $setNameIdPolicy, $nameIdValueReq = null)
676+
public function buildAuthnRequest(Settings $settings, $forceAuthn, $isPassive, $setNameIdPolicy, string|null $nameIdValueReq)
677677
{
678678
return new AuthnRequest($settings, $forceAuthn, $isPassive, $setNameIdPolicy, $nameIdValueReq);
679679
}
@@ -689,7 +689,7 @@ public function buildAuthnRequest(Settings $settings, $forceAuthn, $isPassive, $
689689
* @param string|null $nameIdNameQualifier The NameID NameQualifier will be set in the LogoutRequest.
690690
* @param string|null $nameIdSPNameQualifier The NameID SP NameQualifier will be set in the LogoutRequest.
691691
*/
692-
public function buildLogoutRequest(Settings $settings, $request = null, $nameId = null, $sessionIndex = null, $nameIdFormat = null, $nameIdNameQualifier = null, $nameIdSPNameQualifier = null)
692+
public function buildLogoutRequest(Settings $settings, string|null $request, string|null $nameId, string|null $sessionIndex, string|null $nameIdFormat, string|null $nameIdNameQualifier, string|null $nameIdSPNameQualifier)
693693
{
694694
return new LogoutRequest($settings, $request, $nameId, $sessionIndex, $nameIdFormat, $nameIdNameQualifier, $nameIdSPNameQualifier);
695695
}
@@ -704,7 +704,7 @@ public function buildLogoutRequest(Settings $settings, $request = null, $nameId
704704
* @throws Error
705705
* @throws Exception
706706
*/
707-
public function buildLogoutResponse(Settings $settings, $response = null)
707+
public function buildLogoutResponse(Settings $settings, string|null $response)
708708
{
709709
return new LogoutResponse($settings, $response);
710710
}

src/Saml2/AuthnRequest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class AuthnRequest
4848
* @param bool $setNameIdPolicy When true the AuthNReuqest will set a nameIdPolicy
4949
* @param string $nameIdValueReq Indicates to the IdP the subject that should be authenticated
5050
*/
51-
public function __construct(\OneLogin\Saml2\Settings $settings, $forceAuthn = false, $isPassive = false, $setNameIdPolicy = true, $nameIdValueReq = null)
51+
public function __construct(\OneLogin\Saml2\Settings $settings, $forceAuthn = false, $isPassive = false, $setNameIdPolicy = true, string|null nameIdValueReq)
5252
{
5353
$this->_settings = $settings;
5454

@@ -174,7 +174,7 @@ public function __construct(\OneLogin\Saml2\Settings $settings, $forceAuthn = fa
174174
*
175175
* @return string
176176
*/
177-
public function getRequest($deflate = null)
177+
public function getRequest(bool|null $deflate)
178178
{
179179
$subject = $this->_authnRequest;
180180

src/Saml2/IdPMetadataParser.php

+28-28
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,19 @@ class IdPMetadataParser
2828
* make sure to validate it properly before use it in the parseRemoteXML
2929
* method in order to avoid security issues like SSRF attacks.
3030
*
31-
* @param string $url URL where the IdP metadata is published
32-
* @param string $entityId Entity Id of the desired IdP, if no
33-
* entity Id is provided and the XML
34-
* metadata contains more than one
35-
* IDPSSODescriptor, the first is returned
36-
* @param string $desiredNameIdFormat If available on IdP metadata, use that nameIdFormat
37-
* @param string $desiredSSOBinding Parse specific binding SSO endpoint
38-
* @param string $desiredSLOBinding Parse specific binding SLO endpoint
39-
* @param bool $validatePeer Enable or disable validate peer SSL certificate
31+
* @param string $url URL where the IdP metadata is published
32+
* @param string|null $entityId Entity Id of the desired IdP, if no
33+
* entity Id is provided and the XML
34+
* metadata contains more than one
35+
* IDPSSODescriptor, the first is returned
36+
* @param string|null $desiredNameIdFormat If available on IdP metadata, use that nameIdFormat
37+
* @param string|null $desiredSSOBinding Parse specific binding SSO endpoint
38+
* @param string|null $desiredSLOBinding Parse specific binding SLO endpoint
39+
* @param bool $validatePeer Enable or disable validate peer SSL certificate
4040
*
4141
* @return array metadata info in php-saml settings format
4242
*/
43-
public static function parseRemoteXML($url, $entityId = null, $desiredNameIdFormat = null, $desiredSSOBinding = Constants::BINDING_HTTP_REDIRECT, $desiredSLOBinding = Constants::BINDING_HTTP_REDIRECT, $validatePeer = false)
43+
public static function parseRemoteXML($url, string|null $entityId, string|null $desiredNameIdFormat, $desiredSSOBinding = Constants::BINDING_HTTP_REDIRECT, $desiredSLOBinding = Constants::BINDING_HTTP_REDIRECT, $validatePeer = false)
4444
{
4545
$metadataInfo = array();
4646

@@ -70,18 +70,18 @@ public static function parseRemoteXML($url, $entityId = null, $desiredNameIdForm
7070
/**
7171
* Get IdP Metadata Info from File
7272
*
73-
* @param string $filepath File path
74-
* @param string $entityId Entity Id of the desired IdP, if no
75-
* entity Id is provided and the XML
76-
* metadata contains more than one
77-
* IDPSSODescriptor, the first is returned
78-
* @param string $desiredNameIdFormat If available on IdP metadata, use that nameIdFormat
79-
* @param string $desiredSSOBinding Parse specific binding SSO endpoint
80-
* @param string $desiredSLOBinding Parse specific binding SLO endpoint
73+
* @param string $filepath File path
74+
* @param string|null $entityId Entity Id of the desired IdP, if no
75+
* entity Id is provided and the XML
76+
* metadata contains more than one
77+
* IDPSSODescriptor, the first is returned
78+
* @param string|null $desiredNameIdFormat If available on IdP metadata, use that nameIdFormat
79+
* @param string $desiredSSOBinding Parse specific binding SSO endpoint
80+
* @param string $desiredSLOBinding Parse specific binding SLO endpoint
8181
*
8282
* @return array metadata info in php-saml settings format
8383
*/
84-
public static function parseFileXML($filepath, $entityId = null, $desiredNameIdFormat = null, $desiredSSOBinding = Constants::BINDING_HTTP_REDIRECT, $desiredSLOBinding = Constants::BINDING_HTTP_REDIRECT)
84+
public static function parseFileXML($filepath, string|null $entityId, string|null $desiredNameIdFormat, $desiredSSOBinding = Constants::BINDING_HTTP_REDIRECT, $desiredSLOBinding = Constants::BINDING_HTTP_REDIRECT)
8585
{
8686
$metadataInfo = array();
8787

@@ -99,20 +99,20 @@ public static function parseFileXML($filepath, $entityId = null, $desiredNameIdF
9999
/**
100100
* Get IdP Metadata Info from URL
101101
*
102-
* @param string $xml XML that contains IdP metadata
103-
* @param string $entityId Entity Id of the desired IdP, if no
104-
* entity Id is provided and the XML
105-
* metadata contains more than one
106-
* IDPSSODescriptor, the first is returned
107-
* @param string $desiredNameIdFormat If available on IdP metadata, use that nameIdFormat
108-
* @param string $desiredSSOBinding Parse specific binding SSO endpoint
109-
* @param string $desiredSLOBinding Parse specific binding SLO endpoint
102+
* @param string $xml XML that contains IdP metadata
103+
* @param string|null $entityId Entity Id of the desired IdP, if no
104+
* entity Id is provided and the XML
105+
* metadata contains more than one
106+
* IDPSSODescriptor, the first is returned
107+
* @param string|null $desiredNameIdFormat If available on IdP metadata, use that nameIdFormat
108+
* @param string $desiredSSOBinding Parse specific binding SSO endpoint
109+
* @param string $desiredSLOBinding Parse specific binding SLO endpoint
110110
*
111111
* @return array metadata info in php-saml settings format
112112
*
113113
* @throws Exception
114114
*/
115-
public static function parseXML($xml, $entityId = null, $desiredNameIdFormat = null, $desiredSSOBinding = Constants::BINDING_HTTP_REDIRECT, $desiredSLOBinding = Constants::BINDING_HTTP_REDIRECT)
115+
public static function parseXML($xml, string|null $entityId, string|null $desiredNameIdFormat, $desiredSSOBinding = Constants::BINDING_HTTP_REDIRECT, $desiredSLOBinding = Constants::BINDING_HTTP_REDIRECT)
116116
{
117117
$metadataInfo = array();
118118

src/Saml2/LogoutRequest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class LogoutRequest
6161
* @param string|null $nameIdNameQualifier The NameID NameQualifier will be set in the LogoutRequest.
6262
* @param string|null $nameIdSPNameQualifier The NameID SP NameQualifier will be set in the LogoutRequest.
6363
*/
64-
public function __construct(\OneLogin\Saml2\Settings $settings, $request = null, $nameId = null, $sessionIndex = null, $nameIdFormat = null, $nameIdNameQualifier = null, $nameIdSPNameQualifier = null)
64+
public function __construct(\OneLogin\Saml2\Settings $settings, string|null $request, string|null $nameId, string|null $sessionIndex, string|null $nameIdFormat, string|null $nameIdNameQualifier, string|null $nameIdSPNameQualifier)
6565
{
6666
$this->_settings = $settings;
6767

@@ -161,7 +161,7 @@ public function __construct(\OneLogin\Saml2\Settings $settings, $request = null,
161161
*
162162
* @return string Deflated base64 encoded Logout Request
163163
*/
164-
public function getRequest($deflate = null)
164+
public function getRequest(bool|null $deflate)
165165
{
166166
$subject = $this->_logoutRequest;
167167

@@ -218,7 +218,7 @@ public static function getID($request)
218218
* @throws Exception
219219
* @throws ValidationError
220220
*/
221-
public static function getNameIdData($request, $key = null)
221+
public static function getNameIdData($request, string|null $key)
222222
{
223223
if ($request instanceof DOMDocument) {
224224
$dom = $request;
@@ -282,7 +282,7 @@ public static function getNameIdData($request, $key = null)
282282
* @throws Exception
283283
* @throws ValidationError
284284
*/
285-
public static function getNameId($request, $key = null)
285+
public static function getNameId($request, string|null $key)
286286
{
287287
$nameId = self::getNameIdData($request, $key);
288288
return $nameId['Value'];

src/Saml2/LogoutResponse.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class LogoutResponse
6767
* @throws Error
6868
* @throws Exception
6969
*/
70-
public function __construct(\OneLogin\Saml2\Settings $settings, $response = null)
70+
public function __construct(\OneLogin\Saml2\Settings $settings, string|null $response)
7171
{
7272
$this->_settings = $settings;
7373

@@ -140,7 +140,7 @@ public function getStatus()
140140
*
141141
* @throws ValidationError
142142
*/
143-
public function isValid($requestId = null, $retrieveParametersFromServer = false)
143+
public function isValid(string|null $requestId, $retrieveParametersFromServer = false)
144144
{
145145
$this->_error = null;
146146
try {
@@ -286,7 +286,7 @@ public function build($inResponseTo)
286286
*
287287
* @return string Logout Response deflated and base64 encoded
288288
*/
289-
public function getResponse($deflate = null)
289+
public function getResponse(bool|null $deflate)
290290
{
291291
$logoutResponse = $this->_logoutResponse;
292292

src/Saml2/Metadata.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class Metadata
4242
*
4343
* @return string SAML Metadata XML
4444
*/
45-
public static function builder($sp, $authnsign = false, $wsign = false, $validUntil = null, $cacheDuration = null, $contacts = array(), $organization = array(), $attributes = array(), $ignoreValidUntil = false)
45+
public static function builder($sp, $authnsign = false, $wsign = false, int|null $validUntil, int|null $cacheDuration, $contacts = array(), $organization = array(), $attributes = array(), $ignoreValidUntil = false)
4646
{
4747

4848
if (!isset($validUntil)) {

src/Saml2/Response.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public function __construct(\OneLogin\Saml2\Settings $settings, $response)
130130
* @throws Exception
131131
* @throws ValidationError
132132
*/
133-
public function isValid($requestId = null)
133+
public function isValid(string|null $requestId)
134134
{
135135
$this->_error = null;
136136
try {

src/Saml2/Settings.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class Settings
120120
* @throws Error If any settings parameter is invalid
121121
* @throws Exception If Settings is incorrectly supplied
122122
*/
123-
public function __construct(?array $settings = null,bool $spValidationOnly = false)
123+
public function __construct(array|null $settings,bool $spValidationOnly = false)
124124
{
125125
$this->_spValidationOnly = $spValidationOnly;
126126
$this->_loadPaths();
@@ -872,20 +872,20 @@ public function getIdPSLOResponseUrl()
872872
/**
873873
* Gets the SP metadata. The XML representation.
874874
*
875-
* @param bool $alwaysPublishEncryptionCert When 'true', the returned
876-
* metadata will always include an 'encryption' KeyDescriptor. Otherwise,
877-
* the 'encryption' KeyDescriptor will only be included if
878-
* $advancedSettings['security']['wantNameIdEncrypted'] or
879-
* $advancedSettings['security']['wantAssertionsEncrypted'] are enabled.
880-
* @param int|null $validUntil Metadata's valid time
881-
* @param int|null $cacheDuration Duration of the cache in seconds
882-
* @param bool $ignoreValidUntil exclude the validUntil tag from metadata
875+
* @param bool $alwaysPublishEncryptionCert When 'true', the returned
876+
* metadata will always include an 'encryption' KeyDescriptor. Otherwise,
877+
* the 'encryption' KeyDescriptor will only be included if
878+
* $advancedSettings['security']['wantNameIdEncrypted'] or
879+
* $advancedSettings['security']['wantAssertionsEncrypted'] are enabled.
880+
* @param int|null $validUntil Metadata's valid time
881+
* @param int|null $cacheDuration Duration of the cache in seconds
882+
* @param bool $ignoreValidUntil Exclude the validUntil tag from metadata
883883
*
884884
* @return string SP metadata (xml)
885885
* @throws Exception
886886
* @throws Error
887887
*/
888-
public function getSPMetadata($alwaysPublishEncryptionCert = false, $validUntil = null, $cacheDuration = null, $ignoreValidUntil = false)
888+
public function getSPMetadata($alwaysPublishEncryptionCert = false, int|null $validUntil, int|null $cacheDuration, $ignoreValidUntil = false)
889889
{
890890
$metadata = Metadata::builder($this->_sp, $this->_security['authnRequestsSigned'], $this->_security['wantAssertionsSigned'], $validUntil, $cacheDuration, $this->getContacts(), $this->getOrganization(), [], $ignoreValidUntil);
891891

0 commit comments

Comments
 (0)