vscode-intelephense
vscode-intelephense copied to clipboard
Incorrect behaviour when using anonymous classes
Describe the bug When using anonymous classes inheritance is not checked if the new class extends some other class, not only are abstract methods not checked ie. there is no warning that you haven't implemented the required abstract methods but also you can extend another object type, an interface or a trait, if the class implements an interface the unimplemented methods are also not checked.
However, I do get the auto-completion when implementing the abstract method, and if the signature does not match I also get the expected error.
To Reproduce
<?php
abstract class AbstractClass
{
abstract public function doSomething();
}
interface AbstractInterface
{
function doSomething();
}
trait AbstractTrait
{
abstract public function doSomething();
}
$anonymousClass = new class extends AbstractClass // no error
{
};
$anonymousClass = new class implements AbstractInterface // no error
{
};
$anonymousClass = new class extends AbstractInterface // no error
{
};
$anonymousClass = new class extends AbstractTrait // no error
{
};
Expected behavior I expect to get the same errors as I would have when implementing a regular class.
Platform and version macOS Catalina 10.15.6, Intelephense v1.5.3
Anonymous class does not lack of diagnosis/highlighting of construction parameter.
<?php
$obj = new stdClass;
new class ($obj) // no error, no highlighting
{
function __construct(int $a)
{
}
};
@tianyiw2013 just confirming that this issue still exists... anonymous classes with arguments passed to them do not get any syntax highlighting whatsoever.
i purchased a license, but I am unable to trigger the auto creation of missing abstract methods for anonymous classes