Skip to content

Support new initializers in function parameters #1687

Open
@saibotk

Description

@saibotk

Versions:

  • ide-helper Version: 2.15.1
  • PHP Version: 8.3

Description:

The ModelsCommand handles parameters in the getParameters function.
When a parameter contains an initializer that creates a new instance, the function errors:

Exception: trim(): Argument #1 ($string) must be of type string, DateTime given
// due to -> trim(Object(DateTime))

This is because the function does not handle objects. These are supported since PHP 8.1
https://wiki.php.net/rfc/new_in_initializers

Would be great to have this fixed / implemented.

Steps To Reproduce:

  • Use a default Laravel installation
  • Go to the User model
  • Add a scope:
    public function scopeCreatedBefore(Builder $query, \DateTimeInterface $currentTime = new \DateTime()): Builder
    {
        return $query->where($this->created_at, '<', $currentTime);
    }
  • Run the models generation

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions