Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cake 4.x #101

Merged
merged 50 commits into from
Sep 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
8bd7f74
Bump up dependencies
ADmad Dec 6, 2019
49f31fc
Get test suite running
ADmad Dec 6, 2019
e16f40f
Fix tests
ADmad Dec 6, 2019
6071969
Fix CS errors
ADmad Dec 6, 2019
1b51f20
Ignore phpunit's cache file
ADmad Dec 6, 2019
15e0ccf
Remove deprecated methods and classes
ADmad Dec 6, 2019
c5c7747
Fix typing issues
ADmad Dec 7, 2019
1a47cb8
Update travis config
ADmad Dec 7, 2019
21d9b98
Update .gitattributes
ADmad Dec 7, 2019
dd6a541
Fix test app's namespace
ADmad Dec 11, 2019
8aa5f62
Remove empty folder
ADmad Dec 11, 2019
e219009
Move AbstractDriver under Webservice/Driver.
ADmad Dec 11, 2019
fc8fc8c
Reorganize class namespaces
ADmad Dec 11, 2019
4f8e07e
Update dependency constraints
ADmad Dec 26, 2019
7076e0a
Add files to repo which were missed earlier
ADmad Dec 26, 2019
8e4db6e
update phpstan config
ADmad Dec 26, 2019
b49e9c3
Fix codesniffer version
ADmad Dec 26, 2019
60ecc30
Update readme
ADmad Dec 26, 2019
d34b1c1
Fix CS error
ADmad May 21, 2020
bc301fc
Fix errors reported by static analysis
ADmad May 22, 2020
094cd08
Fix CS error
ADmad May 22, 2020
b068dfc
Improve error message for missing connection.
ADmad May 22, 2020
f3ee55c
Change dependency to cakephp/orm
ADmad May 22, 2020
801c58d
Merge branch 'master' into cake-4.x
ADmad May 25, 2020
ef40a9a
Merge pull request #88 from UseMuffin/endpoint-default-conn-name
ADmad Jun 24, 2020
f8c8f81
Make EndpointLocator implement LocatorInterface.
ADmad Jun 4, 2020
3e01f3b
Merge pull request #90 from UseMuffin/endpoint-locator
ADmad Jun 24, 2020
c4715c6
Update dependencies
ADmad Jul 25, 2020
f9c27fa
Update readme
ADmad Jul 25, 2020
c346772
Fix error when guessing connection name.
ADmad Jul 25, 2020
9fab08a
Use connection config name "webservice" by default.
ADmad Jul 25, 2020
a7d761b
Merge pull request #94 from UseMuffin/endpoint-locator
ADmad Jul 26, 2020
9bc8d00
Fix signature mismatch error.
ADmad Apr 8, 2021
e02ab5b
Merge pull request #96 from UseMuffin/issue-95
ADmad Apr 8, 2021
9a550b2
Switch to GA workflow for CI
ADmad Apr 8, 2021
f687b20
Fix errors reported by phpstan and psalm.
ADmad Apr 8, 2021
4c5434d
Fix placeholder
ADmad Apr 8, 2021
8a1630a
Bump up to CakePHP 4.2
ADmad Apr 8, 2021
30558db
Update phpunit dependency
ADmad Apr 8, 2021
afe5d82
Merge pull request #97 from UseMuffin/stan
ADmad Apr 8, 2021
ead0a4d
Update use of deprecated method
ADmad Apr 8, 2021
f207beb
Update types
ADmad Apr 8, 2021
c71ff71
Rename var
ADmad Apr 8, 2021
4014181
Merge pull request #98 from UseMuffin/return-types
ADmad Apr 8, 2021
9c5181e
Make Schema implement SchemaInterface.
ADmad Aug 8, 2021
5b3e8cf
Fix CI config
ADmad Aug 8, 2021
6c13a92
Revert dependency change.
ADmad Aug 8, 2021
e52f605
Deal with psalm error
ADmad Aug 8, 2021
5999319
Update cakephp package dependency again
ADmad Aug 8, 2021
f5351a3
Update readme
ADmad Sep 11, 2021
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
5 changes: 4 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ end_of_line = crlf

[*.yml]
indent_style = space
indent_size = 2
indent_size = 2

[*.neon]
indent_style = tab
5 changes: 3 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.semver export-ignore
phpunit.xml.dist export-ignore
.travis.yml export-ignore
tests export-ignore
phpstan.neon export-ignore
psalm.xml export-ignore
.github export-ignore
101 changes: 101 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: CI

on:
push:
branches:
- master
pull_request:
branches:
- '*'

jobs:
testsuite:
runs-on: ubuntu-18.04
strategy:
fail-fast: false
matrix:
php-version: ['7.2', '7.4', '8.0']
db-type: ['mysql', 'pgsql']
prefer-lowest: ['']
include:
- php-version: '7.2'
db-type: 'sqlite'
prefer-lowest: 'prefer-lowest'

services:
postgres:
image: postgres
ports:
- 5432:5432
env:
POSTGRES_PASSWORD: postgres

steps:
- uses: actions/checkout@v2

- name: Setup Service
if: matrix.db-type == 'mysql'
run: |
sudo service mysql start
mysql -h 127.0.0.1 -u root -proot -e 'CREATE DATABASE cakephp;'

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl, pdo_${{ matrix.db-type }}
coverage: pcov

- name: Composer install
run: |
composer --version
if ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then
composer update --prefer-lowest --prefer-stable
else
composer install
fi

- name: Run PHPUnit
run: |
if [[ ${{ matrix.db-type }} == 'sqlite' ]]; then export DB_URL='sqlite:///:memory:'; fi
if [[ ${{ matrix.db-type }} == 'mysql' ]]; then export DB_URL='mysql://root:[email protected]/cakephp'; fi
if [[ ${{ matrix.db-type }} == 'pgsql' ]]; then export DB_URL='postgres://postgres:[email protected]/postgres'; fi

if [[ ${{ matrix.php-version }} == '7.4' && ${{ matrix.db-type }} == 'mysql' ]]; then
vendor/bin/phpunit --coverage-clover=coverage.xml
else
vendor/bin/phpunit
fi

- name: Code Coverage Report
if: success() && matrix.php-version == '7.4' && matrix.db-type == 'mysql'
uses: codecov/codecov-action@v1

cs-stan:
name: Coding Standard & Static Analysis
runs-on: ubuntu-18.04

steps:
- uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extensions: mbstring, intl
coverage: none
tools: psalm:4.7, phpstan:0.12

- name: Composer Install
run: composer require cakephp/cakephp-codesniffer:^4.2

- name: Run phpcs
run: vendor/bin/phpcs --standard=CakePHP src/ tests/

- name: Run psalm
if: success() || failure()
run: psalm --output-format=github

- name: Run phpstan
if: success() || failure()
run: phpstan analyse
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/composer.lock
/plugins
/vendor
.phpunit.result.cache
58 changes: 0 additions & 58 deletions .travis.yml

This file was deleted.

31 changes: 24 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Webservice

[![Build Status](https://img.shields.io/travis/UseMuffin/Webservice/master.svg?style=flat-square)](https://travis-ci.org/UseMuffin/Webservice)
[![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)
[![Coverage](https://img.shields.io/codecov/c/github/UseMuffin/Webservice/master.svg?style=flat-square)](https://codecov.io/github/UseMuffin/Webservice)
[![Total Downloads](https://img.shields.io/packagist/dt/muffin/webservice.svg?style=flat-square)](https://packagist.org/packages/muffin/webservice)
[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](LICENSE)
Expand All @@ -23,6 +23,24 @@ bin/cake plugin load Muffin/Webservice

## Usage

### Datasource Configuration

In your `app.php`, add a new `webservice` config under `Datasources`:

```php
'Datasources' => [
// Other db config here
'webservice' => [
'className' => \Muffin\Webservice\Connection::class,
'service' => 'Articles',
// Any additional keys will be set as Driver's config.
],
],
```

If you are making a plugin then conventionally the datasource config key name
should be underscored version of plugin name.

### As an ORM

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

use Cake\Network\Http\Client;
use Muffin\Webservice\AbstractDriver;
use Cake\Http\Client;
use Muffin\Webservice\Driver\AbstractDriver;

class Articles extends AbstractDriver
{
/**
* Initialize is used to easily extend the constructor.
*/
public function initialize()
public function initialize(): void
{
$this->setClient(new Client([
'host' => 'example.com'
Expand All @@ -54,8 +72,8 @@ class Articles extends AbstractDriver
<?php
namespace App\Webservice;

use Muffin\Webservice\Query;
use Muffin\Webservice\ResultSet;
use Muffin\Webservice\Datasource\Query;
use Muffin\Webservice\Datasource\ResultSet;
use Muffin\Webservice\Webservice\Webservice;

class ArticlesWebservice extends Webservice
Expand Down Expand Up @@ -110,7 +128,6 @@ class Article extends Resource
<?php
namespace App\Controller;

use Cake\Event\Event;
use Muffin\Webservice\Model\EndpointLocator;

class ArticlesController extends AppController
Expand Down
15 changes: 9 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "muffin/webservice",
"description": "Extremely simplistic webservices for CakePHP 3",
"description": "Simplistic webservices for CakePHP",
"type": "cakephp-plugin",
"keywords": [
"cakephp",
Expand Down Expand Up @@ -39,12 +39,12 @@
"irc": "irc://irc.freenode.org/muffin"
},
"require": {
"cakephp/orm": "^3.6"
"cakephp/orm": "^4.2"
},
"require-dev": {
"cakephp/cakephp": "^3.6",
"cakephp/cakephp-codesniffer": "^3.0",
"phpunit/phpunit": "^5.7.14|^6.0"
"cakephp/cakephp": "^4.2",
"cakephp/cakephp-codesniffer": "^4.0",
"phpunit/phpunit": "^8.5 || ^9.3"
},
"autoload": {
"psr-4": {
Expand All @@ -53,7 +53,10 @@
},
"autoload-dev": {
"psr-4": {
"Muffin\\Webservice\\Test\\": "tests"
"Muffin\\Webservice\\Test\\": "tests",
"TestApp\\": "tests/test_app/src",
"SomeVendor\\SomePlugin\\": "tests/test_app/plugins/SomeVendor/SomePlugin/src",
"TestPlugin\\": "tests/test_app/plugins/TestPlugin/src"
}
}
}
5 changes: 0 additions & 5 deletions config/bootstrap.php

This file was deleted.

78 changes: 20 additions & 58 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,59 +1,21 @@
parameters:
level: 6
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false
ignoreErrors:
-
message: "#^Strict comparison using \\=\\=\\= between string and null will always evaluate to false\\.$#"
count: 1
path: src/Marshaller.php

-
message: "#^Negated boolean expression is always false\\.$#"
count: 3
path: src/Model/Endpoint.php

-
message: "#^Result of \\|\\| is always true\\.$#"
count: 1
path: src/Model/Endpoint.php

-
message: "#^Unreachable statement \\- code above always terminates\\.$#"
count: 1
path: src/Model/Endpoint.php

-
message: "#^Call to an undefined method Traversable\\:\\:count\\(\\)\\.$#"
count: 1
path: src/Model/Endpoint.php

-
message: "#^Parameter \\#1 \\$connection of method Muffin\\\\Webservice\\\\Model\\\\Endpoint\\:\\:setConnection\\(\\) expects Muffin\\\\Webservice\\\\Connection, Muffin\\\\Webservice\\\\AbstractDriver given\\.$#"
count: 1
path: src/Model/Endpoint.php

-
message: "#^Method Muffin\\\\Webservice\\\\Query\\:\\:endpoint\\(\\) should return \\$this\\(Muffin\\\\Webservice\\\\Query\\)\\|Muffin\\\\Webservice\\\\Model\\\\Endpoint but returns Cake\\\\Datasource\\\\RepositoryInterface\\.$#"
count: 1
path: src/Query.php

-
message: "#^Call to an undefined method Cake\\\\Datasource\\\\RepositoryInterface\\:\\:callFinder\\(\\)\\.$#"
count: 1
path: src/Query.php

-
message: "#^Call to an undefined method Cake\\\\Datasource\\\\RepositoryInterface\\:\\:getName\\(\\)\\.$#"
count: 1
path: src/Query.php

-
message: "#^Return type \\(array\\) of method Muffin\\\\Webservice\\\\Query\\:\\:aliasField\\(\\) should be compatible with return type \\(string\\) of method Cake\\\\Datasource\\\\QueryInterface\\:\\:aliasField\\(\\)$#"
count: 1
path: src/Query.php

-
message: "#^Call to an undefined method Cake\\\\Datasource\\\\RepositoryInterface\\:\\:dispatchEvent\\(\\)\\.$#"
count: 1
path: src/Query.php
level: 6
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false
paths:
- src/
ignoreErrors:
-
message: "#^Call to an undefined method Cake\\\\Datasource\\\\RepositoryInterface\\:\\:callFinder\\(\\)\\.$#"
count: 1
path: src/Datasource/Query.php

-
message: "#^Call to an undefined method Cake\\\\Datasource\\\\RepositoryInterface\\:\\:getName\\(\\)\\.$#"
count: 1
path: src/Datasource/Query.php

-
message: "#^Method Muffin\\\\Webservice\\\\Datasource\\\\Query\\:\\:execute\\(\\) should return bool\\|int\\|Muffin\\\\Webservice\\\\Datasource\\\\ResultSet\\|Muffin\\\\Webservice\\\\Model\\\\Resource but returns Cake\\\\Datasource\\\\ResultSetInterface\\.$#"
count: 1
path: src/Datasource/Query.php
Loading