Skip to content

Commit e52c954

Browse files
authored
Handle cakephp 5.3 deprecations (#580)
This PR updates SwaggerBake to address CakePHP 5.3 deprecations by adjusting plugin/bootstrap conventions and replacing deprecated API usage in test and extension code.
1 parent 29b9aa5 commit e52c954

6 files changed

Lines changed: 11 additions & 12 deletions

File tree

.github/workflows/pull-request.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55

66
jobs:
77
build:
8-
name: PHP 8.4 Test / Analysis
8+
name: PHP 8.5 Test / Analysis
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: Checkout
@@ -14,7 +14,7 @@ jobs:
1414
- name: Setup PHP
1515
uses: shivammathur/setup-php@v2
1616
with:
17-
php-version: '8.4'
17+
php-version: '8.5'
1818
extensions: mbstring, intl, xdebug
1919

2020
- name: PHP Version
@@ -68,7 +68,7 @@ jobs:
6868
runs-on: ubuntu-latest
6969
strategy:
7070
matrix:
71-
version: ['~5.0.0', '^5.0']
71+
version: ['~5.0.0', '^5.2']
7272
steps:
7373
- name: Checkout
7474
uses: actions/checkout@v2

phpmd.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@
3939
</properties>
4040
</rule>
4141
<rule ref="rulesets/naming.xml/ShortMethodName" />
42-
<rule ref="rulesets/unusedcode.xml/UnusedPrivateField" />
43-
<rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod" />
42+
<rule ref="rulesets/unusedcode.xml">
43+
<exclude name="UnusedPrivateField"/>
44+
</rule>
4445
<rule ref="rulesets/controversial.xml/CamelCaseParameterName" />
4546
<rule ref="rulesets/controversial.xml/CamelCaseMethodName" />
4647
<rule ref="rulesets/codesize.xml/CyclomaticComplexity">

src/Lib/Extension/CakeSearch/Extension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function registerListeners(): void
4343
{
4444
EventManager::instance()
4545
->on('SwaggerBake.Operation.created', function (Event $event): void {
46-
$operation = $this->getOperation($event); // phpcs:ignore
46+
$this->getOperation($event);
4747
});
4848
}
4949

src/Lib/Operation/ExceptionResponse.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,15 @@ public function build(Throws $throw)
8787

8888
$this->code = empty($httpCode) ? '500' : $httpCode;
8989
$this->description = $description;
90-
$this->schema = $this->fallback($exceptionFqn);
90+
$this->schema = $this->fallback();
9191

9292
return $this;
9393
}
9494

9595
/**
9696
* @deprecated this method may be removed in version 3.
97-
* @param string $exceptionFqn The FQN of the exception class.
98-
* @return string|null
9997
*/
100-
private function fallback(string $exceptionFqn): ?string
98+
private function fallback(): ?string
10199
{
102100
if (empty($this->config->getExceptionSchema())) {
103101
return null;

src/Plugin.php renamed to src/SwaggerBakePlugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use SwaggerBake\Lib\Service\OpenApiBakerService;
1414
use SwaggerBake\Lib\Service\OpenApiControllerService;
1515

16-
class Plugin extends BasePlugin
16+
class SwaggerBakePlugin extends BasePlugin
1717
{
1818
protected bool $routes = false;
1919

tests/test_app/src/Model/Table/EmployeesTable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function initialize(array $config): void
2828
$this->setDisplayField('id');
2929
$this->setPrimaryKey('id');
3030
$this->addBehavior('Search.Search');
31-
$this->searchManager()
31+
$this->getBehavior('Search')->searchManager()
3232
->add('first_name', 'Search.Like', [
3333
'before' => true,
3434
'after' => true,

0 commit comments

Comments
 (0)