Skip to content

Commit

Permalink
PHP 7.1, updated dependencies, removed unused classes
Browse files Browse the repository at this point in the history
  • Loading branch information
mabar committed Jun 19, 2018
1 parent 081a411 commit 6c2bd1a
Show file tree
Hide file tree
Showing 142 changed files with 1,095 additions and 2,119 deletions.
34 changes: 17 additions & 17 deletions .docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,21 @@ final class HelloController implements IController
* @Path("/world")
* @Method("GET")
*/
public function index(ApiRequest $request, ApiResponse $response)
public function index(ApiRequest $request, ApiResponse $response): ApiResponse
{
return $response->writeBody('Hello world!');
}
}
```

This API by automatic look for all services which implements `Apitte\Core\UI\Controller\IController`.
This API by automatic look for all services which implements `Apitte\Core\UI\Controller\IController`.
Then they are analyzed by annotations loader and `Apitte\Core\Schema\ApiSchema` is build.

You have to mark your controllers with `@Controller` annotation and also define `@ControllerPath`.

Each public method with annotations `@Path` and `@Method` will be added to our API scheme and will be triggered in propel request.

One more thing left, you have to define your controllers as services, to let `Apitte\Core\Handler\ServiceHandler` obtain propel handler.
One more thing left, you have to define your controllers as services, to let `Apitte\Core\Handler\ServiceHandler` obtain propel handler.

```yaml
services:
Expand All @@ -101,7 +101,7 @@ At the end, open your browser and locate to `localhost/<api-project>/hello/world

### Request & Response

`Apitte\Core\Http\ApiRequest` & `Apitte\Core\Http\ApiResponse` implement the PSR-7 interfaces.
`Apitte\Core\Http\ApiRequest` & `Apitte\Core\Http\ApiResponse` implement the PSR-7 interfaces.

## Annotations

Expand Down Expand Up @@ -135,10 +135,10 @@ Core plugins are:
Another available plugins are:

- [`apitte\debug`](https://github.com/apitte/debug) - adds debugging tools for developing
- [`apitte\middlewares`](https://github.com/apitte/middlewares) - adds support for middlewares, depends on `contributte\middlewares`
- [`apitte\middlewares`](https://github.com/apitte/middlewares) - adds support for middlewares, depends on [`contributte\middlewares`](https://github.com/contributte/middlewares)
- [`apitte\negotiation`](https://github.com/apitte/negotiation) - adds support for varient content negotiations (.json, .debug, .csv, etc.)
- [`apitte\openapi`](https://github.com/apitte/openapi) - adds support for openapi and swagger
- [`apitte\events`](https://github.com/apitte/events) - [WIP] - adds support for symfony/event-dispatcher
- [`apitte\events`](https://github.com/apitte/events) - [WIP] - adds support for symfony/event-dispatcher (which is ported into nette via [`contributte\event-dispatcher`](https://github.com/contributte/event-dispatcher))

### CoreDecoratorPlugin

Expand All @@ -150,7 +150,7 @@ api:

This plugin overrides default implementation of `IDispatcher` and allows to add request & response decorators. You can manage/update incoming request data or unify JSON response data via registered decorators.

Each **decorator** should be registered with tag `apitte.core.decorator`.
Each **decorator** should be registered with tag `apitte.core.decorator`.

Each decorator should provide `type` attribute:

Expand All @@ -162,12 +162,12 @@ Also you should define a priority for better sorting. Default is 10.

```yaml
services:
decorator.request.json:
decorator.request.json:
class: App\Model\JsonBodyDecorator
tags: [apitte.core.decorator: [priority: 50, type: handler.before]]

services:
decorator.request.xml:
decorator.request.xml:
class: App\Model\XmlBodyDecorator
tags: [apitte.core.decorator: [priority: 60, type: handler.before]]
```
Expand Down Expand Up @@ -196,7 +196,7 @@ api:
validator:
```

#### Types
#### Types

This plugin allows you to define new annotations.

Expand All @@ -215,7 +215,7 @@ public function detail(ApiRequest $request)
}
```

It converts request parameters to defined types. By default, you can use `int`, `float`, `string`. Or defined
It converts request parameters to defined types. By default, you can use `int`, `float`, `string`. Or defined
more types in neon.

```yaml
Expand All @@ -233,7 +233,7 @@ Don't forget to register default one, because filling of `types` overrides defau

#### Entity

Let's try to picture you have a datagrid with many filter options. You can describe all options manually or
Let's try to picture you have a datagrid with many filter options. You can describe all options manually or
use value object, entity, for it. And it leads us to `@RequestMapper`.

We have some entity with described fields.
Expand All @@ -254,7 +254,7 @@ final class UserFilter extends BasicEntity
}
```

And some endoint with `@RequestMapper` annotation. There's a method `ApiRequest::getEntity()`, it gets
And some endoint with `@RequestMapper` annotation. There's a method `ApiRequest::getEntity()`, it gets
the entity from request attributes. So simple, right?

```php
Expand All @@ -270,7 +270,7 @@ public function filter(ApiRequest $request)
}
```

There's a prepared validator for request entity, but it's disabled by default. You have to
There's a prepared validator for request entity, but it's disabled by default. You have to
pick the validator you want to.

```yaml
Expand All @@ -281,10 +281,10 @@ api:
request:
# By default
validator: Apitte\Core\Mapping\Validator\NullValidator

# Support: @required
validator: Apitte\Core\Mapping\Validator\BasicValidator

# Symfony/Validator
validator: Apitte\Core\Mapping\Validator\SymfonyValidator
```
Expand All @@ -304,7 +304,7 @@ final class UserFilter extends BasicEntity
* )
*/
public $userId;

}
```

Expand Down
20 changes: 7 additions & 13 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
# EditorConfig is awesome: http://EditorConfig.org

# Top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true

# JS / PHP
[*.{js,php,phpt}]
charset = utf-8
trim_trailing_whitespace = true
indent_style = tab
indent_size = 4
indent_size = tab
tab_width = 4

# NEON
[*.neon]
charset = utf-8
indent_style = tab
[*.md]
indent_style = space
indent_size = 4

# Composer, NPM, Travis, BitbucketPipelines
[{composer.json,package.json,.travis.yml,bitbucket-pipelines.yml}]
[{composer.json,package.json,.travis.yml}]
indent_style = space
indent_size = 2
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
/composer.lock

# Tests
/temp/
/tests/*.log
/tests/tmp
/tests/coverage.html
/coverage.xml
24 changes: 11 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
language: php

php:
- 5.6
- 7.0
- 7.1
- 7.2
- 7.1
- 7.2

before_install:
# turn off XDebug
Expand All @@ -19,42 +18,41 @@ script:

jobs:
include:
- env: title="Lowest Dependencies 5.6"
php: 5.6
- env: title="Lowest Dependencies 7.1"
php: 7.1
install:
- travis_retry composer update --no-progress --prefer-dist --prefer-lowest
script:
- composer run-script tester

- env: title="Lowest Dependencies 7.1"
php: 7.1
- env: title="Lowest Dependencies 7.2"
php: 7.2
install:
- travis_retry composer update --no-progress --prefer-dist --prefer-lowest
script:
- composer run-script tester

- stage: Quality Assurance
php: 7.1
php: 7.2
script:
- composer run-script qa

- stage: Test Coverage
php: 7.1
php: 7.2
script:
- composer run-script coverage
after_script:
- wget https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar
- wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.0.0/php-coveralls.phar
- php coveralls.phar --verbose --config tests/.coveralls.yml

- stage: Phpstan
php: 7.1
php: 7.2
script:
- composer run-script phpstan-install
- composer run-script phpstan

allow_failures:
- stage: Test Coverage
- stage: Phpstan

after_failure:
# Print *.actual content
Expand Down
22 changes: 16 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ composer require apitte/core

## Version

| State | Version | Branch | PHP | Composer |
|-------------|--------------|----------|----------|-------------------------------------------------|
| development | `^0.3.0` | `master` | `>= 5.6` | `minimum-stability: dev`, `prefer-stable: true` |
| stable | `^0.2.0` | `master` | `>= 5.6` | |
| State | Version | Branch | PHP | Composer |
|--------|--------------|----------|----------|-------------------------------------------------|
| dev | `^0.4.0` | `master` | `>= 7.1` | `minimum-stability: dev`, `prefer-stable: true` |
| stable | `^0.3.0` | `master` | `>= 7.1` | |
| stable | `^0.2.0` | `master` | `>= 5.6` | |

## Example
## Example

Just define some endpoints, I mean controllers. Place some annotations and thats all.

Expand All @@ -55,7 +56,7 @@ final class HelloController implements IController
* @Path("/world")
* @Method("GET")
*/
public function index(ApiRequest $request, ApiResponse $response)
public function index(ApiRequest $request, ApiResponse $response): ApiResponse
{
return $response->writeBody('Hello world!');
}
Expand Down Expand Up @@ -103,6 +104,15 @@ As you can see, the architecture is ultra simple. `ApiRequest` & `ApiResponse` w
<a href="https://github.com/f3l1x">Milan Felix Šulc</a>
</td>
</tr>
<tr>
<td align="center">
<a href="https://github.com/mabar">
<img width="150" height="150" src="https://avatars0.githubusercontent.com/u/20974277?s=400&v=4">
</a>
</br>
<a href="https://github.com/mabar">Marek Bartoš</a>
</td>
</tr>
<tbody>
</table>

Expand Down
34 changes: 25 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
{
"name": "apitte/core",
"description": "Core API library in Apitte stack",
"keywords": ["api", "apitte", "http", "rest", "nette", "annotation"],
"keywords": [
"api",
"apitte",
"http",
"rest",
"nette",
"annotation"
],
"type": "library",
"license": "MIT",
"license": [
"MIT"
],
"homepage": "https://github.com/apitte/core",
"authors": [
{
Expand All @@ -12,15 +21,21 @@
}
],
"require": {
"php": ">= 5.6",
"contributte/psr7-http-message": "^0.3.0",
"php": ">= 7.1",
"contributte/psr7-http-message": "^0.4.1",
"contributte/phpdoc": "^0.1.0"
},
"require-dev": {
"ninjify/qa": "^0.4.0",
"ninjify/qa": "^0.8.0",
"ninjify/nunjuck": "^0.2.0",
"mockery/mockery": "^0.9.9",
"nette/di": "~2.4.10"
"nette/di": "~2.4.12",
"apitte/negotiation": "dev-experimental",
"symfony/validator": "^4.1.0"
},
"conflict": {
"nette/di": "< 2.4.12",
"nette/utils": "<2.5.2"
},
"autoload": {
"psr-4": {
Expand All @@ -45,11 +60,12 @@
],
"phpstan-install": [
"mkdir -p temp/phpstan",
"composer require -d temp/phpstan phpstan/phpstan:0.8.5",
"composer require -d temp/phpstan phpstan/phpstan-nette:0.8.3"
"composer require -d temp/phpstan phpstan/phpstan:0.9.2",
"composer require -d temp/phpstan phpstan/phpstan-nette:0.9",
"composer require -d temp/phpstan phpstan/phpstan-strict-rules:0.9"
],
"phpstan": [
"temp/phpstan/vendor/bin/phpstan analyse -l 1 -c phpstan.neon src"
"temp/phpstan/vendor/bin/phpstan analyse -l max -c phpstan.neon src"
]
},
"minimum-stability": "dev",
Expand Down
6 changes: 6 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
includes:
- temp/phpstan/vendor/phpstan/phpstan-strict-rules/rules.neon
- temp/phpstan/vendor/phpstan/phpstan-nette/extension.neon
- temp/phpstan/vendor/phpstan/phpstan-nette/rules.neon

parameters:
ignoreErrors:
- '#^Only booleans are allowed in#'
- '#string|null given.$#'
- '#on possibly null value of type#'
- '#^Access to private property \$previous of parent class Exception.$#'

0 comments on commit 6c2bd1a

Please sign in to comment.