Skip to content

Fix build #400

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Dec 21, 2020
Merged

Fix build #400

merged 10 commits into from
Dec 21, 2020

Conversation

Jean85
Copy link
Contributor

@Jean85 Jean85 commented Dec 16, 2020

This is an attempt to check the build status on master since it's failing in #399

@Jean85 Jean85 self-assigned this Dec 16, 2020
@Jean85 Jean85 mentioned this pull request Dec 16, 2020
@Jean85 Jean85 mentioned this pull request Dec 18, 2020
@Jean85
Copy link
Contributor Author

Jean85 commented Dec 18, 2020

I'm unable to reproduce the PHPStan failures locally, I even resorted to run the actions locally with act and I got not errors!

Any pointers?

@Yozhef
Copy link
Contributor

Yozhef commented Dec 18, 2020

I agree with you, too, I can not understand why the problem is shown here =(

@ste93cry
Copy link
Contributor

Given that the last commit on master is green with an older version of PHPStan, as a starting point I suggest you to try locking in the composer.json the version to something lower than the most recent and greater than the one of the that commit so that we can try to pinpoint at least the release that broke the build

@ondrejmirtes
Copy link

The class in question that cannot be found is: Sentry\SentryBundle\EventListener\ErrorListenerExceptionEvent. And it's defined in some really weird way using class aliases in: src/EventListener/ErrorListener.php

I don't know why it doesn't fail locally (doesn't for me either), but it has to be discoverable by PHPStan using this guide: https://phpstan.org/user-guide/discovering-symbols

It's entirely possible it worked thanks to some coincidence because of the order of loaded files. But in order to work 100% of the time, you need to follow what Discovering Symbols says about class aliases. You need to put files that define those aliases to bootstrapFiles. I'm pretty sure that will help.

@ondrejmirtes
Copy link

Let's try if it helps: #402

@ondrejmirtes
Copy link

Yep, it works.

But what's PHPStan actually telling you here is that if the user of this library adds it to their composer.json and tries to instantiate Sentry\SentryBundle\EventListener\ErrorListenerExceptionEvent, it won't work, because the autoloader doesn't know about it.

Yeah, if they first load ErrorListener and only after that they load ErrorListenerExceptionEvent, it will work, but it's pretty brittle to rely on that.

@ste93cry
Copy link
Contributor

ste93cry commented Dec 20, 2020

Thank you for putting the time to help us understanding what's wrong. Although the ErrorListenerExceptionEvent class is not meant to be used by third parties, but rather it's there just to support typehinting, what you said makes sense to me. Do you think that a better way to avoid any issue would be move the code with the class aliases to a dedicated bootstrap file that will be autoloaded by Composer? I'm not sure it makes sense given the reasoning for the existence of these aliases I wrote above, but I would still like to hear your opinion

@ondrejmirtes
Copy link

@ste93cry Yeah, definitely this commit could be entirely reverted d1b65aa and you could add an aliases.php file with all the class aliases and put it into autoload.files in composer.json. That way it would be picked up by PHPStan too.

@Jean85
Copy link
Contributor Author

Jean85 commented Dec 21, 2020

Thanks a lot @ondrejmirtes for solving this mistery for us! It was costing us a lot of wasted time!

@ste93cry
Copy link
Contributor

@Jean85 can you 🙏 update the PR with the changes needed to make it work so that we can merge and unblock all the other PRs?

@Jean85 Jean85 marked this pull request as ready for review December 21, 2020 21:34
@Jean85 Jean85 requested a review from ste93cry December 21, 2020 21:34
@ste93cry ste93cry merged commit 853c2a3 into master Dec 21, 2020
@ste93cry ste93cry deleted the fix-build-master branch December 21, 2020 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants