Skip to content

Commit fa00f1f

Browse files
authored
Merge pull request #101 from UseMuffin/cake-4.x
Cake 4.x
2 parents 9bde164 + f5351a3 commit fa00f1f

File tree

70 files changed

+1157
-1733
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1157
-1733
lines changed

.editorconfig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,7 @@ end_of_line = crlf
1515

1616
[*.yml]
1717
indent_style = space
18-
indent_size = 2
18+
indent_size = 2
19+
20+
[*.neon]
21+
indent_style = tab

.gitattributes

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
.editorconfig export-ignore
33
.gitattributes export-ignore
44
.gitignore export-ignore
5-
.semver export-ignore
6-
phpunit.xml.dist export-ignore
75
.travis.yml export-ignore
86
tests export-ignore
7+
phpstan.neon export-ignore
8+
psalm.xml export-ignore
9+
.github export-ignore

.github/workflows/ci.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- '*'
10+
11+
jobs:
12+
testsuite:
13+
runs-on: ubuntu-18.04
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
php-version: ['7.2', '7.4', '8.0']
18+
db-type: ['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@v2
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+
composer --version
52+
if ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then
53+
composer update --prefer-lowest --prefer-stable
54+
else
55+
composer install
56+
fi
57+
58+
- name: Run PHPUnit
59+
run: |
60+
if [[ ${{ matrix.db-type }} == 'sqlite' ]]; then export DB_URL='sqlite:///:memory:'; fi
61+
if [[ ${{ matrix.db-type }} == 'mysql' ]]; then export DB_URL='mysql://root:root@127.0.0.1/cakephp'; fi
62+
if [[ ${{ matrix.db-type }} == 'pgsql' ]]; then export DB_URL='postgres://postgres:postgres@127.0.0.1/postgres'; fi
63+
64+
if [[ ${{ matrix.php-version }} == '7.4' && ${{ matrix.db-type }} == 'mysql' ]]; then
65+
vendor/bin/phpunit --coverage-clover=coverage.xml
66+
else
67+
vendor/bin/phpunit
68+
fi
69+
70+
- name: Code Coverage Report
71+
if: success() && matrix.php-version == '7.4' && matrix.db-type == 'mysql'
72+
uses: codecov/codecov-action@v1
73+
74+
cs-stan:
75+
name: Coding Standard & Static Analysis
76+
runs-on: ubuntu-18.04
77+
78+
steps:
79+
- uses: actions/checkout@v2
80+
81+
- name: Setup PHP
82+
uses: shivammathur/setup-php@v2
83+
with:
84+
php-version: '7.4'
85+
extensions: mbstring, intl
86+
coverage: none
87+
tools: psalm:4.7, phpstan:0.12
88+
89+
- name: Composer Install
90+
run: composer require cakephp/cakephp-codesniffer:^4.2
91+
92+
- name: Run phpcs
93+
run: vendor/bin/phpcs --standard=CakePHP src/ tests/
94+
95+
- name: Run psalm
96+
if: success() || failure()
97+
run: psalm --output-format=github
98+
99+
- name: Run phpstan
100+
if: success() || failure()
101+
run: phpstan analyse

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/composer.lock
22
/plugins
33
/vendor
4+
.phpunit.result.cache

.travis.yml

Lines changed: 0 additions & 58 deletions
This file was deleted.

README.md

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Webservice
22

3-
[![Build Status](https://img.shields.io/travis/UseMuffin/Webservice/master.svg?style=flat-square)](https://travis-ci.org/UseMuffin/Webservice)
3+
[![Build Status](https://img.shields.io/travis/UseMuffin/Webservice/master.svg?style=flat-square)](https://github.com/UseMuffin/Webservice/actions?query=workflow%3ACI+branch%3Amaster)
44
[![Coverage](https://img.shields.io/codecov/c/github/UseMuffin/Webservice/master.svg?style=flat-square)](https://codecov.io/github/UseMuffin/Webservice)
55
[![Total Downloads](https://img.shields.io/packagist/dt/muffin/webservice.svg?style=flat-square)](https://packagist.org/packages/muffin/webservice)
66
[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](LICENSE)
@@ -23,6 +23,24 @@ bin/cake plugin load Muffin/Webservice
2323

2424
## Usage
2525

26+
### Datasource Configuration
27+
28+
In your `app.php`, add a new `webservice` config under `Datasources`:
29+
30+
```php
31+
'Datasources' => [
32+
// Other db config here
33+
'webservice' => [
34+
'className' => \Muffin\Webservice\Connection::class,
35+
'service' => 'Articles',
36+
// Any additional keys will be set as Driver's config.
37+
],
38+
],
39+
```
40+
41+
If you are making a plugin then conventionally the datasource config key name
42+
should be underscored version of plugin name.
43+
2644
### As an ORM
2745

2846
#### Create driver
@@ -31,15 +49,15 @@ bin/cake plugin load Muffin/Webservice
3149
<?php
3250
namespace App\Webservice\Driver;
3351

34-
use Cake\Network\Http\Client;
35-
use Muffin\Webservice\AbstractDriver;
52+
use Cake\Http\Client;
53+
use Muffin\Webservice\Driver\AbstractDriver;
3654

3755
class Articles extends AbstractDriver
3856
{
3957
/**
4058
* Initialize is used to easily extend the constructor.
4159
*/
42-
public function initialize()
60+
public function initialize(): void
4361
{
4462
$this->setClient(new Client([
4563
'host' => 'example.com'
@@ -54,8 +72,8 @@ class Articles extends AbstractDriver
5472
<?php
5573
namespace App\Webservice;
5674

57-
use Muffin\Webservice\Query;
58-
use Muffin\Webservice\ResultSet;
75+
use Muffin\Webservice\Datasource\Query;
76+
use Muffin\Webservice\Datasource\ResultSet;
5977
use Muffin\Webservice\Webservice\Webservice;
6078

6179
class ArticlesWebservice extends Webservice
@@ -110,7 +128,6 @@ class Article extends Resource
110128
<?php
111129
namespace App\Controller;
112130

113-
use Cake\Event\Event;
114131
use Muffin\Webservice\Model\EndpointLocator;
115132

116133
class ArticlesController extends AppController

composer.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "muffin/webservice",
3-
"description": "Extremely simplistic webservices for CakePHP 3",
3+
"description": "Simplistic webservices for CakePHP",
44
"type": "cakephp-plugin",
55
"keywords": [
66
"cakephp",
@@ -39,12 +39,12 @@
3939
"irc": "irc://irc.freenode.org/muffin"
4040
},
4141
"require": {
42-
"cakephp/orm": "^3.6"
42+
"cakephp/orm": "^4.2"
4343
},
4444
"require-dev": {
45-
"cakephp/cakephp": "^3.6",
46-
"cakephp/cakephp-codesniffer": "^3.0",
47-
"phpunit/phpunit": "^5.7.14|^6.0"
45+
"cakephp/cakephp": "^4.2",
46+
"cakephp/cakephp-codesniffer": "^4.0",
47+
"phpunit/phpunit": "^8.5 || ^9.3"
4848
},
4949
"autoload": {
5050
"psr-4": {
@@ -53,7 +53,10 @@
5353
},
5454
"autoload-dev": {
5555
"psr-4": {
56-
"Muffin\\Webservice\\Test\\": "tests"
56+
"Muffin\\Webservice\\Test\\": "tests",
57+
"TestApp\\": "tests/test_app/src",
58+
"SomeVendor\\SomePlugin\\": "tests/test_app/plugins/SomeVendor/SomePlugin/src",
59+
"TestPlugin\\": "tests/test_app/plugins/TestPlugin/src"
5760
}
5861
}
5962
}

config/bootstrap.php

Lines changed: 0 additions & 5 deletions
This file was deleted.

phpstan.neon

Lines changed: 20 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,21 @@
11
parameters:
2-
level: 6
3-
checkMissingIterableValueType: false
4-
checkGenericClassInNonGenericObjectType: false
5-
ignoreErrors:
6-
-
7-
message: "#^Strict comparison using \\=\\=\\= between string and null will always evaluate to false\\.$#"
8-
count: 1
9-
path: src/Marshaller.php
10-
11-
-
12-
message: "#^Negated boolean expression is always false\\.$#"
13-
count: 3
14-
path: src/Model/Endpoint.php
15-
16-
-
17-
message: "#^Result of \\|\\| is always true\\.$#"
18-
count: 1
19-
path: src/Model/Endpoint.php
20-
21-
-
22-
message: "#^Unreachable statement \\- code above always terminates\\.$#"
23-
count: 1
24-
path: src/Model/Endpoint.php
25-
26-
-
27-
message: "#^Call to an undefined method Traversable\\:\\:count\\(\\)\\.$#"
28-
count: 1
29-
path: src/Model/Endpoint.php
30-
31-
-
32-
message: "#^Parameter \\#1 \\$connection of method Muffin\\\\Webservice\\\\Model\\\\Endpoint\\:\\:setConnection\\(\\) expects Muffin\\\\Webservice\\\\Connection, Muffin\\\\Webservice\\\\AbstractDriver given\\.$#"
33-
count: 1
34-
path: src/Model/Endpoint.php
35-
36-
-
37-
message: "#^Method Muffin\\\\Webservice\\\\Query\\:\\:endpoint\\(\\) should return \\$this\\(Muffin\\\\Webservice\\\\Query\\)\\|Muffin\\\\Webservice\\\\Model\\\\Endpoint but returns Cake\\\\Datasource\\\\RepositoryInterface\\.$#"
38-
count: 1
39-
path: src/Query.php
40-
41-
-
42-
message: "#^Call to an undefined method Cake\\\\Datasource\\\\RepositoryInterface\\:\\:callFinder\\(\\)\\.$#"
43-
count: 1
44-
path: src/Query.php
45-
46-
-
47-
message: "#^Call to an undefined method Cake\\\\Datasource\\\\RepositoryInterface\\:\\:getName\\(\\)\\.$#"
48-
count: 1
49-
path: src/Query.php
50-
51-
-
52-
message: "#^Return type \\(array\\) of method Muffin\\\\Webservice\\\\Query\\:\\:aliasField\\(\\) should be compatible with return type \\(string\\) of method Cake\\\\Datasource\\\\QueryInterface\\:\\:aliasField\\(\\)$#"
53-
count: 1
54-
path: src/Query.php
55-
56-
-
57-
message: "#^Call to an undefined method Cake\\\\Datasource\\\\RepositoryInterface\\:\\:dispatchEvent\\(\\)\\.$#"
58-
count: 1
59-
path: src/Query.php
2+
level: 6
3+
checkMissingIterableValueType: false
4+
checkGenericClassInNonGenericObjectType: false
5+
paths:
6+
- src/
7+
ignoreErrors:
8+
-
9+
message: "#^Call to an undefined method Cake\\\\Datasource\\\\RepositoryInterface\\:\\:callFinder\\(\\)\\.$#"
10+
count: 1
11+
path: src/Datasource/Query.php
12+
13+
-
14+
message: "#^Call to an undefined method Cake\\\\Datasource\\\\RepositoryInterface\\:\\:getName\\(\\)\\.$#"
15+
count: 1
16+
path: src/Datasource/Query.php
17+
18+
-
19+
message: "#^Method Muffin\\\\Webservice\\\\Datasource\\\\Query\\:\\:execute\\(\\) should return bool\\|int\\|Muffin\\\\Webservice\\\\Datasource\\\\ResultSet\\|Muffin\\\\Webservice\\\\Model\\\\Resource but returns Cake\\\\Datasource\\\\ResultSetInterface\\.$#"
20+
count: 1
21+
path: src/Datasource/Query.php

0 commit comments

Comments
 (0)