Make bcmath functions more strict

php.internals

Vladyslav Startsev

7 years ago
Hello everyone! Recently I noticed that there are strange behavior going on if I use bcmath functions (some examples you can see here https://3v4l.org/D3s7J). I also previously had little discussion with Sara Golemon on twitter about this (https://twitter.com/SaraMG/status/1087902930110480384). So to conclude things that I want, is drop behavior (they should throw invalid argument exception) that I've showed in the first link and as Sara suggested add deprecation warning (but I think it should be E_NOTICE level errors) in 7.4. ------ Vladyslav Startsev

Ben Ramsey

7 years ago
> On Feb 7, 2019, at 11:47, Vladyslav Startsev <vladyslavstartsev@gmail.com> wrote: > > Hello everyone! > > Recently I noticed that there are strange behavior going on if I use > bcmath functions (some examples you can see here > https://3v4l.org/D3s7J). I also previously had little discussion with > Sara Golemon on twitter about this > (https://twitter.com/SaraMG/status/1087902930110480384). So to > conclude things that I want, is drop behavior (they should throw > invalid argument exception) that I've showed in the first link and as > Sara suggested add deprecation warning (but I think it should be > E_NOTICE level errors) in 7.4.
Another option to consider is to adopt the same approach as standard math in PHP. Here’s an example using standard addition for the same values: https://3v4l.org/iMGg8 So, maybe it should emit notices and warnings instead? Notice: A non well formed numeric value encountered in… Warning: A non-numeric value encountered in… Cheers, Ben

Vladyslav Startsev

7 years ago
On Fri, Feb 8, 2019 at 1:07 AM Ben Ramsey <ben@benramsey.com> wrote:
> > > On Feb 7, 2019, at 11:47, Vladyslav Startsev <vladyslavstartsev@gmail.com> wrote: > > > > Hello everyone! > > > > Recently I noticed that there are strange behavior going on if I use > > bcmath functions (some examples you can see here > > https://3v4l.org/D3s7J). I also previously had little discussion with > > Sara Golemon on twitter about this > > (https://twitter.com/SaraMG/status/1087902930110480384). So to > > conclude things that I want, is drop behavior (they should throw > > invalid argument exception) that I've showed in the first link and as > > Sara suggested add deprecation warning (but I think it should be > > E_NOTICE level errors) in 7.4. > > > Another option to consider is to adopt the same approach as standard > math in PHP. Here’s an example using standard addition for the same > values: https://3v4l.org/iMGg8 > > So, maybe it should emit notices and warnings instead? > > Notice: A non well formed numeric value encountered in… > Warning: A non-numeric value encountered in… > > Cheers, > Ben
Ha! I like your idea Ben. Should I make RFC? Since no one else responded