therselman 7 years ago
parent
commit
ea97bf0445
  1. 2
      src/Container.php
  2. 97
      src/Uri.php

2
src/Container.php

@ -275,6 +275,8 @@ class Container implements ArrayAccess
$value = $this->bindings[$key]; $value = $this->bindings[$key];
return is_callable($value) ? $value($this) : $value; // $value instanceof Closure return is_callable($value) ? $value($this) : $value; // $value instanceof Closure
} }
throw new \InvalidArgumentException("Undefined container property `\$c->{$key}`");
return null;
/** /**
* Examples of official PHP error messages when a property cannot be found * Examples of official PHP error messages when a property cannot be found

97
src/Uri.php

@ -1772,20 +1772,13 @@ class Uri implements UriInterface
if ( ! ctype_lower($scheme)) if ( ! ctype_lower($scheme))
{ {
throw new InvalidArgumentException(sprintf( throw new InvalidArgumentException("Invalid Uri scheme string; received {$value}");
'Invalid Uri scheme string; received %s',
$value
));
} }
} }
if ( ! array_key_exists($scheme, self::$allowedSchemes) && ! empty($scheme)) if ( ! array_key_exists($scheme, self::$allowedSchemes) && ! empty($scheme))
{ {
throw new InvalidArgumentException(sprintf( throw new InvalidArgumentException("Unsupported Uri scheme `{$scheme}`; must be an empty string or in the set (" . implode(', ', array_keys(self::$allowedSchemes)) . ')');
'Unsupported Uri scheme "%s"; must be an empty string or in the set (%s)',
$scheme,
implode(', ', array_keys(self::$allowedSchemes))
));
} }
$this->_scheme = empty($scheme) ? null : $scheme; $this->_scheme = empty($scheme) ? null : $scheme;
@ -1806,10 +1799,10 @@ class Uri implements UriInterface
} }
else else
{ {
throw new InvalidArgumentException(sprintf( throw new InvalidArgumentException(
'Invalid Uri scheme string provided; expecting a string or null; received %s', 'Invalid Uri scheme string provided; expecting a string or null; received ' .
(is_object($value) ? get_class($value) : gettype($value)) (is_object($value) ? get_class($value) : gettype($value))
)); );
} }
return $value; return $value;
@ -1846,10 +1839,10 @@ class Uri implements UriInterface
} }
else else
{ {
throw new InvalidArgumentException(sprintf( throw new InvalidArgumentException(
'Invalid Uri host; expecting a string or null; received %s', 'Invalid Uri host; expecting a string or null; received ' .
(is_object($value) ? get_class($value) : gettype($value)) (is_object($value) ? get_class($value) : gettype($value))
)); );
} }
return $value; return $value;
@ -1864,10 +1857,9 @@ class Uri implements UriInterface
{ {
if ($port < 1 || $port > 65535) if ($port < 1 || $port > 65535)
{ {
throw new InvalidArgumentException(sprintf( throw new InvalidArgumentException(
'Invalid port "%d" specified; must be a valid TCP/UDP port', "Invalid port `{$port}` specified; must be a valid TCP/UDP port"
$port );
));
} }
} }
else else
@ -1893,10 +1885,10 @@ class Uri implements UriInterface
} }
else else
{ {
throw new InvalidArgumentException(sprintf( throw new InvalidArgumentException(
'Invalid Uri port provided; expecting a numeric string, integer or null; received %s', 'Invalid Uri port provided; expecting a numeric string, integer or null; received ' .
(is_object($value) ? get_class($value) : (is_string($value) ? $value : 'value of type ' . gettype($value))) (is_object($value) ? get_class($value) : (is_string($value) ? $value : 'value of type ' . gettype($value)))
)); );
} }
return $value; return $value;
@ -1941,10 +1933,10 @@ class Uri implements UriInterface
} }
else else
{ {
throw new InvalidArgumentException(sprintf( throw new InvalidArgumentException(
'Invalid Uri path; expecting a string or null; received %s', 'Invalid Uri path; expecting a string or null; received ' .
(is_object($value) ? get_class($value) : gettype($value)) (is_object($value) ? get_class($value) : gettype($value))
)); );
} }
return $value; return $value;
@ -1983,10 +1975,10 @@ class Uri implements UriInterface
} }
else else
{ {
throw new InvalidArgumentException(sprintf( throw new InvalidArgumentException(
'Invalid Uri query string provided; expecting a string or null; received %s', 'Invalid Uri query string provided; expecting a string or null; received ' .
(is_object($value) ? get_class($value) : gettype($value)) (is_object($value) ? get_class($value) : gettype($value))
)); );
} }
return $value; return $value;
@ -2017,10 +2009,10 @@ class Uri implements UriInterface
} }
else else
{ {
throw new InvalidArgumentException(sprintf( throw new InvalidArgumentException(
'Invalid Uri fragment provided; expecting a string or null; received %s', 'Invalid Uri fragment provided; expecting a string or null; received ' .
(is_object($value) ? get_class($value) : gettype($value)) (is_object($value) ? get_class($value) : gettype($value))
)); );
} }
return $value; return $value;
@ -2049,10 +2041,10 @@ class Uri implements UriInterface
} }
else else
{ {
throw new InvalidArgumentException(sprintf( throw new InvalidArgumentException(
'Invalid username provided; expecting a string or null; received %s', 'Invalid username provided; expecting a string or null; received ' .
(is_object($value) ? get_class($value) : gettype($value)) (is_object($value) ? get_class($value) : gettype($value))
)); );
} }
return $value; return $value;
@ -2081,10 +2073,10 @@ class Uri implements UriInterface
} }
else else
{ {
throw new InvalidArgumentException(sprintf( throw new InvalidArgumentException(
'Invalid password provided; expecting a string or null; received %s', 'Invalid password provided; expecting a string or null; received ' .
(is_object($value) ? get_class($value) : gettype($value)) (is_object($value) ? get_class($value) : gettype($value))
)); );
} }
return $value; return $value;
@ -2105,10 +2097,10 @@ class Uri implements UriInterface
} }
else else
{ {
throw new InvalidArgumentException(sprintf( throw new InvalidArgumentException(
'Invalid segments provided; expecting an array or null; received %s', 'Invalid segments provided; expecting an array or null; received ' .
(is_object($value) ? get_class($value) : gettype($value)) (is_object($value) ? get_class($value) : gettype($value))
)); );
} }
return $value; return $value;
@ -2129,10 +2121,10 @@ class Uri implements UriInterface
} }
else else
{ {
throw new InvalidArgumentException(sprintf( throw new InvalidArgumentException(
'Invalid DNS segments; expecting an array or null; received %s', 'Invalid DNS segments; expecting an array or null; received ' .
(is_object($value) ? get_class($value) : gettype($value)) (is_object($value) ? get_class($value) : gettype($value))
)); );
} }
return $value; return $value;
@ -2161,10 +2153,10 @@ class Uri implements UriInterface
} }
else else
{ {
throw new InvalidArgumentException(sprintf( throw new InvalidArgumentException(
'Invalid authority; expecting a string with at most a single `@` sign or null; received %s', 'Invalid authority; expecting a string with at most a single `@` sign or null; received ' .
(is_object($value) ? get_class($value) : gettype($value)) (is_object($value) ? get_class($value) : gettype($value))
)); );
} }
// detect if optional port exists // detect if optional port exists
@ -2223,10 +2215,10 @@ class Uri implements UriInterface
} }
else else
{ {
throw new InvalidArgumentException(sprintf( throw new InvalidArgumentException(
'Invalid authority provided; expecting a string or null; received %s', 'Invalid authority provided; expecting a string or null; received ' .
(is_object($value) ? get_class($value) : gettype($value)) (is_object($value) ? get_class($value) : gettype($value))
)); );
} }
return $value; return $value;
@ -2245,10 +2237,9 @@ class Uri implements UriInterface
if (isset(self::$hashAlgos[$property])) if (isset(self::$hashAlgos[$property]))
{ {
throw new InvalidArgumentException(sprintf( throw new InvalidArgumentException(
'Invalid Uri property "%s"; hash properties are read-only', "Invalid Uri property `{$name}`; hash properties are read-only"
$name );
));
} }
//--- Start of alias and mixed-case properties ---// //--- Start of alias and mixed-case properties ---//

Loading…
Cancel
Save