--level used: 0I've a custom setup for asserting notifications due to special requirements.
\Tests\TestCase I add my \Tests\NotificationAssertionTrait\Tests\NotificationFacade extending the one from Laravelfake method so I can use my own \Tests\NotificationFakeI've create a reproducible project with:
------ --------------------------------------------------------------------
Line TestCase.php
------ --------------------------------------------------------------------
Class \Illuminate\Support\Testing\Fakes\NotificationFacadeFake was
not found while trying to analyse it - discovering symbols is
probably not configured properly.
๐ก Learn more at https://phpstan.org/user-guide/discovering-symbols
18 Class \Illuminate\Support\Testing\Fakes\NotificationFacadeFake was
not found while trying to analyse it - discovering symbols is
probably not configured properly.
๐ก Learn more at https://phpstan.org/user-guide/discovering-symbols
------ --------------------------------------------------------------------
I even tried to minimize the code triggering this, removing actual body of code and such in this commit:
I've literally no idea where it does come up with that name or the line number (!) and where the problem lies ๐คทโโ๏ธ
Fun fact: in tests/NotificationFacade.php I could change
use Illuminate\Support\Facades\Notification;
class NotificationFacade extends Notification
{
}
to
use Illuminate\Support\Facades\Cache;
class NotificationFacade extends Cache
{
}
and then get
Class \Illuminate\Support\Testing\Fakes\CacheFake was not found while trying to analyse it
Class \Illuminate\Support\Testing\Fakes\NotificationFacadeFake was
not found
I think the class' name is Illuminate\Support\Testing\Fakes\NotificationFake
https://github.com/illuminate/support/blob/63a50a0ad26a336907b40bd59621b6b947c8eb41/Testing/Fakes/NotificationFake.php#L16
not NotificationFacadeFake
Of course, that's the perplexing thing ๐ You won't find the name NotificationFacadeFake anywhere in the sample repo!
I failed to mention but as @szepeviktor tried it themselves, removing larastan from the phpstan config "works":
[OK] No errors
I'm only one himself :)
Tried my best to not assume anything ๐
NotificationFacadeFake was coming from this method.
We weren't checking if the fake facade actually exists. Added the check with 852c131 Can you try the latest master?
Also, you need to add @method annotations to the NotificationFacade if you want PHPStan to understand the method calls. Or you can add @mixin \Tests\NotificationFake
I can confirm the issue is fixed with the change!
Also, you need to add
@methodannotations to theNotificationFacadeif you want PHPStan to understand the method calls. Or you can add@mixin \Tests\NotificationFake
Awesome, phpstan even reminded me about that with a "call to an undefined static method"
Is there a release planned soon? Otherwise I can go with the dev alias 0.6-dev I guess.
All solved and so quickly, thank you very much ๐
Is there a release planned soon?
I want to make a new release when there is new PHPStan version is released. There are some bug fixes there that Larastan benefits.
@canvural @szepeviktor I am having a similar issue using the Maatwerk Excel package's Excel facade calling the Excel::fake() during my tests and getting:
Class \Illuminate\Support\Testing\Fakes\ExcelFake was not found while trying to analyse it - discovering symbols is probably not configured properly.
๐ก Learn more at https://phpstan.org/user-guide/discovering-symbols
The actual facade is located in: Maatwebsite\Excel\Fakes.
Should that error also be fixed with https://github.com/nunomaduro/larastan/commit/852c1313e1c94feab8da8055d0abceda97a27586, or should I open a new issue?
@johanvanhelden Are you using 0.6.2?
I thought it was still unreleased because a composer update just now only updated to 0.6.1.
But after removing the package and re-requiring it's at 0.6.2 now and indeed the issue is fixed, thanks!
Most helpful comment
I thought it was still unreleased because a composer update just now only updated to 0.6.1.
But after removing the package and re-requiring it's at 0.6.2 now and indeed the issue is fixed, thanks!