@@ -51,7 +51,8 @@ class OneLogin_Saml2_Utils
5151 */
5252 public static function t ($ msg , $ args = array ())
5353 {
54- assert ('is_string($msg) ' );
54+ assert (is_string ($ msg ));
55+
5556 if (extension_loaded ('gettext ' )) {
5657 bindtextdomain ("phptoolkit " , dirname (dirname (dirname (__FILE__ ))).'/locale ' );
5758 textdomain ('phptoolkit ' );
@@ -80,8 +81,8 @@ public static function t($msg, $args = array())
8081 */
8182 public static function loadXML ($ dom , $ xml )
8283 {
83- assert (' $dom instanceof DOMDocument ' );
84- assert (' is_string($xml) ' );
84+ assert ($ dom instanceof DOMDocument);
85+ assert (is_string ($ xml ));
8586
8687 if (strpos ($ xml , '<!ENTITY ' ) !== false ) {
8788 throw new Exception ('Detected use of ENTITY in XML, disabled to prevent XXE/XEE attacks ' );
@@ -111,8 +112,8 @@ public static function loadXML($dom, $xml)
111112 */
112113 public static function validateXML ($ xml , $ schema , $ debug = false )
113114 {
114- assert (' is_string($xml) || $xml instanceof DOMDocument ' );
115- assert (' is_string($schema) ' );
115+ assert (is_string ($ xml ) || $ xml instanceof DOMDocument);
116+ assert (is_string ($ schema ));
116117
117118 libxml_clear_errors ();
118119 libxml_use_internal_errors (true );
@@ -248,8 +249,8 @@ public static function getStringBetween($str, $start, $end)
248249 */
249250 public static function redirect ($ url , $ parameters = array (), $ stay = false )
250251 {
251- assert (' is_string($url) ' );
252- assert (' is_array($parameters) ' );
252+ assert (is_string ($ url ));
253+ assert (is_array ($ parameters ));
253254
254255 if (substr ($ url , 0 , 1 ) === '/ ' ) {
255256 $ url = self ::getSelfURLhost () . $ url ;
@@ -263,7 +264,7 @@ public static function redirect($url, $parameters = array(), $stay = false)
263264 );
264265 }
265266
266-
267+
267268 /* Add encoded parameters */
268269 if (strpos ($ url , '? ' ) === false ) {
269270 $ paramPrefix = '? ' ;
@@ -726,8 +727,8 @@ public static function parseSAML2Time($time)
726727 */
727728 public static function parseDuration ($ duration , $ timestamp = null )
728729 {
729- assert (' is_string($duration) ' );
730- assert (' is_null($timestamp) || is_int($timestamp) ' );
730+ assert (is_string ($ duration ));
731+ assert (is_null ($ timestamp ) || is_int ($ timestamp ));
731732
732733 /* Parse the duration. We use a very strict pattern. */
733734 $ durationRegEx = '#^(-?)P(?:(?:(?:( \\d+)Y)?(?:( \\d+)M)?(?:( \\d+)D)?(?:T(?:( \\d+)H)?(?:( \\d+)M)?(?:( \\d+)S)?)?)|(?:( \\d+)W))$#D ' ;
@@ -894,7 +895,7 @@ public static function deleteLocalSession()
894895 */
895896 public static function calculateX509Fingerprint ($ x509cert , $ alg = 'sha1 ' )
896897 {
897- assert (' is_string($x509cert) ' );
898+ assert (is_string ($ x509cert ));
898899
899900 $ lines = explode ("\n" , $ x509cert );
900901
@@ -1150,7 +1151,7 @@ public static function decryptElement(DOMElement $encryptedData, XMLSecurityKey
11501151 OneLogin_Saml2_ValidationError::INVALID_XML_FORMAT
11511152 );
11521153 }
1153-
1154+
11541155 $ decryptedElement = $ newDoc ->firstChild ->firstChild ;
11551156 if ($ decryptedElement === null ) {
11561157 throw new OneLogin_Saml2_ValidationError (
@@ -1175,8 +1176,9 @@ public static function decryptElement(DOMElement $encryptedData, XMLSecurityKey
11751176 */
11761177 public static function castKey (XMLSecurityKey $ key , $ algorithm , $ type = 'public ' )
11771178 {
1178- assert ('is_string($algorithm) ' );
1179- assert ('$type === "public" || $type === "private" ' );
1179+ assert (is_string ($ algorithm ));
1180+ assert ($ type === 'public ' || $ type === 'private ' );
1181+
11801182 // do nothing if algorithm is already the type of the key
11811183 if ($ key ->type === $ algorithm ) {
11821184 return $ key ;
0 commit comments