Skip to content

Commit 3c78330

Browse files
authored
Merge f388581 into 99f2724
2 parents 99f2724 + f388581 commit 3c78330

File tree

3 files changed

+88
-37
lines changed

3 files changed

+88
-37
lines changed

.circleci/config.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ reusable-steps:
2525
- npm-cache-{{ .Revision }}
2626
- npm-cache-{{ .Branch }}
2727
- npm-cache
28+
- &restore-php-cs-fixer-cache
29+
restore_cache:
30+
keys:
31+
- php-cs-fixer-cache-{{ .Revision }}
32+
- php-cs-fixer-cache-{{ .Branch }}
33+
- php-cs-fixer-cache
2834
- &save-composer-cache-by-branch
2935
save_cache:
3036
paths:
@@ -45,6 +51,16 @@ reusable-steps:
4551
paths:
4652
- ~/.npm
4753
key: npm-cache-{{ .Revision }}-{{ .BuildNum }}
54+
- &save-php-cs-fixer-cache-by-branch
55+
save_cache:
56+
paths:
57+
- .php_cs.cache
58+
key: php-cs-fixer-cache-{{ .Branch }}-{{ .BuildNum }}
59+
- &save-php-cs-fixer-cache-by-revision
60+
save_cache:
61+
paths:
62+
- .php_cs.cache
63+
key: php-cs-fixer-cache-{{ .Revision }}-{{ .BuildNum }}
4864
- &update-composer
4965
run:
5066
name: Update Composer
@@ -179,6 +195,54 @@ jobs:
179195
- *save-npm-cache-by-revision
180196
- *save-npm-cache-by-branch
181197

198+
php-cs-fixer:
199+
docker:
200+
- image: circleci/php:7.2-node-browsers
201+
environment:
202+
PHP_CS_FIXER_FUTURE_MODE: 1
203+
working_directory: ~/api-platform/core
204+
steps:
205+
- checkout
206+
- *restore-composer-cache
207+
- *restore-php-cs-fixer-cache
208+
- *disable-xdebug-php-extension
209+
- *disable-php-memory-limit
210+
- *update-composer
211+
- run:
212+
name: Install PHP-CS-Fixer
213+
command: composer global require friendsofphp/php-cs-fixer:^2.12
214+
- *save-composer-cache-by-revision
215+
- *save-composer-cache-by-branch
216+
- run:
217+
name: Run PHP-CS-Fixer
218+
command: |-
219+
export PATH="$PATH:$HOME/.composer/vendor/bin"
220+
php-cs-fixer fix --dry-run --diff --ansi
221+
- *save-php-cs-fixer-cache-by-revision
222+
- *save-php-cs-fixer-cache-by-branch
223+
224+
phpstan:
225+
docker:
226+
- image: circleci/php:7.2-node-browsers
227+
working_directory: ~/api-platform/core
228+
steps:
229+
- checkout
230+
- *restore-composer-cache
231+
- *disable-xdebug-php-extension
232+
- *disable-php-memory-limit
233+
- *update-composer
234+
- *update-project-dependencies
235+
- run:
236+
name: Install PHPStan
237+
command: composer global require phpstan/phpstan:^0.8
238+
- *save-composer-cache-by-revision
239+
- *save-composer-cache-by-branch
240+
- run:
241+
name: Run PHPStan
242+
command: |-
243+
export PATH="$PATH:$HOME/.composer/vendor/bin"
244+
phpstan analyse -c phpstan.neon -l5 --ansi src tests
245+
182246
workflows:
183247
version: 2
184248
test-with-coverage:
@@ -189,3 +253,7 @@ workflows:
189253
requires:
190254
- phpunit-php-7.2-coverage
191255
- behat-php-7.2-coverage
256+
lint:
257+
jobs:
258+
- php-cs-fixer
259+
- phpstan

.php_cs.dist

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,21 @@ return PhpCsFixer\Config::create()
4242
'location' => 'after_open',
4343
],
4444
'modernize_types_casting' => true,
45-
'no_extra_consecutive_blank_lines' => [
46-
'break',
47-
'continue',
48-
'curly_brace_block',
49-
'extra',
50-
'parenthesis_brace_block',
51-
'return',
52-
'square_brace_block',
53-
'throw',
54-
'use',
45+
'native_function_invocation' => [
46+
'include' => '@compiler_optimized',
47+
],
48+
'no_extra_blank_lines' => [
49+
'tokens' => [
50+
'break',
51+
'continue',
52+
'curly_brace_block',
53+
'extra',
54+
'parenthesis_brace_block',
55+
'return',
56+
'square_brace_block',
57+
'throw',
58+
'use',
59+
],
5560
],
5661
'no_useless_else' => true,
5762
'no_useless_return' => true,

.travis.yml

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ matrix:
1616
- php: '7.0'
1717
- php: '7.1'
1818
- php: '7.2'
19-
- php: '7.2'
20-
env: lint=1
2119
- php: '7.2'
2220
env: deps=low
2321
- php: '7.2'
@@ -40,12 +38,6 @@ matrix:
4038
before_install:
4139
- phpenv config-rm xdebug.ini || echo "xdebug not available"
4240
- echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
43-
- if [[ $lint = 1 ]]; then
44-
wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.12.0/php-cs-fixer.phar;
45-
fi
46-
- if [[ $lint = 1 ]]; then
47-
composer global require --dev 'phpstan/phpstan:^0.8';
48-
fi
4941
- export PATH="$PATH:$HOME/.composer/vendor/bin"
5042

5143
install:
@@ -56,26 +48,12 @@ install:
5648
fi
5749

5850
script:
59-
- if [[ $lint != 1 ]]; then
60-
tests/Fixtures/app/console cache:clear;
61-
fi
62-
- if [[ $lint != 1 ]]; then
63-
vendor/bin/phpunit;
64-
fi
65-
- if [[ $lint != 1 ]]; then
66-
tests/Fixtures/app/console cache:clear;
67-
fi
51+
- tests/Fixtures/app/console cache:clear
52+
- vendor/bin/phpunit
53+
- tests/Fixtures/app/console cache:clear
6854
- if [[ $APP_ENV = 'postgres' ]]; then
6955
vendor/bin/behat --suite=postgres --format=progress;
70-
elif [[ $lint != 1 ]]; then
56+
else
7157
vendor/bin/behat --suite=default --format=progress;
7258
fi
73-
- if [[ $lint != 1 ]]; then
74-
tests/Fixtures/app/console api:swagger:export > swagger.json && npx swagger-cli validate swagger.json && rm swagger.json;
75-
fi
76-
- if [[ $lint = 1 ]]; then
77-
php php-cs-fixer.phar fix --dry-run --diff --no-ansi;
78-
fi
79-
- if [[ $lint = 1 ]]; then
80-
phpstan analyse -c phpstan.neon -l5 --ansi src tests;
81-
fi
59+
- tests/Fixtures/app/console api:swagger:export > swagger.json && npx swagger-cli validate swagger.json && rm swagger.json

0 commit comments

Comments
 (0)