Skip to content

Add strrev() to NonEmptyStringFunctionsReturnTypeExtension #3921

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

Closed
wants to merge 1 commit into from

Conversation

nsfisis
Copy link

@nsfisis nsfisis commented Apr 6, 2025

Problem

If strrev() takes non-falsy-string or non-empty-string, it should return non-falsy-string or non-empty-string, but it returns just a string.

https://phpstan.org/r/f9b50c8a-1a20-43ff-8715-42f267a28e24

\PHPStan\dumpType(strrev("abc"));
// => string

Solution

Add strrev() to NonEmptyStringFunctionsReturnTypeExtension.

@VincentLanglet
Copy link
Contributor

VincentLanglet commented Apr 12, 2025

Hi @nsfisis

Best would be to have a StrrevFunctionReturnTypeExtension because

  • We can know the strrev of a constant string
  • A lowercase string will still be lowercase
  • A uppercase string will still be uppercase

@VincentLanglet
Copy link
Contributor

Hi @nsfisis

Best would be to have a StrrevFunctionReturnTypeExtension because

  • We can know the strrev of a constant string
  • A lowercase string will still be lowercase
  • A uppercase string will still be uppercase

I did the full implementation in #3960

@nsfisis
Copy link
Author

nsfisis commented Apr 23, 2025

Close this PR in favor of #3960. Thank you @VincentLanglet!

@nsfisis nsfisis closed this Apr 23, 2025
@nsfisis nsfisis deleted the feat/strrev branch April 23, 2025 14:54
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