Skip to content

Conversation

@GromNaN
Copy link
Member

@GromNaN GromNaN commented Sep 7, 2025

Q A
Branch? 6.4
Bug fix? yes
New feature? no
Deprecations? no
Issues Fix #61556 (comment)
License MIT

Remove a useless condition that breaks psalm analysis.

  • 1 << 63 === PHP_INT_MIN we cannot have a lower int value
  • 1 << 64 === 0 so the removing this value doesn't change anything

Fix psalm crash due to bug vimeo/psalm#11209
When PHP_INT_MIN - 1, the value is converted to a float that breaks the type system of psalm https://github.com/vimeo/psalm/blob/279f3eab037923d3f9d3ea3de1a16b425653e30c/src/Psalm/Internal/Type/SimpleAssertionReconciler.php#L2073

Dealing with timestamp >= (1 << 62)/1000 will be necessary when we reach year 146140482.

@carsonbot

This comment was marked as outdated.

@GromNaN GromNaN changed the base branch from 7.4 to 6.4 September 7, 2025 21:13
…Date

1 << 63 === PHP_INT_MIN we cannot have a lower int value

1 << 64 === 0 so the removing this value doesn't change anything

Fix psalm crash due to bug vimeo/psalm#11209

When doing PHP_INT_MIN - 1, the value is converted to a float that breaks the type system of psalm https://github.com/vimeo/psalm/blob/279f3eab037923d3f9d3ea3de1a16b425653e30c/src/Psalm/Internal/Type/SimpleAssertionReconciler.php#L2073
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a psalm analysis issue by removing an unnecessary condition in the CurrencyDataGenerator::icuPairToDate method that was causing static analysis to crash. The removed condition was mathematically redundant since 1 << 63 === PHP_INT_MIN represents the lowest possible integer value, and 1 << 64 === 0, making the subtraction operation meaningless.

  • Removes redundant signed/unsigned 64-bit integer conversion logic
  • Fixes psalm static analysis crash related to integer overflow handling
  • Maintains existing functionality while improving code analysis compatibility

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@Crovitche-1623
Copy link
Contributor

Crovitche-1623 commented Sep 8, 2025

Thanks @GromNaN The fix seems correct to me.

PHP seems to store the sign in the last bit.

Therefore, when we do 1 << 63, PHP automatically transforms the value to a float instead of going in negative values for safety purpose. That was probably the reason why psalm was failing

As you said, this is not an issue if we have a float for the following calculations as long as we don't reach the value (1 << 62) /1000 + 1

@nicolas-grekas
Copy link
Member

Thank you @GromNaN.

@nicolas-grekas nicolas-grekas merged commit 1f64ca9 into symfony:6.4 Sep 8, 2025
8 of 11 checks passed
@GromNaN GromNaN deleted the icuPairToDate branch September 8, 2025 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants