Skip to content

Commit

Permalink
Coding Standards aligned with other projects (#120)
Browse files Browse the repository at this point in the history
* Make rule and deps
* CS applied
  • Loading branch information
Spomky authored Oct 26, 2018
1 parent 0f8a338 commit 678cb06
Show file tree
Hide file tree
Showing 19 changed files with 3,440 additions and 465 deletions.
61 changes: 61 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

$header = 'The MIT License (MIT)
Copyright (c) 2014-2018 Spomky-Labs
This software may be modified and distributed under the terms
of the MIT license. See the LICENSE file for details.';

$finder = PhpCsFixer\Finder::create()
->in(__DIR__.'/src')
->in(__DIR__.'/tests')
;

return PhpCsFixer\Config::create()
->setRules([
'@PSR1' => true,
'@PSR2' => true,
'@Symfony' => true,
'@DoctrineAnnotation' => true,
'@PHP70Migration' => true,
'@PHP71Migration' => true,
'strict_param' => true,
'strict_comparison' => true,
'array_syntax' => ['syntax' => 'short'],
'array_indentation' => true,
'ordered_imports' => true,
'protected_to_private' => true,
'declare_strict_types' => true,
'native_function_invocation' => [
'include' => ['@compiler_optimized'],
'scope' => 'namespaced',
],
'mb_str_functions' => true,
'method_chaining_indentation' => true,
'linebreak_after_opening_tag' => true,
'combine_consecutive_issets' => true,
'combine_consecutive_unsets' => true,
'compact_nullable_typehint' => true,
'no_superfluous_phpdoc_tags' => true,
'no_superfluous_elseif' => true,
'phpdoc_trim_consecutive_blank_line_separation' => true,
'phpdoc_order' => true,
'pow_to_exponentiation' => true,
'simplified_null_return' => true,
'header_comment' => [
'header' => $header,
],
'align_multiline_comment' => [
'comment_type' => 'all_multiline',
],
'php_unit_test_annotation' => [
'case' => 'snake',
'style' => 'annotation',
],
'php_unit_test_case_static_method_calls' => true,
])
->setRiskyAllowed(true)
->setUsingCache(true)
->setFinder($finder)
;
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ matrix:
- php: nightly
include:
- php: 7.1
- php: 7.2
- php: 7.1
env: deps=low
- php: nightly
Expand Down
39 changes: 39 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
##
## OTPHP
## -----
##

install: ## Install the dependencies (dev included)
install: vendor

##
## Coding Standard
## ---------------
##

cs: ## Fix coding standard
cs: vendor
vendor/bin/php-cs-fixer fix

##
## Tests
## -----
##

test: ## Run unit and functional test
test: vendor
vendor/bin/phpunit

.PHONY: install tests help
.DEFAULT_GOAL := help
help:
@grep -E '(^[a-zA-Z_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/'



composer.lock: composer.json
composer update

vendor: composer.lock
composer install

4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
],
"require": {
"php": "^7.1",
"ext-mbstring": "*",
"paragonie/constant_time_encoding": "^2.0",
"beberlei/assert": "^2.4"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.11",
"phpunit/phpunit": "^7.0",
"satooshi/php-coveralls": "^2.0"
"php-coveralls/php-coveralls": "^2.0"
},
"suggest": {
},
Expand Down
Loading

0 comments on commit 678cb06

Please sign in to comment.