pest icon indicating copy to clipboard operation
pest copied to clipboard

[Bug]: Typings for Arch tests seems to be off

Open pataar opened this issue 1 year ago • 5 comments

What Happened

Preset doesn't seem to be available, Phpstan doesn't like that either:

image

The tests work correctly though.

How to Reproduce

  1. Add a testfile named Arch.php
  2. Add the following contents:
<?php
/**
* PHP Preset
*/
arch()
	->preset()
	->php();
  1. Notice the errors above in Phpstorm

Sample Repository

No response

Pest Version

3.0.6

PHP Version

8.3.x

Operation System

macOS

Notes

Using the latest Phpstorm

pataar avatar Sep 12 '24 10:09 pataar

It's certainly nullable, Check here => https://github.com/pestphp/pest-plugin-arch/blob/0a27e55a270cfe73d8cb70551b91002ee2cb64b0/src/Autoload.php#L18

Also in my PhpStorm: Screenshot 2024-09-13 at 6 28 04 PM

You probably need to composer update, or restart PhpStorm.

It's always a good idea to check the code in the repo before placing a bug report. You can click that little pencil icon and it will jump to the source code for you to look at.

CamKem avatar Sep 13 '24 08:09 CamKem

@CamKem Ah, my bad. Switched branches but didn't ran composer install again. The other issue still persists though.

pataar avatar Sep 13 '24 12:09 pataar

@CamKem Ah, my bad. Switched branches but didn't ran composer install again. The other issue still persists though.

You are correct, the TestCall needs to be updated to @mixin the place the preset method is stored or reference a @method for preset. I'm going to do a PR tomorrow for it.

CamKem avatar Sep 18 '24 12:09 CamKem

This was closed by commit 7cd42aafd805a02526424428e4f1ad248d2ef327.

CamKem avatar Sep 29 '24 06:09 CamKem

I still have this issue even with this mentioned commit...

rcerljenko avatar Oct 16 '24 05:10 rcerljenko

Seems like this has been fixed, I am also not able to reproduce it.

If it is still an issue, don't hesitate to write and I'll re-open.

olivernybroe avatar Jul 26 '25 03:07 olivernybroe

@olivermybroe This still seems to be an issue for me. It looks like phpstan does not parse union types separated by pipe |. It looks like it works correctly if they are split into a separate @mixin tag each:

src/PendingCalls/TestCall.php:

/**
 * @internal
 *
 * @mixin HigherOrderCallables
 * @mixin TestCase
 * @mixin Testable
 */

PHP

8.3.26

Pest

4.1.0

PHPStan

2.1.31

Operating System

Ubuntu

Test case

Same as above

biinari avatar Oct 13 '25 20:10 biinari

@biinari could you open a new issue about that? This issue was specifically about typings showing up wrongly in PHPStorm not about PHPStan, thanks!

olivernybroe avatar Oct 14 '25 09:10 olivernybroe

Ah my mistake, I skimmed straight past this being about PHPStorm originally. I'll open a new issue.

Side note: it's a shame neither PHPStorm nor PHPStan seems to document what they support for multiple mixins on the same class.

biinari avatar Oct 15 '25 03:10 biinari

Yeah, the problem is phpdocs doesn't really have a proper standard to them. So it's kinda what the tools wanna do themselves.

olivernybroe avatar Oct 15 '25 12:10 olivernybroe