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

Prevent ErrorException when value is not iterable #175

Merged

Conversation

rogervila
Copy link
Contributor

Hello,

When $value is a string, an ErrorException is thrown with the following message:

foreach() argument must be of type array|object, string given

This PR prevents that exception by checking if $value is an array, as expected.

@rogervila
Copy link
Contributor Author

Hi @scaytrase

I am thinking about using is_iterable instead of is_array. WDYT?

@rogervila rogervila changed the title Prevent ErrorException when value is a string Prevent ErrorException when value is not iterable Jan 27, 2023
@scaytrase
Copy link
Member

Sounds great

@scaytrase scaytrase self-assigned this Jan 27, 2023
@rogervila
Copy link
Contributor Author

@scaytrase done :)

Thank you for the review!

@scaytrase scaytrase merged commit 1c1ffa5 into thephpleague:master Jan 28, 2023
@scaytrase
Copy link
Member

Thanks @rogervila !

@rogervila rogervila deleted the rogervila-prevent-error-exception branch January 30, 2023 09:06
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