Skip to content
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

PHPStan interface mismatch #2887

Closed
calebdw opened this issue Nov 21, 2023 · 8 comments
Closed

PHPStan interface mismatch #2887

calebdw opened this issue Nov 21, 2023 · 8 comments

Comments

@calebdw
Copy link

calebdw commented Nov 21, 2023

Hello,

Running PHPStan on my project yields the following error:

image

Carbon: 2.71.0
PHPStan 1.10.43
Thanks!

@buffcode
Copy link

In the reversal commit phpstan/phpstan-src@d0c0938 of phpstan/phpstan-src@ad6703d the nullable types were removed.

before:

BuiltinMethodReflection::getReflection(): ?ReflectionMethod

after:

BuiltinMethodReflection::getReflection(): ReflectionMethod

Not sure if this was intended.

@kylekatarnls
Copy link
Collaborator

Because extending the macro class was the only way to support properly Carbon macro, even some patches in PHPStan updates can be breaking changes it and it's hard to be compatible with new version without dropping the previous versions (which if we proceed to fast also raises complains).

I'm open to pull-request that would fix this while still supporting PHPStan from 1.10.20 to 1.10.43.

Repository owner deleted a comment from Temepest74 Nov 21, 2023
@kylekatarnls
Copy link
Collaborator

Side note to people adding comments/reactions not helping fixing the issue.

As a open-source provided to you for free, there is no obligation for anyone to immediately jump and fix something. Mostly if the bug was introduced by another library, and mostly if it's not a core feature.

Carbon core feature is enhancing DateTime PHP class with human-friendly methods. The support of PHPStan analysis is a nice-to-have side-feature.

All you have via OSS out of the box is quite a miracle, but it's still not a reason to expect everything you need to get done by someone else. If you want it, you can get your hands dirty and craft the pull-request.

@buffcode
Copy link

See comment: phpstan/phpstan-src@d0c0938#r133136268

Hi, please note that I reverted this as a courtesy to nesbot/carbon package. You shouldn't be interested in this interface because it's not part of the backward compatibility promise: https://phpstan.org/developing-extensions/backward-compatibility-promise

It will be removed in the future.

Please open a discussion with your use-case and I'll guide you what to replace the usage with.

@kylekatarnls
Copy link
Collaborator

Hello, I won't personally invest time in this. If this get removed with no alternative and no one proposed another way to support analysis for the macro methods, then we'll just remove the PHPStan extension from Carbon, and we'll delegate that to whoever is interested in building a library for that.

I have to be a bit picky with what we support because every piece asked/added even when it's done by another volunteer contributor typically ends with maintenance burden on core team.

@buffcode
Copy link

@kylekatarnls Is it viable to extract this functionality into a separate package? This way it won't affect the core package and maintenance could (or could not) progress separately.

I'm not too much into the PHPStan internals and don't know, if this must reside in the nesbot/carbon package or could be supplied by a third-party package.

@kylekatarnls
Copy link
Collaborator

Yes actually that's the path I should have taken from the beginning because having it inside is adding constraint on version supported. With an external package, it could have more flexibility and even fix support for previously released version of both Carbon and PHPStan.

calebdw referenced this issue in phpstan/phpstan-src Nov 21, 2023
@calebdw
Copy link
Author

calebdw commented Nov 21, 2023

Closing as fixed (temporarily) via phpstan/phpstan-src#2762

@calebdw calebdw closed this as completed Nov 21, 2023
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

No branches or pull requests

3 participants