Skip to content

Commit cd764e5

Browse files
committed
cake5 upgrade + new stan setup
1 parent 9cc3be1 commit cd764e5

36 files changed

+208
-255
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,8 @@ trim_trailing_whitespace = true
1414
[*.yml]
1515
indent_size = 2
1616

17+
[phars.xml]
18+
indent_size = 2
19+
1720
[*.neon]
1821
indent_style = tab

.github/workflows/ci.yml

Lines changed: 8 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -4,93 +4,19 @@ on:
44
push:
55
branches:
66
- master
7+
- cake5
78
pull_request:
89
branches:
910
- '*'
1011

12+
permissions:
13+
contents: read
14+
1115
jobs:
1216
testsuite:
13-
runs-on: ubuntu-18.04
14-
strategy:
15-
fail-fast: false
16-
matrix:
17-
php-version: ['7.2', '7.4', '8.0', '8.1']
18-
prefer-lowest: ['']
19-
include:
20-
- php-version: '7.2'
21-
prefer-lowest: 'prefer-lowest'
22-
23-
steps:
24-
- uses: actions/checkout@v3
25-
26-
- name: Setup PHP
27-
uses: shivammathur/setup-php@v2
28-
with:
29-
php-version: ${{ matrix.php-version }}
30-
extensions: mbstring, intl
31-
coverage: pcov
32-
33-
- name: Get composer cache directory
34-
id: composer-cache
35-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
36-
37-
- name: Get date part for cache key
38-
id: key-date
39-
run: echo "::set-output name=date::$(date +'%Y-%m')"
40-
41-
- name: Cache composer dependencies
42-
uses: actions/cache@v3
43-
with:
44-
path: ${{ steps.composer-cache.outputs.dir }}
45-
key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}-${{ matrix.prefer-lowest }}
46-
47-
- name: Composer install
48-
run: |
49-
if ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then
50-
composer update --prefer-lowest --prefer-stable
51-
elif ${{ matrix.php-version == '8.1' }}; then
52-
composer update --ignore-platform-reqs
53-
else
54-
composer update
55-
fi
56-
57-
- name: Run PHPUnit
58-
run: |
59-
if ${{ matrix.php-version == '7.4'}}; then
60-
vendor/bin/phpunit --coverage-clover=coverage.xml
61-
else
62-
vendor/bin/phpunit
63-
fi
64-
65-
- name: Code Coverage Report
66-
if: matrix.php-version == '7.4'
67-
uses: codecov/codecov-action@v3
17+
uses: cakephp/.github/.github/workflows/[email protected]
18+
secrets: inherit
6819

6920
cs-stan:
70-
name: Coding Standard & Static Analysis
71-
runs-on: ubuntu-18.04
72-
73-
steps:
74-
- uses: actions/checkout@v3
75-
76-
- name: Setup PHP
77-
uses: shivammathur/setup-php@v2
78-
with:
79-
php-version: '7.4'
80-
extensions: mbstring, intl
81-
coverage: none
82-
tools: cs2pr
83-
84-
- name: Composer Install
85-
run: composer stan-setup
86-
87-
- name: Run PHP CodeSniffer
88-
run: vendor/bin/phpcs --report=checkstyle src/ tests/ | cs2pr
89-
90-
- name: Run psalm
91-
if: success() || failure()
92-
run: vendor/bin/psalm.phar --output-format=github
93-
94-
- name: Run phpstan
95-
if: success() || failure()
96-
run: vendor/bin/phpstan.phar analyse --error-format=github
21+
uses: cakephp/.github/.github/workflows/[email protected]
22+
secrets: inherit

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
/composer.lock
77
/phpunit.xml
88
/phpcs.xml
9+
/tools
910
/vendor
1011
*.mo
1112
debug.log

.phive/phars.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phive xmlns="https://phar.io/phive">
3+
<phar name="phpstan" version="1.9.12" installed="1.9.12" location="./tools/phpstan" copy="false"/>
4+
<phar name="psalm" version="5.4.0" installed="5.4.0" location="./tools/psalm" copy="false"/>
5+
</phive>

composer.json

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@
1818
"source": "https://github.com/cakephp/queue"
1919
},
2020
"require": {
21-
"php": ">=7.2.0",
22-
"cakephp/cakephp": "^4.1",
21+
"php": ">=8.1",
22+
"cakephp/cakephp": "5.x-dev as 5.0.0",
2323
"enqueue/simple-client": "^0.10",
24-
"psr/log": "^1.1 || ^2.0"
24+
"psr/log": "^3.0"
2525
},
2626
"require-dev": {
27-
"cakephp/bake": "^2.1",
28-
"cakephp/cakephp-codesniffer": "^4.0",
27+
"cakephp/bake": "3.x-dev as 3.0.0",
28+
"cakephp/cakephp-codesniffer": "^5.0",
2929
"enqueue/fs": "^0.10",
30-
"phpunit/phpunit": "^8.5 || ^9.3"
30+
"phpunit/phpunit": "^9.5.19"
3131
},
3232
"autoload": {
3333
"psr-4": {
@@ -52,11 +52,20 @@
5252
],
5353
"cs-check": "phpcs --colors -p src/ tests/",
5454
"cs-fix": "phpcbf --colors -p src/ tests/",
55-
"stan": "phpstan analyse src/ && psalm.phar --show-info=false",
56-
"stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:^1.5 psalm/phar:~4.22 && mv composer.backup composer.json",
55+
"stan": [
56+
"@phpstan",
57+
"@psalm"
58+
],
59+
"phpstan": "tools/phpstan analyse",
60+
"psalm": "tools/psalm --show-info=false",
61+
"stan-baseline": "tools/phpstan --generate-baseline",
62+
"psalm-baseline": "tools/psalm --set-baseline=psalm-baseline.xml",
63+
"stan-setup": "phive install",
5764
"test": "phpunit",
5865
"test-coverage": "phpunit --coverage-clover=clover.xml"
5966
},
67+
"minimum-stability": "dev",
68+
"prefer-stable": true,
6069
"config": {
6170
"sort-packages": true,
6271
"allow-plugins": {

phpstan.neon

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
parameters:
22
level: 6
33
checkMissingIterableValueType: false
4+
checkGenericClassInNonGenericObjectType: false
5+
treatPhpDocTypesAsCertain: false
46
bootstrapFiles:
57
- tests/bootstrap.php
68
paths:

phpunit.xml.dist

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,31 @@
44
colors="true"
55
bootstrap="tests/bootstrap.php"
66
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
7-
<!-- Only collect coverage for src/ -->
8-
<coverage>
9-
<include>
10-
<directory suffix=".php">./src/</directory>
11-
</include>
12-
</coverage>
13-
<testsuites>
14-
<testsuite name="queue">
15-
<directory>tests/TestCase</directory>
16-
</testsuite>
17-
</testsuites>
18-
<listeners>
19-
<listener class="Cake\TestSuite\Fixture\FixtureInjector">
20-
<arguments>
21-
<object class="Cake\TestSuite\Fixture\FixtureManager"/>
22-
</arguments>
23-
</listener>
24-
</listeners>
7+
<testsuites>
8+
<testsuite name="queue">
9+
<directory>tests/TestCase</directory>
10+
</testsuite>
11+
</testsuites>
12+
13+
<extensions>
14+
<extension class="Cake\TestSuite\Fixture\PHPUnitExtension"/>
15+
</extensions>
16+
17+
<!-- Only collect coverage for src/ -->
18+
<coverage>
19+
<include>
20+
<directory suffix=".php">./src/</directory>
21+
</include>
22+
</coverage>
23+
24+
<php>
25+
<ini name="memory_limit" value="-1"/>
26+
<env name="FIXTURE_SCHEMA_METADATA" value="./tests/schema.php"/>
27+
<!-- Postgres
28+
<env name="DB_URL" value="postgres://root@localhost/cake_test_db"/>
29+
-->
30+
<!-- Mysql
31+
<env name="DB_URL" value="mysql://root@localhost/cake_test_db"/>
32+
-->
33+
</php>
2534
</phpunit>

psalm-baseline.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<files psalm-version="dev-master@">
3+
<file src="src/Model/Table/FailedJobsTable.php">
4+
<LessSpecificImplementedReturnType occurrences="4">
5+
<code>\Cake\Queue\Model\Entity\FailedJob[]|\Cake\Datasource\ResultSetInterface</code>
6+
<code>\Cake\Queue\Model\Entity\FailedJob[]|\Cake\Datasource\ResultSetInterface</code>
7+
<code>\Cake\Queue\Model\Entity\FailedJob[]|\Cake\Datasource\ResultSetInterface|false</code>
8+
<code>\Cake\Queue\Model\Entity\FailedJob[]|\Cake\Datasource\ResultSetInterface|false</code>
9+
</LessSpecificImplementedReturnType>
10+
</file>
11+
</files>

psalm.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
<?xml version="1.0"?>
22
<psalm
3+
errorLevel="4"
4+
reportMixedIssues="false"
35
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
46
xmlns="https://getpsalm.org/schema/config"
57
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
68
autoloader="tests/bootstrap.php"
9+
usePhpDocMethodsWithoutMagicCall="true"
10+
errorBaseline="psalm-baseline.xml"
711
>
812
<projectFiles>
913
<directory name="src" />
@@ -13,12 +17,9 @@
1317
</projectFiles>
1418

1519
<issueHandlers>
16-
1720
<MissingClosureReturnType errorLevel="info" />
18-
1921
<PropertyNotSetInConstructor errorLevel="info" />
2022
<MissingConstructor errorLevel="info" />
2123
<MissingClosureParamType errorLevel="info" />
22-
2324
</issueHandlers>
2425
</psalm>

src/Command/JobCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
class JobCommand extends SimpleBakeCommand
2424
{
25-
public $pathFragment = 'Job/';
25+
public string $pathFragment = 'Job/';
2626

2727
/**
2828
* @inheritDoc

0 commit comments

Comments
 (0)