CodeIgniter4 icon indicating copy to clipboard operation
CodeIgniter4 copied to clipboard

fix: validation change behavior regex match in `integer` and `numeric` to php function

Open ddevsr opened this issue 3 years ago • 4 comments

Description Fixed #6489

Checklist:

  • [x] Securely signed commits
  • [x] Component(s) with PHPDoc blocks, only if necessary or adds value
  • [ ] Unit testing, with >80% coverage
  • [x] User guide updated
  • [x] Conforms to style guide

ddevsr avatar Sep 04 '22 05:09 ddevsr

I think that it would be more correct to remove typehint for passed values in all rules. Casting to the appropriate types within the method.

iRedds avatar Sep 04 '22 07:09 iRedds

This PR brings a lot of breaking changes. Probably unacceptable.

There was 1 error:

1) CodeIgniter\Validation\FormatRulesTest::testInteger with data set #0 (1, true)
TypeError: Argument 1 passed to CodeIgniter\Validation\FormatRulesTest::testInteger() must be of the type string or null, int given, called in /home/runner/work/CodeIgniter4/CodeIgniter4/vendor/phpunit/phpunit/src/Framework/TestCase.php on line 1545

/home/runner/work/CodeIgniter4/CodeIgniter4/tests/system/Validation/FormatRulesTest.php:867
phpvfscomposer:///home/runner/work/CodeIgniter4/CodeIgniter4/vendor/phpunit/phpunit/phpunit:97

--

There were 6 failures:

1) CodeIgniter\Validation\FormatRulesTest::testIntegerWithInvalidTypeData with data set "bool true" (true, true)
Failed asserting that false is identical to true.

/home/runner/work/CodeIgniter4/CodeIgniter4/tests/system/Validation/FormatRulesTest.php:812
phpvfscomposer:///home/runner/work/CodeIgniter4/CodeIgniter4/vendor/phpunit/phpunit/phpunit:97

2) CodeIgniter\Validation\FormatRulesTest::testInteger with data set #2 ('42', true)
Failed asserting that false is identical to true.

/home/runner/work/CodeIgniter4/CodeIgniter4/tests/system/Validation/FormatRulesTest.php:877
phpvfscomposer:///home/runner/work/CodeIgniter4/CodeIgniter4/vendor/phpunit/phpunit/phpunit:97

3) CodeIgniter\Validation\FormatRulesTest::testInteger with data set #3 ('-1', true)
Failed asserting that false is identical to true.

/home/runner/work/CodeIgniter4/CodeIgniter4/tests/system/Validation/FormatRulesTest.php:877
phpvfscomposer:///home/runner/work/CodeIgniter4/CodeIgniter4/vendor/phpunit/phpunit/phpunit:97

4) CodeIgniter\Validation\StrictRules\FormatRulesTest::testInteger with data set #0 ('0', true)
Failed asserting that false is identical to true.

/home/runner/work/CodeIgniter4/CodeIgniter4/tests/system/Validation/StrictRules/FormatRulesTest.php:876
phpvfscomposer:///home/runner/work/CodeIgniter4/CodeIgniter4/vendor/phpunit/phpunit/phpunit:97

5) CodeIgniter\Validation\StrictRules\FormatRulesTest::testInteger with data set #1 ('42', true)
Failed asserting that false is identical to true.

/home/runner/work/CodeIgniter4/CodeIgniter4/tests/system/Validation/StrictRules/FormatRulesTest.php:876
phpvfscomposer:///home/runner/work/CodeIgniter4/CodeIgniter4/vendor/phpunit/phpunit/phpunit:97

6) CodeIgniter\Validation\StrictRules\FormatRulesTest::testInteger with data set #2 ('-1', true)
Failed asserting that false is identical to true.

/home/runner/work/CodeIgniter4/CodeIgniter4/tests/system/Validation/StrictRules/FormatRulesTest.php:876
phpvfscomposer:///home/runner/work/CodeIgniter4/CodeIgniter4/vendor/phpunit/phpunit/phpunit:97

kenjis avatar Sep 04 '22 08:09 kenjis

I think that it would be more correct to remove typehint for passed values in all rules. Casting to the appropriate types within the method.

Yes. When we introduce declare(strict_types=1), many TypeError would occur.

kenjis avatar Sep 05 '22 00:09 kenjis

I think that it would be more correct to remove typehint for passed values in all rules. Casting to the appropriate types within the method.

Yes. When we introduce declare(strict_types=1), many TypeError would occur. image

@kenjis this PR stuck on cache test php unit, i already adjusted in integerProvider

ddevsr avatar Sep 05 '22 02:09 ddevsr