From 7fa113fef4035feb3879d2ad05b1dc48bdbbaed2 Mon Sep 17 00:00:00 2001 From: Korvin Szanto Date: Sat, 29 Jun 2019 13:07:55 -0700 Subject: [PATCH] Add phpcs and circleci configurations --- .circleci/config.yml | 42 +++++++++++++++++++ .gitignore | 1 + composer.json | 2 +- phpcs.xml.dist | 14 +++++++ src/Manager.php | 2 +- .../PhalconFrameworkPaginatorAdapter.php | 2 +- src/Serializer/JsonApiSerializer.php | 8 ++-- src/Serializer/Serializer.php | 2 +- 8 files changed, 65 insertions(+), 8 deletions(-) create mode 100644 .circleci/config.yml create mode 100644 phpcs.xml.dist diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000..b6e3aaf8 --- /dev/null +++ b/.circleci/config.yml @@ -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 diff --git a/.gitignore b/.gitignore index a1ecf70f..aaee0d9c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.idea .ruby-version composer.lock build diff --git a/composer.json b/composer.json index 843c20c6..31736618 100644 --- a/composer.json +++ b/composer.json @@ -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": { diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 00000000..dfb69119 --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,14 @@ + + + Fractal Coding Standards + + + + + + + + + + + diff --git a/src/Manager.php b/src/Manager.php index 23a93ce9..2d565aaf 100644 --- a/src/Manager.php +++ b/src/Manager.php @@ -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 * diff --git a/src/Pagination/PhalconFrameworkPaginatorAdapter.php b/src/Pagination/PhalconFrameworkPaginatorAdapter.php index d2bec715..e6f666dd 100644 --- a/src/Pagination/PhalconFrameworkPaginatorAdapter.php +++ b/src/Pagination/PhalconFrameworkPaginatorAdapter.php @@ -93,7 +93,7 @@ public function getPerPage() * Get the next. * * @return int - */ + */ public function getNext() { return $this->paginator->next; diff --git a/src/Serializer/JsonApiSerializer.php b/src/Serializer/JsonApiSerializer.php index 3b2efb53..85d54e5f 100644 --- a/src/Serializer/JsonApiSerializer.php +++ b/src/Serializer/JsonApiSerializer.php @@ -72,17 +72,17 @@ 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) []; } @@ -90,7 +90,7 @@ public function item($resourceKey, array $data) $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); } } diff --git a/src/Serializer/Serializer.php b/src/Serializer/Serializer.php index 06aac300..e3252b08 100644 --- a/src/Serializer/Serializer.php +++ b/src/Serializer/Serializer.php @@ -99,4 +99,4 @@ public function injectData($data, $rawIncludedData); * @return array */ public function filterIncludes($includedData, $data); -} \ No newline at end of file +}