bmewburn / vscode-intelephense

PHP intellisense for Visual Studio Code
https://intelephense.com
Other
1.64k stars 93 forks source link

Add support for PHPSpec and Prophecy matchers #1430

Open shulard opened 4 years ago

shulard commented 4 years ago

Feature description or problem with existing feature

I'm using your extension for a while now but I have trouble when using PHPSpec + Prophecy because it miss specific method understanding (even on the premium version).

As you can see in the following picture, most of the assertions methods are marked unknown :

Screenshot 2020-09-23 at 10 16 37

Describe the solution you'd like

Since inside a spec file, every object injected in methods is constructed as a mock ("prophet" in the Prophecy world), it's not a real instance. Every method exists but must be configured with assertions / expectations. All the willReturn, shouldBeXXX are valid.

Same for the current object instance, when using $this every method for the currently specified object is available and the return value is a spy object that can be tested.

I don't know if you are familiar with these tools, I can help if necessary :smile:.

gvanbeck commented 4 years ago

+1

alexkuc commented 3 years ago

I am also looking to add autocomplete for prophecy but it seems it is not as easy as other libraries/frameworks. It looks like prophecy is using a lot of "magic" (reference).

mikedfunk commented 2 years ago

+1

gvanbeck commented 2 years ago

Is there any status update on this?

kmatulewicz commented 1 year ago

+1

emircanerkul commented 1 year ago

+1

victordev13 commented 10 months ago

+1

kalifg commented 7 months ago

+1

icatalina commented 1 month ago

nothing?

mikedfunk commented 3 weeks ago

FWIW I was able to at least avoid a ton of intelephense detected errors like this:

use Prophecy\ObjectBehavior;

// ...

/**
 * @param ObjectBehavior<MyDependency> $myDependency
 */
public function it_does_something(
  MyDependency $myDependency
): void {
    // no more errors! Autocomplete gets a bit confused, but no errors is worth it IMHO.
    $myDependency->doThing()->shouldBeCalledOnce()->willReturn(true);

    // ...
}