Skip to content

chore: remove occurrences of empty() #72

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

Merged
merged 3 commits into from
Jul 8, 2025
Merged

chore: remove occurrences of empty() #72

merged 3 commits into from
Jul 8, 2025

Conversation

chr-hertel
Copy link
Contributor

Q A
Bug fix? no
New feature? no
Docs? no
Issues
License MIT

Cherry picking php-llm/llm-chain#374

`empty()` is used less and less in favor of bool casts on arrays.
Symfony, for example, banned it from its codebase. I suggest we remove
them from here as well.
@chr-hertel chr-hertel requested a review from Nyholm as a code owner July 6, 2025 21:08
@chr-hertel chr-hertel added Platform Issues & PRs about the AI Platform component Agent Issues & PRs about the AI Agent component Examples Issues & PRs about the example scripts labels Jul 6, 2025
@chr-hertel chr-hertel changed the title chore: remove occurrences of empty() (#374) chore: remove occurrences of empty() Jul 6, 2025
Copy link
Member

@Nyholm Nyholm left a comment

Choose a reason for hiding this comment

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

It is a small think but !$a['b'] is also very generous what it is matching.

Or do you intend to make sure it is defined and not being 'true'?

@chr-hertel
Copy link
Contributor Author

switched to !isset(...) 👍

Copy link
Member

@Nyholm Nyholm left a comment

Choose a reason for hiding this comment

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

Thank you.

Instead of counting, we can compare arrays with an empty array.

@chr-hertel
Copy link
Contributor Author

Thank you.

Instead of counting, we can compare arrays with an empty array.

found some other places as well --- hope i found all 0 === \count(...) and 0 !== \count(...) places

@chr-hertel chr-hertel merged commit 6a98e92 into main Jul 8, 2025
24 checks passed
@chr-hertel chr-hertel deleted the empty-occurrences branch July 8, 2025 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Agent Issues & PRs about the AI Agent component Examples Issues & PRs about the example scripts Platform Issues & PRs about the AI Platform component
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants