Skip to content

Commit ad227c0

Browse files
authored
Merge pull request #6 from intellihr/bugfix/remove-asserts-with-string-parameters
Remove asserts with string parameters
2 parents 64c403a + 6fb20e0 commit ad227c0

File tree

4 files changed

+26
-26
lines changed

4 files changed

+26
-26
lines changed

lib/Saml2/Auth.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,8 @@ public function processSLO($keepLocalSession = false, $requestId = null, $retrie
323323
*/
324324
public function redirectTo($url = '', $parameters = array(), $stay = false)
325325
{
326-
assert('is_string($url)');
327-
assert('is_array($parameters)');
326+
assert(is_string($url));
327+
assert(is_array($parameters));
328328

329329
if (empty($url) && isset($_REQUEST['RelayState'])) {
330330
$url = $_REQUEST['RelayState'];
@@ -442,7 +442,7 @@ public function getLastErrorReason()
442442
*/
443443
public function getAttribute($name)
444444
{
445-
assert('is_string($name)');
445+
assert(is_string($name));
446446

447447
$value = null;
448448
if (isset($this->_attributes[$name])) {
@@ -485,7 +485,7 @@ public function getAttributeWithFriendlyName($friendlyName)
485485
*/
486486
public function login($returnTo = null, $parameters = array(), $forceAuthn = false, $isPassive = false, $stay = false, $setNameIdPolicy = true)
487487
{
488-
assert('is_array($parameters)');
488+
assert(is_array($parameters));
489489

490490
$authnRequest = new OneLogin_Saml2_AuthnRequest($this->_settings, $forceAuthn, $isPassive, $setNameIdPolicy);
491491

@@ -527,7 +527,7 @@ public function login($returnTo = null, $parameters = array(), $forceAuthn = fal
527527
*/
528528
public function logout($returnTo = null, $parameters = array(), $nameId = null, $sessionIndex = null, $stay = false, $nameIdFormat = null, $nameIdNameQualifier = null)
529529
{
530-
assert('is_array($parameters)');
530+
assert(is_array($parameters));
531531

532532
$sloUrl = $this->getSLOurl();
533533
if (empty($sloUrl)) {

lib/Saml2/Error.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
2+
33
/**
44
* Error class of OneLogin PHP Toolkit
55
*
@@ -35,8 +35,8 @@ class OneLogin_Saml2_Error extends Exception
3535
*/
3636
public function __construct($msg, $code = 0, $args = null)
3737
{
38-
assert('is_string($msg)');
39-
assert('is_int($code)');
38+
assert(is_string($msg));
39+
assert(is_int($code));
4040

4141
$message = OneLogin_Saml2_Utils::t($msg, $args);
4242

@@ -111,8 +111,8 @@ class OneLogin_Saml2_ValidationError extends Exception
111111
*/
112112
public function __construct($msg, $code = 0, $args = null)
113113
{
114-
assert('is_string($msg)');
115-
assert('is_int($code)');
114+
assert(is_string($msg));
115+
assert(is_int($code));
116116

117117
$message = OneLogin_Saml2_Utils::t($msg, $args);
118118

lib/Saml2/Settings.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ private function _addDefaultValues()
440440
*/
441441
public function checkSettings($settings)
442442
{
443-
assert('is_array($settings)');
443+
assert(is_array($settings));
444444

445445
if (!is_array($settings) || empty($settings)) {
446446
$errors = array('invalid_syntax');
@@ -498,7 +498,7 @@ public function checkCompressionSettings($settings)
498498
*/
499499
public function checkIdPSettings($settings)
500500
{
501-
assert('is_array($settings)');
501+
assert(is_array($settings));
502502

503503
if (!is_array($settings) || empty($settings)) {
504504
return array('invalid_syntax');
@@ -563,7 +563,7 @@ public function checkIdPSettings($settings)
563563
*/
564564
public function checkSPSettings($settings)
565565
{
566-
assert('is_array($settings)');
566+
assert(is_array($settings));
567567

568568
if (!is_array($settings) || empty($settings)) {
569569
return array('invalid_syntax');
@@ -905,7 +905,7 @@ public function getSPMetadata($alwaysPublishEncryptionCert = false, $validUntil
905905
*/
906906
public function validateMetadata($xml)
907907
{
908-
assert('is_string($xml)');
908+
assert(is_string($xml));
909909

910910
$errors = array();
911911
$res = OneLogin_Saml2_Utils::validateXML($xml, 'saml-schema-metadata-2.0.xsd', $this->_debug);

lib/Saml2/Utils.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class OneLogin_Saml2_Utils
5252
*/
5353
public static function t($msg, $args = array())
5454
{
55-
assert('is_string($msg)');
55+
assert(is_string($msg));
5656
if (extension_loaded('gettext')) {
5757
bindtextdomain("phptoolkit", dirname(dirname(__DIR__)).'/locale');
5858
textdomain('phptoolkit');
@@ -81,8 +81,8 @@ public static function t($msg, $args = array())
8181
*/
8282
public static function loadXML($dom, $xml)
8383
{
84-
assert('$dom instanceof DOMDocument');
85-
assert('is_string($xml)');
84+
assert($dom instanceof DOMDocument);
85+
assert(is_string($xml));
8686

8787
if (strpos($xml, '<!ENTITY') !== false) {
8888
throw new Exception('Detected use of ENTITY in XML, disabled to prevent XXE/XEE attacks');
@@ -114,8 +114,8 @@ public static function loadXML($dom, $xml)
114114
*/
115115
public static function validateXML($xml, $schema, $debug = false)
116116
{
117-
assert('is_string($xml) || $xml instanceof DOMDocument');
118-
assert('is_string($schema)');
117+
assert(is_string($xml) || $xml instanceof DOMDocument);
118+
assert(is_string($schema));
119119

120120
libxml_clear_errors();
121121
libxml_use_internal_errors(true);
@@ -293,8 +293,8 @@ public static function getStringBetween($str, $start, $end)
293293
*/
294294
public static function redirect($url, $parameters = array(), $stay = false)
295295
{
296-
assert('is_string($url)');
297-
assert('is_array($parameters)');
296+
assert(is_string($url));
297+
assert(is_array($parameters));
298298

299299
if (substr($url, 0, 1) === '/') {
300300
$url = self::getSelfURLhost() . $url;
@@ -783,8 +783,8 @@ public static function parseSAML2Time($time)
783783
*/
784784
public static function parseDuration($duration, $timestamp = null)
785785
{
786-
assert('is_string($duration)');
787-
assert('is_null($timestamp) || is_int($timestamp)');
786+
assert(is_string($duration));
787+
assert(is_null($timestamp) || is_int($timestamp));
788788

789789
/* Parse the duration. We use a very strict pattern. */
790790
$durationRegEx = '#^(-?)P(?:(?:(?:(\\d+)Y)?(?:(\\d+)M)?(?:(\\d+)D)?(?:T(?:(\\d+)H)?(?:(\\d+)M)?(?:(\\d+)S)?)?)|(?:(\\d+)W))$#D';
@@ -955,7 +955,7 @@ public static function deleteLocalSession()
955955
*/
956956
public static function calculateX509Fingerprint($x509cert, $alg = 'sha1')
957957
{
958-
assert('is_string($x509cert)');
958+
assert(is_string($x509cert));
959959

960960
$arCert = explode("\n", $x509cert);
961961
$data = '';
@@ -1250,8 +1250,8 @@ public static function decryptElement(DOMElement $encryptedData, XMLSecurityKey
12501250
*/
12511251
public static function castKey(XMLSecurityKey $key, $algorithm, $type = 'public')
12521252
{
1253-
assert('is_string($algorithm)');
1254-
assert('$type === "public" || $type === "private"');
1253+
assert(is_string($algorithm));
1254+
assert($type === "public" || $type === "private");
12551255
// do nothing if algorithm is already the type of the key
12561256
if ($key->type === $algorithm) {
12571257
return $key;

0 commit comments

Comments
 (0)