Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Migrate to static data providers using rector/rector #48668

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 1 commit into from
Feb 14, 2023

Conversation

OskarStark
Copy link
Contributor

@OskarStark OskarStark commented Dec 15, 2022

Q A
Branch? 5.4
Bug fix? no
New feature? no
Deprecations? no
Tickets #48281
License MIT
Doc PR n/a

@nicolas-grekas it can be executed by running:

tools/vendor/bin/rector process --config=tools/rector.php

Review commit by commit.
We need to check now where we use object context in static providers and fix them manually, an maybe merge them manually, unmerge them and apply rector one by one to every branch.

Copy link
Member

@GromNaN GromNaN left a comment

Choose a reason for hiding this comment

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

This is huge 😃

Some abstract test classes are extended in other packages, including packages external to symfony/*, they are covered by our BC policy. Changing the signature of an abstract method to make it static is a breaking change.

We need to update them, but I don't know if that is possible in a backward compatible way.

@OskarStark
Copy link
Contributor Author

Exactly, I don't know either 🤨

@OskarStark
Copy link
Contributor Author

Maybe we can copy the AbstractTestCases and deprecate the old ones, the new ones then switch to the static dataProviders, but are basically the same.

@nicolas-grekas @stof would this work for you?

In the Symfony codebase itself we then use the not deprecated class and bump the requirements in composer.json.

@OskarStark OskarStark force-pushed the static-data-providers-rector branch from d2a196c to 0609d48 Compare December 20, 2022 07:36
@OskarStark
Copy link
Contributor Author

I excluded the abstract test cases for now in b48c5d8

OskarStark added a commit to OskarStark/symfony that referenced this pull request Dec 20, 2022
nicolas-grekas added a commit that referenced this pull request Dec 22, 2022
This PR was squashed before being merged into the 5.4 branch.

Discussion
----------

Use static methods inside data providers

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | n/a
| License       | MIT
| Doc PR        | n/a

refs #48668

follows
* #48625

Commits
-------

9a18048 Use static methods inside data providers
@alexandre-daubois
Copy link
Member

Would that help to create a few PRs aiming to refactor data providers using $this to ease their transition to static ones?

@OskarStark
Copy link
Contributor Author

Would that help to create a few PRs aiming to refactor data providers using $this to ease their transition to static ones?

Yes, this work needs to be done manually anyway, so we can do it in smaller PRs, thanks

fabpot added a commit that referenced this pull request Jan 15, 2023
… providers (alexandre-daubois)

This PR was merged into the 5.4 branch.

Discussion
----------

[Tests] Remove `$this` occurrences in future static data providers

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes-ish
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | Easing #48668 (comment)
| License       | MIT
| Doc PR        | _NA_

Commits
-------

6fb7cb9 [Tests] Remove `$this` occurrences in future static data providers
@OskarStark OskarStark force-pushed the static-data-providers-rector branch from 0609d48 to 28aee0b Compare January 16, 2023 07:36
@OskarStark
Copy link
Contributor Author

@alexandre-daubois I rebased this PR after your

was merged 👍

nicolas-grekas added a commit that referenced this pull request Feb 1, 2023
… future static data providers (alexandre-daubois)

This PR was merged into the 5.4 branch.

Discussion
----------

[Tests] New iteration of removing `$this` occurrences in future static data providers

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes-ish
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | Easing #48668 (comment)
| License       | MIT
| Doc PR        | _NA_

Follow-up of #48980

Commits
-------

1386ac2 [Tests] New iteration of removing `$this` occurrences in future static data providers
symfony-splitter pushed a commit to symfony/http-kernel that referenced this pull request Feb 1, 2023
… future static data providers (alexandre-daubois)

This PR was merged into the 5.4 branch.

Discussion
----------

[Tests] New iteration of removing `$this` occurrences in future static data providers

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes-ish
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | Easing symfony/symfony#48668 (comment)
| License       | MIT
| Doc PR        | _NA_

Follow-up of #48980

Commits
-------

1386ac2e81 [Tests] New iteration of removing `$this` occurrences in future static data providers
symfony-splitter pushed a commit to symfony/security-core that referenced this pull request Feb 1, 2023
… future static data providers (alexandre-daubois)

This PR was merged into the 5.4 branch.

Discussion
----------

[Tests] New iteration of removing `$this` occurrences in future static data providers

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes-ish
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | Easing symfony/symfony#48668 (comment)
| License       | MIT
| Doc PR        | _NA_

Follow-up of #48980

Commits
-------

1386ac2e81 [Tests] New iteration of removing `$this` occurrences in future static data providers
symfony-splitter pushed a commit to symfony/security-http that referenced this pull request Feb 1, 2023
… future static data providers (alexandre-daubois)

This PR was merged into the 5.4 branch.

Discussion
----------

[Tests] New iteration of removing `$this` occurrences in future static data providers

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes-ish
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | Easing symfony/symfony#48668 (comment)
| License       | MIT
| Doc PR        | _NA_

Follow-up of #48980

Commits
-------

1386ac2e81 [Tests] New iteration of removing `$this` occurrences in future static data providers
@alexandre-daubois
Copy link
Member

@TomasVotruba definitely, will comment your issue on my next iteration! 👍

nicolas-grekas added a commit that referenced this pull request Feb 10, 2023
…e-daubois)

This PR was merged into the 5.4 branch.

Discussion
----------

[Tests] Migrate tests to static data providers

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes-ish
| New feature?  | no
| Deprecations? | no
| Tickets       | Continuing #48668 (comment)
| License       | MIT
| Doc PR        | _NA_

This is yet another PR to continue the manual work needed for the  migration of data providers to static ones.
I also took the opportunity to pass a few `static::` to `self::` calls, as pointed out by Nicolas in this comment: #49244 (comment)

cc `@OskarStark` 👋

Commits
-------

3b8b070 [Tests] Migrate tests to static data providers
symfony-splitter pushed a commit to symfony/web-profiler-bundle that referenced this pull request Feb 10, 2023
…e-daubois)

This PR was merged into the 5.4 branch.

Discussion
----------

[Tests] Migrate tests to static data providers

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes-ish
| New feature?  | no
| Deprecations? | no
| Tickets       | Continuing symfony/symfony#48668 (comment)
| License       | MIT
| Doc PR        | _NA_

This is yet another PR to continue the manual work needed for the  migration of data providers to static ones.
I also took the opportunity to pass a few `static::` to `self::` calls, as pointed out by Nicolas in this comment: symfony/symfony#49244 (comment)

cc `@OskarStark` 👋

Commits
-------

3b8b07037b [Tests] Migrate tests to static data providers
@OskarStark OskarStark force-pushed the static-data-providers-rector branch from 2242a61 to acdd54c Compare February 10, 2023 18:37
@OskarStark
Copy link
Contributor Author

Rebased after #49288

@nicolas-grekas
Copy link
Member

There are some remaining failures to fix :)

@OskarStark
Copy link
Contributor Author

I know I need to exclude the abstract test case from notifier, we need to fix this later in a BC way and some others.

I am on it and ofc @alexandre-daubois 👍🏻

I think we can finish this one next week

@OskarStark
Copy link
Contributor Author

@TomasVotruba here is another issue we are facing at our codebase

@alexandre-daubois
Copy link
Member

I am on it and ofc @alexandre-daubois 👍🏻

I hope to send the next (and I hope the last 🤞) one by tomorrow or so!

@TomasVotruba
Copy link
Contributor

@OskarStark I'm on it 👍

nicolas-grekas added a commit that referenced this pull request Feb 13, 2023
…e-daubois)

This PR was merged into the 5.4 branch.

Discussion
----------

[Tests] Migrate tests to static data providers

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes-ish
| New feature?  | no
| Deprecations? | no
| Tickets       | Continuing #48668 (comment)
| License       | MIT
| Doc PR        | _NA_

This PR should take care of remaining errors of #48668.

cc `@OskarStark`

Commits
-------

dea43a6 [Tests] Migrate tests to static data providers
@nicolas-grekas
Copy link
Member

rebase unlocked

@OskarStark OskarStark force-pushed the static-data-providers-rector branch from 41d5ff4 to 3fa5450 Compare February 13, 2023 19:28
@OskarStark
Copy link
Contributor Author

Rebased and excluded Mailer and Notifier tests which use an abstract test case from /Test/ directory

@OskarStark
Copy link
Contributor Author

OskarStark commented Feb 13, 2023

@nicolas-grekas I would propose to keep and upmerge the rector config, as we need to exclude the same paths in the upper branches too 🤷‍♂️ we can remove /tools directory when merging is done, WDYT?

@nicolas-grekas nicolas-grekas force-pushed the static-data-providers-rector branch from 770206a to 2ec54e9 Compare February 14, 2023 08:04
@nicolas-grekas
Copy link
Member

Thank you @OskarStark.

@nicolas-grekas nicolas-grekas merged commit 8ca9e51 into symfony:5.4 Feb 14, 2023
@nicolas-grekas
Copy link
Member

nicolas-grekas commented Feb 14, 2023

For Test folders that we currently skipped, I think it's fine moving them to static methods.
Yes, this is a BC break, but building on those is going to be rare since building a private Notifier, Messenger, Translation bridge or Security strategy is not very common. It's also not something that will break any prod.
Can you please work on a PR that fixes them also? Don't forget to bump the min version in composer.json files of course.

@alexandre-daubois
Copy link
Member

Would love to help on this! Would this kind of PR also target 5.4?

@nicolas-grekas
Copy link
Member

Yes please

@OskarStark OskarStark deleted the static-data-providers-rector branch February 14, 2023 09:55
@OskarStark
Copy link
Contributor Author

I will run the rector again against 5.4, let's see what's left todo then @alexandre-daubois 👍

nicolas-grekas added a commit that referenced this pull request Feb 17, 2023
…tic (OskarStark, alexandre-daubois)

This PR was merged into the 5.4 branch.

Discussion
----------

[BC Break] Make data providers for abstract test cases static

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | Refs #48668
| License       | MIT
| Doc PR        | -

Follows #48668 (comment)

### Todos
* [x] Bump min version in `composer.json` Notifier `@OskarStark`
* [x] Bump min version in `composer.json` Translation `@OskarStark`
* [x] Bump min version in `composer.json` Mailer `@OskarStark`
* [x] Bump min version in `composer.json` Security `@OskarStark` - _nothing todo_
* [x] document BC break in CHANGELOG files Notifier `@OskarStark`
* [x] document BC break in CHANGELOG files Translation `@OskarStark`
* [x] document BC break in CHANGELOG files Mailer `@OskarStark`
* [x] document BC break in CHANGELOG files Security `@OskarStark`
* [x] document BC break in UPGRADE files Notifier `@OskarStark`
* [x] document BC break in UPGRADE files Translation `@OskarStark`
* [x] document BC break in UPGRADE files Mailer `@OskarStark`
* [x] document BC break in UPGRADE files Security `@OskarStark`
* [x] remove $this in static methods `@alexandre`-daubois
* [x] make tests green

Commits
-------

c444a43 [Translation][Mailer] Convert `$this` calls to static ones in data providers
77c8444 [BC Break] Make data providers for abstract test cases static
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants