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

Add a Doctrine DBAL 2.11 Rule Set #4517

Merged
merged 4 commits into from
Oct 31, 2020

Conversation

chrisguitarguy
Copy link
Contributor

See /~https://github.com/doctrine/dbal/blob/master/UPGRADE.md#upgrade-to-211

Lots of changes in DBAL 2.11, but I don't think all of them can be handled by rector. I also fixed a few things in the 3.0 rule set.

Questions:

  • the MasterSlaveConnection -> PrimaryReadReplicaConnection includes renaming some arguments in DriverManager::getConnection's array. Are there pre-existing rectors that can handle something like that?
  • Unsure on the order which these are executed in practice (in order defined?). Some classes are renamed and have methods that changed (DriverException for instance)
  • Really questioning the wisdom of including the fetchAll -> fetchAllAssociative rename -- upgrade guide mentions that quite a few fetchAll* methods were added, but the conneciton docblocks say fetchAll returns associative arrays. Statement docblocks are not clear, but PDO itself defaults to fetch both associative and numeric. Hard to say if this should be included.

@TomasVotruba
Copy link
Member

Hi,

thanks for your contribution 👍

  1. renaming args - I don't see any example in the markdown file, just lot of huge headlines.
    Could you share a diff example of what you mean?

  2. the order is by file, then by node level, e.g. namespace first, then class, then class method etc., then by the order of Rector rules in config. But that if e.g. class method gets renamed, the old names is still used in one single Rector run. So renaming method/classes does not break next rules that depend on the old name.

  3. Again, hard to guess what changed for me. Diff would help.

I'll merge current PR as it is, so we can keep it simple. Feel free to open a new one with addition changes.


Btw, I see there is dbal 4.0 released/planned? Do you think it would be useful to have upgrade set in Rector for 4.0 as well?

@@ -18,7 +19,7 @@
->call('configure', [[
RenameMethodRector::METHOD_CALL_RENAMES => inline_value_objects([
new MethodCallRename(
'DBAL\Platforms\AbstractPlatform',
'Doctrine\DBAL\Platforms\AbstractPlatform',
Copy link
Member

Choose a reason for hiding this comment

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

👍

@TomasVotruba TomasVotruba merged commit 341a322 into rectorphp:master Oct 31, 2020
@chrisguitarguy
Copy link
Contributor Author

renaming args - I don't see any example in the markdown file, just lot of huge headlines.
Could you share a diff example of what you mean?

Not a diff, but here's the relevant bit of the docs:

Screen Shot 2020-11-01 at 5 59 07 AM

the array keys changed from master -> primary, etc.

[RE: fetch*] Again, hard to guess what changed for me. Diff would help.

Take Doctrine\DBAL\Statement, in 2.10:

  $statement = $connection->executeQuery('SELECT ...');

- $rows = $statement->fetchAll(FetchMode::ASSOCIATIVE);
+ $rows = $statement->fetchAllAssociative();

Btw, I see there is dbal 4.0 released/planned? Do you think it would be useful to have upgrade set in Rector for 4.0 as well?

I don't think 3.X is out yet, so they may just be planning deprecations/removals for 4.X

@chrisguitarguy chrisguitarguy deleted the dbal_2.11 branch November 1, 2020 12:05
@chrisguitarguy
Copy link
Contributor Author

Actually, something like this RenameMethodCalledBasedOnParameter in cakephp might work for the Statement issue.

@TomasVotruba
Copy link
Member

Thanks for sharing. I see, let's take it step by step.

In DriverManager::getConnection(), you need to creata Rector rule that listens to Array_::class.
Then foreach it's keys and rename those 3 keys. It a good first rule issue.

Is that something you'd like to contribute?

If so, here is how you create a new rule. I can guide you on the pull-request.

TomasVotruba added a commit that referenced this pull request Jul 14, 2023
rectorphp/rector-src@9217e0d [ChangesReporting] Reuse defined errors vairable on ConsoleOutputFormatter (#4517)
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.

2 participants