diff vendor/zendframework/zend-diactoros/src/Uri.php @ 4:a9cd425dd02b

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:11:55 +0000
parents 5311817fb629
children
line wrap: on
line diff
--- a/vendor/zendframework/zend-diactoros/src/Uri.php	Thu Feb 28 11:14:44 2019 +0000
+++ b/vendor/zendframework/zend-diactoros/src/Uri.php	Thu Feb 28 13:11:55 2019 +0000
@@ -111,16 +111,18 @@
      */
     public function __construct($uri = '')
     {
+        if ('' === $uri) {
+            return;
+        }
+
         if (! is_string($uri)) {
             throw new InvalidArgumentException(sprintf(
                 'URI passed to constructor must be a string; received "%s"',
-                (is_object($uri) ? get_class($uri) : gettype($uri))
+                is_object($uri) ? get_class($uri) : gettype($uri)
             ));
         }
 
-        if ('' !== $uri) {
-            $this->parseUri($uri);
-        }
+        $this->parseUri($uri);
     }
 
     /**
@@ -246,7 +248,7 @@
             throw new InvalidArgumentException(sprintf(
                 '%s expects a string argument; received %s',
                 __METHOD__,
-                (is_object($scheme) ? get_class($scheme) : gettype($scheme))
+                is_object($scheme) ? get_class($scheme) : gettype($scheme)
             ));
         }
 
@@ -277,19 +279,19 @@
             throw new InvalidArgumentException(sprintf(
                 '%s expects a string user argument; received %s',
                 __METHOD__,
-                (is_object($user) ? get_class($user) : gettype($user))
+                is_object($user) ? get_class($user) : gettype($user)
             ));
         }
         if (null !== $password && ! is_string($password)) {
             throw new InvalidArgumentException(sprintf(
-                '%s expects a string password argument; received %s',
+                '%s expects a string or null password argument; received %s',
                 __METHOD__,
-                (is_object($password) ? get_class($password) : gettype($password))
+                is_object($password) ? get_class($password) : gettype($password)
             ));
         }
 
         $info = $this->filterUserInfoPart($user);
-        if ($password) {
+        if (null !== $password) {
             $info .= ':' . $this->filterUserInfoPart($password);
         }
 
@@ -313,7 +315,7 @@
             throw new InvalidArgumentException(sprintf(
                 '%s expects a string argument; received %s',
                 __METHOD__,
-                (is_object($host) ? get_class($host) : gettype($host))
+                is_object($host) ? get_class($host) : gettype($host)
             ));
         }
 
@@ -333,14 +335,14 @@
      */
     public function withPort($port)
     {
-        if (! is_numeric($port) && $port !== null) {
-            throw new InvalidArgumentException(sprintf(
-                'Invalid port "%s" specified; must be an integer, an integer string, or null',
-                (is_object($port) ? get_class($port) : gettype($port))
-            ));
-        }
+        if ($port !== null) {
+            if (! is_numeric($port) || is_float($port)) {
+                throw new InvalidArgumentException(sprintf(
+                    'Invalid port "%s" specified; must be an integer, an integer string, or null',
+                    is_object($port) ? get_class($port) : gettype($port)
+                ));
+            }
 
-        if ($port !== null) {
             $port = (int) $port;
         }
 
@@ -437,7 +439,7 @@
             throw new InvalidArgumentException(sprintf(
                 '%s expects a string argument; received %s',
                 __METHOD__,
-                (is_object($fragment) ? get_class($fragment) : gettype($fragment))
+                is_object($fragment) ? get_class($fragment) : gettype($fragment)
             ));
         }
 
@@ -559,7 +561,7 @@
             return '';
         }
 
-        if (! array_key_exists($scheme, $this->allowedSchemes)) {
+        if (! isset($this->allowedSchemes[$scheme])) {
             throw new InvalidArgumentException(sprintf(
                 'Unsupported scheme "%s"; must be any empty string or in the set (%s)',
                 $scheme,
@@ -655,7 +657,7 @@
     private function splitQueryValue($value)
     {
         $data = explode('=', $value, 2);
-        if (1 === count($data)) {
+        if (! isset($data[1])) {
             $data[] = null;
         }
         return $data;