Skip to content

Conversation

@mttsch
Copy link
Contributor

@mttsch mttsch commented Aug 9, 2025

No description provided.

@TomasVotruba
Copy link
Member

Thanks. Could you resolve conflicts?

@mttsch
Copy link
Contributor Author

mttsch commented Aug 9, 2025

Will do so tomorrow for all of my PHP 8.5 PRs that need conflict resolution.

$rectorConfig->ruleWithConfiguration(
RenameClassConstFetchRector::class,
[
new RenameClassAndConstFetch('PDO', 'DBLIB_ATTR_CONNECTION_TIMEOUT', 'Pdo\Dblib', 'ATTR_CONNECTION_TIMEOUT'),
Copy link
Member

Choose a reason for hiding this comment

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

downgrade rule is needed for this, to downgrade constant to previous available constant, since the constant exists since php 8.4

You can see example of it

https://github.com/rectorphp/rector-downgrade-php/blob/abb7e470dba7afed229f82ac0ecea617b9ffc6ec/rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php#L23

Copy link
Contributor Author

@mttsch mttsch Aug 10, 2025

Choose a reason for hiding this comment

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

@samsonasik Does this really need a new rector implementation or can't the inverse RenameClassAndConstFetch config be used in config/set/downgrade-php85.php?

PS: I just saw some other rule sets also using "normal" rector rename rules, thus I will do the same.

Copy link
Member

Choose a reason for hiding this comment

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

when downgrading code, that exists in old and removed later, or only exists in future php version, the snippet code generate can be used, eg this example

https://github.com/rectorphp/rector-downgrade-php/blob/main/rules/DowngradePhp72/snippet/isatty_closure.php.inc

Then use inline code parser to cover that

https://github.com/rectorphp/rector-downgrade-php/blob/9a127bbd3442ce88d4953f8b65f18192a4fd517a/rules/DowngradePhp72/Rector/FuncCall/DowngradeStreamIsattyRector.php#L148

Copy link
Contributor Author

@mttsch mttsch Aug 10, 2025

Choose a reason for hiding this comment

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

@samsonasik Sadly, I can't connect your comment to this PR but I created rectorphp/rector-downgrade-php#304 where we can tackle this discussion and if that solution has issues relating to your example from the previous comment.

Copy link
Member

Choose a reason for hiding this comment

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

Once code downgraded, the code should keep working even on the future php version is met, eg, downgraded from 8.1 to 8.0, when downgraded code opened in php 8.1, it should keep working.

Php is unfortunatelly not semver, so some tweak for this kind of usage seems needed, like if exists check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am unsure exactly whether rectorphp/rector-downgrade-php#304 meets these requirements. If it does not, someone else should tackle this topic then, please. At this point in time, I do not want to spend my time on writing code to downgrade PHP code.

Copy link
Member

Choose a reason for hiding this comment

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

It's the same rules, just inverted renames.

@TomasVotruba
Copy link
Member

Let's merge this as it is, as downgrade of pdo is quite a niche feature. We can keep those separately.

Thanks for the feature 👌

@TomasVotruba TomasVotruba merged commit 3cd5e4a into rectorphp:main Aug 11, 2025
47 checks passed
@mttsch mttsch deleted the feature/php85-deprecated-pdo-constants-methods branch August 11, 2025 10:02
@github-actions
Copy link
Contributor

This pull request has been automatically locked because it has been closed for 150 days. Please open a new PR if you want to continue the work.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 11, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants