Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@
"source": "https://github.com/cakephp/bake"
},
"require": {
"php": ">=8.1",
"brick/varexporter": "^0.6.0 || ^0.7.0",
"cakephp/cakephp": "^5.1",
"php": ">=8.2",
"brick/varexporter": "^0.7.0",
"cakephp/cakephp": "dev-5.next as 5.4.0",
"cakephp/twig-view": "^2.0.2",
"nikic/php-parser": "^5.0.0"
},
"require-dev": {
"cakephp/cakephp-codesniffer": "^5.0.0",
"cakephp/debug_kit": "^5.0.0",
"phpunit/phpunit": "^10.5.40 || ^11.5.20 || ^12.2.4 || ^13.0"
"phpunit/phpunit": "^11.5.20 || ^12.2.4 || ^13.0"
},
"autoload": {
"psr-4": {
Expand Down
6 changes: 0 additions & 6 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
parameters:
ignoreErrors:
-
message: '#^Method Bake\\BakePlugin\:\:bootstrap\(\) has parameter \$app with generic interface Cake\\Core\\PluginApplicationInterface but does not specify its types\: TSubject$#'
identifier: missingType.generics
count: 1
path: src/BakePlugin.php

-
message: '#^Instanceof between mixed and Cake\\Chronos\\Chronos will always evaluate to false\.$#'
identifier: instanceof.alwaysFalse
Expand Down
3 changes: 1 addition & 2 deletions src/BakePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ protected function discoverCommands(CommandCollection $commands): CommandCollect
*
* @param string $namespace The namespace classes are expected to be in.
* @param string $path The path to look in.
* @return array<string>
* @phpstan-return array<string, class-string<\Bake\Command\BakeCommand>>
* @return array<string, class-string<\Bake\Command\BakeCommand>>
*/
protected function findInPath(string $namespace, string $path): array
{
Expand Down
3 changes: 1 addition & 2 deletions src/Command/CellCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ public function template(): string
* Get template data.
*
* @param \Cake\Console\Arguments $arguments Arguments object.
* @return array
* @phpstan-return array<string, mixed>
* @return array<string, mixed>
*/
public function templateData(Arguments $arguments): array
{
Expand Down
3 changes: 1 addition & 2 deletions src/Command/CommandCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ public function template(): string
* Get template data.
*
* @param \Cake\Console\Arguments $arguments Arguments object.
* @return array
* @phpstan-return array<string, mixed>
* @return array<string, mixed>
*/
public function templateData(Arguments $arguments): array
{
Expand Down
3 changes: 1 addition & 2 deletions src/Command/EnumCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ public function template(): string
* Get template data.
*
* @param \Cake\Console\Arguments $arguments The arguments for the command
* @return array
* @phpstan-return array<string, mixed>
* @return array<string, mixed>
*/
public function templateData(Arguments $arguments): array
{
Expand Down
3 changes: 1 addition & 2 deletions src/Command/SimpleBakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ abstract public function template(): string;
* Get template data.
*
* @param \Cake\Console\Arguments $arguments The arguments for the command
* @return array
* @phpstan-return array<string, mixed>
* @return array<string, mixed>
*/
public function templateData(Arguments $arguments): array
{
Expand Down
1 change: 0 additions & 1 deletion src/View/BakeView.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ public function dispatchEvent(string $name, array $data = [], ?object $subject =
{
$name = (string)preg_replace('/^View\./', 'Bake.', $name);

/** @phpstan-ignore-next-line missingType.generics */
return parent::dispatchEvent($name, $data, $subject);
}

Expand Down
12 changes: 3 additions & 9 deletions templates/bake/Model/enum.twig
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,16 @@
namespace: "#{namespace}\\Model\\Enum",
classImports: [
'Cake\\Database\\Type\\EnumLabelInterface',
'Cake\\Utility\\Inflector',
'Cake\\Database\\Type\\EnumLabelTrait',
],
}) }}

{{ DocBlock.classDescription(name, 'Enum', [])|raw }}
enum {{ name }}: {{ backingType }} implements EnumLabelInterface
{
use EnumLabelTrait;
{% if cases %}
{{ Bake.concat('\n ', cases) }}

{{ Bake.concat('\n ', cases) }}
{% endif %}
/**
* @return string
*/
public function label(): string
{
return Inflector::humanize(Inflector::underscore($this->name));
}
}
10 changes: 2 additions & 8 deletions tests/comparisons/Model/testBakeEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,12 @@
namespace Bake\Test\App\Model\Enum;

use Cake\Database\Type\EnumLabelInterface;
use Cake\Utility\Inflector;
use Cake\Database\Type\EnumLabelTrait;

/**
* FooBar Enum
*/
enum FooBar: string implements EnumLabelInterface
{
/**
* @return string
*/
public function label(): string
{
return Inflector::humanize(Inflector::underscore($this->name));
}
use EnumLabelTrait;
}
10 changes: 2 additions & 8 deletions tests/comparisons/Model/testBakeEnumBackedInt.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,12 @@
namespace Bake\Test\App\Model\Enum;

use Cake\Database\Type\EnumLabelInterface;
use Cake\Utility\Inflector;
use Cake\Database\Type\EnumLabelTrait;

/**
* FooBar Enum
*/
enum FooBar: int implements EnumLabelInterface
{
/**
* @return string
*/
public function label(): string
{
return Inflector::humanize(Inflector::underscore($this->name));
}
use EnumLabelTrait;
}
12 changes: 3 additions & 9 deletions tests/comparisons/Model/testBakeEnumBackedIntWithCases.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,16 @@
namespace Bake\Test\App\Model\Enum;

use Cake\Database\Type\EnumLabelInterface;
use Cake\Utility\Inflector;
use Cake\Database\Type\EnumLabelTrait;

/**
* FooBar Enum
*/
enum FooBar: int implements EnumLabelInterface
{
use EnumLabelTrait;

case Foo = 0;
case Bar = 1;
case BarBaz = 9;

/**
* @return string
*/
public function label(): string
{
return Inflector::humanize(Inflector::underscore($this->name));
}
}
12 changes: 3 additions & 9 deletions tests/comparisons/Model/testBakeEnumBackedWithCases.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,16 @@
namespace Bake\Test\App\Model\Enum;

use Cake\Database\Type\EnumLabelInterface;
use Cake\Utility\Inflector;
use Cake\Database\Type\EnumLabelTrait;

/**
* FooBar Enum
*/
enum FooBar: string implements EnumLabelInterface
{
use EnumLabelTrait;

case Foo = 'foo';
case Bar = 'b';
case BarBaz = 'bar_baz';

/**
* @return string
*/
public function label(): string
{
return Inflector::humanize(Inflector::underscore($this->name));
}
}
12 changes: 3 additions & 9 deletions tests/comparisons/Model/testBakeTableWithEnumConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,16 @@
namespace Bake\Test\App\Model\Enum;

use Cake\Database\Type\EnumLabelInterface;
use Cake\Utility\Inflector;
use Cake\Database\Type\EnumLabelTrait;

/**
* BakeUserNullableGender Enum
*/
enum BakeUserNullableGender: string implements EnumLabelInterface
{
use EnumLabelTrait;

case Male = 'male';
case Female = 'female';
case Diverse = 'diverse';

/**
* @return string
*/
public function label(): string
{
return Inflector::humanize(Inflector::underscore($this->name));
}
}
12 changes: 3 additions & 9 deletions tests/test_app/App/Model/Enum/BakeUserNullableGender.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,16 @@
namespace Bake\Test\App\Model\Enum;

use Cake\Database\Type\EnumLabelInterface;
use Cake\Utility\Inflector;
use Cake\Database\Type\EnumLabelTrait;

/**
* BakeUserNullableGender Enum
*/
enum BakeUserNullableGender: string implements EnumLabelInterface
{
use EnumLabelTrait;

case Male = 'male';
case Female = 'female';
case Diverse = 'diverse';

/**
* @return string
*/
public function label(): string
{
return Inflector::humanize(Inflector::underscore($this->name));
}
}
Loading