Skip to content

Not finding imported functions #3035

Description

@nexxai

I use Pest as my testing harness and phpactor seems to have a problem with finding its imported functions.

For example, in this code, I get a phpactor: Function "get" not found even though the test itself actually works correctly:

use function Pest\Laravel\get;

test('guests are redirected to the login page for admin dashboard', function () {
    $response = get(route('admin.dashboard'));
    $response->assertRedirect(route('login'));
});

I'm not sure if I'm doing something wrong or if this is a limitation of phpactor. If anyone has any insight, I'd love to hear.

Source:
Image

Activity

  1. mamazu commented on Mar 25, 2026

    @mamazu
    Contributor

    Hm, interesting.
    What version of phpactor are you using?

    Is it in the index of phpactor?

    phpactor index:query "get"

    If the answer is no maybe try clearing the index.

    Just FYI there is already an issue with pest (completely unrelated) but it's not the first issue: #2344

  2. nexxai commented on Mar 25, 2026

    @nexxai
    Author

    So I ran that query and got no results. You wouldn't happen to know where the index is stored when it's being loaded as an LSP via Mason in neovim, would you? I'm not seeing any obvious files in my project or in the ~/.local/share/nvim/mason/packages/phpactor folders.

    3:49:33 PM in mason/packages/phpactor
    🔋 100% ➜ ./phpactor index:query "get"
    
    3:49:40 PM in mason/packages/phpactor
    🔋 100% ➜ 
  3. dantleech commented on Mar 25, 2026

    @dantleech
    Collaborator

    that should be phpactor index:query Pest\\Laravel\\get:

    phpactor index:query Pest\\Laravel\\get
    Function:Pest\Laravel\get
    Path:file://blah/vendor/pestphp/pest-plugin-laravel/src/Http.php
    

    it's indexed, but indeed I do not get completion for it.

  4. mamazu commented on Mar 25, 2026

    @mamazu
    Contributor

    @dantleech Do you want to investigate it or should I? :D

  5. dantleech commented on Mar 25, 2026

    @dantleech
    Collaborator

    Do you want to investigate it or should I?

    I'm going to bed, so go for it 😆

  6. mamazu commented on Mar 26, 2026

    @mamazu
    Contributor

    Okay, I've never worked with pest so I haven't found the package I need to install for this to even get the get function into my project. But from the most recent documentation I found it would be $this->get which brings it back to the other linked issue.

    https://laravel.com/docs/13.x/http-tests (first code block)

  7. dantleech commented on Mar 26, 2026

    @dantleech
    Collaborator

    The function is defined in the pest-plugin-laravel package. I'll invstigate why it's indexed bu not found.

  8. dantleech commented on Mar 26, 2026

    @dantleech
    Collaborator

    so it does work for me this morning - I suspect it's an indexing problem. phpactor index:build --reset and restart your IDE might be a workaround.

  9. nexxai commented on Mar 27, 2026

    @nexxai
    Author

    Is the index per project and if so, where do I actually run the rebuild command?

  10. mamazu commented on Mar 27, 2026

    @mamazu
    Contributor

    Run the index build command in your project directory. Then phpactor will know which index to rebuild.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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