-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[Console] Remove redundant method getSaturation() #50317
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
Conversation
|
Hey! I see that this is your first PR. That is great! Welcome! Symfony has a contribution guide which I suggest you to read. In short:
Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change. When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor! I am going to sit back now and wait for the reviews. Cheers! Carsonbot |
maxbeckers
left a comment
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.
LGTM
|
Merging in 6.3 as this is not a bug fix, but mainly an improvement. |
|
Thank you @ivanpepelko. |
…epelko) This PR was submitted for the 6.2 branch but it was merged into the 6.3 branch instead. Discussion ---------- [Console] Remove redundant method getSaturation() | Q | A | ------------- | --- | Branch? | 6.2 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | none | License | MIT | Doc PR | none 1. in `getSaturation()`, `$diff` is compared against `int` zero. This will only yield `true` when RGB values contain min/max color value (`0` or `255`). It will be always `false` for floats. 2. in `degradeHexColorToAnsi4()` value returned from `getSaturation()` is `round`ed, which returns float, thus making comparison to `int` zero useless. 3. in the same method, bitwise operations (final `return` statement) will convert number to `int` anyway, so the explicit cast was removed In conclusion, `getSaturation` is redundant. Tests are expanded to show that even in min/max cases everything works fine. Commits ------- 38021b5 [Console] Remove redundant method getSaturation()
|
I think the main issue was a bug on line 167: should have been $diff was always less between 0.0 and 1.0, so would always (int) to 0, or 1. My contribution feels a bit redundant given that they've moved on and refactored a while back, but might help someone wondering why getSaturation doesn't return anything useful. |
getSaturation(),$diffis compared againstintzero. This will only yieldtruewhen RGB values contain min/max color value (0or255). It will be alwaysfalsefor floats.degradeHexColorToAnsi4()value returned fromgetSaturation()isrounded, which returns float, thus making comparison tointzero useless.returnstatement) will convert number tointanyway, so the explicit cast was removedIn conclusion,
getSaturationis redundant. Tests are expanded to show that even in min/max cases everything works fine.