Skip to content

Commit b03ac89

Browse files
committed
Merge branch 'hotfix/50'
Close #50
2 parents 4485859 + 8974b43 commit b03ac89

File tree

10 files changed

+37
-31
lines changed

10 files changed

+37
-31
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
},
3838
"require-dev": {
3939
"phpunit/phpunit": "^4.8",
40-
"squizlabs/php_codesniffer": "^2.3.1"
40+
"squizlabs/php_codesniffer": "^2.7"
4141
},
4242
"autoload": {
4343
"psr-4": {

composer.lock

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

phpcs.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
<!-- inherit rules from: -->
1010
<rule ref="PSR2"/>
1111
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
12+
<rule ref="Generic.Formatting.SpaceAfterNot"/>
13+
<rule ref="Squiz.WhiteSpace.OperatorSpacing">
14+
<properties>
15+
<property name="ignoreNewlines" value="true"/>
16+
</properties>
17+
</rule>
1218
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
1319
<properties>
1420
<property name="ignoreBlankLines" value="false"/>

src/ApiProblem.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public function __construct($status, $detail, $type = null, $title = null, array
153153
}
154154

155155
// Ensure a valid HTTP status
156-
if (!is_numeric($status)
156+
if (! is_numeric($status)
157157
|| ($status < 100)
158158
|| ($status > 599)
159159
) {
@@ -313,7 +313,7 @@ protected function createDetailFromException()
313313
/** @var Exception|Throwable $e */
314314
$e = $this->detail;
315315

316-
if (!$this->detailIncludesStackTrace) {
316+
if (! $this->detailIncludesStackTrace) {
317317
return $e->getMessage();
318318
}
319319

src/ApiProblemResponse.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function getContent()
6969
public function getHeaders()
7070
{
7171
$headers = parent::getHeaders();
72-
if (!$headers->has('content-type')) {
72+
if (! $headers->has('content-type')) {
7373
$headers->addHeaderLine('content-type', ApiProblem::CONTENT_TYPE);
7474
}
7575

@@ -86,7 +86,7 @@ public function getHeaders()
8686
*/
8787
public function getReasonPhrase()
8888
{
89-
if (!empty($this->reasonPhrase)) {
89+
if (! empty($this->reasonPhrase)) {
9090
return $this->reasonPhrase;
9191
}
9292

src/Listener/ApiProblemListener.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class ApiProblemListener extends AbstractListenerAggregate
4646
*/
4747
public function __construct($filters = null)
4848
{
49-
if (!empty($filters)) {
49+
if (! empty($filters)) {
5050
if (is_string($filters)) {
5151
$this->acceptFilters = [$filters];
5252
}
@@ -81,14 +81,14 @@ public function attach(EventManagerInterface $events, $priority = 1)
8181
*/
8282
public function onRender(MvcEvent $e)
8383
{
84-
if (!$this->validateErrorEvent($e)) {
84+
if (! $this->validateErrorEvent($e)) {
8585
return;
8686
}
8787

8888
// Next, do we have a view model in the result?
8989
// If not, nothing more to do.
9090
$model = $e->getResult();
91-
if (!$model instanceof ModelInterface || $model instanceof ApiProblemModel) {
91+
if (! $model instanceof ModelInterface || $model instanceof ApiProblemModel) {
9292
return;
9393
}
9494

@@ -122,13 +122,13 @@ public function onDispatch(MvcEvent $e)
122122
$services = $app->getServiceManager();
123123
$config = $services->get('config');
124124

125-
if (!isset($config['zf-api-problem']['render_error_controllers'])) {
125+
if (! isset($config['zf-api-problem']['render_error_controllers'])) {
126126
return;
127127
}
128128

129129
$controller = $e->getRouteMatch()->getParam('controller');
130130
$controllers = $config['zf-api-problem']['render_error_controllers'];
131-
if (!in_array($controller, $controllers)) {
131+
if (! in_array($controller, $controllers)) {
132132
// The current controller is not in our list of controllers to handle
133133
return;
134134
}
@@ -150,13 +150,13 @@ public function onDispatch(MvcEvent $e)
150150
*/
151151
public function onDispatchError(MvcEvent $e)
152152
{
153-
if (!$this->validateErrorEvent($e)) {
153+
if (! $this->validateErrorEvent($e)) {
154154
return;
155155
}
156156

157157
// Marshall an ApiProblem and view model based on the exception
158158
$exception = $e->getParam('exception');
159-
if (!$exception instanceof \Exception) {
159+
if (! $exception instanceof \Exception) {
160160
// If it's not an exception, do not know what to do.
161161
return;
162162
}
@@ -178,24 +178,24 @@ public function onDispatchError(MvcEvent $e)
178178
protected function validateErrorEvent(MvcEvent $e)
179179
{
180180
// only worried about error pages
181-
if (!$e->isError()) {
181+
if (! $e->isError()) {
182182
return false;
183183
}
184184

185185
// and then, only if we have an Accept header...
186186
$request = $e->getRequest();
187-
if (!$request instanceof HttpRequest) {
187+
if (! $request instanceof HttpRequest) {
188188
return false;
189189
}
190190

191191
$headers = $request->getHeaders();
192-
if (!$headers->has('Accept')) {
192+
if (! $headers->has('Accept')) {
193193
return false;
194194
}
195195

196196
// ... that matches certain criteria
197197
$accept = $headers->get('Accept');
198-
if (!$this->matchAcceptCriteria($accept)) {
198+
if (! $this->matchAcceptCriteria($accept)) {
199199
return false;
200200
}
201201

src/Listener/RenderErrorListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function onRenderError(MvcEvent $e)
6666

6767
$exception = $e->getParam('exception');
6868
if ($exception instanceof \Exception
69-
&& !$exception instanceof ViewExceptionInterface
69+
&& ! $exception instanceof ViewExceptionInterface
7070
) {
7171
$code = $exception->getCode();
7272
if ($code >= 100 && $code <= 600) {

src/Listener/SendApiProblemResponseListener.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function displayExceptions()
7676
public function sendContent(SendResponseEvent $e)
7777
{
7878
$response = $e->getResponse();
79-
if (!$response instanceof ApiProblemResponse) {
79+
if (! $response instanceof ApiProblemResponse) {
8080
return $this;
8181
}
8282
$response->getApiProblem()->setDetailIncludesStackTrace($this->displayExceptions());
@@ -97,7 +97,7 @@ public function sendContent(SendResponseEvent $e)
9797
public function sendHeaders(SendResponseEvent $e)
9898
{
9999
$response = $e->getResponse();
100-
if (!$response instanceof ApiProblemResponse) {
100+
if (! $response instanceof ApiProblemResponse) {
101101
return $this;
102102
}
103103

@@ -118,7 +118,7 @@ public function sendHeaders(SendResponseEvent $e)
118118
public function __invoke(SendResponseEvent $event)
119119
{
120120
$response = $event->getResponse();
121-
if (!$response instanceof ApiProblemResponse) {
121+
if (! $response instanceof ApiProblemResponse) {
122122
return $this;
123123
}
124124

src/View/ApiProblemRenderer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function setDisplayExceptions($flag)
4040
*/
4141
public function render($nameOrModel, $values = null)
4242
{
43-
if (!$nameOrModel instanceof ApiProblemModel) {
43+
if (! $nameOrModel instanceof ApiProblemModel) {
4444
return '';
4545
}
4646

src/View/ApiProblemStrategy.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function selectRenderer(ViewEvent $e)
4141
{
4242
$model = $e->getModel();
4343

44-
if (!$model instanceof ApiProblemModel) {
44+
if (! $model instanceof ApiProblemModel) {
4545
// unrecognized model; do nothing
4646
return;
4747
}
@@ -61,13 +61,13 @@ public function selectRenderer(ViewEvent $e)
6161
public function injectResponse(ViewEvent $e)
6262
{
6363
$result = $e->getResult();
64-
if (!is_string($result)) {
64+
if (! is_string($result)) {
6565
// We don't have a string, and thus, no JSON
6666
return;
6767
}
6868

6969
$model = $e->getModel();
70-
if (!$model instanceof ApiProblemModel) {
70+
if (! $model instanceof ApiProblemModel) {
7171
// Model is not an ApiProblemModel; we cannot handle it here
7272
return;
7373
}

0 commit comments

Comments
 (0)