Skip to content

[Bug]: Macro calls helper code generated invalid signature for Eloquent macros #703

@miagg

Description

@miagg

Bug description

I have register the following macro in my AppServiceProvider class

use Illuminate\Database\Eloquent\Builder;

Builder::macro('searchFor', function (string|array $attributes, string $searchTerm) {
            $attributes = \Arr::wrap($attributes);

            foreach ($attributes as $attribute) {
                $this->query->orWhere(function ($query) use ($searchTerm, $attribute) {
                    foreach (explode(' ', $searchTerm) as $term) {
                        $query->whereRaw(
                            "LOWER($attribute COLLATE utf8mb4_unicode_ci) like LOWER(?)",
                            "%$term%"
                        );
                    }
                });
            }

            return $this;
        });

However when I generate helper code it seems to skip the first argument ($attributes) for some reason.

Here is the generated signature on my _laravel_idea/_ide_helper_macro.php

namespace Illuminate\Database\Eloquent {
    
    /**
     ...
     * @method $this searchFor(string $searchTerm)
     ...
     */ 
    class Builder {}
}

My macro does work however PHPStorm complains that the signature is wrong.

screenshot

Any thoughts?

Plugin version

No response

Operating system

MacOS

Steps to reproduce

As described above.

Relevant log output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions