Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
WyriHaximus committed Jun 24, 2020
1 parent 3793497 commit fc2542c
Show file tree
Hide file tree
Showing 23 changed files with 8,442 additions and 1 deletion.
13 changes: 13 additions & 0 deletions .dependabot/config.yml
@@ -0,0 +1,13 @@
version: 1
update_configs:
- package_manager: "php:composer"
directory: "/"
update_schedule: "live"
default_labels:
- "Dependencies 📦"
- "PHP 🐘"
version_requirement_updates: "widen_ranges"
automerged_updates:
- match:
dependency_type: "all"
update_type: "semver:minor"
6 changes: 6 additions & 0 deletions .gitattributes
@@ -0,0 +1,6 @@
.travis.yml export-ignore
.gitignore export-ignore
.gitattributes export-ignore
.scrutinizer.yml export-ignore
phpunit.xml.dist export-ignore
Makefile export-ignore
1 change: 1 addition & 0 deletions .github/FUNDING.yml
@@ -0,0 +1 @@
github: WyriHaximus
47 changes: 47 additions & 0 deletions .github/workflows/ci.yml
@@ -0,0 +1,47 @@
name: Continuous Integration
on:
push:
pull_request:
jobs:
composer-install:
strategy:
matrix:
php: [7.4]
composer: [lowest, current, highest]
runs-on: ubuntu-latest
container:
image: wyrihaximusnet/php:${{ matrix.php }}-zts-alpine3.10-dev-root
steps:
- uses: actions/checkout@v1
- name: Cache composer packages
uses: actions/cache@v1
with:
path: ./vendor/
key: ${{ matrix.composer }}-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
- name: Install Dependencies
run: composer update --prefer-lowest --no-progress --ansi --no-interaction --prefer-dist
if: matrix.composer == 'lowest'
- name: Install Dependencies
run: composer install --ansi --no-progress --no-interaction --prefer-dist
if: matrix.composer == 'current'
- name: Install Dependencies
run: composer update --ansi --no-progress --no-interaction --prefer-dist
if: matrix.composer == 'highest'
qa:
strategy:
matrix:
php: [7.4]
composer: [lowest, current, highest]
qa: [lint, cs, stan, psalm, unit-ci, infection, composer-require-checker, composer-unused]
needs: composer-install
runs-on: ubuntu-latest
container:
image: wyrihaximusnet/php:${{ matrix.php }}-zts-alpine3.10-dev-root
steps:
- uses: actions/checkout@v1
- name: Cache composer packages
uses: actions/cache@v1
with:
path: ./vendor/
key: ${{ matrix.composer }}-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
- run: make ${{ matrix.qa }}
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
vendor
24 changes: 24 additions & 0 deletions .php_cs
@@ -0,0 +1,24 @@
<?php declare(strict_types=1);

use WyriHaximus\CsFixerConfig\PhpCsFixerConfig;
use PhpCsFixer\Config;

return (function (): Config
{
$paths = [
__DIR__ . DIRECTORY_SEPARATOR . 'src',
__DIR__ . DIRECTORY_SEPARATOR . 'tests',
];

return PhpCsFixerConfig::create()
->setFinder(
PhpCsFixer\Finder::create()
->in($paths)
->append($paths)
)
->setUsingCache(false)
->setRules([
'native_function_invocation' => false,
])
;
})();
68 changes: 68 additions & 0 deletions .scrutinizer.yml
@@ -0,0 +1,68 @@
filter:
paths: [src/*]
excluded_paths: [tests/* examples/*]
tools:
external_code_coverage: true
php_analyzer: true
php_hhvm: true
php_sim: true
php_pdepend: true
sensiolabs_security_checker: true
php_changetracking: true
php_code_sniffer:
enabled: true
config:
tab_width: 0
encoding: utf8
ruleset: ~
standard: "PSR2"
php_cs_fixer:
enabled: true
config:
level: psr2
php_mess_detector:
enabled: true
config:
ruleset: ~
code_size_rules:
cyclomatic_complexity: true
npath_complexity: true
excessive_method_length: true
excessive_class_length: true
excessive_parameter_list: true
excessive_public_count: true
too_many_fields: true
too_many_methods: true
excessive_class_complexity: true
design_rules:
exit_expression: true
eval_expression: true
goto_statement: true
number_of_class_children: true
depth_of_inheritance: true
coupling_between_objects: true
unused_code_rules:
unused_private_field: true
unused_local_variable: true
unused_private_method: true
unused_formal_parameter: true
naming_rules:
short_variable:
minimum: 3
long_variable:
maximum: 20
short_method:
minimum: 3
constructor_conflict: true
constant_naming: true
boolean_method_name: true
controversial_rules:
superglobals: true
camel_case_class_name: true
camel_case_property_name: true
camel_case_method_name: true
camel_case_parameter_name: true
camel_case_variable_name: true
checks:
php:
code_rating: true
21 changes: 21 additions & 0 deletions LICENSE
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Cees-Jan Kiewiet

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
45 changes: 45 additions & 0 deletions Makefile
@@ -0,0 +1,45 @@
# set all to phony
SHELL=bash

.PHONY: *

ifneq ("$(wildcard /.dockerenv)","")
DOCKER_RUN=
else
DOCKER_RUN=docker run --rm -it \
-v `pwd`:`pwd` \
-w `pwd` \
"wyrihaximusnet/php:7.4-zts-alpine3.11-dev"
endif

all: lint cs-fix cs stan psalm unit infection composer-require-checker composer-unused

lint:
$(DOCKER_RUN) vendor/bin/parallel-lint --exclude vendor .

cs:
$(DOCKER_RUN) vendor/bin/phpcs --parallel=$(nproc)

cs-fix:
$(DOCKER_RUN) vendor/bin/phpcbf --parallel=$(nproc)

stan:
$(DOCKER_RUN) vendor/bin/phpstan analyse src tests --level max --ansi -c phpstan.neon

psalm:
$(DOCKER_RUN) vendor/bin/psalm --threads=$(nproc) --shepherd --stats

unit:
$(DOCKER_RUN) vendor/bin/phpunit --colors=always -c phpunit.xml.dist --coverage-text --coverage-html covHtml --coverage-clover ./build/logs/clover.xml

unit-ci: unit
if [ -f ./build/logs/clover.xml ]; then wget https://scrutinizer-ci.com/ocular.phar && sleep 3 && php ocular.phar code-coverage:upload --format=php-clover ./build/logs/clover.xml; fi

infection:
$(DOCKER_RUN) vendor/bin/infection --ansi --min-msi=100 --min-covered-msi=100 --threads=$(nproc)

composer-require-checker:
$(DOCKER_RUN) vendor/bin/composer-require-checker --ignore-parse-errors --ansi -vvv --config-file=composer-require-checker.json

composer-unused:
$(DOCKER_RUN) composer unused --ansi
64 changes: 63 additions & 1 deletion README.md
@@ -1 +1,63 @@
# psr-15-adapter
# ReactPHP/HTTP PSR 15 adapter

![Continuous Integration](https://github.com/Reactphp-parallel/psr-15-adapter/workflows/Continuous%20Integration/badge.svg)
[![Latest Stable Version](https://poser.pugx.org/React-parallel/psr-15-adapter/v/stable.png)](https://packagist.org/packages/React-parallel/psr-15-adapter)
[![Total Downloads](https://poser.pugx.org/React-parallel/psr-15-adapter/downloads.png)](https://packagist.org/packages/React-parallel/psr-15-adapter)
[![Code Coverage](https://scrutinizer-ci.com/g/Reactphp-parallel/psr-15-adapter/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/Reactphp-parallel/psr-15-adapter/?branch=master)
[![Type Coverage](https://shepherd.dev/github/Reactphp-parallel/psr-15-adapter/coverage.svg)](https://shepherd.dev/github/Reactphp-parallel/psr-15-adapter)
[![License](https://poser.pugx.org/React-parallel/psr-15-adapter/license.png)](https://packagist.org/packages/React-parallel/psr-15-adapter)

### Installation ###

To install via [Composer](http://getcomposer.org/), use the command below, it will automatically detect the latest version and bind it with `~`.

```
composer require react-parallel/psr-15-adapter
```

# Usage

The middleware adapter accepts any PSR-15 middleware instance that meets for following criteria:
* Only uses scalars and userland classes
* Doesn't hold references to anything but scalars and userland classes
* Doesn't have internal state or relies on external state

```php
$loop = Factory::create();
$pool = new Infinite($loop, 10);
$streamFactory = new StreamFactory(new EventLoopBridge($loop));
$psr15Middleware = new ThePsr15MiddlewareOfYourChoice();
$server = new React\Http\Server(
$loop,
new ReactMiddleware($streamFactory, $pool, $psr15Middleware)
);
```

## Contributing ##

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

## License ##

Copyright 2020 [Cees-Jan Kiewiet](http://wyrihaximus.net/)

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
20 changes: 20 additions & 0 deletions composer-require-checker.json
@@ -0,0 +1,20 @@
{
"symbol-whitelist" : [
"null", "true", "false",
"static", "self", "parent",
"array", "string", "int", "float", "bool", "iterable", "callable", "void", "object",
"WyriHaximus\\Constants\\ComposerAutoloader\\LOCATION", "Psr\\Http\\Message\\ResponseInterface",
"Psr\\Http\\Message\\ServerRequestInterface", "Psr\\Http\\Server\\RequestHandlerInterface",
"ReactParallel\\Contracts\\PoolInterface", "WyriHaximus\\Constants\\Numeric\\ZERO"
],
"php-core-extensions" : [
"Core",
"date",
"pcre",
"Phar",
"Reflection",
"SPL",
"standard"
],
"scan-files" : []
}
63 changes: 63 additions & 0 deletions composer.json
@@ -0,0 +1,63 @@
{
"name": "react-parallel/psr-15-adapter",
"description": "\ud83c\udfab\ud83c\udf9f\ufe0f ",
"license": "MIT",
"authors": [
{
"name": "Cees-Jan Kiewiet",
"email": "ceesjank@gmail.com",
"homepage": "http://wyrihaximus.net/"
}
],
"require": {
"php": "^7.4",
"ext-parallel": "*",
"ancarda/psr7-string-stream": "^1.3",
"opis/closure": "^3.5",
"psr/http-server-middleware": "^1.0",
"react-parallel/event-loop": "dev-master",
"react-parallel/future-to-promise-converter": "^1.0",
"react-parallel/infinite-pool": "^1.0",
"react-parallel/runtime": "^1.0",
"react-parallel/streams": "dev-master",
"react/event-loop": "^1.1",
"react/http": "^0.8.6",
"react/promise": "^2.7",
"reactivex/rxphp": "^2.0",
"wyrihaximus/constants": "^1.5",
"wyrihaximus/psr-15-cat": "^1.1"
},
"require-dev": {
"moneyphp/money": "^3.2 || ^3.2.1",
"ocramius/package-versions": "^1.4",
"thecodingmachine/safe": "^1.1",
"wyrihaximus/async-test-utilities": "^2.0",
"wyrihaximus/iterator-or-array-to-array": "^1.1"
},
"config": {
"platform": {
"php": "7.4"
},
"sort-packages": true
},
"autoload": {
"psr-4": {
"ReactParallel\\Psr15Adapter\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"ReactParallel\\Tests\\Psr15Adapter\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-install-cmd": [
"composer normalize"
],
"post-update-cmd": [
"composer normalize"
]
}
}

0 comments on commit fc2542c

Please sign in to comment.