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

Commit 178d40e

Browse files
committed
Import internal functions and constants
1 parent e0539d8 commit 178d40e

9 files changed

+57
-3
lines changed

src/Exception/CommonProblemDetailsExceptionTrait.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
namespace Zend\ProblemDetails\Exception;
1111

12+
use function array_merge;
13+
1214
/**
1315
* Common functionality for ProblemDetailsExceptionInterface implementations.
1416
*

src/ProblemDetailsMiddleware.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
use Psr\Http\Server\RequestHandlerInterface;
1818
use Throwable;
1919

20+
use function array_walk;
21+
use function error_reporting;
22+
use function in_array;
23+
use function restore_error_handler;
24+
use function set_error_handler;
25+
2026
/**
2127
* Middleware that ensures a Problem Details response is returned
2228
* for all errors and Exceptions/Throwables.
@@ -76,7 +82,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
7682
*/
7783
public function attachListener(callable $listener) : void
7884
{
79-
if (\in_array($listener, $this->listeners, true)) {
85+
if (in_array($listener, $this->listeners, true)) {
8086
return;
8187
}
8288

src/ProblemDetailsNotFoundHandler.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
use Psr\Http\Server\MiddlewareInterface;
1616
use Psr\Http\Server\RequestHandlerInterface;
1717

18+
use function sprintf;
19+
1820
class ProblemDetailsNotFoundHandler implements MiddlewareInterface
1921
{
2022
/**

src/ProblemDetailsResponseFactory.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,25 @@
1818
use Spatie\ArrayToXml\ArrayToXml;
1919
use Throwable;
2020

21+
use function array_merge;
22+
use function array_walk_recursive;
23+
use function get_class;
24+
use function get_resource_type;
25+
use function is_array;
26+
use function is_int;
27+
use function is_resource;
28+
use function json_decode;
29+
use function json_encode;
30+
use function preg_replace;
31+
use function print_r;
32+
use function sprintf;
33+
use function strpos;
34+
35+
use const JSON_PRESERVE_ZERO_FRACTION;
36+
use const JSON_PRETTY_PRINT;
37+
use const JSON_UNESCAPED_SLASHES;
38+
use const JSON_UNESCAPED_UNICODE;
39+
2140
/**
2241
* Create a Problem Details response.
2342
*

test/Exception/ProblemDetailsExceptionInterfaceTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
use Zend\ProblemDetails\Exception\CommonProblemDetailsExceptionTrait;
1414
use Zend\ProblemDetails\Exception\ProblemDetailsExceptionInterface;
1515

16+
use function json_decode;
17+
use function json_encode;
18+
1619
class ProblemDetailsExceptionTest extends TestCase
1720
{
1821
protected $status = 403;

test/ProblemDetailsAssertionsTrait.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@
1616
use Psr\Http\Message\StreamInterface;
1717
use Throwable;
1818

19+
use function array_walk_recursive;
20+
use function get_class;
21+
use function json_decode;
22+
use function json_encode;
23+
use function simplexml_load_string;
24+
use function sprintf;
25+
use function var_export;
26+
1927
trait ProblemDetailsAssertionsTrait
2028
{
2129
public function assertProblemDetails(array $expected, array $details) : void

test/ProblemDetailsMiddlewareTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
use Psr\Http\Server\RequestHandlerInterface;
1818
use Zend\ProblemDetails\ProblemDetailsMiddleware;
1919
use Zend\ProblemDetails\ProblemDetailsResponseFactory;
20+
21+
use function trigger_error;
22+
23+
use const E_USER_ERROR;
2024
use ZendTest\ProblemDetails\TestAsset;
2125

2226
class ProblemDetailsMiddlewareTest extends TestCase
@@ -90,14 +94,14 @@ public function testMiddlewareRegistersErrorHandlerToConvertErrorsToProblemDetai
9094
$handler
9195
->handle(Argument::that([$this->request, 'reveal']))
9296
->will(function () {
93-
trigger_error('Triggered error!', \E_USER_ERROR);
97+
trigger_error('Triggered error!', E_USER_ERROR);
9498
});
9599

96100
$expected = $this->prophesize(ResponseInterface::class)->reveal();
97101
$this->responseFactory
98102
->createResponseFromThrowable($this->request->reveal(), Argument::that(function ($e) {
99103
$this->assertInstanceOf(ErrorException::class, $e);
100-
$this->assertEquals(\E_USER_ERROR, $e->getSeverity());
104+
$this->assertEquals(E_USER_ERROR, $e->getSeverity());
101105
$this->assertEquals('Triggered error!', $e->getMessage());
102106
return true;
103107
}))

test/ProblemDetailsResponseFactoryFactoryTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
use Zend\ProblemDetails\ProblemDetailsResponseFactory;
2222
use Zend\ProblemDetails\ProblemDetailsResponseFactoryFactory;
2323

24+
use const JSON_PRESERVE_ZERO_FRACTION;
25+
use const JSON_PRETTY_PRINT;
26+
use const JSON_UNESCAPED_SLASHES;
27+
use const JSON_UNESCAPED_UNICODE;
28+
2429
class ProblemDetailsResponseFactoryFactoryTest extends TestCase
2530
{
2631
protected function setUp() : void

test/ProblemDetailsResponseFactoryTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
use Zend\ProblemDetails\Exception\ProblemDetailsExceptionInterface;
2323
use Zend\ProblemDetails\ProblemDetailsResponseFactory;
2424

25+
use function array_keys;
26+
use function fclose;
27+
use function fopen;
28+
use function stripos;
29+
2530
class ProblemDetailsResponseFactoryTest extends TestCase
2631
{
2732
use ProblemDetailsAssertionsTrait;

0 commit comments

Comments
 (0)