Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit b3361cc

Browse files
committed
Merge branch 'hotfix/6'
Close #6 Close #7
2 parents 9aaa282 + abf6ba2 commit b3361cc

22 files changed

+140
-113
lines changed

.travis.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,22 @@ matrix:
2020
- php: 7.1
2121
env:
2222
- DEPS=locked
23+
- CS_CHECK=true
2324
- TEST_COVERAGE=true
2425
- php: 7.1
2526
env:
2627
- DEPS=latest
28+
- php: nightly
29+
env:
30+
- DEPS=lowest
31+
- php: nightly
32+
env:
33+
- DEPS=locked
34+
- php: nightly
35+
env:
36+
- DEPS=latest
37+
allow_failures:
38+
- php: nightly
2739

2840
before_install:
2941
- if [[ $TEST_COVERAGE != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi
@@ -39,7 +51,6 @@ install:
3951
script:
4052
- if [[ $TEST_COVERAGE == 'true' ]]; then composer test-coverage ; else composer test ; fi
4153
- if [[ $CS_CHECK == 'true' ]]; then composer cs-check ; fi
42-
- if [[ $CS_CHECK == 'true' ]]; then composer license-check ; fi
4354

4455
after_script:
4556
- if [[ $TEST_COVERAGE == 'true' ]]; then composer upload-coverage ; fi

CHANGELOG.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,35 @@
22

33
All notable changes to this project will be documented in this file, in reverse chronological order by release.
44

5+
## 0.3.0 - 2017-07-31
6+
7+
### Added
8+
9+
- [#7](https://github.com/weierophinney/problem-details/pull/7) adds an explicit
10+
dependency on ext/json.
11+
12+
### Changed
13+
14+
- [#7](https://github.com/weierophinney/problem-details/pull/7) updates each
15+
of the following to place them under the new `ProblemDetails\Exception`
16+
namespace:
17+
- `CommonProblemDetailsException`
18+
- `InvalidResponseBodyException`
19+
- `MissingResponseException`
20+
- `ProblemDetailsException`
21+
22+
### Deprecated
23+
24+
- Nothing.
25+
26+
### Removed
27+
28+
- Nothing.
29+
30+
### Fixed
31+
32+
- Nothing.
33+
534
## 0.2.1 - 2017-06-13
635

736
### Added

CONTRIBUTING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ To run tests:
1919

2020
```console
2121
$ git clone git://github.com/weierophinney/problem-details.git
22-
$ cd zend-expressive
22+
$ cd problem-details
2323
```
2424

2525
- Install dependencies via composer:
@@ -75,14 +75,14 @@ pull your work into the master repository. We recommend using
7575

7676
```console
7777
$ git clone git://github.com/weierophinney/problem-details.git
78-
$ cd zend-expressive
78+
$ cd problem-details
7979
```
8080

8181
4. Add a remote to your fork; substitute your GitHub username in the command
8282
below.
8383

8484
```console
85-
$ git remote add {username} [email protected]:{username}/zend-expressive.git
85+
$ git remote add {username} [email protected]:{username}/problem-details.git
8686
$ git fetch {username}
8787
```
8888

@@ -145,7 +145,7 @@ Delta compression using up to 2 threads.
145145
Compression objects: 100% (18/18), done.
146146
Writing objects: 100% (20/20), 8.19KiB, done.
147147
Total 20 (delta 12), reused 0 (delta 0)
148-
To ssh://[email protected]/{username}/zend-expressive.git
148+
To ssh://[email protected]/{username}/problem-details.git
149149
b5583aa..4f51698 HEAD -> master
150150
```
151151

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"sort-packages": true
88
},
99
"require": {
10+
"ext-json": "*",
1011
"fig/http-message-util": "^1.1.2",
1112
"http-interop/http-middleware": "^0.4.1",
1213
"php": "^7.1",

composer.lock

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

doc/book/exception.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ details.
77
To facilitate this, we provide an interface, `ProblemDetailsException`:
88

99
```php
10-
namespace ProblemDetails;
10+
namespace ProblemDetails\Exception;
1111

1212
use JsonSerializable;
1313

@@ -50,8 +50,8 @@ transaction problem details, you might do so as follows:
5050

5151
```php
5252
use DomainException;
53-
use ProblemDetails\CommonProblemDetailsException;
54-
use ProblemDetails\ProblemDetailsException;
53+
use ProblemDetails\Exception\CommonProblemDetailsException;
54+
use ProblemDetails\Exception\ProblemDetailsException;
5555

5656
class TransactionException extends DomainException implements ProblemDetailsException
5757
{
@@ -96,7 +96,7 @@ And it might result in the following:
9696
"title": "You have insufficient funds to complete the transaction.",
9797
"detail": "Your transaction required 5.63, but you only have 1.37 in your account",
9898
"account": "https://example.com/api/accounts/12345",
99-
"balance": 1.37,
99+
"balance": 1.37
100100
}
101101
```
102102

doc/book/middleware.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ This middleware does the following:
1919
throwing any errors handled as `ErrorException` instances.
2020
- Wraps a call to the `$delegate` in a `try`/`catch` block; if nothing is
2121
caught, and a response is returned, it returns the response immediately. If a
22-
response is _not_ returned, it raises a `ProblemDetails\MissingResponseException`.
22+
response is _not_ returned, it raises a
23+
`ProblemDetails\Exception\MissingResponseException`.
2324
- For all caught throwables, it passes the throwable to
2425
`ProblemDetailsResponseFactory::createResponseFromThrowable()` to generate a
2526
Problem Details response.

doc/book/quick-start.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,11 @@ as the HTTP status if it falls in the 400 or 500 range (500 will be used
155155
otherwise).
156156

157157
You can also create custom exceptions that provide details for the factory to
158-
consume by implementing `ProblemDetails\ProblemDetailsException`, which defines
159-
the following:
158+
consume by implementing `ProblemDetails\Exception\ProblemDetailsException`,
159+
which defines the following:
160160

161161
```php
162-
namespace ProblemDetails;
162+
namespace ProblemDetails\Exception;
163163

164164
use JsonSerializable;
165165

@@ -211,8 +211,8 @@ By composing this trait, you can easily define custom exception types:
211211
namespace Api;
212212

213213
use DomainException as PhpDomainException;
214-
use ProblemDetails\CommonProblemDetailsException;
215-
use ProblemDetails\ProblemDetailsException;
214+
use ProblemDetails\Exception\CommonProblemDetailsException;
215+
use ProblemDetails\Exception\ProblemDetailsException;
216216

217217
class DomainException extends PhpDomainException implements ProblemDetailsException
218218
{
@@ -249,8 +249,8 @@ a `ProblemDetailsResponseFactory`, and does the following:
249249
- Otherwise, it creates a PHP error handler that converts PHP errors to
250250
`ErrorException` instances, and then wraps processing of the delegate in a
251251
try/catch block. If the delegate does not return a `ResponseInterface`, a
252-
`ProblemDetails\MissingResponseException` is raised; otherwise, the response
253-
is returned.
252+
`ProblemDetails\Exception\MissingResponseException` is raised; otherwise, the
253+
response is returned.
254254
- Any throwable or exception caught is passed to the
255255
`ProblemDetailsResponseFactory::createResponseFromThrowable()` method, and the
256256
response generated is returned.

src/ConfigProvider.php

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,26 @@
33
namespace ProblemDetails;
44

55
/**
6-
* The configuration provider for the ProblemDetails module
6+
* Configuration provider for the package.
77
*
88
* @see https://docs.zendframework.com/zend-component-installer/
99
*/
1010
class ConfigProvider
1111
{
1212
/**
13-
* Returns the configuration array
14-
*
15-
* To add a bit of a structure, each section is defined in a separate
16-
* method which returns an array with its configuration.
17-
*
18-
* @return array
13+
* Returns the configuration array.
1914
*/
20-
public function __invoke()
15+
public function __invoke() : array
2116
{
2217
return [
2318
'dependencies' => $this->getDependencies(),
2419
];
2520
}
2621

2722
/**
28-
* Returns the container dependencies
29-
*
30-
* @return array
23+
* Returns the container dependencies.
3124
*/
32-
public function getDependencies()
25+
public function getDependencies() : array
3326
{
3427
return [
3528
'factories' => [

src/CommonProblemDetailsException.php renamed to src/Exception/CommonProblemDetailsException.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace ProblemDetails;
3+
namespace ProblemDetails\Exception;
44

55
/**
66
* Common functionality for ProblemDetailsException implementations.
@@ -66,11 +66,11 @@ public function getAdditionalData() : array
6666
}
6767

6868
/**
69-
* Serialize the exception to an array of problem details.
70-
*
71-
* Likely useful for the JsonSerializable implementation, but also
72-
* for cases where the XML variant is desired.
73-
*/
69+
* Serialize the exception to an array of problem details.
70+
*
71+
* Likely useful for the JsonSerializable implementation, but also
72+
* for cases where the XML variant is desired.
73+
*/
7474
public function toArray() : array
7575
{
7676
$problem = [
@@ -80,13 +80,18 @@ public function toArray() : array
8080
'type' => $this->type,
8181
];
8282

83-
if (! empty($this->additional)) {
83+
if ($this->additional) {
8484
$problem = array_merge($this->additional, $problem);
8585
}
8686

8787
return $problem;
8888
}
8989

90+
/**
91+
* Allow serialization via json_encode().
92+
*
93+
* @return array
94+
*/
9095
public function jsonSerialize()
9196
{
9297
return $this->toArray();

0 commit comments

Comments
 (0)