Skip to content

Commit a38f0b7

Browse files
authored
Merge pull request #485 from thephpleague/feature/phpcs-circleci
Add phpcs and circleci configurations and run phpcs check on PRs
2 parents 4317558 + 7fa113f commit a38f0b7

File tree

8 files changed

+65
-8
lines changed

8 files changed

+65
-8
lines changed

.circleci/config.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# PHP CircleCI 2.0 configuration file
2+
#
3+
# Check https://circleci.com/docs/2.0/language-php/ for more details
4+
#
5+
version: 2
6+
jobs:
7+
build:
8+
docker:
9+
# Specify the version you desire here
10+
- image: circleci/php:7.2
11+
12+
# Specify service dependencies here if necessary
13+
# CircleCI maintains a library of pre-built images
14+
# documented at https://circleci.com/docs/2.0/circleci-images/
15+
# Using the RAM variation mitigates I/O contention
16+
# for database intensive operations.
17+
# - image: circleci/mysql:5.7-ram
18+
#
19+
# - image: redis:2.8.19
20+
21+
steps:
22+
- checkout
23+
24+
- run: sudo apt update # PHP CircleCI 2.0 Configuration File# PHP CircleCI 2.0 Configuration File sudo apt install zlib1g-dev libsqlite3-dev
25+
26+
# Download and cache dependencies
27+
- restore_cache:
28+
keys:
29+
# "composer.lock" can be used if it is committed to the repo
30+
- v1-dependencies-{{ checksum "composer.json" }}
31+
# fallback to using the latest cache if no exact match is found
32+
- v1-dependencies-
33+
34+
- run: composer install -n --prefer-dist
35+
36+
- save_cache:
37+
key: v1-dependencies-{{ checksum "composer.json" }}
38+
paths:
39+
- ./vendor
40+
41+
# Check code style
42+
- run: ./vendor/bin/phpcs src

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.idea
12
.ruby-version
23
composer.lock
34
build

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"mockery/mockery": "~0.9",
3030
"pagerfanta/pagerfanta": "~1.0.0",
3131
"phpunit/phpunit": "^4.8.35 || ^7.5",
32-
"squizlabs/php_codesniffer": "~1.5",
32+
"squizlabs/php_codesniffer": "~1.5|~2.0|~3.4",
3333
"zendframework/zend-paginator": "~2.3"
3434
},
3535
"suggest": {

phpcs.xml.dist

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="fractal">
3+
<description>Fractal Coding Standards</description>
4+
<arg value="p" />
5+
6+
<config name="ignore_warnings_on_exit" value="1" />
7+
<config name="ignore_errors_on_exit" value="1" />
8+
9+
<arg name="colors" />
10+
<arg value="s" />
11+
12+
<!-- Use the PSR2 Standard-->
13+
<rule ref="PSR2" />
14+
</ruleset>

src/Manager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ public function parseIncludes($includes)
223223
/**
224224
* Parse field parameter.
225225
*
226-
* @param array $fieldsets Array of fields to include. It must be an array whose keys
226+
* @param array $fieldsets Array of fields to include. It must be an array whose keys
227227
* are resource types and values an array or a string
228228
* of the fields to return, separated by a comma
229229
*

src/Pagination/PhalconFrameworkPaginatorAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function getPerPage()
9393
* Get the next.
9494
*
9595
* @return int
96-
*/
96+
*/
9797
public function getNext()
9898
{
9999
return $this->paginator->next;

src/Serializer/JsonApiSerializer.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,25 +72,25 @@ public function item($resourceKey, array $data)
7272

7373
unset($resource['data']['attributes']['id']);
7474

75-
if(isset($resource['data']['attributes']['links'])) {
75+
if (isset($resource['data']['attributes']['links'])) {
7676
$custom_links = $data['links'];
7777
unset($resource['data']['attributes']['links']);
7878
}
7979

80-
if (isset($resource['data']['attributes']['meta'])){
80+
if (isset($resource['data']['attributes']['meta'])) {
8181
$resource['data']['meta'] = $data['meta'];
8282
unset($resource['data']['attributes']['meta']);
8383
}
8484

85-
if(empty($resource['data']['attributes'])) {
85+
if (empty($resource['data']['attributes'])) {
8686
$resource['data']['attributes'] = (object) [];
8787
}
8888

8989
if ($this->shouldIncludeLinks()) {
9090
$resource['data']['links'] = [
9191
'self' => "{$this->baseUrl}/$resourceKey/$id",
9292
];
93-
if(isset($custom_links)) {
93+
if (isset($custom_links)) {
9494
$resource['data']['links'] = array_merge($resource['data']['links'], $custom_links);
9595
}
9696
}

src/Serializer/Serializer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,4 @@ public function injectData($data, $rawIncludedData);
9999
* @return array
100100
*/
101101
public function filterIncludes($includedData, $data);
102-
}
102+
}

0 commit comments

Comments
 (0)