-
-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Filter for arithmetic operations #28 #29
base: 2.12.x
Are you sure you want to change the base?
Conversation
Signed-off-by: Flávio Gomes da Silva Lisboa <[email protected]>
Signed-off-by: Flávio Gomes da Silva Lisboa <[email protected]>
No worries, there is no way to let you fix the codestyle. |
Signed-off-by: Flávio Gomes da Silva Lisboa <[email protected]>
Thank you and excuse me. I thought I must format the code again and sent a new change... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We definitely need some documentation that shows real use cases for this filter.
Signed-off-by: Flávio Gomes da Silva Lisboa <[email protected]>
Signed-off-by: Flávio Gomes da Silva Lisboa <[email protected]>
I made a little change on typing, but I don't know I had to follow all the messages in https://github.com/laminas/laminas-filter/actions/runs/1033956242. I think some parameters must be mixed, because they can be integers or floats. |
Bumps [pear/archive_tar](https://github.com/pear/Archive_Tar) from 1.4.13 to 1.4.14. - [Release notes](https://github.com/pear/Archive_Tar/releases) - [Commits](pear/Archive_Tar@1.4.13...1.4.14) --- updated-dependencies: - dependency-name: pear/archive_tar dependency-type: direct:development ... Signed-off-by: dependabot[bot] <[email protected]>
Signed-off-by: Bert Van Hauwaert <[email protected]>
Signed-off-by: Bert Van Hauwaert <[email protected]>
Signed-off-by: Bert Van Hauwaert <[email protected]>
Signed-off-by: Bert Van Hauwaert <[email protected]>
Signed-off-by: Bert Van Hauwaert <[email protected]>
Signed-off-by: Flávio Gomes da Silva Lisboa <[email protected]>
Signed-off-by: Flávio Gomes da Silva Lisboa <[email protected]>
Signed-off-by: Flávio Gomes da Silva Lisboa <[email protected]>
Signed-off-by: Flávio Gomes da Silva Lisboa <[email protected]>
Hi, @Ocramius. I have splitted the new filter into five filters, according your guideline. |
Signed-off-by: Tobias Trozowski <[email protected]>
Removed zendframework bridge dependency
Fixed broken anchors in docs
Signed-off-by: Frank Brückner <[email protected]>
…te-list Adds call-outs for new and deprecated features of version 2.12.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First, this needs to be rebased against the current release branch (currently 2.13.x, but likely to become 2.14.x later today when the PHP 8.1 support is merged); there are a few artifacts in here that seem to be from already merged changes (specifically the AllowList
and DenyList
implementations and tests).
Second, I've noted a number of areas where the behavior of the filters would not behave as expected when using integer values and operands. These likely need to be split into additional filters to allow both integer and float operations (with the exception of the Div
filter, where a float is always expected).
src/Add.php
Outdated
$value = (float) $value; | ||
$operand = (float) $this->options['operand']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the cast to float here?
If I were operating on integers, I'd expect an integer return value. Perhaps this should be broken into "AddInteger" and "AddFloat"?
src/Sub.php
Outdated
$value = (float) $value; | ||
$operand = (float) $this->options['operand']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same remark as for the Add
filter; should this maybe be broken into SubInt
and SubFloat
?
$value = (float) $value; | ||
$operand = (float) $this->options['operand']; | ||
return ($value % $operand); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't do what you think it does. From the manual:
Operands of modulo are converted to int before processing. For floating-point modulo, see fmod().
In other words, using the %
operator will always return an integer. If you want to work with floats, you need to use fmod()
. So, perhaps two variants, Mod
and FloatMod
, are needed.
src/Mul.php
Outdated
$value = (float) $value; | ||
$operand = (float) $this->options['operand']; | ||
return ($value * $operand); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same remark as for Add
and Sub
: if integers are used, I'd expect an integer return value, not casting to float.
Signed-off-by: Flávio Gomes da Silva Lisboa <[email protected]>
Signed-off-by: Flávio Gomes da Silva Lisboa <[email protected]>
Signed-off-by: Flávio Gomes da Silva Lisboa <[email protected]>
Signed-off-by: Flávio Gomes da Silva Lisboa <[email protected]>
Signed-off-by: Flávio Gomes da Silva Lisboa <[email protected]>
Signed-off-by: Flávio Gomes da Silva Lisboa <[email protected]>
Signed-off-by: Flávio Gomes da Silva Lisboa <[email protected]>
Signed-off-by: Flávio Gomes da Silva Lisboa <[email protected]>
Signed-off-by: Flávio Gomes da Silva Lisboa <[email protected]>
Signed-off-by: Flávio Gomes da Silva Lisboa <[email protected]>
Signed-off-by: Flávio Gomes da Silva Lisboa <[email protected]>
Signed-off-by: Flávio Gomes da Silva Lisboa <[email protected]>
Feature Request
Summary
I created this filter for an application that converts values from APIs. It's useful for measure unit conversions and making adjustments. For example, an endpoint returns the amount of RAM requested by an user and you can add a security margin.