Add cakephp54 rector ruleset#408
Merged
Merged
Conversation
The 5.4 migration guide already tells users to run
bin/cake upgrade rector --rules cakephp54 <path>
but no such ruleset existed, so the command failed.
Covers the two mechanically automatable 5.4 changes:
- Console helpers moved from the Cake\Command\Helper namespace to
Cake\Console\Helper. The core keeps class_alias shims, so this is a
plain class rename.
- SelectQuery::disableHydration() is deprecated in favor of the new
Table::unhydratedFind(), which returns an UnhydratedSelectQuery whose
static type matches the array result shape. The new
DisableHydrationToUnhydratedFindRector collapses a
find()->...->disableHydration() chain into unhydratedFind()->...,
and skips receivers that are not a Table as well as detached queries
where the originating find() call is not part of the chain.
LordSimal
approved these changes
Jul 22, 2026
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
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.
The 5.4 migration guide already tells users to run
but there was no such ruleset, so the command failed. This adds it.
What is automated
Two of the 5.4 changes are mechanically automatable:
Console helper namespace move.
Cake\Command\Helper\{Banner,Progress,Table,Tree}Helperare deprecated in favor ofCake\Console\Helper\*. The core keepsclass_aliasshims, so a plainRenameClassRectormapping is enough.SelectQuery::disableHydration()->Table::unhydratedFind(). NewDisableHydrationToUnhydratedFindRectorcollapses the chain:It walks down the fluent chain to the originating
find()call, so intermediate calls are preserved. It deliberately skips:Cake\ORM\Table(associations have nounhydratedFind()counterpart)$query->disableHydration()where thefind()call is not part of the same chainThose cases still need a manual look, since the replacement returns a different class (
UnhydratedSelectQuery).Not automated (deliberately)
EventAwareApplicationInterface::pluginEvents()is deprecated but still declared on the interface in 5.4, so removing the implementation would break the contract until 6.0. This belongs in thecakephp60set.Mailer::$nameis deprecated as unused; removing a property an app might still read is not safe to do blind.HasMany/BelongsToManydefault strategy change (select->subquery) could be pinned back with an opt-in BC ruleset that injects'strategy' => 'select'. Happy to add that as a follow-up if wanted, but it is opinionated enough that it should not be in the default set.BaseCommand::initialize()ordering, subcommand token rejection,Number::parseFloat()returning null, deferredafterSaveCommit/afterDeleteCommit, cross-table entity assertions, the FormHelperhiddenattribute) with no PHP-level rewrite.Notes
RectorCommandTest::testApply54plus original/upgraded app fixtures cover the set end to end; the rule itself has focused fixtures including two skip cases.RenameClassRectorbehavior in this repo, matching thecakephp53fixture.FileRenameCommandTest::testTemplateserrors locally on5.xas well, unrelated to this change.