Skip to content
This repository was archived by the owner on Mar 2, 2018. It is now read-only.

Commit 75c8ecb

Browse files
committed
Merge branch 'LukasReschke-fix-phpdocs' Fix PHPDocs and correct invalid throw exceptions
2 parents 282b39d + b7445d1 commit 75c8ecb

File tree

6 files changed

+45
-36
lines changed

6 files changed

+45
-36
lines changed

lib/Saml2/Auth.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class OneLogin_Saml2_Auth
6262
* SessionNotOnOrAfter. When the user is logged, this stored it
6363
* from the AuthnStatement of the SAML Response
6464
*
65-
* @var DateTime
65+
* @var int|null
6666
*/
6767
private $_sessionExpiration;
6868

@@ -84,7 +84,7 @@ class OneLogin_Saml2_Auth
8484
* The NotOnOrAfter value of the valid SubjectConfirmationData
8585
* node (if any) of the last assertion processed
8686
*
87-
* @var DateTime
87+
* @var int
8888
*/
8989
private $_lastAssertionNotOnOrAfter;
9090

@@ -98,7 +98,7 @@ class OneLogin_Saml2_Auth
9898
/**
9999
* Reason of the last error.
100100
*
101-
* @var string
101+
* @var string|null
102102
*/
103103
private $_errorReason;
104104

@@ -150,8 +150,7 @@ public function getSettings()
150150
* Set the strict mode active/disable
151151
*
152152
* @param bool $value Strict parameter
153-
*
154-
* @return array The settings data.
153+
* @throws OneLogin_Saml2_Error
155154
*/
156155
public function setStrict($value)
157156
{
@@ -292,6 +291,7 @@ public function processSLO($keepLocalSession = false, $requestId = null, $retrie
292291
* @param string $url The target URL to redirect the user.
293292
* @param array $parameters Extra parameters to be passed as part of the url
294293
* @param bool $stay True if we want to stay (returns the url string) False to redirect
294+
* @return string|null
295295
*/
296296
public function redirectTo($url = '', $parameters = array(), $stay = false)
297297
{
@@ -388,7 +388,7 @@ public function getErrors()
388388
/**
389389
* Returns the reason for the last error
390390
*
391-
* @return string Error reason
391+
* @return string|null Error reason
392392
*/
393393
public function getLastErrorReason()
394394
{
@@ -423,7 +423,7 @@ public function getAttribute($name)
423423
* @param bool $stay True if we want to stay (returns the url string) False to redirect
424424
* @param bool $setNameIdPolicy When true the AuthNReuqest will set a nameIdPolicy element
425425
*
426-
* @return If $stay is True, it return a string with the SLO URL + LogoutRequest + parameters
426+
* @return string|null If $stay is True, it return a string with the SLO URL + LogoutRequest + parameters
427427
*/
428428
public function login($returnTo = null, $parameters = array(), $forceAuthn = false, $isPassive = false, $stay = false, $setNameIdPolicy = true)
429429
{
@@ -463,7 +463,7 @@ public function login($returnTo = null, $parameters = array(), $forceAuthn = fal
463463
* @param string|null $nameIdFormat The NameID Format will be set in the LogoutRequest.
464464
* @param string|null $nameIdNameQualifier The NameID NameQualifier will be set in the LogoutRequest.
465465
*
466-
* @return If $stay is True, it return a string with the SLO URL + LogoutRequest + parameters
466+
* @return string|null If $stay is True, it return a string with the SLO URL + LogoutRequest + parameters
467467
*
468468
* @throws OneLogin_Saml2_Error
469469
*/
@@ -651,7 +651,7 @@ public function getLastAssertionId()
651651
}
652652

653653
/**
654-
* @return The NotOnOrAfter value of the valid
654+
* @return int The NotOnOrAfter value of the valid
655655
* SubjectConfirmationData node (if any)
656656
* of the last assertion processed
657657
*/
@@ -677,7 +677,7 @@ public function getLastRequestXML()
677677
* If the SAMLResponse was encrypted, by default tries
678678
* to return the decrypted XML.
679679
*
680-
* @return string The Response XML
680+
* @return string|null The Response XML
681681
*/
682682
public function getLastResponseXML()
683683
{

lib/Saml2/IdPMetadataParser.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public static function parseFileXML($filepath, $entityId = null, $desiredNameIdF
8585
* @param string $desiredSLOBinding Parse specific binding SLO endpoint.
8686
*
8787
* @return array metadata info in php-saml settings format
88+
* @throws \Exception
8889
*/
8990
public static function parseXML($xml, $entityId = null, $desiredNameIdFormat = null, $desiredSSOBinding = OneLogin_Saml2_Constants::BINDING_HTTP_REDIRECT, $desiredSLOBinding = OneLogin_Saml2_Constants::BINDING_HTTP_REDIRECT)
9091
{
@@ -149,13 +150,11 @@ public static function parseXML($xml, $entityId = null, $desiredNameIdFormat = n
149150
if (!empty($keyDescriptorCertSigningNodes) || !empty($keyDescriptorCertEncryptionNodes)) {
150151
$metadataInfo['idp']['x509certMulti'] = array();
151152
if (!empty($keyDescriptorCertSigningNodes)) {
152-
$idpInfo['x509certMulti']['signing'] = array();
153153
foreach ($keyDescriptorCertSigningNodes as $keyDescriptorCertSigningNode) {
154154
$metadataInfo['idp']['x509certMulti']['signing'][] = OneLogin_Saml2_Utils::formatCert($keyDescriptorCertSigningNode->nodeValue, false);
155155
}
156156
}
157157
if (!empty($keyDescriptorCertEncryptionNodes)) {
158-
$idpInfo['x509certMulti']['encryption'] = array();
159158
foreach ($keyDescriptorCertEncryptionNodes as $keyDescriptorCertEncryptionNode) {
160159
$metadataInfo['idp']['x509certMulti']['encryption'][] = OneLogin_Saml2_Utils::formatCert($keyDescriptorCertEncryptionNode->nodeValue, false);
161160
}
@@ -197,8 +196,8 @@ public static function parseXML($xml, $entityId = null, $desiredNameIdFormat = n
197196
/**
198197
* Inject metadata info into php-saml settings array
199198
*
200-
* @param string $settings php-saml settings array
201-
* @param string $metadataInfo array metadata info
199+
* @param array $settings php-saml settings array
200+
* @param array $metadataInfo array metadata info
202201
*
203202
* @return array settings
204203
*/

lib/Saml2/LogoutResponse.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class OneLogin_Saml2_LogoutResponse
3232

3333
/**
3434
* After execute a validation process, if it fails, this var contains the cause
35-
* @var string
35+
* @var string|null
3636
*/
3737
private $_error;
3838

@@ -87,7 +87,7 @@ public function getIssuer()
8787
/**
8888
* Gets the Status of the Logout Response.
8989
*
90-
* @return string The Status
90+
* @return string|null The Status
9191
*/
9292
public function getStatus()
9393
{
@@ -271,7 +271,7 @@ public function getError()
271271
}
272272

273273
/**
274-
* @return the ID of the Response
274+
* @return string the ID of the Response
275275
*/
276276
public function getId()
277277
{

lib/Saml2/Response.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class OneLogin_Saml2_Response
4747
/**
4848
* NotOnOrAfter value of a valid SubjectConfirmationData node
4949
*
50-
* @var DateTime
50+
* @var int
5151
*/
5252
private $_validSCDNotOnOrAfter;
5353

@@ -409,7 +409,7 @@ public function isValid($requestId = null)
409409
}
410410

411411
/**
412-
* @return the ID of the Response
412+
* @return string|null the ID of the Response
413413
*/
414414
public function getId()
415415
{
@@ -421,12 +421,12 @@ public function getId()
421421
}
422422

423423
/**
424-
* @return the ID of the assertion in the Response
424+
* @return string|null the ID of the assertion in the Response
425425
*/
426426
public function getAssertionId()
427427
{
428428
if (!$this->validateNumAssertions()) {
429-
throw new IllegalArgumentException("SAML Response must contain 1 Assertion.");
429+
throw new InvalidArgumentException("SAML Response must contain 1 Assertion.");
430430
}
431431
$assertionNodes = $this->_queryAssertion("");
432432
$id = null;
@@ -439,7 +439,8 @@ public function getAssertionId()
439439
}
440440

441441
/**
442-
* @return the NotOnOrAfter value of the valid SubjectConfirmationData * node if any
442+
* @return int the NotOnOrAfter value of the valid SubjectConfirmationData
443+
* node if any
443444
*/
444445
public function getAssertionNotOnOrAfter()
445446
{
@@ -524,6 +525,7 @@ public function getAudiences()
524525
* Gets the Issuers (from Response and Assertion).
525526
*
526527
* @return array @issuers The issuers of the assertion/response
528+
* @throws OneLogin_Saml2_ValidationError
527529
*/
528530
public function getIssuers()
529531
{
@@ -621,7 +623,7 @@ public function getNameIdData()
621623
/**
622624
* Gets the NameID provided by the SAML response from the IdP.
623625
*
624-
* @return string Name ID Value
626+
* @return string|null Name ID Value
625627
*/
626628
public function getNameId()
627629
{
@@ -636,7 +638,7 @@ public function getNameId()
636638
/**
637639
* Gets the NameID Format provided by the SAML response from the IdP.
638640
*
639-
* @return string Name ID Format
641+
* @return string|null Name ID Format
640642
*/
641643
public function getNameIdFormat()
642644
{
@@ -651,7 +653,7 @@ public function getNameIdFormat()
651653
/**
652654
* Gets the NameID NameQualifier provided by the SAML response from the IdP.
653655
*
654-
* @return string Name ID NameQualifier
656+
* @return string|null Name ID NameQualifier
655657
*/
656658
public function getNameIdNameQualifier()
657659
{

lib/Saml2/Settings.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class OneLogin_Saml2_Settings
8888
/**
8989
* Setting errors.
9090
*
91-
* @var array
91+
* @var bool
9292
*/
9393
private $_spValidationOnly = false;
9494

@@ -98,6 +98,7 @@ class OneLogin_Saml2_Settings
9898
* - Loads settings info from settings file or array/object provided
9999
*
100100
* @param array|object|null $settings SAML Toolkit Settings
101+
* @param bool $spValidationOnly
101102
*
102103
* @throws OneLogin_Saml2_Error If any settings parameter is invalid
103104
* @throws Exception If OneLogin_Saml2_Settings is incorrectly supplied
@@ -149,6 +150,7 @@ public function __construct($settings = null, $spValidationOnly = false)
149150

150151
/**
151152
* Sets the paths of the different folders
153+
* @suppress PhanUndeclaredConstant
152154
*/
153155
private function _loadPaths()
154156
{
@@ -287,6 +289,7 @@ private function _loadSettingsFromArray($settings)
287289
*
288290
* @return bool True if the settings info is valid
289291
* @throws OneLogin_Saml2_Error
292+
* @suppress PhanUndeclaredVariable
290293
*/
291294
private function _loadSettingsFromFile()
292295
{
@@ -300,13 +303,15 @@ private function _loadSettingsFromFile()
300303
);
301304
}
302305

303-
include $filename;
306+
/** @var array $settings */
307+
include $filename;
304308

305309
// Add advance_settings if exists
306310

307311
$advancedFilename = $this->getConfigPath().'advanced_settings.php';
308312

309313
if (file_exists($advancedFilename)) {
314+
/** @var array $advancedSettings */
310315
include $advancedFilename;
311316
$settings = array_merge($settings, $advancedSettings);
312317
}
@@ -997,6 +1002,7 @@ public function getErrors()
9971002
* Activates or deactivates the strict mode.
9981003
*
9991004
* @param bool $value Strict parameter
1005+
* @throws Exception
10001006
*/
10011007
public function setStrict($value)
10021008
{
@@ -1048,7 +1054,7 @@ public function getBaseURL()
10481054
/**
10491055
* Sets the IdP certificate.
10501056
*
1051-
* @param string $value IdP certificate
1057+
* @param string $cert IdP certificate
10521058
*/
10531059
public function setIdPCert($cert)
10541060
{

lib/Saml2/Utils.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,22 @@ class OneLogin_Saml2_Utils
1818

1919

2020
/**
21-
* @var string
21+
* @var string|null
2222
*/
2323
private static $_host;
2424

2525
/**
26-
* @var string
26+
* @var string|null
2727
*/
2828
private static $_protocol;
2929

3030
/**
31-
* @var int
31+
* @var int|null
3232
*/
3333
private static $_port;
3434

3535
/**
36-
* @var string
36+
* @var string|null
3737
*/
3838
private static $_baseurlpath;
3939

@@ -73,7 +73,7 @@ public static function t($msg, $args = array())
7373
*
7474
* @throws Exception
7575
*
76-
* @return DOMDocument $dom The result of load the XML at the DomDocument
76+
* @return DOMDocument|false $dom The result of load the XML at the DomDocument
7777
*/
7878
public static function loadXML($dom, $xml)
7979
{
@@ -646,14 +646,14 @@ public static function extractOriginalQueryParam($name)
646646
*/
647647
public static function generateUniqueID()
648648
{
649-
return 'ONELOGIN_' . sha1(uniqid(mt_rand(), true));
649+
return 'ONELOGIN_' . sha1(uniqid((string)mt_rand(), true));
650650
}
651651

652652
/**
653653
* Converts a UNIX timestamp to SAML2 timestamp on the form
654654
* yyyy-mm-ddThh:mm:ss(\.s+)?Z.
655655
*
656-
* @param string $time The time we should convert (DateTime).
656+
* @param string|int $time The time we should convert (DateTime).
657657
*
658658
* @return string $timestamp SAML2 timestamp.
659659
*/
@@ -727,6 +727,7 @@ public static function parseDuration($duration, $timestamp = null)
727727

728728
/* Parse the duration. We use a very strict pattern. */
729729
$durationRegEx = '#^(-?)P(?:(?:(?:(\\d+)Y)?(?:(\\d+)M)?(?:(\\d+)D)?(?:T(?:(\\d+)H)?(?:(\\d+)M)?(?:(\\d+)S)?)?)|(?:(\\d+)W))$#D';
730+
$matches = [];
730731
if (!preg_match($durationRegEx, $duration, $matches)) {
731732
throw new Exception('Invalid ISO 8601 duration: ' . $duration);
732733
}
@@ -801,7 +802,7 @@ public static function parseDuration($duration, $timestamp = null)
801802
* @param string $cacheDuration The duration, as a string.
802803
* @param string $validUntil The valid until date, as a string or as a timestamp
803804
*
804-
* @return int $expireTime The expiration time.
805+
* @return int|null $expireTime The expiration time.
805806
*/
806807
public static function getExpireTime($cacheDuration = null, $validUntil = null)
807808
{
@@ -885,6 +886,7 @@ public static function deleteLocalSession()
885886
* Calculates the fingerprint of a x509cert.
886887
*
887888
* @param string $x509cert x509 cert
889+
* @param string $alg
888890
*
889891
* @return null|string Formatted fingerprint
890892
*/

0 commit comments

Comments
 (0)