functional-php / fantasy-land

Specification for interoperability of common algebraic structures in PHP
BSD 3-Clause "New" or "Revised" License
34 stars 10 forks source link

PHPStan fails to compile #22

Open AlexanderAllen opened 3 weeks ago

AlexanderAllen commented 3 weeks ago

I've been asserting the functor laws locally for fun and I am observing that PHPStan fails to compile on some generics.

For example, FunctionalPHP\FantasyLand\Functor: https://phpstan.org/r/fef7dc4c-8448-4c36-9e25-92f78145b7fe

I haven't tested all functors or laws yet (in the process of doing so), but thought I would make a note of it.

If I manage to assert laws and generic accuracy for all the objects listed by this spec, I'll issue a PR.

I really want to use this spec as opposed to reinventing the wheel (who wants to do that), but I do not want to implement this until the generics are rock solid.

AlexanderAllen commented 3 weeks ago

Another example that will fail to compile (maybe that particular callable syntax is no longer supported) is in #16.

krtek4 commented 2 weeks ago

Hi,

First of all, thank you for your interest in this repository :)

PHPStan is not a "compiler" so it doesn't "compile" anything. Secondly, the errors are in the doc block, so it's more of a documentation issue.

The last real commit on this project is 4 years ago, there's been a lot of new version of PHP since then and also a lot of advance.

As far as I remember, the doc block has been written like that because there was no better way to express things at the time. I don't know if we could do better now, I have written a single line of PHP in the last 5 years.

I also doubt the types defined here could be of used in any recent PHP project. I would recommend you find a more recent library implementing functional primitives l. Sadly I can't point you in any direction.

This being said, if you're willing to change the doc block to make PHPStan happy I'll happily merge the PR.

Cheers