Skip to content

chained method calls evaluate to first called methods signature #184

Description

@haase-fabian

PHPantom version

phpantom_lsp 0.8.0-dirty

Installation method

Pre-built binary from GitHub Releases

Operating system

Linux x86_64

Editor

Neovim

Bug description

Directly chained method calls do not change the context.

phpantom thinks method call 2 has signature of first method call.

-> Expected 2 arguments, got 1 phpantom (argument_count_mismatch) [12, 34]

-> inlay hints show $a instead of $c (in the example)

Steps to reproduce

  1. Create this file:
<?php

declare(strict_types=1);

function makeCallable(string $a, string $b): callable
{
    return fn (string $c) => "$a $b $c";
}

function main()
{
    return makeCallable('1', '2')('test');
}
  1. Trigger linting
  2. Should give inlay hint $c for 'test' but is $a
  3. Should not give argument_count_mismatch

Error output or panic trace


.phpantom.toml

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions