From a434c49a65f892a427289f879977be8294a6f843 Mon Sep 17 00:00:00 2001 From: webimpress Date: Thu, 15 Mar 2018 13:00:32 +0000 Subject: [PATCH 1/4] Import internal functions and constants --- src/AbstractSerializer.php | 8 ++++++++ src/CallbackStream.php | 4 ++++ src/HeaderSecurity.php | 11 +++++++++++ src/MessageTrait.php | 13 +++++++++++++ src/PhpInputStream.php | 2 ++ src/RelativeStream.php | 2 ++ src/Request.php | 2 ++ src/Request/ArraySerializer.php | 2 ++ src/Request/Serializer.php | 3 +++ src/RequestTrait.php | 9 +++++++++ src/Response.php | 6 ++++++ src/Response/ArraySerializer.php | 2 ++ src/Response/HtmlResponse.php | 6 ++++++ src/Response/InjectContentTypeTrait.php | 4 ++++ src/Response/JsonResponse.php | 9 +++++++++ src/Response/RedirectResponse.php | 6 ++++++ src/Response/SapiEmitterTrait.php | 8 ++++++++ src/Response/SapiStreamEmitter.php | 5 +++++ src/Response/Serializer.php | 3 +++ src/Response/TextResponse.php | 6 ++++++ src/Response/XmlResponse.php | 6 ++++++ src/Server.php | 2 ++ src/ServerRequest.php | 3 +++ src/ServerRequestFactory.php | 23 +++++++++++++++++++++++ src/Stream.php | 22 ++++++++++++++++++++++ src/UploadedFile.php | 23 +++++++++++++++++++++++ src/Uri.php | 20 ++++++++++++++++++++ test/MessageTraitTest.php | 2 ++ test/PhpInputStreamTest.php | 3 +++ test/RelativeStreamTest.php | 2 ++ test/Request/SerializerTest.php | 3 +++ test/Response/AbstractEmitterTest.php | 3 +++ test/Response/JsonResponseTest.php | 12 ++++++++++++ test/Response/SapiStreamEmitterTest.php | 17 +++++++++++++++++ test/Response/XmlResponseTest.php | 2 ++ test/ResponseTest.php | 5 +++++ test/ServerTest.php | 3 +++ test/StreamTest.php | 22 ++++++++++++++++++++++ test/UploadedFileTest.php | 21 ++++++++++++++++++++- test/UriTest.php | 2 ++ 40 files changed, 306 insertions(+), 1 deletion(-) diff --git a/src/AbstractSerializer.php b/src/AbstractSerializer.php index 9ee9afd0..cd07fa6d 100644 --- a/src/AbstractSerializer.php +++ b/src/AbstractSerializer.php @@ -12,6 +12,14 @@ use Psr\Http\Message\StreamInterface; use UnexpectedValueException; +use function array_pop; +use function implode; +use function ltrim; +use function preg_match; +use function sprintf; +use function str_replace; +use function ucwords; + /** * Provides base functionality for request and response de/serialization * strategies, including functionality for retrieving a line at a time from diff --git a/src/CallbackStream.php b/src/CallbackStream.php index c8e6bc6f..8913ffb6 100644 --- a/src/CallbackStream.php +++ b/src/CallbackStream.php @@ -13,6 +13,10 @@ use RuntimeException; use Psr\Http\Message\StreamInterface; +use function array_key_exists; + +use const SEEK_SET; + /** * Implementation of PSR HTTP streams */ diff --git a/src/HeaderSecurity.php b/src/HeaderSecurity.php index 929db97d..72e83e14 100644 --- a/src/HeaderSecurity.php +++ b/src/HeaderSecurity.php @@ -9,6 +9,17 @@ use InvalidArgumentException; +use function get_class; +use function gettype; +use function in_array; +use function is_numeric; +use function is_object; +use function is_string; +use function ord; +use function preg_match; +use function sprintf; +use function strlen; + /** * Provide security tools around HTTP headers to prevent common injection vectors. * diff --git a/src/MessageTrait.php b/src/MessageTrait.php index 5f506207..d249d86a 100644 --- a/src/MessageTrait.php +++ b/src/MessageTrait.php @@ -10,6 +10,19 @@ use InvalidArgumentException; use Psr\Http\Message\StreamInterface; +use function array_map; +use function array_merge; +use function get_class; +use function gettype; +use function implode; +use function is_array; +use function is_object; +use function is_resource; +use function is_string; +use function preg_match; +use function sprintf; +use function strtolower; + /** * Trait implementing the various methods defined in MessageInterface. * diff --git a/src/PhpInputStream.php b/src/PhpInputStream.php index 6dc8783a..8713d027 100644 --- a/src/PhpInputStream.php +++ b/src/PhpInputStream.php @@ -7,6 +7,8 @@ namespace Zend\Diactoros; +use function stream_get_contents; + /** * Caching version of php://input */ diff --git a/src/RelativeStream.php b/src/RelativeStream.php index 10a9308a..5f2eb915 100644 --- a/src/RelativeStream.php +++ b/src/RelativeStream.php @@ -10,6 +10,8 @@ use Psr\Http\Message\StreamInterface; use RuntimeException; +use const SEEK_SET; + /** * Class RelativeStream * diff --git a/src/Request.php b/src/Request.php index aacc2dd3..422862ec 100644 --- a/src/Request.php +++ b/src/Request.php @@ -11,6 +11,8 @@ use Psr\Http\Message\StreamInterface; use Psr\Http\Message\UriInterface; +use function strtolower; + /** * HTTP Request encapsulation * diff --git a/src/Request/ArraySerializer.php b/src/Request/ArraySerializer.php index f48db37e..f5e25eba 100644 --- a/src/Request/ArraySerializer.php +++ b/src/Request/ArraySerializer.php @@ -12,6 +12,8 @@ use Zend\Diactoros\Request; use Zend\Diactoros\Stream; +use function sprintf; + /** * Serialize or deserialize request messages to/from arrays. * diff --git a/src/Request/Serializer.php b/src/Request/Serializer.php index 8f45e5ed..20148631 100644 --- a/src/Request/Serializer.php +++ b/src/Request/Serializer.php @@ -18,6 +18,9 @@ use Zend\Diactoros\Stream; use Zend\Diactoros\Uri; +use function preg_match; +use function sprintf; + /** * Serialize (cast to string) or deserialize (cast string to Request) messages. * diff --git a/src/RequestTrait.php b/src/RequestTrait.php index d8062e9f..a1bdc3de 100644 --- a/src/RequestTrait.php +++ b/src/RequestTrait.php @@ -11,6 +11,15 @@ use Psr\Http\Message\StreamInterface; use Psr\Http\Message\UriInterface; +use function array_keys; +use function get_class; +use function gettype; +use function is_object; +use function is_string; +use function preg_match; +use function sprintf; +use function strtolower; + /** * Trait with common request behaviors. * diff --git a/src/Response.php b/src/Response.php index 24aeb4e6..0d059a81 100644 --- a/src/Response.php +++ b/src/Response.php @@ -11,6 +11,12 @@ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\StreamInterface; +use function gettype; +use function is_float; +use function is_numeric; +use function is_scalar; +use function sprintf; + /** * HTTP response encapsulation. * diff --git a/src/Response/ArraySerializer.php b/src/Response/ArraySerializer.php index be4ab3e7..7afe4194 100644 --- a/src/Response/ArraySerializer.php +++ b/src/Response/ArraySerializer.php @@ -12,6 +12,8 @@ use Zend\Diactoros\Response; use Zend\Diactoros\Stream; +use function sprintf; + /** * Serialize or deserialize response messages to/from arrays. * diff --git a/src/Response/HtmlResponse.php b/src/Response/HtmlResponse.php index 1e1f032a..ad5ec8e1 100644 --- a/src/Response/HtmlResponse.php +++ b/src/Response/HtmlResponse.php @@ -14,6 +14,12 @@ use Zend\Diactoros\Response; use Zend\Diactoros\Stream; +use function get_class; +use function gettype; +use function is_object; +use function is_string; +use function sprintf; + /** * HTML response. * diff --git a/src/Response/InjectContentTypeTrait.php b/src/Response/InjectContentTypeTrait.php index 4f2caf84..445e1324 100644 --- a/src/Response/InjectContentTypeTrait.php +++ b/src/Response/InjectContentTypeTrait.php @@ -9,6 +9,10 @@ namespace Zend\Diactoros\Response; +use function array_keys; +use function array_reduce; +use function strtolower; + trait InjectContentTypeTrait { /** diff --git a/src/Response/JsonResponse.php b/src/Response/JsonResponse.php index b20cbfaf..b8a032a3 100644 --- a/src/Response/JsonResponse.php +++ b/src/Response/JsonResponse.php @@ -11,6 +11,15 @@ use Zend\Diactoros\Response; use Zend\Diactoros\Stream; +use function is_object; +use function is_resource; +use function json_encode; +use function json_last_error; +use function json_last_error_msg; +use function sprintf; + +use const JSON_ERROR_NONE; + /** * JSON response. * diff --git a/src/Response/RedirectResponse.php b/src/Response/RedirectResponse.php index bce82499..800428cd 100644 --- a/src/Response/RedirectResponse.php +++ b/src/Response/RedirectResponse.php @@ -13,6 +13,12 @@ use Psr\Http\Message\UriInterface; use Zend\Diactoros\Response; +use function get_class; +use function gettype; +use function is_object; +use function is_string; +use function sprintf; + /** * Produce a redirect response. */ diff --git a/src/Response/SapiEmitterTrait.php b/src/Response/SapiEmitterTrait.php index ce9612c8..3d0f6c6c 100644 --- a/src/Response/SapiEmitterTrait.php +++ b/src/Response/SapiEmitterTrait.php @@ -10,6 +10,14 @@ use Psr\Http\Message\ResponseInterface; use RuntimeException; +use function header; +use function headers_sent; +use function ob_get_length; +use function ob_get_level; +use function sprintf; +use function str_replace; +use function ucwords; + trait SapiEmitterTrait { /** diff --git a/src/Response/SapiStreamEmitter.php b/src/Response/SapiStreamEmitter.php index e06c99f2..a44b8c0f 100644 --- a/src/Response/SapiStreamEmitter.php +++ b/src/Response/SapiStreamEmitter.php @@ -8,6 +8,11 @@ namespace Zend\Diactoros\Response; use Psr\Http\Message\ResponseInterface; + +use function is_array; +use function preg_match; +use function strlen; +use function substr; use RuntimeException; use Zend\Diactoros\RelativeStream; diff --git a/src/Response/Serializer.php b/src/Response/Serializer.php index 03e6f4e2..918643c6 100644 --- a/src/Response/Serializer.php +++ b/src/Response/Serializer.php @@ -15,6 +15,9 @@ use Zend\Diactoros\Response; use Zend\Diactoros\Stream; +use function preg_match; +use function sprintf; + final class Serializer extends AbstractSerializer { /** diff --git a/src/Response/TextResponse.php b/src/Response/TextResponse.php index 13df29d8..6ed2a601 100644 --- a/src/Response/TextResponse.php +++ b/src/Response/TextResponse.php @@ -14,6 +14,12 @@ use Zend\Diactoros\Response; use Zend\Diactoros\Stream; +use function get_class; +use function gettype; +use function is_object; +use function is_string; +use function sprintf; + /** * Plain text response. * diff --git a/src/Response/XmlResponse.php b/src/Response/XmlResponse.php index 0e3d7578..5f81e9ee 100644 --- a/src/Response/XmlResponse.php +++ b/src/Response/XmlResponse.php @@ -12,6 +12,12 @@ use Zend\Diactoros\Response; use Zend\Diactoros\Stream; +use function get_class; +use function gettype; +use function is_object; +use function is_string; +use function sprintf; + /** * XML response. * diff --git a/src/Server.php b/src/Server.php index dfe84004..491addae 100644 --- a/src/Server.php +++ b/src/Server.php @@ -11,6 +11,8 @@ use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\ResponseInterface; +use function property_exists; + /** * "Serve" incoming HTTP requests * diff --git a/src/ServerRequest.php b/src/ServerRequest.php index 0ac78869..bf98cd32 100644 --- a/src/ServerRequest.php +++ b/src/ServerRequest.php @@ -13,6 +13,9 @@ use Psr\Http\Message\UploadedFileInterface; use Psr\Http\Message\UriInterface; +use function array_key_exists; +use function is_array; + /** * Server-side HTTP request * diff --git a/src/ServerRequestFactory.php b/src/ServerRequestFactory.php index 2d79d377..57cdc167 100644 --- a/src/ServerRequestFactory.php +++ b/src/ServerRequestFactory.php @@ -12,6 +12,29 @@ use stdClass; use UnexpectedValueException; +use function array_change_key_case; +use function array_key_exists; +use function array_keys; +use function explode; +use function implode; +use function is_array; +use function is_callable; +use function ltrim; +use function preg_match; +use function preg_match_all; +use function preg_replace; +use function sprintf; +use function strlen; +use function strpos; +use function strrpos; +use function strtolower; +use function strtr; +use function substr; +use function urldecode; + +use const CASE_LOWER; +use const PREG_SET_ORDER; + /** * Class for marshaling a request object from the current PHP environment. * diff --git a/src/Stream.php b/src/Stream.php index af84d9b9..d05235f5 100644 --- a/src/Stream.php +++ b/src/Stream.php @@ -11,6 +11,28 @@ use RuntimeException; use Psr\Http\Message\StreamInterface; +use function array_key_exists; +use function fclose; +use function feof; +use function fopen; +use function fread; +use function fseek; +use function fstat; +use function ftell; +use function fwrite; +use function get_resource_type; +use function is_int; +use function is_resource; +use function is_string; +use function restore_error_handler; +use function set_error_handler; +use function stream_get_contents; +use function stream_get_meta_data; +use function strstr; + +use const E_WARNING; +use const SEEK_SET; + /** * Implementation of PSR HTTP streams */ diff --git a/src/UploadedFile.php b/src/UploadedFile.php index f1f34aec..c260b0c1 100644 --- a/src/UploadedFile.php +++ b/src/UploadedFile.php @@ -12,6 +12,29 @@ use Psr\Http\Message\UploadedFileInterface; use RuntimeException; +use function dirname; +use function fclose; +use function fopen; +use function fwrite; +use function is_dir; +use function is_int; +use function is_resource; +use function is_string; +use function is_writable; +use function move_uploaded_file; +use function sprintf; +use function strpos; + +use const PHP_SAPI; +use const UPLOAD_ERR_CANT_WRITE; +use const UPLOAD_ERR_EXTENSION; +use const UPLOAD_ERR_FORM_SIZE; +use const UPLOAD_ERR_INI_SIZE; +use const UPLOAD_ERR_NO_FILE; +use const UPLOAD_ERR_NO_TMP_DIR; +use const UPLOAD_ERR_OK; +use const UPLOAD_ERR_PARTIAL; + class UploadedFile implements UploadedFileInterface { const ERROR_MESSAGES = [ diff --git a/src/Uri.php b/src/Uri.php index 8900e374..6a68b447 100644 --- a/src/Uri.php +++ b/src/Uri.php @@ -10,6 +10,26 @@ use InvalidArgumentException; use Psr\Http\Message\UriInterface; +use function array_key_exists; +use function array_keys; +use function count; +use function explode; +use function get_class; +use function gettype; +use function implode; +use function is_numeric; +use function is_object; +use function is_string; +use function ltrim; +use function parse_url; +use function preg_replace; +use function preg_replace_callback; +use function rawurlencode; +use function sprintf; +use function strpos; +use function strtolower; +use function substr; + /** * Implementation of Psr\Http\UriInterface. * diff --git a/test/MessageTraitTest.php b/test/MessageTraitTest.php index 5f9d6c1c..b7759fd6 100644 --- a/test/MessageTraitTest.php +++ b/test/MessageTraitTest.php @@ -14,6 +14,8 @@ use ReflectionMethod; use Zend\Diactoros\Request; +use function count; + class MessageTraitTest extends TestCase { /** diff --git a/test/PhpInputStreamTest.php b/test/PhpInputStreamTest.php index e9887b1f..aa3bbcf2 100644 --- a/test/PhpInputStreamTest.php +++ b/test/PhpInputStreamTest.php @@ -10,6 +10,9 @@ use PHPUnit\Framework\TestCase; use Zend\Diactoros\PhpInputStream; +use function file_get_contents; +use function substr; + class PhpInputStreamTest extends TestCase { /** diff --git a/test/RelativeStreamTest.php b/test/RelativeStreamTest.php index 98805ea1..46534d4e 100644 --- a/test/RelativeStreamTest.php +++ b/test/RelativeStreamTest.php @@ -13,6 +13,8 @@ use Zend\Diactoros\RelativeStream; use Zend\Diactoros\Stream; +use const SEEK_SET; + /** * @covers \Zend\Diactoros\RelativeStream */ diff --git a/test/Request/SerializerTest.php b/test/Request/SerializerTest.php index 21a5ec6d..0c5ed049 100644 --- a/test/Request/SerializerTest.php +++ b/test/Request/SerializerTest.php @@ -18,6 +18,9 @@ use Zend\Diactoros\Stream; use Zend\Diactoros\Uri; +use function json_encode; +use function strlen; + class SerializerTest extends TestCase { public function testSerializesBasicRequest() diff --git a/test/Response/AbstractEmitterTest.php b/test/Response/AbstractEmitterTest.php index 48bb95ee..2c810ea8 100644 --- a/test/Response/AbstractEmitterTest.php +++ b/test/Response/AbstractEmitterTest.php @@ -12,6 +12,9 @@ use Zend\Diactoros\Response\SapiEmitter; use ZendTest\Diactoros\TestAsset\HeaderStack; +use function ob_end_clean; +use function ob_start; + abstract class AbstractEmitterTest extends TestCase { /** diff --git a/test/Response/JsonResponseTest.php b/test/Response/JsonResponseTest.php index 9100b18d..0c51d51b 100644 --- a/test/Response/JsonResponseTest.php +++ b/test/Response/JsonResponseTest.php @@ -11,6 +11,18 @@ use PHPUnit\Framework\TestCase; use Zend\Diactoros\Response\JsonResponse; +use function fopen; +use function json_decode; +use function json_encode; +use function sprintf; + +use const JSON_HEX_AMP; +use const JSON_HEX_APOS; +use const JSON_HEX_QUOT; +use const JSON_HEX_TAG; +use const JSON_PRETTY_PRINT; +use const JSON_UNESCAPED_SLASHES; + class JsonResponseTest extends TestCase { public function testConstructorAcceptsDataAndCreatesJsonEncodedMessageBody() diff --git a/test/Response/SapiStreamEmitterTest.php b/test/Response/SapiStreamEmitterTest.php index 7be4bb6d..f24100ac 100644 --- a/test/Response/SapiStreamEmitterTest.php +++ b/test/Response/SapiStreamEmitterTest.php @@ -18,6 +18,23 @@ use Zend\Diactoros\Response\TextResponse; use ZendTest\Diactoros\TestAsset\HeaderStack; +use function gc_collect_cycles; +use function gc_disable; +use function gc_enable; +use function is_callable; +use function json_encode; +use function max; +use function memory_get_usage; +use function ob_end_clean; +use function ob_end_flush; +use function ob_get_clean; +use function ob_start; +use function str_repeat; +use function strlen; +use function substr; + +use const SEEK_SET; + class SapiStreamEmitterTest extends AbstractEmitterTest { public function setUp() diff --git a/test/Response/XmlResponseTest.php b/test/Response/XmlResponseTest.php index 3abbe69d..810a0827 100644 --- a/test/Response/XmlResponseTest.php +++ b/test/Response/XmlResponseTest.php @@ -12,6 +12,8 @@ use Psr\Http\Message\StreamInterface; use Zend\Diactoros\Response\XmlResponse; +use const PHP_EOL; + class XmlResponseTest extends TestCase { public function testConstructorAcceptsBodyAsString() diff --git a/test/ResponseTest.php b/test/ResponseTest.php index e395f8a6..ab2a9923 100644 --- a/test/ResponseTest.php +++ b/test/ResponseTest.php @@ -14,6 +14,11 @@ use Zend\Diactoros\Response; use Zend\Diactoros\Stream; +use function in_array; +use function libxml_set_streams_context; +use function preg_match; +use function stream_context_create; + class ResponseTest extends TestCase { /** diff --git a/test/ServerTest.php b/test/ServerTest.php index 5bdac59c..26218d7e 100644 --- a/test/ServerTest.php +++ b/test/ServerTest.php @@ -19,6 +19,9 @@ use Zend\Diactoros\Stream; use ZendTest\Diactoros\TestAsset\HeaderStack; +use function array_pop; +use function uniqid; + class ServerTest extends TestCase { /** diff --git a/test/StreamTest.php b/test/StreamTest.php index 5174f26f..818c33b1 100644 --- a/test/StreamTest.php +++ b/test/StreamTest.php @@ -13,6 +13,28 @@ use RuntimeException; use Zend\Diactoros\Stream; +use function curl_init; +use function feof; +use function file_exists; +use function file_put_contents; +use function fopen; +use function fread; +use function fseek; +use function fstat; +use function ftok; +use function function_exists; +use function fwrite; +use function imagecreate; +use function is_resource; +use function shmop_open; +use function stream_get_meta_data; +use function sys_get_temp_dir; +use function tempnam; +use function uniqid; +use function unlink; + +use const DIRECTORY_SEPARATOR; + class StreamTest extends TestCase { public $tmpnam; diff --git a/test/UploadedFileTest.php b/test/UploadedFileTest.php index 2b28f00e..c21e833c 100644 --- a/test/UploadedFileTest.php +++ b/test/UploadedFileTest.php @@ -14,6 +14,25 @@ use Zend\Diactoros\Stream; use Zend\Diactoros\UploadedFile; +use function basename; +use function file_exists; +use function file_get_contents; +use function fopen; +use function is_scalar; +use function sys_get_temp_dir; +use function tempnam; +use function uniqid; +use function unlink; + +use const UPLOAD_ERR_CANT_WRITE; +use const UPLOAD_ERR_EXTENSION; +use const UPLOAD_ERR_FORM_SIZE; +use const UPLOAD_ERR_INI_SIZE; +use const UPLOAD_ERR_NO_FILE; +use const UPLOAD_ERR_NO_TMP_DIR; +use const UPLOAD_ERR_OK; +use const UPLOAD_ERR_PARTIAL; + class UploadedFileTest extends TestCase { protected $tmpFile; @@ -337,7 +356,7 @@ public function testMoveToCreatesStreamIfOnlyAFilenameWasProvided() public function errorConstantsAndMessages() { foreach (UploadedFile::ERROR_MESSAGES as $constant => $message) { - if ($constant === \UPLOAD_ERR_OK) { + if ($constant === UPLOAD_ERR_OK) { continue; } yield $constant => [$constant, $message]; diff --git a/test/UriTest.php b/test/UriTest.php index 1decccff..3283aeed 100644 --- a/test/UriTest.php +++ b/test/UriTest.php @@ -11,6 +11,8 @@ use PHPUnit\Framework\TestCase; use Zend\Diactoros\Uri; +use function sprintf; + class UriTest extends TestCase { public function testConstructorSetsAllProperties() From c8f371831e81f3312be8cc93e932c1194b366a1a Mon Sep 17 00:00:00 2001 From: webimpress Date: Thu, 15 Mar 2018 13:00:48 +0000 Subject: [PATCH 2/4] Optimize imports - removed unused and alphabetical order --- src/CallbackStream.php | 2 +- src/Response/SapiEmitter.php | 1 - src/Response/SapiStreamEmitter.php | 2 -- src/Server.php | 2 +- src/Stream.php | 2 +- test/MessageTraitTest.php | 1 - test/Response/SapiEmitterTest.php | 1 - test/Response/SapiStreamEmitterTest.php | 2 +- test/ServerTest.php | 2 +- 9 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/CallbackStream.php b/src/CallbackStream.php index 8913ffb6..9537a349 100644 --- a/src/CallbackStream.php +++ b/src/CallbackStream.php @@ -10,8 +10,8 @@ namespace Zend\Diactoros; use InvalidArgumentException; -use RuntimeException; use Psr\Http\Message\StreamInterface; +use RuntimeException; use function array_key_exists; diff --git a/src/Response/SapiEmitter.php b/src/Response/SapiEmitter.php index 111e83be..4c4178bb 100644 --- a/src/Response/SapiEmitter.php +++ b/src/Response/SapiEmitter.php @@ -8,7 +8,6 @@ namespace Zend\Diactoros\Response; use Psr\Http\Message\ResponseInterface; -use RuntimeException; class SapiEmitter implements EmitterInterface { diff --git a/src/Response/SapiStreamEmitter.php b/src/Response/SapiStreamEmitter.php index a44b8c0f..0c0101f7 100644 --- a/src/Response/SapiStreamEmitter.php +++ b/src/Response/SapiStreamEmitter.php @@ -13,8 +13,6 @@ use function preg_match; use function strlen; use function substr; -use RuntimeException; -use Zend\Diactoros\RelativeStream; class SapiStreamEmitter implements EmitterInterface { diff --git a/src/Server.php b/src/Server.php index 491addae..0b3202ed 100644 --- a/src/Server.php +++ b/src/Server.php @@ -8,8 +8,8 @@ namespace Zend\Diactoros; use OutOfBoundsException; -use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\ServerRequestInterface; use function property_exists; diff --git a/src/Stream.php b/src/Stream.php index d05235f5..35fa20a6 100644 --- a/src/Stream.php +++ b/src/Stream.php @@ -8,8 +8,8 @@ namespace Zend\Diactoros; use InvalidArgumentException; -use RuntimeException; use Psr\Http\Message\StreamInterface; +use RuntimeException; use function array_key_exists; use function fclose; diff --git a/test/MessageTraitTest.php b/test/MessageTraitTest.php index b7759fd6..6c01fb47 100644 --- a/test/MessageTraitTest.php +++ b/test/MessageTraitTest.php @@ -11,7 +11,6 @@ use PHPUnit\Framework\TestCase; use Psr\Http\Message\MessageInterface; use Psr\Http\Message\StreamInterface; -use ReflectionMethod; use Zend\Diactoros\Request; use function count; diff --git a/test/Response/SapiEmitterTest.php b/test/Response/SapiEmitterTest.php index ab1b18ef..4682fd5d 100644 --- a/test/Response/SapiEmitterTest.php +++ b/test/Response/SapiEmitterTest.php @@ -7,7 +7,6 @@ namespace ZendTest\Diactoros\Response; -use Zend\Diactoros\Response; class SapiEmitterTest extends AbstractEmitterTest { diff --git a/test/Response/SapiStreamEmitterTest.php b/test/Response/SapiStreamEmitterTest.php index f24100ac..b7a57afd 100644 --- a/test/Response/SapiStreamEmitterTest.php +++ b/test/Response/SapiStreamEmitterTest.php @@ -12,8 +12,8 @@ use Zend\Diactoros\CallbackStream; use Zend\Diactoros\Response; use Zend\Diactoros\Response\EmptyResponse; -use Zend\Diactoros\Response\JsonResponse; use Zend\Diactoros\Response\HtmlResponse; +use Zend\Diactoros\Response\JsonResponse; use Zend\Diactoros\Response\SapiStreamEmitter; use Zend\Diactoros\Response\TextResponse; use ZendTest\Diactoros\TestAsset\HeaderStack; diff --git a/test/ServerTest.php b/test/ServerTest.php index 26218d7e..fe9b1165 100644 --- a/test/ServerTest.php +++ b/test/ServerTest.php @@ -8,8 +8,8 @@ namespace ZendTest\Diactoros; use OutOfBoundsException; -use PHPUnit_Framework_MockObject_MockObject; use PHPUnit\Framework\TestCase; +use PHPUnit_Framework_MockObject_MockObject; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Zend\Diactoros\Response; From 3b4664d40b8cb65f7737b8846e244ecfbc731c55 Mon Sep 17 00:00:00 2001 From: webimpress Date: Thu, 15 Mar 2018 13:19:59 +0000 Subject: [PATCH 3/4] Removed two imported functions - these are mocked in tests We have to find a better method to test functionality which depends on internal functions. --- src/Response/SapiEmitterTrait.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Response/SapiEmitterTrait.php b/src/Response/SapiEmitterTrait.php index 3d0f6c6c..89f1eeb5 100644 --- a/src/Response/SapiEmitterTrait.php +++ b/src/Response/SapiEmitterTrait.php @@ -10,8 +10,6 @@ use Psr\Http\Message\ResponseInterface; use RuntimeException; -use function header; -use function headers_sent; use function ob_get_length; use function ob_get_level; use function sprintf; From 765fc2f44921e3ae3e6517450f7a33f8ec67cace Mon Sep 17 00:00:00 2001 From: webimpress Date: Thu, 15 Mar 2018 14:08:19 +0000 Subject: [PATCH 4/4] CS fix - removed empty line --- test/Response/SapiEmitterTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/test/Response/SapiEmitterTest.php b/test/Response/SapiEmitterTest.php index 4682fd5d..5d506687 100644 --- a/test/Response/SapiEmitterTest.php +++ b/test/Response/SapiEmitterTest.php @@ -7,7 +7,6 @@ namespace ZendTest\Diactoros\Response; - class SapiEmitterTest extends AbstractEmitterTest { }