Skip to content

Commit 6694403

Browse files
authored
Merge pull request #1097 from cakephp/3.next
3.next
2 parents 314d3aa + df1095e commit 6694403

21 files changed

Lines changed: 92 additions & 116 deletions

‎composer.json‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@
2222
"source": "https://github.com/cakephp/bake"
2323
},
2424
"require": {
25-
"php": ">=8.1",
26-
"brick/varexporter": "^0.6.0 || ^0.7.0",
27-
"cakephp/cakephp": "^5.1",
28-
"cakephp/twig-view": "^2.0.2",
25+
"php": ">=8.2",
26+
"brick/varexporter": "^0.7.0",
27+
"cakephp/cakephp": "^5.4",
28+
"cakephp/twig-view": "^2.1",
2929
"nikic/php-parser": "^5.0.0"
3030
},
3131
"require-dev": {
3232
"cakephp/cakephp-codesniffer": "^5.0.0",
3333
"cakephp/debug_kit": "^5.0.0",
34-
"phpunit/phpunit": "^10.5.40 || ^11.5.20 || ^12.2.4 || ^13.0"
34+
"phpunit/phpunit": "^11.5.20 || ^12.2.4 || ^13.0"
3535
},
3636
"autoload": {
3737
"psr-4": {

‎phpstan-baseline.neon‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
parameters:
22
ignoreErrors:
3-
-
4-
message: '#^Method Bake\\BakePlugin\:\:bootstrap\(\) has parameter \$app with generic interface Cake\\Core\\PluginApplicationInterface but does not specify its types\: TSubject$#'
5-
identifier: missingType.generics
6-
count: 1
7-
path: src/BakePlugin.php
8-
93
-
104
message: '#^Instanceof between mixed and Cake\\Chronos\\Chronos will always evaluate to false\.$#'
115
identifier: instanceof.alwaysFalse

‎src/BakePlugin.php‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ protected function discoverCommands(CommandCollection $commands): CommandCollect
109109
*
110110
* @param string $namespace The namespace classes are expected to be in.
111111
* @param string $path The path to look in.
112-
* @return array<string>
113-
* @phpstan-return array<string, class-string<\Bake\Command\BakeCommand>>
112+
* @return array<string, class-string<\Bake\Command\BakeCommand>>
114113
*/
115114
protected function findInPath(string $namespace, string $path): array
116115
{

‎src/Command/CellCommand.php‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ public function template(): string
5959
* Get template data.
6060
*
6161
* @param \Cake\Console\Arguments $arguments Arguments object.
62-
* @return array
63-
* @phpstan-return array<string, mixed>
62+
* @return array<string, mixed>
6463
*/
6564
public function templateData(Arguments $arguments): array
6665
{

‎src/Command/CommandCommand.php‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ public function template(): string
5757
* Get template data.
5858
*
5959
* @param \Cake\Console\Arguments $arguments Arguments object.
60-
* @return array
61-
* @phpstan-return array<string, mixed>
60+
* @return array<string, mixed>
6261
*/
6362
public function templateData(Arguments $arguments): array
6463
{

‎src/Command/ControllerAllCommand.php‎

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,6 @@ public static function defaultName(): string
4040
return 'bake controller all';
4141
}
4242

43-
/**
44-
* initialize
45-
*
46-
* @return void
47-
*/
48-
public function initialize(): void
49-
{
50-
parent::initialize();
51-
$this->controllerCommand = new ControllerCommand();
52-
}
53-
5443
/**
5544
* Execute the command.
5645
*
@@ -82,6 +71,11 @@ public function execute(Arguments $args, ConsoleIo $io): ?int
8271
*/
8372
protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionParser
8473
{
74+
// Assigned here (not initialize()) because on CakePHP 5.4+ the parser is built
75+
// before initialize() runs, while older versions build it after. ??= keeps it
76+
// safe under either ordering and idempotent across repeated calls.
77+
$this->controllerCommand ??= new ControllerCommand();
78+
8579
$parser = $this->controllerCommand->buildOptionParser($parser);
8680
$parser
8781
->setDescription('Bake all controller files with tests.')

‎src/Command/EnumCommand.php‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ public function template(): string
6161
* Get template data.
6262
*
6363
* @param \Cake\Console\Arguments $arguments The arguments for the command
64-
* @return array
65-
* @phpstan-return array<string, mixed>
64+
* @return array<string, mixed>
6665
*/
6766
public function templateData(Arguments $arguments): array
6867
{

‎src/Command/ModelAllCommand.php‎

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,6 @@ public static function defaultName(): string
4040
return 'bake model all';
4141
}
4242

43-
/**
44-
* initialize
45-
*
46-
* @return void
47-
*/
48-
public function initialize(): void
49-
{
50-
parent::initialize();
51-
$this->modelCommand = new ModelCommand();
52-
}
53-
5443
/**
5544
* Gets the option parser instance and configures it.
5645
*
@@ -59,6 +48,11 @@ public function initialize(): void
5948
*/
6049
protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionParser
6150
{
51+
// Assigned here (not initialize()) because on CakePHP 5.4+ the parser is built
52+
// before initialize() runs, while older versions build it after. ??= keeps it
53+
// safe under either ordering and idempotent across repeated calls.
54+
$this->modelCommand ??= new ModelCommand();
55+
6256
$parser = $this->modelCommand->buildOptionParser($parser);
6357
$parser
6458
->setDescription('Bake all model files with associations and validation.')

‎src/Command/SimpleBakeCommand.php‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ abstract public function template(): string;
5353
* Get template data.
5454
*
5555
* @param \Cake\Console\Arguments $arguments The arguments for the command
56-
* @return array
57-
* @phpstan-return array<string, mixed>
56+
* @return array<string, mixed>
5857
*/
5958
public function templateData(Arguments $arguments): array
6059
{

‎src/Command/TemplateAllCommand.php‎

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,6 @@ public static function defaultName(): string
3737
return 'bake template all';
3838
}
3939

40-
/**
41-
* initialize
42-
*
43-
* @return void
44-
*/
45-
public function initialize(): void
46-
{
47-
parent::initialize();
48-
$this->templateCommand = new TemplateCommand();
49-
}
50-
5140
/**
5241
* Execute the command.
5342
*
@@ -85,6 +74,11 @@ public function execute(Arguments $args, ConsoleIo $io): int
8574
*/
8675
protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionParser
8776
{
77+
// Assigned here (not initialize()) because on CakePHP 5.4+ the parser is built
78+
// before initialize() runs, while older versions build it after. buildOptionParser()
79+
// always runs before execute(), so this guarantees the subcommand is available there.
80+
$this->templateCommand ??= new TemplateCommand();
81+
8882
$parser = $this->_setCommonOptions($parser);
8983
$parser
9084
->setDescription('Bake all view template files.')

0 commit comments

Comments
 (0)