Skip to content

Commit afe5d82

Browse files
authored
Merge pull request #97 from UseMuffin/stan
Stan
2 parents e02ab5b + 30558db commit afe5d82

20 files changed

+180
-133
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
@@ -4,5 +4,6 @@
44
.gitignore export-ignore
55
.travis.yml export-ignore
66
tests export-ignore
7-
phpstan.neon
8-
psalm.xml
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:[email protected]/cakephp'; fi
62+
if [[ ${{ matrix.db-type }} == 'pgsql' ]]; then export DB_URL='postgres://postgres:[email protected]/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

.travis.yml

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

README.md

Lines changed: 1 addition & 1 deletion
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)

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@
3939
"irc": "irc://irc.freenode.org/muffin"
4040
},
4141
"require": {
42-
"cakephp/orm": "^4.1"
42+
"cakephp/orm": "^4.2"
4343
},
4444
"require-dev": {
45-
"cakephp/cakephp": "^4.1",
45+
"cakephp/cakephp": "^4.2",
4646
"cakephp/cakephp-codesniffer": "^4.0",
47-
"phpunit/phpunit": "~8.5.0"
47+
"phpunit/phpunit": "^8.5 || ^9.3"
4848
},
4949
"autoload": {
5050
"psr-4": {

phpstan.neon

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
parameters:
2-
level: 6
3-
checkMissingIterableValueType: false
4-
checkGenericClassInNonGenericObjectType: false
5-
ignoreErrors:
6-
-
7-
message: "#^Call to an undefined method Cake\\\\Datasource\\\\RepositoryInterface\\:\\:callFinder\\(\\)\\.$#"
8-
count: 1
9-
path: src/Datasource/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
1012

11-
-
12-
message: "#^Call to an undefined method Cake\\\\Datasource\\\\RepositoryInterface\\:\\:getName\\(\\)\\.$#"
13-
count: 1
14-
path: src/Datasource/Query.php
13+
-
14+
message: "#^Call to an undefined method Cake\\\\Datasource\\\\RepositoryInterface\\:\\:getName\\(\\)\\.$#"
15+
count: 1
16+
path: src/Datasource/Query.php
1517

16-
-
17-
message: "#^Cannot call method total\\(\\) on Cake\\\\Datasource\\\\ResultSetInterface\\|int\\<1, max\\>\\|int\\<min, \\-1\\>\\|true\\.$#"
18-
count: 1
19-
path: src/Datasource/Query.php
18+
-
19+
message: "#^Cannot call method total\\(\\) on Cake\\\\Datasource\\\\ResultSetInterface\\|int\\<min, \\-1\\>\\|int\\<1, max\\>\\|true\\.$#"
20+
count: 1
21+
path: src/Datasource/Query.php

psalm.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
<DocblockTypeContradiction errorLevel="info" />
2323
<RedundantConditionGivenDocblockType errorLevel="info" />
2424

25+
<UnsafeInstantiation errorLevel="info" />
26+
2527
<UnresolvableInclude errorLevel="info" />
2628
</issueHandlers>
2729
</psalm>

src/Datasource/Exception/MissingConnectionException.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33

44
namespace Muffin\Webservice\Datasource\Exception;
55

6-
use Cake\Core\Exception\Exception;
6+
use Cake\Core\Exception\CakeException;
77

8-
class MissingConnectionException extends Exception
8+
class MissingConnectionException extends CakeException
99
{
1010
/**
1111
* Template string that has attributes sprintf()'ed into it.
1212
*
1313
* @var string
1414
*/
15-
protected $_messageTemplate = 'No `%` connection configured.';
15+
protected $_messageTemplate = 'No `%s` connection configured.';
1616
}

src/Datasource/Marshaller.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,12 +284,9 @@ public function mergeMany($entities, array $data, array $options = []): array
284284
})
285285
->toArray();
286286

287-
/** @psalm-suppress NullArrayOffset */
287+
/** @psalm-suppress NullArrayOffset, InvalidArrayOffset */
288288
$new = $indexed[null] ?? [];
289-
/**
290-
* @psalm-suppress PossiblyNullArrayOffset
291-
* @psalm-suppress NullArrayOffset
292-
*/
289+
/** @psalm-suppress PossiblyNullArrayOffset, InvalidArrayOffset */
293290
unset($indexed[null]);
294291
$output = [];
295292

src/Datasource/Query.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,22 +328,22 @@ public function action(int $action)
328328
*
329329
* Pages should start at 1.
330330
*
331-
* @param int $page The page number you want.
331+
* @param int $num The page number you want.
332332
* @param int $limit The number of rows you want in the page. If null
333333
* the current limit clause will be used.
334334
* @return $this
335335
*/
336-
public function page(int $page, ?int $limit = null)
336+
public function page(int $num, ?int $limit = null)
337337
{
338-
if ($page < 1) {
338+
if ($num < 1) {
339339
throw new InvalidArgumentException('Pages must start at 1.');
340340
}
341341

342342
if ($limit !== null) {
343343
$this->limit($limit);
344344
}
345345

346-
$this->_parts['page'] = $page;
346+
$this->_parts['page'] = $num;
347347

348348
return $this;
349349
}
@@ -558,6 +558,7 @@ protected function _execute(): ResultSetInterface
558558
return new $decorator($this->__resultSet);
559559
}
560560

561+
/** @var \Cake\Datasource\ResultSetInterface */
561562
return $this->__resultSet = $this->_webservice->execute($this);
562563
}
563564

0 commit comments

Comments
 (0)