Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Commit c8d18c6

Browse files
committed
Check codestyle on Travis
1 parent c051b54 commit c8d18c6

File tree

4 files changed

+63
-10
lines changed

4 files changed

+63
-10
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
composer.phar
22
composer.lock
33
vendor
4+
.php_cs.cache
45

56
# generic files to ignore
67
*.lock
78
*.DS_Store
89
*~
910
*.swp
10-
.idea
11+
.idea

.php_cs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
$finder = Symfony\CS\Finder\DefaultFinder::create()
4+
->in(array(__DIR__ . '/lib', __DIR__ . '/tests'));
5+
6+
return Symfony\CS\Config\Config::create()
7+
->fixers(array(
8+
'duplicate_semicolon',
9+
'extra_empty_lines',
10+
'multiline_array_trailing_comma',
11+
'namespace_no_leading_whitespace',
12+
'new_with_braces',
13+
'no_blank_lines_after_class_opening',
14+
'no_empty_lines_after_phpdocs',
15+
'object_operator',
16+
'operators_spaces',
17+
'trim_array_spaces',
18+
'phpdoc_indent',
19+
'phpdoc_no_access',
20+
'phpdoc_no_empty_return',
21+
'phpdoc_no_package',
22+
'phpdoc_scalar',
23+
'phpdoc_trim',
24+
'phpdoc_types',
25+
'phpdoc_order',
26+
'unused_use',
27+
'ordered_use',
28+
'remove_leading_slash_use',
29+
'remove_lines_between_uses',
30+
'function_typehint_space',
31+
'self_accessor',
32+
'single_array_no_trailing_comma',
33+
'single_blank_line_before_namespace',
34+
'single_quote',
35+
'spaces_cast',
36+
'whitespacy_lines',
37+
'newline_after_open_tag',
38+
))
39+
->level(Symfony\CS\FixerInterface::PSR2_LEVEL)
40+
->setUsingCache(true)
41+
->finder($finder);

.travis.yml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ php:
1010
- 7
1111
- hhvm
1212

13+
matrix:
14+
include:
15+
# Add PHP 7 build to check codestyle only in PHP 7 build
16+
- php: 7
17+
env: CHECK_CODESTYLE=1
18+
1319
env:
1420
global:
1521
- DISPLAY=:99.0
@@ -19,18 +25,21 @@ cache:
1925
- $HOME/.composer/cache
2026

2127
before_install:
22-
- composer self-update
28+
- travis_retry composer self-update
2329

2430
install:
25-
- composer install --no-interaction --prefer-source
31+
- travis_retry composer install --no-interaction --prefer-source
2632

2733
before_script:
28-
- sh -e /etc/init.d/xvfb start
29-
- wget -q -t 3 http://selenium-release.storage.googleapis.com/2.45/selenium-server-standalone-2.45.0.jar
30-
- java -jar selenium-server-standalone-2.45.0.jar -log selenium.log &
31-
- until $(echo | nc localhost 4444); do sleep 1; echo waiting for selenium-server...; done;
32-
33-
script: ./vendor/bin/phpunit
34+
- if [ -z "$CHECK_CODESTYLE" ]; then sh -e /etc/init.d/xvfb start; fi
35+
- if [ -z "$CHECK_CODESTYLE" ]; then wget -q -t 3 http://selenium-release.storage.googleapis.com/2.45/selenium-server-standalone-2.45.0.jar; fi
36+
- if [ -z "$CHECK_CODESTYLE" ]; then java -jar selenium-server-standalone-2.45.0.jar -log selenium.log; fi &
37+
- if [ -z "$CHECK_CODESTYLE" ]; then until $(echo | nc localhost 4444); do sleep 1; echo waiting for selenium-server...; done; fi
38+
39+
script:
40+
- if [ -n "$CHECK_CODESTYLE" ]; then ./vendor/bin/php-cs-fixer fix --diff --dry-run; fi
41+
- if [ -n "$CHECK_CODESTYLE" ]; then ./vendor/bin/phpcs --standard=PSR2 ./lib/ ./tests/; fi
42+
- if [ -z "$CHECK_CODESTYLE" ]; then ./vendor/bin/phpunit; fi
3443

3544
after_script:
3645
- cat selenium.log

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
"ext-curl": "*"
1616
},
1717
"require-dev": {
18-
"phpunit/phpunit": "4.6.* || ~5.0"
18+
"phpunit/phpunit": "4.6.* || ~5.0",
19+
"friendsofphp/php-cs-fixer": "^1.11",
20+
"squizlabs/php_codesniffer": "^2.6"
1921
},
2022
"suggest": {
2123
"phpdocumentor/phpdocumentor": "2.*"

0 commit comments

Comments
 (0)