Skip to content

Conversation

@Ocramius
Copy link
Contributor

@Ocramius Ocramius commented Apr 2, 2020

This patch introduces a few improvements on the codebase:

  • adds vimeo/psalm minimal tests (not testing sources, just declared API)
  • adds @psalm-pure and @psalm-immutable to enumerable types, allowing usage of Enum in functionally pure (type-checked) contexts
  • add better type declarations where refinements are possible (such as non-empty-string vs string, where applicable)
  • removes some exported files from dist package (noticed because I wanted to exclude psalm.xml from exports)

I kept very conservative on type definitions: I wanted to restrict also on ::has() and ::get(), but that would introduce downstream issues, such as ::has($unknown) failing due to missing upfront assertions.

Note: this is compatible with #138 too.

@@ -1,75 +1,76 @@
sudo: false
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what happened here: was the file commited with \r\n before?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea how this happened


# run benchmarks to make sure they are working fine
- php vendor/bin/phpbench run --no-interaction --revs=1 --retry-threshold=100
- vendor/bin/psalm
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only addition here

@Ocramius Ocramius force-pushed the feature/pure-enumerable branch 2 times, most recently from 5d80683 to c7d61a5 Compare April 2, 2020 11:29
@Ocramius
Copy link
Contributor Author

Ocramius commented Apr 2, 2020

Succeeded: not sure why CI failed to report status.

https://travis-ci.org/github/marc-mabe/php-enum/builds/670092398

@Ocramius Ocramius force-pushed the feature/pure-enumerable branch from c7d61a5 to c2c18a6 Compare April 2, 2020 11:51
@Ocramius
Copy link
Contributor Author

Ocramius commented Apr 2, 2020

@marc-mabe
Copy link
Owner

Thanks @Ocramius,
I highly appreciate your contribution 👍

@marc-mabe marc-mabe merged commit 93b7bbb into marc-mabe:master Apr 5, 2020
@marc-mabe marc-mabe added this to the 4.3.0 milestone Apr 5, 2020
@Ocramius
Copy link
Contributor Author

Ocramius commented Apr 5, 2020 via email

@Ocramius Ocramius deleted the feature/pure-enumerable branch April 22, 2020 11:59
@marc-mabe
Copy link
Owner

Hi @Ocramius,
I have created an RC release now including generic types.
Please check if everything works as expected.

@Ocramius
Copy link
Contributor Author

Trying it out, thanks!

@Ocramius
Copy link
Contributor Author

Tried on a downstream codebase that relies on vimeo/psalm: seems to be all good, although I didn't add any specific types that rely on the new generics :-)

@marc-mabe
Copy link
Owner

marc-mabe commented Apr 26, 2020

Thanks!
I'll try that on two projects using PHPStan this week and if everything is fine I create a stable release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants