Skip to content

Issue with IDE Helper Not Generating Macro Methods for Filament Macros #1685

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
pslxx opened this issue Feb 27, 2025 · 4 comments
Open

Issue with IDE Helper Not Generating Macro Methods for Filament Macros #1685

pslxx opened this issue Feb 27, 2025 · 4 comments
Labels

Comments

@pslxx
Copy link

pslxx commented Feb 27, 2025

Versions:

  • ide-helper Version: #.#.#
  • Laravel Version: #.#.#
  • PHP Version: #.#.#

Description:

Steps To Reproduce:

I used the Laravel macro feature to add a check method to the Filament MountableAction class within AppServiceProvider. While the functionality works correctly and has been tested, I want IDE (PhpStorm) to provide proper autocompletion for this method. I attempted to generate the hints using ide-helper:generate, but it did not include the macro method.

After analyzing the ide-helper codebase, I discovered that its macro method generation is incompatible with Filament’s macro structure.

**Root Cause:**​

Laravel’s default macro structure follows the format: 'method_name' => Closure.
Filament’s macros use a nested structure: 'method_name' => [CLASS_NAME => Closure].
This mismatch causes ide-helper to encounter errors when retrieving macro methods, resulting in the method being skipped entirely during code generation.

@pslxx pslxx added the bug label Feb 27, 2025
@pslxx
Copy link
Author

pslxx commented Feb 27, 2025

Laravel Macro
image
Filament Macro
image

@pslxx
Copy link
Author

pslxx commented Feb 27, 2025

Temporary fixed: Alias.php

Image

@emanueljacob
Copy link

emanueljacob commented Mar 4, 2025

@pslxx I tried your solution temporarily, in hope I could create a PR for this. However in my case my macro has NOT been generated in my _ide_helper.php file. So are you sure you have shown all your temporary changes?

P.s. i highly recommend to use code markup when presenting code. its easy, because you just have to copy paste your code between ```php\n \n``` and every reader is able to easily copy (and test out) your code. Screenshots are a really bad practice for presenting code ...
Example:

        if (is_array($macro_func) && is_callable(array_values($macro_func)[0])) {
            return new ReflectionFunction(array_values($macro_func)[0]);
        }

@mk-helenoftroy
Copy link

@emanueljacob

This code seems to work fine for me. Notice the missing \ before ReflectionFunction.

      if (is_array($macro_func) && is_callable(array_values($macro_func)[0])) {
          return new \ReflectionFunction(array_values($macro_func)[0]);
      }

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants