Skip to content

Commit c965436

Browse files
authored
IntType fix (#142)
1 parent ca4e596 commit c965436

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

src/IntType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ final public static function from(
1717
return (int) $value;
1818
}
1919

20-
if (Validators::isNumeric($value) && (int) $value === (int) \ceil(\abs((float) $value))) {
20+
if (Validators::isNumeric($value) && \abs((int) $value) === (int) \ceil(\abs((float) $value))) {
2121
return (int) $value;
2222
}
2323

tests/IntTypeTest.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ final class IntTypeTest extends TestCase
4545
'1',
4646
1.000_00,
4747
'1.00000',
48+
-1,
49+
-1.0,
50+
'-1.0',
4851
];
4952

5053
foreach ($invalid as $value) {

0 commit comments

Comments
 (0)