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 typed method_exists breaks missing nested relation hydration #696

Open
nickfls opened this issue Dec 15, 2021 · 2 comments · May be fixed by #704
Open

PHP 8 typed method_exists breaks missing nested relation hydration #696

nickfls opened this issue Dec 15, 2021 · 2 comments · May be fixed by #704

Comments

@nickfls
Copy link

nickfls commented Dec 15, 2021

PHP Version: 8.0
Laravel Framework 8.76.1
laravelcollective/html: v6.2.1

Issue location: \Collective\Html\Eloquent\FormAccessible:52

When Form class encounters a value from a missing relation, it correctly returns false for isNestedModel .

However, Laravel places the name of [missing] relation into subject's relations array with null value.
When the second value from the missing nested model is looked up isNestedModel now returns true (correctly) and as a result, null fetched with getRelation() is passed to method_exists on line 52 forcing PHP 8.0 to throw

TypeError
method_exists(): Argument #1 ($object_or_class) must be of type object|string, null given`
@Healyhatman
Copy link

Bumping this because if this package is not abandoned I'd love an update.

To replicate:

Say you have a model DexClient with a relation 'client', and you open the form for a DexClient that doesn't have an attached client.

{{ Form::model($dexClient, [...]) }}

{{ Form::select('client', ...) }}

on PHP 8 that's all you need to throw an exception.

@themuddfamily
Copy link

I have pushed a fix for this on my fork of this project: https://github.com/LaravelLux/html

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 a pull request may close this issue.

3 participants