Skip to content

Commit

Permalink
Merge pull request #485 from thephpleague/feature/phpcs-circleci
Browse files Browse the repository at this point in the history
Add phpcs and circleci configurations and run phpcs check on PRs
  • Loading branch information
matthewtrask authored Jun 30, 2019
2 parents 4317558 + 7fa113f commit a38f0b7
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 8 deletions.
42 changes: 42 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# PHP CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-php/ for more details
#
version: 2
jobs:
build:
docker:
# Specify the version you desire here
- image: circleci/php:7.2

# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
# Using the RAM variation mitigates I/O contention
# for database intensive operations.
# - image: circleci/mysql:5.7-ram
#
# - image: redis:2.8.19

steps:
- checkout

- run: sudo apt update # PHP CircleCI 2.0 Configuration File# PHP CircleCI 2.0 Configuration File sudo apt install zlib1g-dev libsqlite3-dev

# Download and cache dependencies
- restore_cache:
keys:
# "composer.lock" can be used if it is committed to the repo
- v1-dependencies-{{ checksum "composer.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- run: composer install -n --prefer-dist

- save_cache:
key: v1-dependencies-{{ checksum "composer.json" }}
paths:
- ./vendor

# Check code style
- run: ./vendor/bin/phpcs src
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea
.ruby-version
composer.lock
build
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"mockery/mockery": "~0.9",
"pagerfanta/pagerfanta": "~1.0.0",
"phpunit/phpunit": "^4.8.35 || ^7.5",
"squizlabs/php_codesniffer": "~1.5",
"squizlabs/php_codesniffer": "~1.5|~2.0|~3.4",
"zendframework/zend-paginator": "~2.3"
},
"suggest": {
Expand Down
14 changes: 14 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0"?>
<ruleset name="fractal">
<description>Fractal Coding Standards</description>
<arg value="p" />

<config name="ignore_warnings_on_exit" value="1" />
<config name="ignore_errors_on_exit" value="1" />

<arg name="colors" />
<arg value="s" />

<!-- Use the PSR2 Standard-->
<rule ref="PSR2" />
</ruleset>
2 changes: 1 addition & 1 deletion src/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public function parseIncludes($includes)
/**
* Parse field parameter.
*
* @param array $fieldsets Array of fields to include. It must be an array whose keys
* @param array $fieldsets Array of fields to include. It must be an array whose keys
* are resource types and values an array or a string
* of the fields to return, separated by a comma
*
Expand Down
2 changes: 1 addition & 1 deletion src/Pagination/PhalconFrameworkPaginatorAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function getPerPage()
* Get the next.
*
* @return int
*/
*/
public function getNext()
{
return $this->paginator->next;
Expand Down
8 changes: 4 additions & 4 deletions src/Serializer/JsonApiSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,25 +72,25 @@ public function item($resourceKey, array $data)

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

if(isset($resource['data']['attributes']['links'])) {
if (isset($resource['data']['attributes']['links'])) {
$custom_links = $data['links'];
unset($resource['data']['attributes']['links']);
}

if (isset($resource['data']['attributes']['meta'])){
if (isset($resource['data']['attributes']['meta'])) {
$resource['data']['meta'] = $data['meta'];
unset($resource['data']['attributes']['meta']);
}

if(empty($resource['data']['attributes'])) {
if (empty($resource['data']['attributes'])) {
$resource['data']['attributes'] = (object) [];
}

if ($this->shouldIncludeLinks()) {
$resource['data']['links'] = [
'self' => "{$this->baseUrl}/$resourceKey/$id",
];
if(isset($custom_links)) {
if (isset($custom_links)) {
$resource['data']['links'] = array_merge($resource['data']['links'], $custom_links);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Serializer/Serializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,4 @@ public function injectData($data, $rawIncludedData);
* @return array
*/
public function filterIncludes($includedData, $data);
}
}

0 comments on commit a38f0b7

Please sign in to comment.