Skip to content

Commit 95343c7

Browse files
authored
Merge pull request #119 from ADmad/cake5
Cake5
2 parents 495589f + a6cd30e commit 95343c7

21 files changed

+165
-298
lines changed

.gitattributes

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
.editorconfig export-ignore
44
.gitattributes export-ignore
55
.gitignore export-ignore
6-
phpcs.xml.dist export-ignore
6+
phpcs.xml export-ignore
77
phpstan.neon export-ignore
88
phpstan-baseline.neon export-ignore
99
phpunit.xml.dist export-ignore

.github/workflows/ci.yml

+7-88
Original file line numberDiff line numberDiff line change
@@ -8,95 +8,14 @@ on:
88
branches:
99
- '*'
1010

11+
permissions:
12+
contents: read
13+
1114
jobs:
1215
testsuite:
13-
runs-on: ubuntu-20.04
14-
strategy:
15-
fail-fast: false
16-
matrix:
17-
php-version: ['7.4', '8.0', '8.1']
18-
db-type: [sqlite, mysql, pgsql]
19-
prefer-lowest: ['']
20-
include:
21-
- php-version: '7.2'
22-
db-type: 'sqlite'
23-
prefer-lowest: 'prefer-lowest'
24-
25-
services:
26-
postgres:
27-
image: postgres
28-
ports:
29-
- 5432:5432
30-
env:
31-
POSTGRES_PASSWORD: postgres
32-
33-
steps:
34-
- uses: actions/checkout@v3
35-
36-
- name: Setup Service
37-
if: matrix.db-type == 'mysql'
38-
run: |
39-
sudo service mysql start
40-
mysql -h 127.0.0.1 -u root -proot -e 'CREATE DATABASE cakephp;'
41-
42-
- name: Setup PHP
43-
uses: shivammathur/setup-php@v2
44-
with:
45-
php-version: ${{ matrix.php-version }}
46-
extensions: mbstring, intl, pdo_${{ matrix.db-type }}
47-
coverage: pcov
48-
49-
- name: Composer install
50-
run: |
51-
if ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then
52-
composer update --prefer-lowest --prefer-stable
53-
else
54-
composer install
55-
fi
56-
57-
- name: Setup problem matchers for PHPUnit
58-
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
59-
60-
- name: Run PHPUnit
61-
run: |
62-
if [[ ${{ matrix.db-type }} == 'sqlite' ]]; then export DB_URL='sqlite:///:memory:'; fi
63-
if [[ ${{ matrix.db-type }} == 'mysql' ]]; then export DB_URL='mysql://root:[email protected]/cakephp'; fi
64-
if [[ ${{ matrix.db-type }} == 'pgsql' ]]; then export DB_URL='postgres://postgres:[email protected]/postgres'; fi
65-
if [[ ${{ matrix.php-version }} == '7.4' ]]; then
66-
vendor/bin/phpunit --coverage-clover=coverage.xml
67-
else
68-
vendor/bin/phpunit
69-
fi
70-
71-
- name: Code Coverage Report
72-
if: success() && matrix.php-version == '7.4'
73-
uses: codecov/codecov-action@v3
16+
uses: ADmad/.github/.github/workflows/testsuite-with-db.yml@master
17+
secrets: inherit
7418

7519
cs-stan:
76-
name: Coding Standard & Static Analysis
77-
runs-on: ubuntu-20.04
78-
79-
steps:
80-
- uses: actions/checkout@v3
81-
82-
- name: Setup PHP
83-
uses: shivammathur/setup-php@v2
84-
with:
85-
php-version: '7.4'
86-
extensions: mbstring, intl
87-
coverage: none
88-
tools: cs2pr, vimeo/psalm:4, phpstan:1
89-
90-
- name: Composer Install
91-
run: composer install
92-
93-
- name: Run phpcs
94-
run: vendor/bin/phpcs -q --report=checkstyle --standard=vendor/cakephp/cakephp-codesniffer/CakePHP src/ tests/ | cs2pr
95-
96-
- name: Run psalm
97-
if: always()
98-
run: psalm --output-format=github
99-
100-
- name: Run psalm
101-
if: always()
102-
run: phpstan analyse
20+
uses: ADmad/.github/.github/workflows/cs-stan.yml@master
21+
secrets: inherit

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/composer.lock
22
/phpunit.xml
33
/vendor/
4-
.phpunit.result.cache
4+
/.phpunit.cache
55
/.idea/
66
/config/Migrations/schema-dump-default.lock
7+
/tools

composer.json

+7-6
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
"description": "A CakePHP plugin which allows you to authenticate using social providers like Facebook/Google/Twitter etc.",
44
"type": "cakephp-plugin",
55
"require": {
6-
"cakephp/cakephp": "^4.1",
7-
"socialconnect/auth": "^3.1"
6+
"cakephp/cakephp": "^5.0",
7+
"socialconnect/auth": "^3.3"
88
},
99
"require-dev": {
10-
"phpunit/phpunit": "^8.5.0 || ^9.5.0",
11-
"cakephp/cakephp-codesniffer": "^4.0"
10+
"phpunit/phpunit": "^10.1",
11+
"cakephp/cakephp-codesniffer": "^5.0"
1212
},
1313
"autoload": {
1414
"psr-4": {
@@ -24,8 +24,9 @@
2424
},
2525
"license": "MIT",
2626
"scripts": {
27-
"cs-check": "vendor/bin/phpcs -n -p --extensions=php --standard=vendor/cakephp/cakephp-codesniffer/CakePHP src/ tests/",
28-
"cs-fix": "vendor/bin/phpcbf -p --extensions=php --standard=vendor/cakephp/cakephp-codesniffer/CakePHP src/ tests/"
27+
"cs-check": "phpcs --colors -p ./src ./tests",
28+
"cs-fix": "phpcbf --colors -p ./src ./tests",
29+
"test": "phpunit"
2930
},
3031
"config": {
3132
"allow-plugins": {

phpcs.xml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="CakePHP Sentry">
3+
<config name="installed_paths" value="../../cakephp/cakephp-codesniffer" />
4+
5+
<rule ref="CakePHP" />
6+
</ruleset>

phpstan-baseline.neon

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: "#^Parameter \\#1 \\$callback of function call_user_func expects callable\\(\\)\\: mixed, array\\{Cake\\\\ORM\\\\Table, mixed\\} given\\.$#"
5+
count: 1
6+
path: src/Middleware/SocialAuthMiddleware.php
7+
8+
-
9+
message: "#^Method ADmad\\\\SocialAuth\\\\SocialAuthPlugin\\:\\:bootstrap\\(\\) has parameter \\$app with generic interface Cake\\\\Core\\\\PluginApplicationInterface but does not specify its types\\: TSubject$#"
10+
count: 1
11+
path: src/SocialAuthPlugin.php

phpstan.neon

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1+
includes:
2+
- phpstan-baseline.neon
3+
14
parameters:
25
level: 8
36
checkMissingIterableValueType: false
47
bootstrapFiles:
58
- tests/bootstrap.php
69
paths:
710
- src/
8-
ignoreErrors:
9-
-
10-
message: "#^Parameter \\#1 \\$function of function call_user_func expects callable\\(\\)\\: mixed, array\\{Cake\\\\ORM\\\\Table, mixed\\} given\\.$#"
11-
count: 1
12-
path: src/Middleware/SocialAuthMiddleware.php

phpunit.xml.dist

+24-18
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,35 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit
3-
bootstrap="tests/bootstrap.php"
4-
colors="true"
5-
stopOnFailure="false"
6-
>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
bootstrap="tests/bootstrap.php"
4+
colors="true"
5+
stopOnFailure="false"
6+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd"
7+
cacheDirectory=".phpunit.cache">
78

89
<testsuites>
910
<testsuite name="social-auth">
1011
<directory>tests/</directory>
1112
</testsuite>
1213
</testsuites>
1314

14-
<!-- Setup a listener for fixtures -->
15-
<listeners>
16-
<listener
17-
class="Cake\TestSuite\Fixture\FixtureInjector">
18-
<arguments>
19-
<object class="Cake\TestSuite\Fixture\FixtureManager"/>
20-
</arguments>
21-
</listener>
22-
</listeners>
15+
<extensions>
16+
<bootstrap class="Cake\TestSuite\Fixture\Extension\PHPUnitExtension"/>
17+
</extensions>
2318

24-
<filter>
25-
<whitelist>
19+
<source>
20+
<include>
2621
<directory suffix=".php">src/</directory>
27-
</whitelist>
28-
</filter>
22+
</include>
23+
</source>
24+
25+
<php>
26+
<ini name="memory_limit" value="-1"/>
27+
<env name="FIXTURE_SCHEMA_METADATA" value="./tests/schema.php"/>
28+
<!-- Postgres
29+
<env name="DB_URL" value="postgres://root@localhost/cake_test_db"/>
30+
-->
31+
<!-- Mysql
32+
<env name="DB_URL" value="mysql://root@localhost/cake_test_db"/>
33+
-->
34+
</php>
2935
</phpunit>

psalm.xml

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?xml version="1.0"?>
22
<psalm
3+
findUnusedPsalmSuppress="true"
4+
findUnusedBaselineEntry="true"
5+
findUnusedCode="false"
36
resolveFromConfigFile="true"
47
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
58
xmlns="https://getpsalm.org/schema/config"

src/Database/Type/SerializedType.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
namespace ADmad\SocialAuth\Database\Type;
1212

13-
use Cake\Database\DriverInterface;
13+
use Cake\Database\Driver;
1414
use Cake\Database\Type\BaseType;
1515
use PDO;
1616

@@ -20,10 +20,10 @@ class SerializedType extends BaseType
2020
* Convert a value data into a serialized string.
2121
*
2222
* @param mixed $value The value to convert.
23-
* @param \Cake\Database\DriverInterface $driver The driver instance to convert with.
23+
* @param \Cake\Database\Driver $driver The driver instance to convert with.
2424
* @return string|null
2525
*/
26-
public function toDatabase($value, DriverInterface $driver)
26+
public function toDatabase(mixed $value, Driver $driver): mixed
2727
{
2828
if ($value === null || is_string($value)) {
2929
return $value;
@@ -36,10 +36,10 @@ public function toDatabase($value, DriverInterface $driver)
3636
* Convert string values to PHP data structure.
3737
*
3838
* @param mixed $value The value to convert.
39-
* @param \Cake\Database\DriverInterface $driver The driver instance to convert with.
39+
* @param \Cake\Database\Driver $driver The driver instance to convert with.
4040
* @return mixed
4141
*/
42-
public function toPHP($value, DriverInterface $driver)
42+
public function toPHP(mixed $value, Driver $driver): mixed
4343
{
4444
if ($value === null) {
4545
return $value;
@@ -58,10 +58,10 @@ public function toPHP($value, DriverInterface $driver)
5858
* Get the correct PDO binding type for string data.
5959
*
6060
* @param mixed $value The value being bound.
61-
* @param \Cake\Database\DriverInterface $driver The driver.
61+
* @param \Cake\Database\Driver $driver The driver.
6262
* @return int
6363
*/
64-
public function toStatement($value, DriverInterface $driver)
64+
public function toStatement(mixed $value, Driver $driver): int
6565
{
6666
if ($value === null) {
6767
return PDO::PARAM_NULL;
@@ -76,7 +76,7 @@ public function toStatement($value, DriverInterface $driver)
7676
* @param mixed $value The value to convert.
7777
* @return mixed Converted value.
7878
*/
79-
public function marshal($value)
79+
public function marshal(mixed $value): mixed
8080
{
8181
if (is_array($value) || $value === null) {
8282
return $value;

0 commit comments

Comments
 (0)