Skip to content

Commit

Permalink
Merge branch '4.x' into AddMultipleErrorHandlers
Browse files Browse the repository at this point in the history
  • Loading branch information
l0gicgate committed Jan 5, 2020
2 parents 6537a86 + d420a9e commit bf4c579
Show file tree
Hide file tree
Showing 123 changed files with 486 additions and 71 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pull request for each branch. This allows me to review and pull in new features

## Style Guide

All pull requests must adhere to the [PSR-2 standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md).
All pull requests must adhere to the [PSR-12 standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-12-extended-coding-style-guide.md).

## Unit Testing

Expand Down
3 changes: 3 additions & 0 deletions Slim/App.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand Down Expand Up @@ -27,6 +28,8 @@
use Slim\Routing\RouteResolver;
use Slim\Routing\RouteRunner;

use function strtoupper;

class App extends RouteCollectorProxy implements RequestHandlerInterface
{
/**
Expand Down
10 changes: 10 additions & 0 deletions Slim/CallableResolver.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand All @@ -16,6 +17,15 @@
use RuntimeException;
use Slim\Interfaces\AdvancedCallableResolverInterface;

use function class_exists;
use function is_array;
use function is_callable;
use function is_object;
use function is_string;
use function json_encode;
use function preg_match;
use function sprintf;

final class CallableResolver implements AdvancedCallableResolverInterface
{
/**
Expand Down
1 change: 1 addition & 0 deletions Slim/Error/AbstractErrorRenderer.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand Down
5 changes: 5 additions & 0 deletions Slim/Error/Renderers/HtmlErrorRenderer.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand All @@ -12,6 +13,10 @@
use Slim\Error\AbstractErrorRenderer;
use Throwable;

use function get_class;
use function htmlentities;
use function sprintf;

/**
* Default Slim application HTML Error Renderer
*/
Expand Down
7 changes: 7 additions & 0 deletions Slim/Error/Renderers/JsonErrorRenderer.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand All @@ -12,6 +13,12 @@
use Slim\Error\AbstractErrorRenderer;
use Throwable;

use function get_class;
use function json_encode;

use const JSON_PRETTY_PRINT;
use const JSON_UNESCAPED_SLASHES;

/**
* Default Slim application JSON Error Renderer
*/
Expand Down
5 changes: 5 additions & 0 deletions Slim/Error/Renderers/PlainTextErrorRenderer.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand All @@ -12,6 +13,10 @@
use Slim\Error\AbstractErrorRenderer;
use Throwable;

use function get_class;
use function htmlentities;
use function sprintf;

/**
* Default Slim application Plain Text Error Renderer
*/
Expand Down
5 changes: 5 additions & 0 deletions Slim/Error/Renderers/XmlErrorRenderer.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand All @@ -12,6 +13,10 @@
use Slim\Error\AbstractErrorRenderer;
use Throwable;

use function get_class;
use function sprintf;
use function str_replace;

/**
* Default Slim application XML Error Renderer
*/
Expand Down
1 change: 1 addition & 0 deletions Slim/Exception/HttpBadRequestException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand Down
1 change: 1 addition & 0 deletions Slim/Exception/HttpException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand Down
1 change: 1 addition & 0 deletions Slim/Exception/HttpForbiddenException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand Down
1 change: 1 addition & 0 deletions Slim/Exception/HttpInternalServerErrorException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand Down
3 changes: 3 additions & 0 deletions Slim/Exception/HttpMethodNotAllowedException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand All @@ -9,6 +10,8 @@

namespace Slim\Exception;

use function implode;

class HttpMethodNotAllowedException extends HttpSpecializedException
{
/**
Expand Down
1 change: 1 addition & 0 deletions Slim/Exception/HttpNotFoundException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand Down
1 change: 1 addition & 0 deletions Slim/Exception/HttpNotImplementedException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand Down
1 change: 1 addition & 0 deletions Slim/Exception/HttpSpecializedException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand Down
1 change: 1 addition & 0 deletions Slim/Exception/HttpUnauthorizedException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand Down
4 changes: 3 additions & 1 deletion Slim/Factory/AppFactory.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand Down Expand Up @@ -179,7 +180,8 @@ protected static function attemptResponseFactoryDecoration(
ResponseFactoryInterface $responseFactory,
StreamFactoryInterface $streamFactory
): ResponseFactoryInterface {
if (static::$slimHttpDecoratorsAutomaticDetectionEnabled
if (
static::$slimHttpDecoratorsAutomaticDetectionEnabled
&& SlimHttpPsr17Factory::isResponseFactoryAvailable()
) {
return SlimHttpPsr17Factory::createDecoratedResponseFactory($responseFactory, $streamFactory);
Expand Down
1 change: 1 addition & 0 deletions Slim/Factory/Psr17/GuzzlePsr17Factory.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand Down
19 changes: 19 additions & 0 deletions Slim/Factory/Psr17/LaminasDiactorosPsr17Factory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
* @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
*/

declare(strict_types=1);

namespace Slim\Factory\Psr17;

class LaminasDiactorosPsr17Factory extends Psr17Factory
{
protected static $responseFactoryClass = 'Laminas\Diactoros\ResponseFactory';
protected static $streamFactoryClass = 'Laminas\Diactoros\StreamFactory';
protected static $serverRequestCreatorClass = 'Laminas\Diactoros\ServerRequestFactory';
protected static $serverRequestCreatorMethod = 'fromGlobals';
}
3 changes: 2 additions & 1 deletion Slim/Factory/Psr17/NyholmPsr17Factory.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace Slim\Factory\Psr17;
Expand All @@ -21,7 +22,7 @@ public static function getServerRequestCreator(): ServerRequestCreatorInterface
* Nyholm Psr17Factory implements all factories in one unified
* factory which implements all of the PSR-17 factory interfaces
*/
$psr17Factory = new static::$responseFactoryClass;
$psr17Factory = new static::$responseFactoryClass();

$serverRequestCreator = new static::$serverRequestCreatorClass(
$psr17Factory,
Expand Down
8 changes: 6 additions & 2 deletions Slim/Factory/Psr17/Psr17Factory.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand All @@ -15,6 +16,9 @@
use Slim\Interfaces\Psr17FactoryInterface;
use Slim\Interfaces\ServerRequestCreatorInterface;

use function class_exists;
use function get_called_class;

abstract class Psr17Factory implements Psr17FactoryInterface
{
/**
Expand Down Expand Up @@ -46,7 +50,7 @@ public static function getResponseFactory(): ResponseFactoryInterface
throw new RuntimeException(get_called_class() . ' could not instantiate a response factory.');
}

return new static::$responseFactoryClass;
return new static::$responseFactoryClass();
}

/**
Expand All @@ -58,7 +62,7 @@ public static function getStreamFactory(): StreamFactoryInterface
throw new RuntimeException(get_called_class() . ' could not instantiate a stream factory.');
}

return new static::$streamFactoryClass;
return new static::$streamFactoryClass();
}

/**
Expand Down
4 changes: 4 additions & 0 deletions Slim/Factory/Psr17/Psr17FactoryProvider.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand All @@ -11,6 +12,8 @@

use Slim\Interfaces\Psr17FactoryProviderInterface;

use function array_unshift;

class Psr17FactoryProvider implements Psr17FactoryProviderInterface
{
/**
Expand All @@ -19,6 +22,7 @@ class Psr17FactoryProvider implements Psr17FactoryProviderInterface
protected static $factories = [
SlimPsr17Factory::class,
NyholmPsr17Factory::class,
LaminasDiactorosPsr17Factory::class,
ZendDiactorosPsr17Factory::class,
GuzzlePsr17Factory::class,
];
Expand Down
1 change: 1 addition & 0 deletions Slim/Factory/Psr17/ServerRequestCreator.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand Down
1 change: 1 addition & 0 deletions Slim/Factory/Psr17/SlimHttpPsr17Factory.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand Down
3 changes: 3 additions & 0 deletions Slim/Factory/Psr17/SlimHttpServerRequestCreator.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand All @@ -13,6 +14,8 @@
use RuntimeException;
use Slim\Interfaces\ServerRequestCreatorInterface;

use function class_exists;

class SlimHttpServerRequestCreator implements ServerRequestCreatorInterface
{
/**
Expand Down
1 change: 1 addition & 0 deletions Slim/Factory/Psr17/SlimPsr17Factory.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand Down
1 change: 1 addition & 0 deletions Slim/Factory/Psr17/ZendDiactorosPsr17Factory.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand Down
4 changes: 3 additions & 1 deletion Slim/Factory/ServerRequestCreatorFactory.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand Down Expand Up @@ -76,7 +77,8 @@ public static function determineServerRequestCreator(): ServerRequestCreatorInte
protected static function attemptServerRequestCreatorDecoration(
ServerRequestCreatorInterface $serverRequestCreator
): ServerRequestCreatorInterface {
if (static::$slimHttpDecoratorsAutomaticDetectionEnabled
if (
static::$slimHttpDecoratorsAutomaticDetectionEnabled
&& SlimHttpServerRequestCreator::isServerRequestDecoratorAvailable()
) {
return new SlimHttpServerRequestCreator($serverRequestCreator);
Expand Down
13 changes: 13 additions & 0 deletions Slim/Handlers/ErrorHandler.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand All @@ -24,6 +25,18 @@
use Slim\Interfaces\ErrorRendererInterface;
use Throwable;

use function array_intersect;
use function array_key_exists;
use function array_keys;
use function call_user_func;
use function count;
use function current;
use function error_log;
use function explode;
use function implode;
use function next;
use function preg_match;

/**
* Default Slim application error handler
*
Expand Down
1 change: 1 addition & 0 deletions Slim/Handlers/Strategies/RequestHandler.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand Down
1 change: 1 addition & 0 deletions Slim/Handlers/Strategies/RequestResponse.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand Down
Loading

0 comments on commit bf4c579

Please sign in to comment.