Skip to content

Use conditional return type for words() - #1075

Open
alies-dev wants to merge 1 commit into
FakerPHP:1.24from
alies-dev:words-conditional-return
Open

alies-dev wants to merge 1 commit into
FakerPHP:1.24from
alies-dev:words-conditional-return

Conversation

@alies-dev

Copy link
Copy Markdown

What is the reason for this PR?

  • A new feature
  • Fixed an issue

words() returns a string when $asText is true and a list of strings otherwise, but it is annotated as array|string. Every caller has to narrow the result manually.

Author's checklist

  • Follow the Contribution Guide
  • New features and changes are documented

Summary of changes

Lorem::words() and the Generator @method now use ($asText is true ? string : list<string>). PHPStan resolves it on both the provider and the generator magic method.

Review checklist

  • All checks have passed
  • Changes are added to the CHANGELOG.md
  • Changes are approved by maintainer

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