Skip to content

Commit

Permalink
Revert a BC break on filer_var based assertions (webmozarts#154)
Browse files Browse the repository at this point in the history
These assertions accepted objects that could be cast to string in 1.5.0
Changing this is a BC break, so we revert that change here.
  • Loading branch information
BackEndTea authored Nov 24, 2019
1 parent 7e202b1 commit 7697fe1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
4 changes: 0 additions & 4 deletions src/Assert.php
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,6 @@ public static function false($value, $message = '')
*/
public static function ip($value, $message = '')
{
static::string($value, $message);
if (false === \filter_var($value, \FILTER_VALIDATE_IP)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a value to be an IP. Got: %s',
Expand All @@ -716,7 +715,6 @@ public static function ip($value, $message = '')
*/
public static function ipv4($value, $message = '')
{
static::string($value, $message);
if (false === \filter_var($value, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV4)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a value to be an IPv4. Got: %s',
Expand All @@ -733,7 +731,6 @@ public static function ipv4($value, $message = '')
*/
public static function ipv6($value, $message = '')
{
static::string($value, $message);
if (false === \filter_var($value, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV6)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a value to be an IPv6. Got %s',
Expand All @@ -750,7 +747,6 @@ public static function ipv6($value, $message = '')
*/
public static function email($value, $message = '')
{
static::string($value, $message);
if (false === \filter_var($value, FILTER_VALIDATE_EMAIL)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a value to be a valid e-mail address. Got %s',
Expand Down
8 changes: 4 additions & 4 deletions tests/AssertTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ public function getTests()
array('throws', array(function() { trigger_error('test'); }, 'Unthrowable'), false, false, 70000),
array('throws', array(function() { throw new Error(); }, 'Throwable'), true, true, 70000),
array('ip', array('192.168.0.1'), true),
array('ip', array(new ToStringClass('192.168.0.1')), false),
array('ip', array(new ToStringClass('192.168.0.1')), true),
array('ip', array('255.255.255.255'), true),
array('ip', array('0.0.0.0'), true),
array('ip', array('2001:0db8:0000:0042:0000:8a2e:0370:7334'), true),
Expand All @@ -472,7 +472,7 @@ public function getTests()
array('ip', array(null), false),
array('ip', array(false), false),
array('ipv4', array('192.168.0.1'), true),
array('ipv4', array(new ToStringClass('192.168.0.1')), false),
array('ipv4', array(new ToStringClass('192.168.0.1')), true),
array('ipv4', array('255.255.255.255'), true),
array('ipv4', array('0.0.0.0'), true),
array('ipv4', array('2001:0db8:0000:0042:0000:8a2e:0370:7334'), false),
Expand All @@ -488,7 +488,7 @@ public function getTests()
array('ipv6', array('255.255.255.255'), false),
array('ipv6', array('0.0.0.0'), false),
array('ipv6', array('2001:0db8:0000:0042:0000:8a2e:0370:7334'), true),
array('ipv6', array(new ToStringClass('2001:0db8:0000:0042:0000:8a2e:0370:7334')), false),
array('ipv6', array(new ToStringClass('2001:0db8:0000:0042:0000:8a2e:0370:7334')), true),
array('ipv6', array('::ffff:192.0.2.1'), true),
array('ipv6', array('::1'), true),
array('ipv6', array('::'), true),
Expand All @@ -501,7 +501,7 @@ public function getTests()
array('email', array(123), false),
array('email', array('foo.com'), false),
array('email', array('[email protected]'), true),
array('email', array(new ToStringClass('[email protected]')), false),
array('email', array(new ToStringClass('[email protected]')), true),
array('uniqueValues', array(array('qwerty', 'qwerty')), false),
array('uniqueValues', array(array('asdfg', 'qwerty')), true),
array('uniqueValues', array(array(123, '123')), false),
Expand Down

0 comments on commit 7697fe1

Please sign in to comment.