Skip to content

filter_var has different behavior in PHP 7.x #6

Description

@peter279k

Issue summary

The filter_var has the different behavior in the php-7.x versions.

System informations

  • OS: Linux/Ubuntu 18.04.2 LTS
  • PHP version: php-7.1.30

Standalone code, or other way to reproduce the problem

Please consider following code snippets firstly:

It's for php-7.x:

filter_var('not-int',  FILTER_VALIDATE_INT, ['options' => ['min_range' => 1, 'default' => 20]]); // 20

It's for php-5.x:

filter_var('not-int',  FILTER_VALIDATE_INT, ['options' => ['min_range' => 1, 'default' => 20]]); // false

It effects the line 229 in src/Millipede.php class.

Expected result

The tests will be done and has the green message in php-7.x.

Actual result

The tests will have the failed assertion due to different filter_var behavior in different PHP versions.

PHPUnit 4.8.36 by Sebastian Bergmann and contributors.

Runtime:	PHP 7.1.30-1+ubuntu18.04.1+deb.sury.org+1 with Xdebug 2.7.1
Configuration:	/data/millipede-php/phpunit.xml

.......F......F................................

Time: 389 ms, Memory: 6.00MB

There were 2 failures:

1) MillipedeTest\MillipedeTest::testSetSizeThrowsException
Failed asserting that exception of type "\InvalidArgumentException" is thrown.

2) MillipedeTest\MillipedeTest::testSetCurveThrowsException
Failed asserting that exception of type "\InvalidArgumentException" is thrown.

FAILURES!
Tests: 47, Assertions: 58, Failures: 2.

Once accepting this, I can solve this issue.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions