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

big refactor #17

Merged
merged 1 commit into from
May 7, 2024
Merged

big refactor #17

merged 1 commit into from
May 7, 2024

Conversation

Lctrs
Copy link
Contributor

@Lctrs Lctrs commented May 5, 2024

  • dropping support for PHP < 8.1.0
  • simplify phpdoc types, making Option the only source of truth for most methods
  • added some static analysis assert for Option#isSome() and Option#isNone() (closes Php storm flags unwrap method as unreachble statement #16)
  • added Option#inspect() and Option#filter() from their Rust counterparts
  • migrating from phpspec to PHPUnit
  • added a Makefile to help during development
  • added a coding standard via easy-coding-standard
  • added mutation testing coverage via infection
  • added some static analysis tests
  • modernize github actions setup
  • added dependabot config
  • upgrading all dependencies

@Lctrs
Copy link
Contributor Author

Lctrs commented May 5, 2024

@prewk sorry for the massive PR.

@Lctrs Lctrs force-pushed the v4 branch 2 times, most recently from cffebf0 to be1fbcb Compare May 5, 2024 23:07
@prewk
Copy link
Owner

prewk commented May 6, 2024

Awesome stuff, I'll look at it as soon as I can.

@prewk
Copy link
Owner

prewk commented May 6, 2024

Everything is great and you're probably right about $pass (their purpose was to fill a usability gap in PHP that arose often when I used the Options/Results), but since it's a breaking change I'd appreciate if you could do this in two commits:

  1. Everything but the $pass change
  2. The $pass removal

I'll bump (1) as a minor and (2) as a major.

Thanks for your hard work!

@Lctrs
Copy link
Contributor Author

Lctrs commented May 6, 2024

There are other breaking changes than the removal of pass properties, making the classes final is one of them (forgot to add that in the changelog).

@prewk
Copy link
Owner

prewk commented May 6, 2024

Alright, are you able to split that up as well?

If not, at the very least - fix #16 in one commit and the rest in another, would that be okay?

@Lctrs
Copy link
Contributor Author

Lctrs commented May 6, 2024

Will see what I can do.

* dropping support for `PHP < 8.1.0`
* simplify phpdoc types, making `Option` the only source of truth for most methods
* added some static analysis assert for `Option#isSome()` and `Option#isNone()` (closes prewk#16)
* added `Option#inspect()` and `Option#filter()` from their Rust counterparts
* migrating from phpspec to PHPUnit
* added a Makefile to help during development
* added a coding standard via `easy-coding-standard`
* added mutation testing coverage via `infection`
* added some static analysis tests
* modernize github actions setup
* added dependabot config
* upgrading all dependencies
@Lctrs Lctrs changed the title V4 big refactor May 6, 2024
@Lctrs
Copy link
Contributor Author

Lctrs commented May 6, 2024

@prewk I removed:

  • final classes
  • removal of $pass handling
  • Option#iter(): array -> Option#iter(): iterable

There should not be any BC left.

@prewk
Copy link
Owner

prewk commented May 6, 2024

Awesome! I'd love for the BC stuff as well, but as its own commit, then I can tag the commit appropriately afterwards 👍

@Lctrs
Copy link
Contributor Author

Lctrs commented May 6, 2024

Will do once this got merged.

@Lctrs
Copy link
Contributor Author

Lctrs commented May 6, 2024

Side note: we could integrate Roave/BackwardCompatibilityCheck to check if no BC has been introduced.

@prewk
Copy link
Owner

prewk commented May 6, 2024

Will do once this got merged.

Sure, if you prefer. I'll tag afterwards anyway so it doesn't really matter to me.

(I'll need to look through the changes a bit deeper before merging)

Side note: we could integrate Roave/BackwardCompatibilityCheck to check if no BC has been introduced.

Looks like a fun/great tool, not sure if this extremely slowly moving lib needs even more CI tooling around it tho :) Too much to maintain.

@Lctrs
Copy link
Contributor Author

Lctrs commented May 6, 2024

Sure, if you prefer. I'll tag afterwards anyway so it doesn't really matter to me.

It's just to be able to have newer CI setup with upgraded deps :)

@prewk
Copy link
Owner

prewk commented May 6, 2024

I see, that makes sense 👍

@prewk
Copy link
Owner

prewk commented May 6, 2024

The PHP 8.1 is nice but also BC 🤔 Maybe too hard to split out at this stage?

Maybe I should backpedal here and just do all your stuff with one big major bump instead..

@Lctrs
Copy link
Contributor Author

Lctrs commented May 6, 2024

Would say that dropping support for some PHP versions is not a BC for me, but some method's signatures do have changed. Even if they're still aligned with what was said in phpdoc, this can still be considered as BC.

@prewk
Copy link
Owner

prewk commented May 6, 2024

If I'm using this lib on a PHP version with dropped support, doing a minor update would be a BC I guess?

Anyway, sorry for making you do unnecessary work. Just throw it all in as your original intent was, I'll do one release with a major bump instead. (Still reviewing)

@prewk prewk self-assigned this May 6, 2024
Copy link
Owner

@prewk prewk left a comment

Choose a reason for hiding this comment

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

Solid stuff, learnt a lot about the state of the PHP ecosystem from reading your PR :)

Comment on lines +13 to +15
* @covers \Prewk\Option
* @uses \Prewk\Option\None
* @uses \Prewk\Option\Some
Copy link
Owner

Choose a reason for hiding this comment

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

question: What are these for? Coveralls?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, and for infection to know what to do.

tl;dr @covers is for code that should be included in coverage reports, and modified by infection. @uses is for code used by the tests, but to not be included in coverage reports, or modified by infection.

*/
function baz(None $none): void
{
}
Copy link
Owner

Choose a reason for hiding this comment

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

question: Can you TLDR how the static analysis stuff works? Does it help psalm somehow?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't help psalm, it just checks that our type assertions are correct.

Here, we check eg. if after Option#isSome() returns true, psalm understands that we have a Some instance by passing it to a function that expects a Some instance as its first arg. Since psalm doesn't generate an error for this, it means our type assertions are valid.

@Lctrs
Copy link
Contributor Author

Lctrs commented May 6, 2024

If I'm using this lib on a PHP version with dropped support, doing a minor update would be a BC I guess?

No, because composer won't even pickup the new version since it won't satisfy the defined php constraints.

Lctrs added a commit to Lctrs/result that referenced this pull request May 7, 2024
Same as prewk/option#17

* dropping support for `PHP < 8.1.0`
* simplify phpdoc types, making `Result` the only source of truth for most methods
* Turning `Ok<T, E>` into `Ok<T>` and `Err<T,E>` into `Err<E>`
* added some static analysis assert for `Result#isOk()` and `Result#isErr()`
* added a bunch of missing methods on `Result` from their Rust counterparts
* migrating from phpspec to PHPUnit
* added a Makefile to help during development
* added a coding standard via `easy-coding-standard`
* added mutation testing coverage via `infection`
* added some static analysis tests
* modernize github actions setup
* added dependabot config
* upgrading all dependencies
@Lctrs Lctrs mentioned this pull request May 7, 2024
Lctrs added a commit to Lctrs/result that referenced this pull request May 7, 2024
Same as prewk/option#17

* dropping support for `PHP < 8.1.0`
* simplify phpdoc types, making `Result` the only source of truth for most methods
* Turning `Ok<T, E>` into `Ok<T>` and `Err<T,E>` into `Err<E>`
* added some static analysis assert for `Result#isOk()` and `Result#isErr()`
* added a bunch of missing methods on `Result` from their Rust counterparts
* migrating from phpspec to PHPUnit
* added a Makefile to help during development
* added a coding standard via `easy-coding-standard`
* added mutation testing coverage via `infection`
* added some static analysis tests
* modernize github actions setup
* added dependabot config
* upgrading all dependencies
prewk pushed a commit to prewk/result that referenced this pull request May 7, 2024
Same as prewk/option#17

* dropping support for `PHP < 8.1.0`
* simplify phpdoc types, making `Result` the only source of truth for most methods
* Turning `Ok<T, E>` into `Ok<T>` and `Err<T,E>` into `Err<E>`
* added some static analysis assert for `Result#isOk()` and `Result#isErr()`
* added a bunch of missing methods on `Result` from their Rust counterparts
* migrating from phpspec to PHPUnit
* added a Makefile to help during development
* added a coding standard via `easy-coding-standard`
* added mutation testing coverage via `infection`
* added some static analysis tests
* modernize github actions setup
* added dependabot config
* upgrading all dependencies
@prewk prewk merged commit 8cce003 into prewk:master May 7, 2024
10 checks passed
@Lctrs Lctrs deleted the v4 branch May 7, 2024 18:17
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.

Php storm flags unwrap method as unreachble statement
2 participants