Fix incorrect @mixin in PendingAwaitablePage#183
Fix incorrect @mixin in PendingAwaitablePage#183DrWarpMan wants to merge 1 commit intopestphp:4.xfrom
Conversation
|
sorry, i was not able to understand the issue, can you re-create it and elaborate? |
|
@nunomaduro the issue is, I don't get typings/autocomplete in VS code with the PHP Intelephense extension. When you add If you wanted to do both (intersection), you'd write them on two separate lines: /**
* @mixin A
* @mixin B
*/
class MixedClassAnd I believe PendingAwaitablePage is extending both Webpage & AwaitableWebpage, which is an intersection, not "one or the other". So in the pest plugin browser code, you can either do: /**
* @mixin AwaitableWebpage
* @mixin Webpage
*/
class PendingAwaitablePageOr remove Webpage from it altogether, hence AwaitableWebpage already uses /**
* @mixin AwaitableWebpage
*/
class PendingAwaitablePageHere is a PHPStan playground example with Note: Even if we didn't consider my specific IDE problem with this, I think the Webpage mixin is still wrong inside the PendingAwaitablePage class and can be safely removed, cause it is already defined within the AwaitableWebpage class. |
|
VS code PHP Intelephense extension developers made a change on their side, so this is no longer an issue for me anyways. |
|
I just faced this issue too with Intelephense, but I don't think Pest's source code is at fault here. The PHPStan playground you linked is expected to produce an issue because class B doesn't have the Here's a working version: https://phpstan.org/r/e313887f-0cb6-4d7a-b787-059f2eea157e As Pest relies on this heavily internally and it passes in PHPStan, I'd suggest we'd reopen this issue in Intelephense or creating another one. |
I created this PR, and it's still open as you may have noticed. I'm not a maintainer there, so I don't know if it will be merged😅 And more importantly, that PR won't solve this issue. It would just enable the generation of a helper file which patches the |
I used the pre-release version of Intelephense and I no longer had problems there, EDIT: Ah I understand now.. Intelephense is closed source 😅, and the PR I linked wasn't even in Intelephense, sorry I got it all confused. Anyways, for the matter at hand:
But that's the point. That's exactly what is happening in Pest code. From the information I gathered, I believe this is what is happening: Solution? 2.) Use a mixin intersection |
|
@DrWarpMan Yeah, seems like it's not really correct that the mixin union is being used in this case..
All good, yeah I had an issue in Intelephense with the I just switched to the pre-release version of Intelephense too, great that it seems to be solved!🎉 That said, as you explained that the mixin tags here are not really correct, and I'd support you in opening another PR, otherwise I'm glad that the end result seems to work now at least :) |
Issue
I believe the
@mixindirective inside PendingAwaitablePage class is currently wrong.PendingAwaitablePage makes calls to AwaitableWebpage, not the Webpage class.
It's the AwaitableWebpage that makes calls to Webpage afterwards.
As far as I can see the order is: PendingAwaitablePage => AwaitableWebpage => Webpage
The currently incorrect
@mixin, is the reason for the following issue with VS Code PHP Intelephense extension. PHPStorm on the other hand seems to consider union mixin as intersection, so the problem does not occur there.Solution
AwaitableWebpage does have
@mixin Webpage, so we can just remove theWebpagefrom the mixin in PendingAwaitablePage class, since it's redundant anyway.