Skip to content

Commit 4de8756

Browse files
committed
Init
1 parent 8eb2888 commit 4de8756

File tree

10 files changed

+386
-0
lines changed

10 files changed

+386
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
vendor
2+
build
3+
#A library must not provide a composer.lock file
4+
composer.lock

.scrutinizer.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
build_failure_conditions:
2+
- 'project.metric_change("scrutinizer.quality", < -0.30)'
3+
- 'elements.rating(<= D).exists' # No classes/methods with a rating of D or worse
4+
- 'issues.severity(>= MAJOR).exists' # New major or higher severity issues
5+
- 'project.metric("scrutinizer.quality", < 9)' # Code Quality Rating drops below 9
6+
- 'project.metric("scrutinizer.test_coverage", < 1)' # Code Coverage must alway be 100%
7+
- 'patches.label("Doc Comments").exists' # No doc comments patches allowed
8+
- 'patches.label("Spacing").exists' # No spacing patches allowed
9+
- 'patches.label("Bug").exists' # No bug patches allowed
10+
- 'issues.label("coding-style").exists' # No coding style issues allowed
11+
build:
12+
dependencies:
13+
override:
14+
- make build
15+
tests:
16+
stop_on_failure: true
17+
override:
18+
- php-scrutinizer-run --enable-security-analysis
19+
- make codestyle
20+
-
21+
command: make coverage
22+
idle_timeout: 1200
23+
coverage:
24+
file: 'build/coverage/clover.xml'
25+
format: 'php-clover'
26+
cache:
27+
directories:
28+
- ~/.composer
29+
- vendor
30+
31+
environment:
32+
variables:
33+
CI: 'true'
34+
TEST_OUTPUT_STYLE: 'pretty'
35+
COMPOSER_OPTIONS: '--optimize-autoloader'
36+
COVERAGE_OUTPUT_STYLE: 'clover'
37+
COVERAGE_CLOVER_FILE_PATH: 'build/coverage/clover.xml'
38+
PHPCS_DISABLE_WARNING: "true"
39+
php:
40+
version: "7.1"
41+
timezone: UTC
42+
postgresql: false
43+
redis: false
44+
filter:
45+
paths:
46+
- src/*
47+
checks:
48+
php:
49+
code_rating: true
50+
duplication: true
51+
no_debug_code: true
52+
check_method_contracts:
53+
verify_interface_like_constraints: true
54+
verify_documented_constraints: true
55+
verify_parent_constraints: true
56+
simplify_boolean_return: true
57+
return_doc_comments: true
58+
return_doc_comment_if_not_inferrable: true
59+
remove_extra_empty_lines: true
60+
properties_in_camelcaps: true
61+
phpunit_assertions: true
62+
parameters_in_camelcaps: true
63+
parameter_doc_comments: true
64+
param_doc_comment_if_not_inferrable: true
65+
overriding_parameter: true
66+
no_trailing_whitespace: true
67+
no_short_variable_names:
68+
minimum: '3'
69+
no_short_method_names:
70+
minimum: '3'
71+
no_long_variable_names:
72+
maximum: '20'
73+
no_goto: true
74+
naming_conventions:
75+
local_variable: '^[a-z][a-zA-Z0-9]*$'
76+
abstract_class_name: ^Abstract|Factory$
77+
utility_class_name: 'Utils?$'
78+
constant_name: '^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$'
79+
property_name: '^[a-z][a-zA-Z0-9]*$'
80+
method_name: '^(?:[a-z]|__)[a-zA-Z0-9]*$'
81+
parameter_name: '^[a-z][a-zA-Z0-9]*$'
82+
interface_name: '^[A-Z][a-zA-Z0-9]*Interface$'
83+
type_name: '^[A-Z][a-zA-Z0-9]*$'
84+
exception_name: '^[A-Z][a-zA-Z0-9]*Exception$'
85+
isser_method_name: '^(?:is|has|should|may|supports)'
86+
more_specific_types_in_doc_comments: true
87+
fix_doc_comments: false

.travis.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
language: php
2+
3+
php:
4+
- '7.0'
5+
- '7.1'
6+
- '7.2'
7+
8+
env:
9+
global:
10+
CI: 'true'
11+
TEST_OUTPUT_STYLE: 'pretty'
12+
PHPCS_REPORT_STYLE: 'full'
13+
COMPOSER_OPTIONS: '--optimize-autoloader'
14+
15+
sudo: false
16+
17+
matrix:
18+
fast_finish: true
19+
20+
before_install:
21+
# remove xdebug to speed up build
22+
- phpenv config-rm xdebug.ini
23+
24+
install:
25+
- make build
26+
script:
27+
- make test-technical
28+
- make test-functional
29+
30+
cache:
31+
directories:
32+
- $HOME/.composer
33+
- vendor

CONTRIBUTING.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Contributing
2+
3+
## Getting Started
4+
* Fork, then clone the repo:
5+
```bash
6+
git clone git@github.com:your-username/php-jsonrpc-params-symfony-constraint-doc-sdk.git
7+
````
8+
9+
* Make sure everything goes well:
10+
```bash
11+
make build
12+
make test
13+
```
14+
15+
* Make your changes (Add/Update tests according to your changes).
16+
* Make sure tests are still green:
17+
```bash
18+
make test
19+
```
20+
21+
* To check code coverage, launch
22+
```bash
23+
make coverage
24+
```
25+
26+
* Push to your fork and [submit a pull request](https://github.com/yoanm/php-jsonrpc-params-symfony-constraint-doc-sdk/compare/).
27+
* Wait for feedback or merge.
28+
29+
Some stuff that will increase your pull request's acceptance:
30+
* Write tests.
31+
* Follow PSR-2 coding style.
32+
* Write good commit messages.
33+
* Do not rebase or squash your commits when a review has been made.

Makefile

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
COLOR_ENABLED ?= true
2+
TEST_OUTPUT_STYLE ?= dot
3+
COVERAGE_OUTPUT_STYLE ?= html
4+
5+
## DIRECTORY AND FILE
6+
BUILD_DIRECTORY ?= build
7+
REPORTS_DIRECTORY ?= ${BUILD_DIRECTORY}/reports
8+
COVERAGE_DIRECTORY ?= ${BUILD_DIRECTORY}/coverage
9+
COVERAGE_CLOVER_FILE_PATH ?= ${COVERAGE_DIRECTORY}/clover.xml
10+
11+
## Commands options
12+
### Composer
13+
#COMPOSER_OPTIONS=
14+
### Phpcs
15+
PHPCS_REPORT_STYLE ?= full
16+
PHPCS_DISABLE_WARNING ?= "false"
17+
#PHPCS_REPORT_FILE=
18+
#PHPCS_REPORT_FILE_OPTION=
19+
20+
# Enable/Disable color ouput
21+
ifeq ("${COLOR_ENABLED}","true")
22+
PHPUNIT_COLOR_OPTION ?= --colors=always
23+
BEHAT_COLOR_OPTION ?= --colors
24+
PHPCS_COLOR_OPTION ?= --colors
25+
COMPOSER_COLOR_OPTION ?= --ansi
26+
else
27+
PHPUNIT_COLOR_OPTION ?= --colors=never
28+
PHPCS_COLOR_OPTION ?= --no-colors
29+
BEHAT_COLOR_OPTION ?= --no-colors
30+
COMPOSER_COLOR_OPTION ?= --no-ansi
31+
endif
32+
33+
ifeq ("${TEST_OUTPUT_STYLE}","pretty")
34+
PHPUNIT_OUTPUT_STYLE_OPTION ?= --testdox
35+
BEHAT_OUTPUT_STYLE_OPTION ?= --format pretty
36+
else
37+
PHPUNIT_OUTPUT_STYLE_OPTION ?=
38+
BEHAT_OUTPUT_STYLE_OPTION ?= --format progress
39+
endif
40+
41+
ifeq ("${COVERAGE_OUTPUT_STYLE}","clover")
42+
PHPUNIT_COVERAGE_OPTION ?= --coverage-clover ${COVERAGE_CLOVER_FILE_PATH}
43+
else
44+
ifeq ("${COVERAGE_OUTPUT_STYLE}","html")
45+
PHPUNIT_COVERAGE_OPTION ?= --coverage-html ${COVERAGE_DIRECTORY}
46+
else
47+
PHPUNIT_COVERAGE_OPTION ?= --coverage-text
48+
endif
49+
endif
50+
51+
ifneq ("${PHPCS_REPORT_FILE}","")
52+
PHPCS_REPORT_FILE_OPTION ?= --report-file=${PHPCS_REPORT_FILE}
53+
endif
54+
55+
ifneq ("${PHPCS_DISABLE_WARNING}","true")
56+
PHPCS_DISABLE_WARNING_OPTION=
57+
else
58+
PHPCS_DISABLE_WARNING_OPTION=-n
59+
endif
60+
61+
62+
## Project build (install and configure)
63+
build: install configure
64+
65+
## Project installation
66+
install:
67+
composer install ${COMPOSER_COLOR_OPTION} ${COMPOSER_OPTIONS} --prefer-dist --no-suggest --no-interaction
68+
69+
## project Configuration
70+
configure:
71+
72+
# Project tests
73+
test:
74+
make test-functional
75+
make test-technical
76+
make codestyle
77+
78+
test-technical:
79+
./vendor/bin/phpunit ${PHPUNIT_COLOR_OPTION} ${PHPUNIT_OUTPUT_STYLE_OPTION} --testsuite technical
80+
81+
test-functional:
82+
./vendor/bin/phpunit ${PHPUNIT_COLOR_OPTION} ${PHPUNIT_OUTPUT_STYLE_OPTION} --testsuite functional
83+
./vendor/bin/behat ${BEHAT_COLOR_OPTION} ${BEHAT_OUTPUT_STYLE_OPTION} --no-snippets
84+
85+
codestyle: create-reports-directory
86+
./vendor/bin/phpcs ${PHPCS_DISABLE_WARNING_OPTION} --standard=phpcs.xml.dist ${PHPCS_COLOR_OPTION} ${PHPCS_REPORT_FILE_OPTION} --report=${PHPCS_REPORT_STYLE}
87+
88+
coverage: create-coverage-directory
89+
./vendor/bin/phpunit ${PHPUNIT_COLOR_OPTION} ${PHPUNIT_OUTPUT_STYLE_OPTION} ${PHPUNIT_COVERAGE_OPTION}
90+
91+
92+
93+
# Internal commands
94+
create-coverage-directory:
95+
mkdir -p ${COVERAGE_DIRECTORY}
96+
97+
create-reports-directory:
98+
mkdir -p ${REPORTS_DIRECTORY}
99+
100+
101+
.PHONY: build install configure test test-technical test-functional codestyle coverage create-coverage-directory create-reports-directory
102+
.DEFAULT: build

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# JSON-RPC params symfony constraint doc
2+
[![License](https://img.shields.io/github/license/yoanm/php-jsonrpc-params-symfony-constraint-doc-sdk.svg)](https://github.com/yoanm/php-jsonrpc-params-symfony-constraint-doc-sdk) [![Code size](https://img.shields.io/github/languages/code-size/yoanm/php-jsonrpc-params-symfony-constraint-doc-sdk.svg)](https://github.com/yoanm/php-jsonrpc-params-symfony-constraint-doc-sdk) [![PHP Versions](https://img.shields.io/badge/php-7.0%20%2F%207.1%20%2F%207.2-8892BF.svg)](https://php.net/)
3+
4+
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/yoanm/php-jsonrpc-params-symfony-constraint-doc-sdk/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/yoanm/php-jsonrpc-params-symfony-constraint-doc-sdk/?branch=master) [![Build Status](https://scrutinizer-ci.com/g/yoanm/php-jsonrpc-params-symfony-constraint-doc-sdk/badges/build.png?b=master)](https://scrutinizer-ci.com/g/yoanm/php-jsonrpc-params-symfony-constraint-doc-sdk/build-status/master) [![Code Coverage](https://scrutinizer-ci.com/g/yoanm/php-jsonrpc-params-symfony-constraint-doc-sdk/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/yoanm/php-jsonrpc-params-symfony-constraint-doc-sdk/?branch=master)
5+
6+
[![Travis Build Status](https://img.shields.io/travis/yoanm/php-jsonrpc-params-symfony-constraint-doc-sdk/master.svg?label=travis)](https://travis-ci.org/yoanm/php-jsonrpc-params-symfony-constraint-doc-sdk) [![Travis PHP versions](https://img.shields.io/travis/php-v/yoanm/php-jsonrpc-params-symfony-constraint-doc-sdk.svg)](https://travis-ci.org/yoanm/php-jsonrpc-params-symfony-constraint-doc-sdk)
7+
8+
[![Latest Stable Version](https://img.shields.io/packagist/v/yoanm/jsonrpc-params-symfony-constraint-doc-sdk.svg)](https://packagist.org/packages/yoanm/jsonrpc-params-symfony-constraint-doc-sdk) [![Packagist PHP version](https://img.shields.io/packagist/php-v/yoanm/jsonrpc-params-symfony-constraint-doc-sdk.svg)](https://packagist.org/packages/yoanm/jsonrpc-params-symfony-constraint-doc-sdk)
9+
10+
SDK to generate JSON-RPC documentation from symfony constraint
11+
12+
## How to use
13+
14+
15+
## Contributing
16+
See [contributing note](./CONTRIBUTING.md)

behat.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
default:
2+
suites:
3+
default:
4+
contexts:
5+
- Tests\Functional\BehatContext\FeatureContext: ~

composer.json

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"name": "yoanm/jsonrpc-params-symfony-constraint-doc-sdk",
3+
"description": "Simple JSON-RPC params validator that use Symfony validator component",
4+
"license": "MIT",
5+
"type": "library",
6+
"support": {
7+
"issues": "https://github.com/yoanm/php-jsonrpc-params-symfony-constraint-doc-sdk/issues"
8+
},
9+
"authors": [
10+
{
11+
"name": "Yoanm",
12+
"email": "yoanm@users.noreply.github.com",
13+
"role": "Developer"
14+
}
15+
],
16+
"autoload": {
17+
"psr-4": {
18+
"Yoanm\\JsonRpcParamsSymfonyConstraintDoc\\": "src"
19+
}
20+
},
21+
"autoload-dev": {
22+
"psr-4": {
23+
"Tests\\": "tests",
24+
"Tests\\Functional\\BehatContext\\": "features/bootstrap"
25+
}
26+
},
27+
"require": {
28+
"php": ">=7.0",
29+
"yoanm/jsonrpc-server-doc-sdk": "dev-release/1.0.0",
30+
"symfony/validator": "^3.0 || ^4.0"
31+
},
32+
"require-dev": {
33+
"behat/behat": "~3.0",
34+
"squizlabs/php_codesniffer": "3.*",
35+
"phpunit/phpunit": "^6.0 || ^7.0",
36+
"yoanm/php-unit-extended": "^1.0",
37+
"matthiasnoback/symfony-dependency-injection-test": "^2.0 || ^3.0",
38+
"matthiasnoback/symfony-config-test": "^3.0 || ^4.0",
39+
"symfony/framework-bundle": "^3.4",
40+
"symfony/http-kernel": "^3.4",
41+
"symfony/routing": "^3.4",
42+
"yoanm/jsonrpc-server-doc-sdk": "dev-release/1.0.0"
43+
},
44+
"minimum-stability": "dev"
45+
}

phpcs.xml.dist

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="php-jsonrpc-params-symfony-constraint-doc-sdk">
3+
<file>src</file>
4+
<file>tests</file>
5+
<file>features/bootstrap</file>
6+
7+
<arg value="p"/>
8+
<arg name="colors"/>
9+
<arg name="extensions" value="php"/>
10+
11+
<rule ref="PSR2"/>
12+
</ruleset>

phpunit.xml.dist

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
4+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.8/phpunit.xsd"
6+
backupStaticAttributes="false"
7+
colors="true"
8+
processIsolation="false"
9+
10+
stopOnRisky="true"
11+
processUncoveredFilesFromWhitelist="true"
12+
addUncoveredFilesFromWhitelist="true"
13+
checkForUnintentionallyCoveredCode="true"
14+
15+
stopOnError="true"
16+
stopOnFailure="true"
17+
18+
convertErrorsToExceptions="true"
19+
convertNoticesToExceptions="true"
20+
convertWarningsToExceptions="true"
21+
22+
beStrictAboutOutputDuringTests="true"
23+
beStrictAboutTestsThatDoNotTestAnything="true"
24+
beStrictAboutChangesToGlobalState="true"
25+
backupGlobals="true"
26+
27+
forceCoversAnnotation="true"
28+
29+
bootstrap="vendor/autoload.php"
30+
>
31+
<listeners>
32+
<listener class="Yoanm\PhpUnitExtended\Listener\YoanmTestsStrategyListener"/>
33+
</listeners>
34+
35+
<testsuites>
36+
<testsuite name="functional">
37+
<directory>tests/Functional/*</directory>
38+
</testsuite>
39+
<testsuite name="technical">
40+
<directory>tests/Technical/*</directory>
41+
</testsuite>
42+
</testsuites>
43+
44+
<filter>
45+
<whitelist>
46+
<directory>src</directory>
47+
</whitelist>
48+
</filter>
49+
</phpunit>

0 commit comments

Comments
 (0)