Skip to content

Commit

Permalink
misc
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed May 2, 2024
1 parent 0327110 commit e2e9124
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ It looks like very modern PHP, right? But what if we pass some values:
$price = new Price('100.82', '2');
```

What will be the price's first value? We'd love to see `100.82` float, right?
What will be the price value? We'd love to see `100.82` float, right?

This is what our code really does ([see 3v4l.org](https://3v4l.org/lKgfG)):

Expand All @@ -46,7 +46,7 @@ return (int) $value + (string) $anotherValue + (float) $thirdValue;
Seeing it like this is an obvious red flag, but without using `declare(strict_types=1)`, PHP will silently continue. If we're lucky and we have enabled deprecation warning to trigger errors, we might see:

```bash
Deprecated: Implicit conversion from float-string "100.82" to int loses precision in /in/lKgfG on line 5
Deprecated: Implicit conversion from float-string "100.82" to int loses precision on line 5
```

But this is usually lost because we must run our tests with enabled deprecation warnings.
Expand Down

0 comments on commit e2e9124

Please sign in to comment.