Skip to content
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

fix: Images\Handlers\GDHandler Implicit conversion from float to int loses precision #5965

Merged
merged 1 commit into from May 6, 2022

Conversation

kenjis
Copy link
Member

@kenjis kenjis commented May 5, 2022

Description
Fixes #5941

Checklist:

  • Securely signed commits
  • [] Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • [] User guide updated
  • Conforms to style guide

@kenjis kenjis added the bug Verified issues on the current code behavior or pull requests that will fix them label May 5, 2022
@kenjis kenjis force-pushed the fix-GDHandler-php81-error branch from 3b689cc to e0407ee Compare May 5, 2022 13:01
@@ -451,7 +451,7 @@ protected function textOverlay(string $text, array $options = [], bool $isShadow
* Get the rest of the string and split it into 2-length
* hex values:
*/
$opacity = ($options['opacity'] * 127);
$opacity = (int) ($options['opacity'] * 127);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Casting by (int) removes the decimals part. https://3v4l.org/8lXKD
Is that the intended behavior or should we use round()?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at my comment in #5370 (comment), it seems this is to match the current behavior.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Frankly, I don't think there is much difference either way.
And yes, this is to match the current behavior.

@kenjis kenjis merged commit 94fd4cc into codeigniter4:develop May 6, 2022
@kenjis kenjis deleted the fix-GDHandler-php81-error branch May 6, 2022 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: PHP 8.1 Images\Handlers\GDHandler Implicit conversion from float to int loses precision
2 participants