plugin icon indicating copy to clipboard operation
plugin copied to clipboard

[Bug]: Exception 'x' is never thrown in the corresponding 'try' block when using Facades

Open stefblokdijk opened this issue 1 year ago • 1 comments

Bug description

When I generate the helper code for my custom facade's, the @throws are not being added to _ide_helper_facades.php which will result in the following warning when I add a try/catch block in my code.

Besides that, it's not hinting that the method could throw an exception which other code does and the exception is grayed out hinting that it's unused. Other code hints are provided such as the params and return.

CleanShot 2024-03-21 at 18 16 09@2x CleanShot 2024-03-21 at 18 19 34@2x

Here is what my code looks like:

app\Facades\Example.php

<?php

namespace App\Facades;

use Illuminate\Support\Facades\Facade;

/**
 * @see \App\Services\Example
 */
class Example extends Facade
{
    protected static function getFacadeAccessor()
    {
        return 'example';
    }
}

app\Services\Example.php

<?php

namespace App\Services;

use App\Exceptions\TestException;
use Illuminate\Support\Collection;

class Example
{
    /**
     * Test
     *
     * @param array $test
     *
     * @return \Illuminate\Support\Collection
     * @throws \App\Exceptions\TestException
     */
    public function test(array $test): Collection
    {
        throw new TestException('Test Error');
    }
}

vendor/_laravel_idea/_ide_helper_facades.php (snippet)

    /**
     * @see \App\Services\Example::test
     * @method static \Illuminate\Support\Collection test(array $test)
     */
    class Example {}

Plugin version

8.1.2.232

Operating system

MacOS

Steps to reproduce

No response

Relevant log output

No response

stefblokdijk avatar Mar 21 '24 21:03 stefblokdijk

I have the same problem on windows. A function has a @throw doc block and the facade doesn't mention any of those.

schonhoff avatar Jul 17 '24 14:07 schonhoff

Laravel Idea 10 supports Facades natively, so this issue should disappear. Please update and try.

adelf avatar Feb 24 '25 06:02 adelf