Skip to content

Commit

Permalink
Merge branch '4.x' into feature/exception-http-status-gone
Browse files Browse the repository at this point in the history
  • Loading branch information
l0gicgate committed Oct 2, 2021
2 parents f239642 + 66e8ba5 commit b155038
Show file tree
Hide file tree
Showing 21 changed files with 136 additions and 219 deletions.
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: composer
directory: "/"
schedule:
interval: monthly
open-pull-requests-limit: 10
versioning-strategy: increase
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [7.2, 7.3, 7.4, 8.0]
php: [7.3, 7.4, 8.0]
experimental: [false]
include:
- php: 8.0
Expand All @@ -37,7 +37,7 @@ jobs:

- name: Static analysis
if: matrix.analysis
run: vendor/bin/phpstan analyse Slim
run: vendor/bin/phpstan

- name: Tests
run: vendor/bin/phpunit --coverage-clover clover.xml
Expand All @@ -47,5 +47,5 @@ jobs:
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
composer require php-coveralls/php-coveralls -n
composer require php-coveralls/php-coveralls -n -W
vendor/bin/php-coveralls --coverage_clover=clover.xml -v
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Changelog

# 4.8.0 - 2021-05-19
- [3034: Fix phpunit dependency version](https://github.com/slimphp/Slim/pull/3034) thanks to @l0gicgate
- [3037: Replace Travis by GitHub Actions](https://github.com/slimphp/Slim/pull/3037) thanks to @t0mmy742
- [3043: Cover App creation from AppFactory with empty Container](https://github.com/slimphp/Slim/pull/3043) thanks to @t0mmy742
- [3045: Update phpstan/phpstan requirement from ^0.12.58 to ^0.12.64](https://github.com/slimphp/Slim/pull/3045) thanks to @dependabot-preview[bot]
- [3047: documentation: min php 7.2 required](https://github.com/slimphp/Slim/pull/3047) thanks to @Rotzbua
- [3054: Update phpstan/phpstan requirement from ^0.12.64 to ^0.12.70](https://github.com/slimphp/Slim/pull/3054) thanks to @dependabot-preview[bot]
- [3056: Fix docblock in ErrorMiddleware](https://github.com/slimphp/Slim/pull/3056) thanks to @piotr-cz
- [3060: Update phpstan/phpstan requirement from ^0.12.70 to ^0.12.80](https://github.com/slimphp/Slim/pull/3060) thanks to @dependabot-preview[bot]
- [3061: Update nyholm/psr7 requirement from ^1.3 to ^1.4](https://github.com/slimphp/Slim/pull/3061) thanks to @dependabot-preview[bot]
- [3063: Allow ^1.0 || ^2.0 in psr/container](https://github.com/slimphp/Slim/pull/3063) thanks to @Ayesh
- [3069: Classname/Method Callable Arrays](https://github.com/slimphp/Slim/pull/3069) thanks to @ddrv
- [3078: Update squizlabs/php_codesniffer requirement from ^3.5 to ^3.6](https://github.com/slimphp/Slim/pull/3078) thanks to @dependabot[bot]
- [3079: Update phpspec/prophecy requirement from ^1.12 to ^1.13](https://github.com/slimphp/Slim/pull/3079) thanks to @dependabot[bot]
- [3080: Update guzzlehttp/psr7 requirement from ^1.7 to ^1.8](https://github.com/slimphp/Slim/pull/3080) thanks to @dependabot[bot]
- [3082: Update phpstan/phpstan requirement from ^0.12.80 to ^0.12.85](https://github.com/slimphp/Slim/pull/3082) thanks to @dependabot[bot]

# 4.7.0 - 2020-11-30

### Fixed
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ Slim is a PHP micro-framework that helps you quickly write simple yet powerful w
It's recommended that you use [Composer](https://getcomposer.org/) to install Slim.

```bash
$ composer require slim/slim:^4.0
$ composer require slim/slim
```

This will install Slim and all required dependencies. Slim requires PHP 7.2 or newer.
This will install Slim and all required dependencies. Slim requires PHP 7.3 or newer.

## Choose a PSR-7 Implementation & ServerRequest Creator

Before you can get up and running with Slim you will need to choose a PSR-7 implementation that best fits your application. A few notable ones:
- [Slim-Psr7](https://github.com/slimphp/Slim-Psr7) - This is the Slim Framework PSR-7 implementation
- [Nyholm/psr7](https://github.com/Nyholm/psr7) & [Nyholm/psr7-server](https://github.com/Nyholm/psr7-server) - This is the fastest, strictest and most lightweight implementation available
- [Guzzle/psr7](https://github.com/guzzle/psr7) & [http-interop/http-factory-guzzle](https://github.com/http-interop/http-factory-guzzle) - This is the implementation used by the Guzzle Client, featuring extra functionality for stream and file handling
- [Guzzle/psr7](https://github.com/guzzle/psr7) - This is the implementation used by the Guzzle Client, featuring extra functionality for stream and file handling
- [laminas-diactoros](https://github.com/laminas/laminas-diactoros) - This is the Laminas (Zend) PSR-7 implementation


Expand Down Expand Up @@ -54,7 +54,7 @@ $app = AppFactory::create();
In order for auto-detection to work and enable you to use `AppFactory::create()` and `App::run()` without having to manually create a `ServerRequest` you need to install one of the following implementations:
- [Slim-Psr7](https://github.com/slimphp/Slim-Psr7) - Install using `composer require slim/psr7`
- [Nyholm/psr7](https://github.com/Nyholm/psr7) & [Nyholm/psr7-server](https://github.com/Nyholm/psr7-server) - Install using `composer require nyholm/psr7 nyholm/psr7-server`
- [Guzzle/psr7](https://github.com/guzzle/psr7) & [http-interop/http-factory-guzzle](https://github.com/http-interop/http-factory-guzzle) - Install using `composer require guzzlehttp/psr7 http-interop/http-factory-guzzle`
- [Guzzle/psr7](https://github.com/guzzle/psr7) - Install using `composer require guzzlehttp/psr7`
- [laminas-diactoros](https://github.com/laminas/laminas-diactoros) - Install using `composer require laminas/laminas-diactoros`

Then create file _public/index.php_.
Expand Down
2 changes: 1 addition & 1 deletion Slim/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class App extends RouteCollectorProxy implements RequestHandlerInterface
*
* @var string
*/
public const VERSION = '4.7.0';
public const VERSION = '4.8.1';

/**
* @var RouteResolverInterface
Expand Down
23 changes: 23 additions & 0 deletions Slim/CallableResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public function __construct(?ContainerInterface $container = null)
*/
public function resolve($toResolve): callable
{
$toResolve = $this->prepareToResolve($toResolve);
if (is_callable($toResolve)) {
return $this->bindToContainer($toResolve);
}
Expand Down Expand Up @@ -90,6 +91,7 @@ public function resolveMiddleware($toResolve): callable
*/
private function resolveByPredicate($toResolve, callable $predicate, string $defaultMethod): callable
{
$toResolve = $this->prepareToResolve($toResolve);
if (is_callable($toResolve)) {
return $this->bindToContainer($toResolve);
}
Expand Down Expand Up @@ -144,6 +146,9 @@ private function resolveSlimNotation(string $toResolve): array
$instance = $this->container->get($class);
} else {
if (!class_exists($class)) {
if ($method) {
$class .= '::' . $method . '()';
}
throw new RuntimeException(sprintf('Callable %s does not exist', $class));
}
$instance = new $class($this->container);
Expand Down Expand Up @@ -187,4 +192,22 @@ private function bindToContainer(callable $callable): callable
}
return $callable;
}

/**
* @param string|callable $toResolve
* @return string|callable
*/
private function prepareToResolve($toResolve)
{
if (!is_array($toResolve)) {
return $toResolve;
}
$candidate = $toResolve;
$class = array_shift($candidate);
$method = array_shift($candidate);
if (is_string($class) && is_string($method)) {
return $class . ':' . $method;
}
return $toResolve;
}
}
4 changes: 2 additions & 2 deletions Slim/Factory/Psr17/GuzzlePsr17Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

class GuzzlePsr17Factory extends Psr17Factory
{
protected static $responseFactoryClass = 'Http\Factory\Guzzle\ResponseFactory';
protected static $streamFactoryClass = 'Http\Factory\Guzzle\StreamFactory';
protected static $responseFactoryClass = 'GuzzleHttp\Psr7\HttpFactory';
protected static $streamFactoryClass = 'GuzzleHttp\Psr7\HttpFactory';
protected static $serverRequestCreatorClass = 'GuzzleHttp\Psr7\ServerRequest';
protected static $serverRequestCreatorMethod = 'fromGlobals';
}
1 change: 0 additions & 1 deletion Slim/Factory/Psr17/Psr17FactoryProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class Psr17FactoryProvider implements Psr17FactoryProviderInterface
SlimPsr17Factory::class,
NyholmPsr17Factory::class,
LaminasDiactorosPsr17Factory::class,
ZendDiactorosPsr17Factory::class,
GuzzlePsr17Factory::class,
];

Expand Down
19 changes: 0 additions & 19 deletions Slim/Factory/Psr17/ZendDiactorosPsr17Factory.php

This file was deleted.

13 changes: 8 additions & 5 deletions Slim/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,23 @@

use Psr\Log\AbstractLogger;
use Psr\Log\InvalidArgumentException;
use Stringable;

use function error_log;

class Logger extends AbstractLogger
{
/**
* @param mixed $level
* @param string $message
* @param array<mixed> $context
* @param mixed $level
* @param string|Stringable $message
* @param array<mixed> $context
*
* @return void
*
* @throws InvalidArgumentException
*/
public function log($level, $message, array $context = [])
public function log($level, $message, array $context = []): void
{
error_log($message);
error_log((string) $message);
}
}
29 changes: 14 additions & 15 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,31 +43,30 @@
"wiki": "https://github.com/slimphp/Slim/wiki"
},
"require": {
"php": "^7.2 || ^8.0",
"php": "^7.3 || ^8.0",
"ext-json": "*",
"nikic/fast-route": "^1.3",
"psr/container": "^1.0",
"psr/container": "^1.0 || ^2.0",
"psr/http-factory": "^1.0",
"psr/http-message": "^1.0",
"psr/http-server-handler": "^1.0",
"psr/http-server-middleware": "^1.0",
"psr/log": "^1.1"
"psr/log": "^1.1 || ^2.0 || ^3.0"
},
"require-dev": {
"ext-simplexml": "*",
"adriansuter/php-autoload-override": "^1.2",
"guzzlehttp/psr7": "^1.7",
"http-interop/http-factory-guzzle": "^1.0",
"laminas/laminas-diactoros": "^2.4",
"nyholm/psr7": "^1.3",
"nyholm/psr7-server": "^1.0.1",
"phpspec/prophecy": "^1.12",
"phpstan/phpstan": "^0.12.70",
"phpunit/phpunit": "^8.5.13 || ^9.3.8",
"guzzlehttp/psr7": "^2.0",
"laminas/laminas-diactoros": "^2.8",
"nyholm/psr7": "^1.4",
"nyholm/psr7-server": "^1.0",
"phpspec/prophecy": "^1.14",
"phpspec/prophecy-phpunit": "^2.0",
"phpstan/phpstan": "^0.12.99",
"phpunit/phpunit": "^9.5",
"slim/http": "^1.2",
"slim/psr7": "^1.3",
"squizlabs/php_codesniffer": "^3.5",
"weirdan/prophecy-shim": "^1.0 || ^2.0.2"
"slim/psr7": "^1.5",
"squizlabs/php_codesniffer": "^3.6"
},
"autoload": {
"psr-4": {
Expand All @@ -87,7 +86,7 @@
],
"phpunit": "phpunit",
"phpcs": "phpcs",
"phpstan": "phpstan analyse Slim --memory-limit=-1"
"phpstan": "phpstan --memory-limit=-1"
},
"suggest": {
"ext-simplexml": "Needed to support XML format in BodyParsingMiddleware",
Expand Down
5 changes: 3 additions & 2 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
parameters:
level: max
inferPrivatePropertyTypeFromConstructor: true
level: max
paths:
- Slim
34 changes: 11 additions & 23 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,36 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/8.5/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
beStrictAboutTestsThatDoNotTestAnything="true"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
beStrictAboutChangesToGlobalState="true"
beStrictAboutOutputDuringTests="true"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="tests/bootstrap.php"
executionOrder="random"
>
<testsuites>
<testsuite name="Slim Test Suite">
<directory>./tests/</directory>
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory>./Slim/</directory>
</whitelist>
</filter>
<logging>
<log
type="coverage-html"
target="./coverage"
lowUpperBound="20"
highLowerBound="50"
/>
</logging>

<coverage processUncoveredFiles="true">
<include>
<directory>Slim</directory>
</include>
<report>
<html outputDirectory="coverage" lowUpperBound="20" highLowerBound="50"/>
</report>
</coverage>
</phpunit>
58 changes: 0 additions & 58 deletions tests/Assets/PhpFunctionOverrides.php

This file was deleted.

Loading

0 comments on commit b155038

Please sign in to comment.