Skip to content
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

Fix: Add a check for usage of the empty() construct #188

Merged
merged 3 commits into from
Nov 27, 2023
Merged

Conversation

RikudouSage
Copy link
Collaborator

Description

I've noticed some code which uses the empty() construct. The construct does way too many things and should not be used in any modern code. Additionally it looks like a function but isn't, which might cause problems in a few cases.

This PR adds a PHPStan rule that checks for usage of empty() and offers a hint if the type of variable is known.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@RikudouSage
Copy link
Collaborator Author

You can check what the output looks like here: https://github.com/Unleash/unleash-client-php/actions/runs/6997953019/job/19035484861?pr=188

Copy link
Member

@sighphyre sighphyre left a comment

Choose a reason for hiding this comment

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

Oh wow, that's pretty cool. Yes please!

@RikudouSage RikudouSage merged commit 62eeea7 into main Nov 27, 2023
11 checks passed
@RikudouSage RikudouSage deleted the fix/no-empty branch November 27, 2023 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants