Skip to content

Intelephense do not show hints correctly on new object instantiation #3277

Open
@mihailov-vf

Description

@mihailov-vf

Describe the bug
When I use intelephense with parametrized constructor, I get the following situation.

I just see the base type of parameters but do not see the type hint from array shapes or incorrect types on new object instantiation.

To Reproduce

class A {
    public function __construct(array $params) {
        $this->params = $params;
    }
}

class B extends A {
    /**
     * @param array{a: int} $params
     */
    public function __construct(array $params) {
        parent::__construct($params);
    }
}

$b = new B(['a' => 22.2]);

Expected behavior
To show the correct types hints and errors on instantiation like on static methods

Screenshots
Constructor whitout hints
Image

Static method with hints
Image

Platform and version
OS: Linux x64 6.8.0-59-generic
VSCodium Version: 1.100.23258
PHP: 7.3|8.4
Intelephense: 1.14.4

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions