Skip to content

PHP 8 typed method_exists breaks missing nested relation hydration #696

Description

@nickfls

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`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions