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: str_replace(): Passing null warning #822

Open
usernotnull opened this issue Mar 17, 2022 · 2 comments
Open

fix: str_replace(): Passing null warning #822

usernotnull opened this issue Mar 17, 2022 · 2 comments
Assignees
Labels

Comments

@usernotnull
Copy link
Contributor

On PHP 8, we can't pass null to str_replace, it will generate a warning.

image

I'll make a PR to add a null check, which will remove the warning on many requests.

@iwasherefirst2
Copy link
Collaborator

This issue only occurs when incorrect attributes are passed to getURLFromRouteNameTranslated. To handle this properly, I believe the function should throw an exception if the value is null.

This would help prevent unexpected behavior and make it clear that the provided attributes are incomplete or invalid.

Do you agree @jordyvanderhaegen ?

@iwasherefirst2 iwasherefirst2 self-assigned this Dec 3, 2024
@jordyvanderhaegen
Copy link
Collaborator

Ideally this is the same behaviour as Laravel's route method, where a UrlGenerationException is thrown when passing null as a route parameter.

route('posts.show', ['post' => null]);

// Illuminate\Routing\Exceptions\UrlGenerationException
// Missing required parameter for [Route: posts.show] [URI: blog/posts/{post}] [Missing parameter: post].

https://github.com/laravel/framework/blob/11.x/src/Illuminate/Routing/RouteUrlGenerator.php#L89-L91
https://github.com/laravel/framework/blob/11.x/src/Illuminate/Routing/RouteUrlGenerator.php#L187-L208

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants