Skip to content

Conversation

@IanDelMar
Copy link
Contributor

Adds return type extension for normalize_whitespace().

For constant strings:

  • trims strings
  • keeps empty and falsy strings
  • generalises all other constant strings

For non-constant strings:

  • converts non-falsy-string to non-empty-string (' 0' is no longer non-falsy after trim())
  • converts non-empty-string to string (' ' is no longer non-empty after trim())
  • preserves all other AccessoryTypes

@IanDelMar
Copy link
Contributor Author

The error is related to uppercase-string, introduced in PHPStan 1.12.12. It appears some issues around it were only resolved in 2.0.3. Should we remove the ' FOO ' assertion, or bump the minimum required PHPStan version to 2.0.3? I think we can safely just remove the assertion.

@IanDelMar
Copy link
Contributor Author

Perhaps uppercase-string was introduced in v1 and not in v2 initially. From the release description of version 2.0.3:

This release includes improvements and fixes from PHPStan 1.12.12.

Still, we can just remove the assertion. The type is not actively used, but is part of the return types composed from the AccessoryTypes by PHPStan.

@szepeviktor
Copy link
Owner

🫡 abnormalize_whitespace

@szepeviktor szepeviktor merged commit 585afd4 into szepeviktor:2.x Sep 9, 2025
1 of 2 checks passed
@IanDelMar IanDelMar deleted the normalize_whitespace branch September 9, 2025 04:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants