-
-
Notifications
You must be signed in to change notification settings - Fork 166
Make Mutator::getDefinition
return type non-nullable
#1958
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add tests to make sure this change works as expected?
We are going to extract `Mutator` interface to a separate package, so other developers can require `infection/mutator` and use only that small package with interface(s) to write their custom mutators. And we 100% must require write definitions for their mutators. If we allow null, developers will simply return null which we are not interested in. For example Rector does the same - Rector requires providing description / diff / docs for their "rectors". It's a win-win - immediately clear what class is going to do. The same is for us. Later, even Remedies (3rd parameter will be non-nullable), but this is another story.
adc6837
to
f50582e
Compare
theofidry
approved these changes
May 5, 2024
github-merge-queue bot
referenced
this pull request
in Lendable/json-serializer
May 28, 2024
[](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [infection/infection](https://togithub.com/infection/infection) | `^0.28.1` -> `^0.29.0` | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>infection/infection (infection/infection)</summary> ### [`v0.29.0`](https://togithub.com/infection/infection/blob/HEAD/CHANGELOG.md#0290-2024-05-28) [Compare Source](https://togithub.com/infection/infection/compare/0.28.1...0.29.0) [Full Changelog](https://togithub.com/infection/infection/compare/0.28.1...0.29.0) **Added:** - Support custom mutators by [@​vss414](https://togithub.com/vss414) in [https://github.com/infection/infection/pull/1686](https://togithub.com/infection/infection/pull/1686) - Custom mutator generator by [@​maks-rafalko](https://togithub.com/maks-rafalko) in [https://github.com/infection/infection/pull/1969](https://togithub.com/infection/infection/pull/1969) Read about how to create custom mutators: https://infection.github.io/guide/custom-mutators.html **Changed:** - Move `Infection\Mutator\Mutator` to a separate package by [@​maks-rafalko](https://togithub.com/maks-rafalko) in [https://github.com/infection/infection/pull/1963](https://togithub.com/infection/infection/pull/1963) - Make `Mutator::getDefinition` return type non-nullable by [@​maks-rafalko](https://togithub.com/maks-rafalko) in [https://github.com/infection/infection/pull/1958](https://togithub.com/infection/infection/pull/1958) - Enable Rector's `AddCoversClassAttributeRector` rule by [@​maks-rafalko](https://togithub.com/maks-rafalko) in [https://github.com/infection/infection/pull/1962](https://togithub.com/infection/infection/pull/1962) - Mention Discord instead of Slack in issue github template by [@​staabm](https://togithub.com/staabm) in [https://github.com/infection/infection/pull/1951](https://togithub.com/infection/infection/pull/1951) - test: Force mutators to include remedies by [@​theofidry](https://togithub.com/theofidry) in [https://github.com/infection/infection/pull/1954](https://togithub.com/infection/infection/pull/1954) - Use the latest composer 2 to prevent issue with incompatibility for Box and composer 2.1 by [@​maks-rafalko](https://togithub.com/maks-rafalko) in [https://github.com/infection/infection/pull/1957](https://togithub.com/infection/infection/pull/1957) - Use the latest v1 test checker action by [@​maks-rafalko](https://togithub.com/maks-rafalko) in [https://github.com/infection/infection/pull/1960](https://togithub.com/infection/infection/pull/1960) - Upgrade Rector and fix new issues by [@​maks-rafalko](https://togithub.com/maks-rafalko) in [https://github.com/infection/infection/pull/1961](https://togithub.com/infection/infection/pull/1961) - Use new PHP-CS-Fixer with parallelization by [@​maks-rafalko](https://togithub.com/maks-rafalko) in [https://github.com/infection/infection/pull/1964](https://togithub.com/infection/infection/pull/1964) - Remove our own custom FQCN visitor as we already use php-parser's `NameResolver` visitor by [@​maks-rafalko](https://togithub.com/maks-rafalko) in [https://github.com/infection/infection/pull/1967](https://togithub.com/infection/infection/pull/1967) - Replace deprecated constant `NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN` with `NodeVisitor::DONT_TRAVERSE_CURRENT_AND_CHILDREN` by [@​maks-rafalko](https://togithub.com/maks-rafalko) in [https://github.com/infection/infection/pull/1968](https://togithub.com/infection/infection/pull/1968) - Remove our own `ParentConnectorVisitor` and use `nikic-phpparser`'s one by [@​maks-rafalko](https://togithub.com/maks-rafalko) in [https://github.com/infection/infection/pull/1970](https://togithub.com/infection/infection/pull/1970) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/Lendable/json-serializer). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zNzcuOCIsInVwZGF0ZWRJblZlciI6IjM3LjM3Ny44IiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIiwibGFiZWxzIjpbXX0=--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We are going to extract
Mutator
interface to a separate package (see #1686), so other developers can requireinfection/mutator
and use only that small package with interface(s) to write their custom mutators.And we 100% must require write definitions for their mutators. If we allow null, developers will simply return null which we are not interested in.
For example Rector does the same - Rector requires providing description / diff / docs for their "rectors". It's a win-win - immediately clear what class is going to do.
The same is for us. Later, even Remedies (3rd parameter) will be non-nullable, but this is another story.