Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PHPCS configuration #188

Merged
merged 3 commits into from
Jul 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ phpunit.xml
composer.lock
humbuglog.txt
coverage
phpcs.xml
108 changes: 84 additions & 24 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,15 @@ build:
redis: false
rabbitmq: false
php:
version: 7.1.0
tools:
php_sim: true
php_pdepend: true
php_analyzer: true
php_changetracking: true
sensiolabs_security_checker: true
php_mess_detector: true
php_code_coverage: true
external_code_coverage:
timeout: 1800
php_code_sniffer:
enabled: true
config:
standard: "PSR2"
php_cpd:
enabled: true
excluded_dirs: ["test", "vendor"]
php_loc:
enabled: true
excluded_dirs: ["test", "vendor"]
version: 7.1
cache:
disabled: false
directories:
- ~/.composer/cache
tests:
after:
- phpcs-run

checks:
php:
code_rating: true
Expand Down Expand Up @@ -61,6 +49,78 @@ checks:
verify_access_scope_valid: true
verify_argument_usable_as_reference: true
verify_property_names: true
filter:
excluded_paths:
- test/*
uppercase_constants: true
simplify_boolean_return: true
return_doc_comments: true
remove_extra_empty_lines: true
properties_in_camelcaps: true
phpunit_assertions: true
parameters_in_camelcaps: true
parameter_doc_comments: true
overriding_parameter: true
optional_parameters_at_the_end: true
no_short_variable_names:
minimum: '2'
no_long_variable_names:
maximum: '20'
no_goto: true
newline_at_end_of_file: true
more_specific_types_in_doc_comments: false
function_in_camel_caps: true
encourage_single_quotes: true
encourage_postdec_operator: true
classes_in_camel_caps: true
check_method_contracts:
verify_interface_like_constraints: true
verify_documented_constraints: true
verify_parent_constraints: true
avoid_unnecessary_concatenation: true
avoid_perl_style_comments: true
avoid_multiple_statements_on_same_line: true
align_assignments: true
deadlock_detection_in_loops: true
use_self_instead_of_fqcn: true
single_namespace_per_use: true
side_effects_or_types: true
require_scope_for_properties: true
require_scope_for_methods: true
psr2_switch_declaration: true
psr2_class_declaration: true
property_assignments: true
parse_doc_comments: true
overriding_private_members: true
no_underscore_prefix_in_properties: true
no_underscore_prefix_in_methods: true
no_trait_type_hints: true
no_trailing_whitespace: true
no_short_open_tag: true
no_global_keyword: true
no_exit: true
no_eval: true
no_error_suppression: true
no_empty_statements: true
no_debug_code: true
no_commented_out_code: true
no_unnecessary_if: true
return_in_constructor: true
php5_style_constructor: true
instanceof_class_exists: true
foreach_traversable: true
call_to_parent_method: true
blank_line_after_namespace_declaration: true
avoid_usage_of_logical_operators: true
avoid_superglobals: true
avoid_length_functions_in_loops: true
avoid_duplicate_types: true
avoid_closing_tag: true
avoid_corrupting_byteorder_marks: true
avoid_aliased_php_functions: true
encourage_shallow_comparison: true

build_failure_conditions:
- 'elements.rating(<= C).new.exists' # No new classes/methods with a rating of C or worse allowed
- 'issues.label("coding-style").new.exists' # No new coding style issues allowed
- 'issues.severity(>= MAJOR).new.exists' # New issues of major or higher severity
- 'project.metric_change("scrutinizer.test_coverage", < 0)' # Code Coverage decreased from previous inspection
- 'patches.label("Doc Comments").new.exists' # No new doc comments patches allowed
- 'patches.label("Unused Use Statements").new.exists' # No new unused imports patches allowed
41 changes: 32 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,45 @@
language: php
dist: trusty
sudo: false
language: php

php:
- 7.1
- 7.2
- nightly

cache:
directories:
- $HOME/.composer/cache

before_script:
- composer install
before_install:
- mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{,.disabled} || echo "xdebug not available"
- composer self-update

install: travis_retry composer install

script:
- ./vendor/bin/phpunit --coverage-clover ./clover.xml --testsuite=unit
- ./vendor/bin/phpunit test/functional
# - if php -i |grep -qE xdebug; then ./vendor/bin/humbug --options='--testsuite=unit'; fi
- ./vendor/bin/phpunit --testsuite=unit
- ./vendor/bin/phpunit --testsuite=functional

jobs:
allow_failures:
- php: 7.2
- php: nightly

include:
- stage: Coverage
before_script:
- mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{.disabled,}
- if [[ ! $(php -m | grep -si xdebug) ]]; then echo "xdebug required for coverage"; exit 1; fi
script:
- ./vendor/bin/phpunit --testsuite=unit --coverage-clover ./clover.xml
after_script:
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover ./clover.xml

after_script:
- wget https://scrutinizer-ci.com/ocular.phar
- if [ -f clover.xml ]; then php ocular.phar code-coverage:upload --format=php-clover ./clover.xml; fi
# - stage: Mutation
# before_script:
# - mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{.disabled,}
# - if [[ ! $(php -m | grep -si xdebug) ]]; then echo "xdebug required for coverage"; exit 1; fi
# script:
# - ./vendor/bin/humbug --options='--testsuite=unit'
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"phpmd/phpmd": "^2.5",
"phpunit/php-invoker": "^1.1",
"phpunit/phpunit": "^6.0",
"squizlabs/php_codesniffer": "^2.7"
"squizlabs/php_codesniffer": "^3.0"
},
"suggest":{
"mdanter/ecc": "Required to use Elliptic Curves based algorithms."
Expand Down
15 changes: 15 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<ruleset name="JWT style">
<description>The coding standard for lcobucci/jwt.</description>

<arg name="basepath" value="."/>
<arg name="extensions" value="php"/>
<arg name="parallel" value="80" />
<arg name="colors" />
<arg value="np"/>

<file>src</file>
<file>test</file>

<rule ref="PSR2"/>
</ruleset>