Skip to content

Commit

Permalink
Fully-qualified function calls
Browse files Browse the repository at this point in the history
  • Loading branch information
t0mmy742 committed Jan 3, 2020
1 parent 5fa2471 commit 8f87a94
Show file tree
Hide file tree
Showing 17 changed files with 97 additions and 6 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"psr/http-message": "^1.0"
},
"require-dev": {
"adriansuter/php-autoload-override": "v0.1-beta",
"laminas/laminas-diactoros": "^2.0",
"nyholm/psr7": "^1.0",
"php-http/psr7-integration-tests": "dev-master",
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.1/phpunit.xsd"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/8.5/phpunit.xsd"
colors="true"
bootstrap="tests/bootstrap.php"
>
Expand Down
18 changes: 18 additions & 0 deletions src/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,24 @@
use Psr\Http\Message\StreamInterface;
use RuntimeException;

use function basename;
use function in_array;
use function is_array;
use function is_resource;
use function is_string;
use function json_encode;
use function json_last_error;
use function json_last_error_msg;
use function mime_content_type;
use function preg_replace;
use function rawurlencode;
use function sprintf;
use function stream_get_meta_data;
use function strlen;
use function substr;

use const JSON_ERROR_NONE;

class Response implements ResponseInterface
{
/**
Expand Down
16 changes: 16 additions & 0 deletions src/ServerRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,22 @@
use Psr\Http\Message\UriInterface;
use RuntimeException;

use function array_merge;
use function count;
use function explode;
use function is_array;
use function is_null;
use function is_object;
use function json_decode;
use function libxml_clear_errors;
use function libxml_disable_entity_loader;
use function libxml_use_internal_errors;
use function parse_str;
use function preg_split;
use function property_exists;
use function simplexml_load_string;
use function strtolower;

class ServerRequest implements ServerRequestInterface
{
/**
Expand Down
3 changes: 3 additions & 0 deletions tests/Psr7Integration/Laminas/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
use Slim\Http\Factory\DecoratedResponseFactory;
use Slim\Tests\Http\Providers\LaminasDiactorosPsr17FactoryProvider;

use function define;
use function defined;

class ResponseTest extends ResponseIntegrationTest
{
public static function setUpBeforeClass(): void
Expand Down
3 changes: 3 additions & 0 deletions tests/Psr7Integration/Laminas/ServerRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
use Slim\Http\Factory\DecoratedServerRequestFactory;
use Slim\Tests\Http\Providers\LaminasDiactorosPsr17FactoryProvider;

use function define;
use function defined;

class ServerRequestTest extends ServerRequestIntegrationTest
{
public static function setUpBeforeClass(): void
Expand Down
3 changes: 3 additions & 0 deletions tests/Psr7Integration/Laminas/UriTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
use Slim\Http\Factory\DecoratedUriFactory;
use Slim\Tests\Http\Providers\LaminasDiactorosPsr17FactoryProvider;

use function define;
use function defined;

class UriTest extends UriIntegrationTest
{
public static function setUpBeforeClass(): void
Expand Down
3 changes: 3 additions & 0 deletions tests/Psr7Integration/Nyholm/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
use Slim\Http\Factory\DecoratedResponseFactory;
use Slim\Tests\Http\Providers\NyholmPsr17FactoryProvider;

use function define;
use function defined;

class ResponseTest extends ResponseIntegrationTest
{
public static function setUpBeforeClass(): void
Expand Down
3 changes: 3 additions & 0 deletions tests/Psr7Integration/Nyholm/ServerRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
use Slim\Http\Factory\DecoratedServerRequestFactory;
use Slim\Tests\Http\Providers\NyholmPsr17FactoryProvider;

use function define;
use function defined;

class ServerRequestTest extends ServerRequestIntegrationTest
{
public static function setUpBeforeClass(): void
Expand Down
3 changes: 3 additions & 0 deletions tests/Psr7Integration/Nyholm/UriTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
use Slim\Http\Factory\DecoratedUriFactory;
use Slim\Tests\Http\Providers\NyholmPsr17FactoryProvider;

use function define;
use function defined;

class UriTest extends UriIntegrationTest
{
public static function setUpBeforeClass(): void
Expand Down
3 changes: 3 additions & 0 deletions tests/Psr7Integration/Zend/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
use Slim\Tests\Http\Providers\ZendDiactorosPsr17FactoryProvider;
use Zend\Diactoros\StreamFactory;

use function define;
use function defined;

class ResponseTest extends ResponseIntegrationTest
{
public static function setUpBeforeClass(): void
Expand Down
3 changes: 3 additions & 0 deletions tests/Psr7Integration/Zend/ServerRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
use Slim\Tests\Http\Providers\ZendDiactorosPsr17FactoryProvider;
use Zend\Diactoros\StreamFactory;

use function define;
use function defined;

class ServerRequestTest extends ServerRequestIntegrationTest
{
public static function setUpBeforeClass(): void
Expand Down
3 changes: 3 additions & 0 deletions tests/Psr7Integration/Zend/UriTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
use Slim\Tests\Http\Providers\ZendDiactorosPsr17FactoryProvider;
use Zend\Diactoros\StreamFactory;

use function define;
use function defined;

class UriTest extends UriIntegrationTest
{
public static function setUpBeforeClass(): void
Expand Down
9 changes: 9 additions & 0 deletions tests/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@
use Slim\Http\Response;
use Slim\Tests\Http\Providers\Psr17FactoryProvider;

use function chr;
use function fclose;
use function fopen;
use function is_resource;
use function json_decode;
use function property_exists;

use const JSON_HEX_AMP;

class ResponseTest extends TestCase
{
public function testDisableSetter()
Expand Down
9 changes: 6 additions & 3 deletions tests/ServerRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
use RuntimeException;
use Slim\Http\Factory\DecoratedServerRequestFactory;
use Slim\Tests\Http\Providers\Psr17FactoryProvider;
use stdClass;

use function property_exists;

class ServerRequestTest extends TestCase
{
Expand Down Expand Up @@ -833,7 +836,7 @@ public function testGetParsedBodyXml()
->withHeader('Content-Type', 'application/hal+xml;charset=utf8')
->withBody($stream);

/** @var \stdClass $obj */
/** @var stdClass $obj */
$obj = $request->getParsedBody();
$this->assertEquals('John', $obj->name);
}
Expand All @@ -854,7 +857,7 @@ public function testGetParsedBodyStructuredSuffixXml()
->withHeader('Content-Type', 'application/xml;charset=utf8')
->withBody($stream);

/** @var \stdClass $obj */
/** @var stdClass $obj */
$obj = $request->getParsedBody();
$this->assertEquals('John', $obj->name);
}
Expand All @@ -875,7 +878,7 @@ public function testGetParsedBodyXmlWithTextXMLMediaType()
->withHeader('Content-Type', 'text/xml')
->withBody($stream);

/** @var \stdClass $obj */
/** @var stdClass $obj */
$obj = $request->getParsedBody();
$this->assertEquals('John', $obj->name);
}
Expand Down
2 changes: 2 additions & 0 deletions tests/UriTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
use Slim\Http\Factory\DecoratedUriFactory;
use Slim\Tests\Http\Providers\Psr17FactoryProvider;

use function property_exists;

class UriTest extends TestCase
{
public function testDisableSetter()
Expand Down
19 changes: 17 additions & 2 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@

declare(strict_types=1);

require __DIR__ . '/../vendor/autoload.php';
use AdrianSuter\Autoload\Override\Override;
use Slim\Http\ServerRequest;

require __DIR__ . '/Assets/PhpFunctionOverrides.php';
$classLoader = require __DIR__ . '/../vendor/autoload.php';

//require __DIR__ . '/Assets/PhpFunctionOverrides.php';

Override::apply($classLoader, [
ServerRequest::class => [
'preg_split' => function (string $pattern, string $subject, int $limit = -1, int $flags = 0) {
if (isset($GLOBALS['preg_split_return'])) {
return $GLOBALS['preg_split_return'];
}

return preg_split($pattern, $subject, $limit, $flags);
}
]
]);

0 comments on commit 8f87a94

Please sign in to comment.