Skip to content

3.next#1097

Merged
ADmad merged 7 commits into
3.xfrom
3.next
Jul 19, 2026
Merged

3.next#1097
ADmad merged 7 commits into
3.xfrom
3.next

Conversation

@ADmad

@ADmad ADmad commented Jul 19, 2026

Copy link
Copy Markdown
Member

No description provided.

dereuromark and others added 7 commits June 5, 2026 16:34
ControllerAllCommand, ModelAllCommand and TemplateAllCommand declared their
wrapped subcommand as a non-nullable typed property and assigned it in
initialize(). On CakePHP 5.4 BaseCommand::run() builds the option parser
before calling initialize(), so buildOptionParser() reads the property while
it is still uninitialized:

    Typed property Bake\Command\ControllerAllCommand::$controllerCommand
    must not be accessed before initialization

Move the assignment into the constructor so the subcommand is available
regardless of the lifecycle ordering. The override of initialize() is dropped;
the inherited BakeCommand::initialize() (table-locator fallback) still runs.
TemplateAllCommand never read the property in buildOptionParser(), so its
breakage was latent; the change keeps the three commands consistent.
The constructor approach broke on cakephp/cakephp 5.1, where BaseCommand has
no constructor yet (Error: Cannot call constructor via parent::__construct()).
Bake supports ^5.1.

Assign the wrapped subcommand lazily in buildOptionParser() with ??= instead.
buildOptionParser() always runs before execute() on every supported version,
and on 5.4 it runs before initialize() too, so the property is always set
before use regardless of lifecycle ordering. ??= is safe on an uninitialized
typed property and idempotent across repeated parser builds.
…bcommand

Assign AllCommand subcommands in the constructor (fix uninitialized typed property on CakePHP 5.4)
* Generate enums with EnumLabelTrait

* update phpstan ignores
@ADmad
ADmad merged commit 6694403 into 3.x Jul 19, 2026
16 checks passed
@ADmad
ADmad deleted the 3.next branch July 19, 2026 19:00
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