Skip to content

Commit 460ff7e

Browse files
authored
Merge pull request #305 from stof/array_typehint
Use array typehints for array arguments
2 parents 63c9f88 + 69458d1 commit 460ff7e

3 files changed

Lines changed: 13 additions & 25 deletions

File tree

src/Saml2/Auth.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -332,10 +332,9 @@ public function processSLO($keepLocalSession = false, $requestId = null, $retrie
332332
*
333333
* @return string|null
334334
*/
335-
public function redirectTo($url = '', $parameters = array(), $stay = false)
335+
public function redirectTo($url = '', array $parameters = array(), $stay = false)
336336
{
337337
assert(is_string($url));
338-
assert(is_array($parameters));
339338

340339
if (empty($url) && isset($_REQUEST['RelayState'])) {
341340
$url = $_REQUEST['RelayState'];
@@ -475,10 +474,8 @@ public function getAttribute($name)
475474
*
476475
* @return string|null If $stay is True, it return a string with the SLO URL + LogoutRequest + parameters
477476
*/
478-
public function login($returnTo = null, $parameters = array(), $forceAuthn = false, $isPassive = false, $stay = false, $setNameIdPolicy = true)
477+
public function login($returnTo = null, array $parameters = array(), $forceAuthn = false, $isPassive = false, $stay = false, $setNameIdPolicy = true)
479478
{
480-
assert(is_array($parameters));
481-
482479
$authnRequest = new AuthnRequest($this->_settings, $forceAuthn, $isPassive, $setNameIdPolicy);
483480

484481
$this->_lastRequest = $authnRequest->getXML();
@@ -513,14 +510,12 @@ public function login($returnTo = null, $parameters = array(), $forceAuthn = fal
513510
* @param string|null $nameIdFormat The NameID Format will be set in the LogoutRequest.
514511
* @param string|null $nameIdNameQualifier The NameID NameQualifier will be set in the LogoutRequest.
515512
*
516-
* @return If $stay is True, it return a string with the SLO URL + LogoutRequest + parameters
513+
* @return string|null If $stay is True, it return a string with the SLO URL + LogoutRequest + parameters
517514
*
518515
* @throws Error
519516
*/
520-
public function logout($returnTo = null, $parameters = array(), $nameId = null, $sessionIndex = null, $stay = false, $nameIdFormat = null, $nameIdNameQualifier = null)
517+
public function logout($returnTo = null, array $parameters = array(), $nameId = null, $sessionIndex = null, $stay = false, $nameIdFormat = null, $nameIdNameQualifier = null)
521518
{
522-
assert(is_array($parameters));
523-
524519
$sloUrl = $this->getSLOurl();
525520
if (empty($sloUrl)) {
526521
throw new Error(

src/Saml2/Settings.php

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ public function getSchemasPath()
245245
*
246246
* @return bool True if the settings info is valid
247247
*/
248-
private function _loadSettingsFromArray($settings)
248+
private function _loadSettingsFromArray(array $settings)
249249
{
250250
if (isset($settings['sp'])) {
251251
$this->_sp = $settings['sp'];
@@ -444,11 +444,9 @@ private function _addDefaultValues()
444444
*
445445
* @return array $errors Errors found on the settings data
446446
*/
447-
public function checkSettings($settings)
447+
public function checkSettings(array $settings)
448448
{
449-
assert(is_array($settings));
450-
451-
if (!is_array($settings) || empty($settings)) {
449+
if (empty($settings)) {
452450
$errors = array('invalid_syntax');
453451
} else {
454452
$errors = array();
@@ -502,11 +500,9 @@ public function checkCompressionSettings($settings)
502500
*
503501
* @return array $errors Errors found on the IdP settings data
504502
*/
505-
public function checkIdPSettings($settings)
503+
public function checkIdPSettings(array $settings)
506504
{
507-
assert(is_array($settings));
508-
509-
if (!is_array($settings) || empty($settings)) {
505+
if (empty($settings)) {
510506
return array('invalid_syntax');
511507
}
512508

@@ -567,11 +563,9 @@ public function checkIdPSettings($settings)
567563
*
568564
* @return array $errors Errors found on the SP settings data
569565
*/
570-
public function checkSPSettings($settings)
566+
public function checkSPSettings(array $settings)
571567
{
572-
assert(is_array($settings));
573-
574-
if (!is_array($settings) || empty($settings)) {
568+
if (empty($settings)) {
575569
return array('invalid_syntax');
576570
}
577571

@@ -900,7 +894,7 @@ public function getSPMetadata()
900894
*
901895
* @param string $xml Metadata's XML that will be validate
902896
*
903-
* @return Array The list of found errors
897+
* @return array The list of found errors
904898
*/
905899
public function validateMetadata($xml)
906900
{

src/Saml2/Utils.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,9 @@ public static function getStringBetween($str, $start, $end)
237237
*
238238
* @throws Error
239239
*/
240-
public static function redirect($url, $parameters = array(), $stay = false)
240+
public static function redirect($url, array $parameters = array(), $stay = false)
241241
{
242242
assert(is_string($url));
243-
assert(is_array($parameters));
244243

245244
if (substr($url, 0, 1) === '/') {
246245
$url = self::getSelfURLhost() . $url;

0 commit comments

Comments
 (0)