Skip to content

Conversation

@afilina
Copy link
Contributor

@afilina afilina commented Oct 30, 2025

Part of this effort: #1849

Adding a sniff for removed/deprecated class constants NumberFormatter::TYPE_CURRENCY. This is different from bare constants like MCRYPT_MODE_CFB.

Implemented in a similar fashion to RemovedMagicMethods.

  • Message depends on deprecation status: Class constant NumberFormatter::TYPE_CURRENCY is deprecated since PHP 8.3..
  • Message depends on deprecation status: SoftDeprecated , Deprecated and Removed.
  • Added a test with potentially confusing syntax to ensure no false positives.
  • Assumed 10.0.0 target release.
  • Since we don't deal with runtime values, the check is a simple string on each side of the double colon, allowing of empty characters.

The scaffolding is there to allow for easily adding soft deprecations and removals later on, similar to how RemovedMagicMethods does it.
Getting the content of tokens is easier to reason about because the sprintf gives a hint about the expected string format we later compare.
@afilina afilina marked this pull request as draft October 31, 2025 13:48
- Pass the pointer of the constant name to addMessage() instead of the double colon. This was needed to satisfy the multiline test case.
- Comments on test cases are now more detailed to make it easier to reason about and maintain the test.
- Capture a variety of syntaxes where the target class and constant names are present, but it's not the _syntax_ we want.
@afilina
Copy link
Contributor Author

afilina commented Oct 31, 2025

@jrfnl Did we ever solve the question of documenting sniffs that cover different items, like RemovedFunctions? It makes no sense to put them all in the same *Standard.xml file. What should I do about the docs for this PR? Other than that, it's ready.

@afilina afilina marked this pull request as ready for review October 31, 2025 14:33
@afilina afilina changed the title Deprecate NumberFormatter::TYPE_CURRENCY PHP 8.3: Deprecate NumberFormatter::TYPE_CURRENCY Nov 14, 2025
@afilina afilina changed the title PHP 8.3: Deprecate NumberFormatter::TYPE_CURRENCY PHP 8.5: Deprecate NumberFormatter::TYPE_CURRENCY Nov 14, 2025
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.

2 participants