bmewburn / vscode-intelephense

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

Property annotations aren't recognized #1923

Open driesvints opened 3 years ago

driesvints commented 3 years ago

Describe the bug I have a method which returns an instance of Stripe\StripeClient. This class has several property annotations on it that indicate types returned by its magic __get method. When I call this method it won't indicate these property types.

To Reproduce

  1. Clone https://github.com/laravel/cashier-stripe locally
  2. Install dependencies using composer install
  3. Open the project in VS Code with the Intelephense plugin enabled
  4. Go to this line in the Subscription class, hover over ->subscriptionItems and notice that no type is indicated meaning subsequent calls like the ->create( method are also not properly indicated/clickable.

Expected behavior I'd expect Intelephense to indicate the proper type on the magic property and the ability to click-through to the typed object because it's annotated on the class.

Screenshots

The stripe method that I'm calling:

    /**
     * Get the Stripe SDK client.
     *
     * @param  array  $options
     * @return \Stripe\StripeClient
     */
    public static function stripe(array $options = [])
    {
        return Cashier::stripe($options);
    }

And the subsequent Cashier::stripe method:

    /**
     * Get the Stripe SDK client.
     *
     * @param  array  $options
     * @return \Stripe\StripeClient
     */
    public static function stripe(array $options = [])
    {
        return new StripeClient(array_merge([
            'api_key' => $options['api_key'] ?? config('cashier.secret'),
            'stripe_version' => static::STRIPE_VERSION,
        ], $options));
    }

The Stripe client is properly typed and I'm able to click-through:

Screen Shot 2021-08-19 at 16 05 46

But nothing appears when I hover over subscriptionItems:

Screen Shot 2021-08-19 at 16 05 52

Platform and version macOS Big Sur 11.5.1 VS Code Intelephense v1.7.1

driesvints commented 3 years ago

I now notice that this happening with most of the annotated classes from the Stripe PHP SDK. I'm guessing it's more wide spread of a problem.

romanstingler commented 8 months ago

there are "simple" bugs like

when I use something like this in my tests

 /** @var CEClient $ceClient */
$ceClient = $this->mock(CEClient::class);

everything works

but if I use

/** @var CEClient $ceClient */
$ceClient = $this->mock(CEClient::class, function (MockInterface $mock) {
    $mock->shouldReceive('createFulfillment')
        ->andThrow(new Exception('Exception occurred'));
});

It doesn't recognize the type correctly, image