Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / zendframework / zend-escaper / src / Escaper.php
index e68e32b05d5cc4126f9a3a9ccce1b06e995e3da9..5cec9684ef4695d74c0e56806dc3cacb4b63db87 100644 (file)
@@ -95,7 +95,11 @@ class Escaper
     public function __construct($encoding = null)
     {
         if ($encoding !== null) {
-            $encoding = (string) $encoding;
+            if (! is_string($encoding)) {
+                throw new Exception\InvalidArgumentException(
+                    get_class($this) . ' constructor parameter must be a string, received ' . gettype($encoding)
+                );
+            }
             if ($encoding === '') {
                 throw new Exception\InvalidArgumentException(
                     get_class($this) . ' constructor parameter does not allow a blank value'
@@ -103,7 +107,7 @@ class Escaper
             }
 
             $encoding = strtolower($encoding);
-            if (!in_array($encoding, $this->supportedEncodings)) {
+            if (! in_array($encoding, $this->supportedEncodings)) {
                 throw new Exception\InvalidArgumentException(
                     'Value of \'' . $encoding . '\' passed to ' . get_class($this)
                     . ' constructor parameter is invalid. Provide an encoding supported by htmlspecialchars()'
@@ -321,7 +325,7 @@ class Escaper
             $result = $this->convertEncoding($string, 'UTF-8', $this->getEncoding());
         }
 
-        if (!$this->isUtf8($result)) {
+        if (! $this->isUtf8($result)) {
             throw new Exception\RuntimeException(
                 sprintf('String to be escaped was not valid UTF-8 or could not be converted: %s', $result)
             );