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

PHP 8.1 warning on passing null to explode #176

Closed
hermitpopcorn opened this issue Mar 7, 2023 · 1 comment
Closed

PHP 8.1 warning on passing null to explode #176

hermitpopcorn opened this issue Mar 7, 2023 · 1 comment
Assignees

Comments

@hermitpopcorn
Copy link

When running on PHP 8.1, hits to API endpoints will emit a warning that says:

explode(): Passing null to parameter #2 ($string) of type string is deprecated in /var/www/html/vendor/apiato/core/Traits /ResponseTrait.php on line 90

originating from this line in parseRequestedIncludes function in ResponseTrait:

protected function parseRequestedIncludes(): array
{
return explode(',', Request::get('include'));
}

Due to Request::get('include') returning null and accepting null has been deprecated.

The same thing may happen to the function before it, since there's also a call to Request::get('filter') and then the return value gets exploded in the following line.

Seems easy to fix, such as by adding ?? '' to them, also maybe there are more places where Apiato calls explode on a possibly null/falsy value?

@Mohammad-Alavi Mohammad-Alavi self-assigned this Mar 7, 2023
@Mohammad-Alavi
Copy link
Member

Mohammad-Alavi commented Jun 4, 2023

Thank you! I fixed this in Core v8.

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

No branches or pull requests

2 participants