Skip to content

Commit aaa4d89

Browse files
authored
v0.1.0
2 parents 20a97f5 + 5b2688e commit aaa4d89

37 files changed

+1501
-6
lines changed

.gitignore

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

.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+
-
19+
command: make coverage
20+
idle_timeout: 1200
21+
coverage:
22+
file: 'build/coverage/clover.xml'
23+
format: 'php-clover'
24+
- php-scrutinizer-run --enable-security-analysis
25+
- make codestyle
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: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
language: php
2+
3+
php:
4+
- '7.1'
5+
- '7.2'
6+
- '7.3'
7+
8+
env:
9+
global:
10+
CI: 'true'
11+
TEST_OUTPUT_STYLE: 'pretty'
12+
PHPCS_REPORT_STYLE: 'full'
13+
COMPOSER_OPTIONS: '--optimize-autoloader'
14+
matrix:
15+
- SYMFONY_VERSION: '~3.0'
16+
- SYMFONY_VERSION: '~4.0'
17+
18+
sudo: false
19+
20+
matrix:
21+
fast_finish: true
22+
23+
before_install:
24+
# remove xdebug to speed up build
25+
- phpenv config-rm xdebug.ini || true
26+
27+
install:
28+
- composer require symfony/http-kernel:$SYMFONY_VERSION symfony/dependency-injection:$SYMFONY_VERSION
29+
- make build
30+
script:
31+
- make test-technical
32+
- make test-functional
33+
34+
cache:
35+
directories:
36+
- $HOME/.composer
37+
- vendor
38+
39+
branches:
40+
except:
41+
- /.*\-dev$/

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

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Symfony JSON-RPC params documentation
2+
[![License](https://img.shields.io/github/license/yoanm/symfony-jsonrpc-params-sf-constraints-doc.svg)](https://github.com/yoanm/symfony-jsonrpc-params-sf-constraints-doc) [![Code size](https://img.shields.io/github/languages/code-size/yoanm/symfony-jsonrpc-params-sf-constraints-doc.svg)](https://github.com/yoanm/symfony-jsonrpc-params-sf-constraints-doc) [![Dependencies](https://img.shields.io/librariesio/github/yoanm/symfony-jsonrpc-params-sf-constraints-doc.svg)](https://libraries.io/packagist/yoanm%2Fsymfony-jsonrpc-params-sf-constraints-doc)
3+
4+
[![Scrutinizer Build Status](https://img.shields.io/scrutinizer/build/g/yoanm/symfony-jsonrpc-params-sf-constraints-doc.svg?label=Scrutinizer&logo=scrutinizer)](https://scrutinizer-ci.com/g/yoanm/symfony-jsonrpc-params-sf-constraints-doc/build-status/master) [![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/yoanm/symfony-jsonrpc-params-sf-constraints-doc/master.svg?logo=scrutinizer)](https://scrutinizer-ci.com/g/yoanm/symfony-jsonrpc-params-sf-constraints-doc/?branch=master) [![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/yoanm/symfony-jsonrpc-params-sf-constraints-doc/master.svg?logo=scrutinizer)](https://scrutinizer-ci.com/g/yoanm/symfony-jsonrpc-params-sf-constraints-doc/?branch=master)
5+
6+
[![Travis Build Status](https://img.shields.io/travis/com/yoanm/symfony-jsonrpc-params-sf-constraints-doc/master.svg?label=Travis&logo=travis)](https://travis-ci.com/yoanm/symfony-jsonrpc-params-sf-constraints-doc) [![Travis PHP versions](https://img.shields.io/travis/php-v/yoanm/symfony-jsonrpc-params-sf-constraints-doc.svg?logo=travis)](https://php.net/) [![Travis Symfony Versions](https://img.shields.io/badge/Symfony-v3%20%2F%20v4-8892BF.svg?logo=travis)](https://symfony.com/)
7+
8+
[![Latest Stable Version](https://img.shields.io/packagist/v/yoanm/symfony-jsonrpc-params-sf-constraints-doc.svg)](https://packagist.org/packages/yoanm/symfony-jsonrpc-params-sf-constraints-doc) [![Packagist PHP version](https://img.shields.io/packagist/php-v/yoanm/symfony-jsonrpc-params-sf-constraints-doc.svg)](https://packagist.org/packages/yoanm/symfony-jsonrpc-params-sf-constraints-doc)
9+
10+
Symfony bundle for easy Symfony constraints to JSON-RPC documentation transformation
11+
12+
Symfony bundle for [yoanm/jsonrpc-params-symfony-constraint-doc-sdk](https://github.com/yoanm/php-jsonrpc-params-symfony-constraint-doc-sdk)
13+
14+
## How to use
15+
16+
Once configured, your project will automatically create documentation for JSON-RPC params
17+
18+
See below how to configure it.
19+
20+
## Configuration
21+
22+
[Behat demo app configuration folders](./features/demo_app) can be used as examples.
23+
24+
- Add the bundles in your config/bundles.php file:
25+
```php
26+
// config/bundles.php
27+
return [
28+
...
29+
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
30+
Yoanm\SymfonyJsonRpcHttpServer\JsonRpcHttpServerBundle::class => ['all' => true],
31+
Yoanm\SymfonyJsonRpcHttpServerDoc\JsonRpcHttpServerDocBundle::class => ['all' => true],
32+
Yoanm\SymfonyJsonRpcParamsSfConstraintsDoc\JsonRpcParamsSfConstraintsDocBundle::class => ['all' => true],
33+
...
34+
];
35+
```
36+
37+
- Configure `yoanm/symfony-jsonrpc-http-server` as described on [yoanm/symfony-jsonrpc-http-server](https://github.com/yoanm/symfony-jsonrpc-http-server) documentation.
38+
39+
- Configure `yoanm/symfony-jsonrpc-http-server-doc` as described on [yoanm/symfony-jsonrpc-http-server-doc](https://github.com/yoanm/symfony-jsonrpc-http-server-doc) documentation.
40+
41+
- Query your project at documentation endpoint and you should see JSON-RPC params documentation for each methods
42+
43+
 
44+
45+
## Contributing
46+
See [contributing note](./CONTRIBUTING.md)

behat.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
default:
2+
suites:
3+
default:
4+
contexts:
5+
- Tests\Functional\BehatContext\DemoAppContext: ~
6+
coverage:
7+
extensions:
8+
LeanPHP\Behat\CodeCoverage\Extension:
9+
drivers:
10+
- local
11+
filter:
12+
whitelist:
13+
include:
14+
directories:
15+
'src': ~
16+
report:
17+
format: html
18+
options:
19+
target: build/behat-coverage

composer.json

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"description": "Symfony bundle for easy Symfony constraints to JSON-RPC documentation transformation",
44
"license": "MIT",
55
"type": "library",
6-
"minimum-stability": "dev",
76
"support": {
87
"issues": "https://github.com/yoanm/symfony-jsonrpc-params-sf-constraints-doc/issues"
98
},
@@ -22,24 +21,30 @@
2221
"autoload-dev": {
2322
"psr-4": {
2423
"Tests\\": "tests",
25-
"Tests\\Functional\\BehatContext\\": "features/bootstrap"
24+
"Tests\\Functional\\BehatContext\\": "features/bootstrap",
25+
"DemoApp\\": "features/demo_app/src"
2626
}
2727
},
28+
"suggest": {
29+
"yoanm/symfony-jsonrpc-http-server": "Symfony Bundle to convert an HTTP json-rpc request into HTTP json-rpc response"
30+
},
2831
"require": {
2932
"php": ">=7.1",
30-
"yoanm/jsonrpc-server-sdk": "dev-release/3.0.0",
31-
"yoanm/jsonrpc-params-symfony-validator-sdk": "dev-release/1.0.0",
32-
"yoanm/jsonrpc-params-symfony-constraint-doc-sdk": "dev-release/1.0.0",
33-
"yoanm/symfony-jsonrpc-http-server-doc": "dev-feature/improve",
33+
"yoanm/jsonrpc-server-sdk": "^3.0",
34+
"yoanm/jsonrpc-params-symfony-validator-sdk": "^0.1",
35+
"yoanm/jsonrpc-params-symfony-constraint-doc-sdk": "^0.1",
36+
"yoanm/symfony-jsonrpc-http-server-doc": "^0.1",
3437
"symfony/http-kernel": "^3.0 || ^4.0",
3538
"symfony/dependency-injection": "^3.0 || ^4.0"
3639
},
3740
"require-dev": {
41+
"ext-json": "*",
3842
"behat/behat": "~3.0",
3943
"squizlabs/php_codesniffer": "3.*",
4044
"phpunit/phpunit": "^6.0 || ^7.0",
4145
"matthiasnoback/symfony-dependency-injection-test": "^2.0 || ^3.0",
4246
"matthiasnoback/symfony-config-test": "^3.0 || ^4.0",
47+
"symfony/framework-bundle": "^3.0 || ^4.0",
4348
"yoanm/php-unit-extended": "~1.0"
4449
}
4550
}

0 commit comments

Comments
 (0)