Skip to content

Commit d50fef1

Browse files
Merge pull request #210 from MarcinOrlowski/dev
Adds coding standard check action
2 parents e9739f1 + b5fff1f commit d50fef1

34 files changed

+289
-179
lines changed

.config/composer-laravel-8.x.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
"laravel/framework": "^8.0"
1313
},
1414
"require-dev": {
15-
"marcin-orlowski/coding-standard": "^1.3",
15+
"marcin-orlowski/coding-standard": "^2.2",
1616
"marcin-orlowski/phpunit-extra-asserts": "^1.2",
1717
"orchestra/testbench": "^6.0",
18-
"phpunit/phpunit": "^8.0",
19-
"phpunit/php-code-coverage": "^7.0",
18+
"phpunit/phpunit": "^9.0",
19+
"phpunit/php-code-coverage": "^9.0",
2020
"nunomaduro/larastan": "^0.7.6"
2121
}
2222
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
##################################################################################
2+
#
3+
# Laravel API Response Builder Static code analysis Github Action config
4+
#
5+
# @package MarcinOrlowski\ResponseBuilder
6+
#
7+
# @author Marcin Orlowski <mail (#) marcinOrlowski (.) com>
8+
# @copyright 2016-2021 Marcin Orlowski
9+
# @license http://www.opensource.org/licenses/mit-license.php MIT
10+
# @link https://github.com/MarcinOrlowski/laravel-api-response-builder
11+
#
12+
##################################################################################
13+
14+
name: "Coding Standards"
15+
16+
on:
17+
push:
18+
branches:
19+
- "master"
20+
pull_request:
21+
branches:
22+
- "master"
23+
- "dev"
24+
25+
jobs:
26+
build:
27+
strategy:
28+
# do not stop the workflow if single run failed
29+
fail-fast: false
30+
matrix:
31+
# quotes are needed it is treated as a number and zero at decimal part is gone at runtime
32+
laravel: ["8.x"]
33+
php: ["8.0"]
34+
35+
runs-on: ubuntu-latest
36+
37+
steps:
38+
- name: "Checkout repository..."
39+
uses: actions/checkout@v2
40+
41+
- name: "Setup proper composer.json"
42+
shell: bash
43+
run: cp -f ".config/composer-laravel-${{ matrix.laravel }}.json" composer.json
44+
45+
# https://github.com/marketplace/actions/composer-php-actions
46+
- name: "Installing dependencies..."
47+
uses: php-actions/composer@v6
48+
with:
49+
version: 2
50+
php_version: "${{ matrix.php }}"
51+
dev: yes
52+
53+
- name: "Checking coding standards for 'src/'..."
54+
shell: bash
55+
run: vendor/bin/phpcs -s --basepath="$(pwd)" --standard="vendor/marcin-orlowski/coding-standard/coding-standard/MarcinOrlowski/" "src/"
56+
57+
- name: "Checking coding standards for 'tests/'..."
58+
shell: bash
59+
run: vendor/bin/phpcs -s --basepath="$(pwd)" --standard="vendor/marcin-orlowski/coding-standard/coding-standard/MarcinOrlowski/" "tests/"

.github/workflows/coverage.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ jobs:
3939
uses: actions/checkout@v2
4040

4141
- name: "Setup proper composer.json"
42+
shell: bash
4243
run: cp -f ".config/composer-laravel-${{ matrix.laravel }}.json" composer.json
4344

4445
# https://github.com/marketplace/actions/composer-php-actions

.github/workflows/phpstan.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ jobs:
3939
uses: actions/checkout@v2
4040

4141
- name: "Setup proper composer.json"
42+
shell: bash
4243
run: cp -f ".config/composer-laravel-${{ matrix.laravel }}.json" composer.json
4344

4445
# https://github.com/marketplace/actions/composer-php-actions

.github/workflows/phpunit.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ jobs:
4343
uses: actions/checkout@v2
4444

4545
- name: "Setup proper composer.json"
46+
shell: bash
4647
run: cp -f ".config/composer-laravel-${{ matrix.laravel }}.json" composer.json
4748

4849
# https://github.com/marketplace/actions/composer-php-actions

.travis.yml

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

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,21 @@
33
# REST API Response Builder for Laravel #
44

55
[![Latest Stable Version](https://poser.pugx.org/marcin-orlowski/laravel-api-response-builder/v)](https://packagist.org/packages/marcin-orlowski/laravel-api-response-builder)
6-
[![Unit Tests](https://github.com/MarcinOrlowski/laravel-api-response-builder/actions/workflows/phpunit.yml/badge.svg?branch=master)](https://github.com/MarcinOrlowski/laravel-api-response-builder/actions/workflows/phpunit.yml)
7-
[![Static Analysis](https://github.com/MarcinOrlowski/laravel-api-response-builder/actions/workflows/phpstan.yml/badge.svg?branch=master)](https://github.com/MarcinOrlowski/laravel-api-response-builder/actions/workflows/phpstan.yml)
8-
[![Code Quality](https://scrutinizer-ci.com/g/MarcinOrlowski/laravel-api-response-builder/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/MarcinOrlowski/laravel-api-response-builder/?branch=master)
9-
[![Code Coverage](https://codecov.io/gh/MarcinOrlowski/laravel-api-response-builder/branch/master/graph/badge.svg?token=s3WnvhiI7n)](https://codecov.io/gh/MarcinOrlowski/laravel-api-response-builder)
106
[![Codacy Grade Badge](https://api.codacy.com/project/badge/Grade/44f427e872e2480597bde0242417a2a7)](https://www.codacy.com/app/MarcinOrlowski/laravel-api-response-builder)
117
[![Monthly Downloads](https://poser.pugx.org/marcin-orlowski/laravel-api-response-builder/d/monthly)](https://packagist.org/packages/marcin-orlowski/laravel-api-response-builder)
8+
[![Code Quality](https://scrutinizer-ci.com/g/MarcinOrlowski/laravel-api-response-builder/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/MarcinOrlowski/laravel-api-response-builder/?branch=master)
9+
[![Code Coverage](https://codecov.io/gh/MarcinOrlowski/laravel-api-response-builder/branch/master/graph/badge.svg?token=s3WnvhiI7n)](https://codecov.io/gh/MarcinOrlowski/laravel-api-response-builder)
1210
[![License](https://poser.pugx.org/marcin-orlowski/laravel-api-response-builder/license)](https://packagist.org/packages/marcin-orlowski/laravel-api-response-builder)
1311

12+
Master branch:
13+
[![Unit Tests](https://github.com/MarcinOrlowski/laravel-api-response-builder/actions/workflows/phpunit.yml/badge.svg?branch=master)](https://github.com/MarcinOrlowski/laravel-api-response-builder/actions/workflows/phpunit.yml)
14+
[![Static Analysis](https://github.com/MarcinOrlowski/laravel-api-response-builder/actions/workflows/phpstan.yml/badge.svg?branch=master)](https://github.com/MarcinOrlowski/laravel-api-response-builder/actions/workflows/phpstan.yml)
15+
[![Coding Standards](https://github.com/MarcinOrlowski/laravel-api-response-builder/actions/workflows/coding-standards.yml/badge.svg?branch=master)](https://github.com/MarcinOrlowski/laravel-api-response-builder/actions/workflows/coding-standards.yml)
16+
1417
Development branch:
1518
[![Unit Tests](https://github.com/MarcinOrlowski/laravel-api-response-builder/actions/workflows/phpunit.yml/badge.svg?branch=dev)](https://github.com/MarcinOrlowski/laravel-api-response-builder/actions/workflows/phpunit.yml)
1619
[![Static Analysis](https://github.com/MarcinOrlowski/laravel-api-response-builder/actions/workflows/phpstan.yml/badge.svg?branch=dev)](https://github.com/MarcinOrlowski/laravel-api-response-builder/actions/workflows/phpstan.yml)
20+
[![Coding Standards](https://github.com/MarcinOrlowski/laravel-api-response-builder/actions/workflows/coding-standards.yml/badge.svg?branch=dev)](https://github.com/MarcinOrlowski/laravel-api-response-builder/actions/workflows/coding-standards.yml)
1721

1822
## Table of contents ##
1923

docs/CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* v9.3.0 (2021-06-21)
1212
* Added `data_always_object` config option that, when enabled enforces response `data` node
1313
to always be JSON object (for `NULL` it will return empty object `{}`).
14+
* Updated code style to match standard ruleset.
1415
* Improved code quality (fully pass on PHPStan's strict mode)
1516
* Fixed floats being rejected as direct primitive payload.
1617
* Fixed `Converter` unit tests for primitives-as-payload.

src/BaseApiCodes.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ class BaseApiCodes
9999
* @throws Ex\NotIntegerException
100100
*
101101
* @noinspection PhpUnhandledExceptionInspection
102+
* phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
102103
*/
103104
protected static function getBaseMap(): array
104105
{
@@ -126,6 +127,7 @@ protected static function getBaseMap(): array
126127
* @throws Ex\NotIntegerException
127128
*
128129
* @noinspection PhpMethodNamingConventionInspection
130+
* phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
129131
*/
130132
public static function OK(): int
131133
{
@@ -142,6 +144,7 @@ public static function OK(): int
142144
* @throws Ex\NotIntegerException
143145
*
144146
* @noinspection PhpMethodNamingConventionInspection
147+
* phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
145148
*/
146149
public static function NO_ERROR_MESSAGE(): int
147150
{
@@ -158,6 +161,7 @@ public static function NO_ERROR_MESSAGE(): int
158161
* @throws Ex\NotIntegerException
159162
*
160163
* @noinspection PhpMethodNamingConventionInspection
164+
* phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
161165
*/
162166
public static function EX_HTTP_NOT_FOUND(): int
163167
{
@@ -174,6 +178,7 @@ public static function EX_HTTP_NOT_FOUND(): int
174178
* @throws Ex\NotIntegerException
175179
*
176180
* @noinspection PhpMethodNamingConventionInspection
181+
* phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
177182
*/
178183
public static function EX_HTTP_EXCEPTION(): int
179184
{
@@ -190,6 +195,7 @@ public static function EX_HTTP_EXCEPTION(): int
190195
* @throws Ex\NotIntegerException
191196
*
192197
* @noinspection PhpMethodNamingConventionInspection
198+
* phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
193199
*/
194200
public static function EX_UNCAUGHT_EXCEPTION(): int
195201
{
@@ -206,6 +212,7 @@ public static function EX_UNCAUGHT_EXCEPTION(): int
206212
* @throws Ex\NotIntegerException
207213
*
208214
* @noinspection PhpMethodNamingConventionInspection
215+
* phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
209216
*/
210217
public static function EX_AUTHENTICATION_EXCEPTION(): int
211218
{
@@ -222,6 +229,7 @@ public static function EX_AUTHENTICATION_EXCEPTION(): int
222229
* @throws Ex\NotIntegerException
223230
*
224231
* @noinspection PhpMethodNamingConventionInspection
232+
* phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
225233
*/
226234
public static function EX_VALIDATION_EXCEPTION(): int
227235
{
@@ -238,6 +246,7 @@ public static function EX_VALIDATION_EXCEPTION(): int
238246
* @throws Ex\NotIntegerException
239247
*
240248
* @noinspection PhpMethodNamingConventionInspection
249+
* phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
241250
*/
242251
public static function EX_HTTP_SERVICE_UNAVAILABLE(): int
243252
{

src/Converters/ArrayableConverter.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ final class ArrayableConverter implements ConverterContract
3131
* name match or inheritance).
3232
*
3333
* @return array
34+
*
35+
* phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceAfterLastUsed
3436
*/
3537
public function convert(object $obj, /** @scrutinizer ignore-unused */ array $config): array
3638
{

0 commit comments

Comments
 (0)