Skip to content

Support new initializers in function parameters #1687

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

Open
saibotk opened this issue Feb 28, 2025 · 0 comments · May be fixed by #1696
Open

Support new initializers in function parameters #1687

saibotk opened this issue Feb 28, 2025 · 0 comments · May be fixed by #1696
Labels

Comments

@saibotk
Copy link

saibotk commented Feb 28, 2025

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
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.

1 participant