Skip to content

Commit f899a6e

Browse files
authored
Merge pull request #3442 from maksimovic/3.x-php85
2 parents 565632b + 7fc3b4e commit f899a6e

47 files changed

Lines changed: 553 additions & 781 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/tests.yml

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,51 @@
11
name: Tests
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
branches: [3.x]
6+
pull_request:
47

58
jobs:
69
tests:
7-
name: Tests PHP ${{ matrix.php }}
10+
name: PHP ${{ matrix.php }}
811
runs-on: ubuntu-latest
9-
continue-on-error: ${{ matrix.experimental }}
1012
strategy:
1113
fail-fast: false
1214
matrix:
13-
php: [7.3, 7.4, 8.0]
14-
experimental: [false]
15+
php: ['8.1', '8.2', '8.3', '8.4', '8.5']
1516
include:
16-
- php: 8.0
17-
analysis: true
18-
- php: 8.1
19-
experimental: true
17+
- php: '8.5'
18+
coverage: 'xdebug'
2019

2120
steps:
2221
- name: Checkout
23-
uses: actions/checkout@v2
22+
uses: actions/checkout@v4
2423

2524
- name: Set up PHP ${{ matrix.php }}
2625
uses: shivammathur/setup-php@v2
2726
with:
2827
php-version: ${{ matrix.php }}
29-
coverage: xdebug
28+
coverage: ${{ matrix.coverage || 'none' }}
3029

3130
- name: Install dependencies with Composer
32-
uses: ramsey/composer-install@v1
31+
uses: ramsey/composer-install@v3
3332

3433
- name: Coding standards
35-
if: matrix.analysis
3634
run: vendor/bin/phpcs
3735

3836
- name: Static analysis
39-
if: matrix.analysis
40-
run: vendor/bin/phpstan
37+
run: vendor/bin/phpstan analyse --memory-limit=512M
4138

4239
- name: Tests
40+
if: ${{ !matrix.coverage }}
41+
run: vendor/bin/phpunit
42+
43+
- name: Tests with coverage
44+
if: ${{ matrix.coverage }}
4345
run: vendor/bin/phpunit --coverage-clover clover.xml
4446

4547
- name: Upload coverage results to Coveralls
46-
if: matrix.analysis
48+
if: ${{ matrix.coverage }}
4749
env:
4850
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4951
run: |

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ coverage
44
vendor
55
.DS_Store
66
.idea
7+
.phpunit.result.cache

.travis.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ It's recommended that you use [Composer](https://getcomposer.org/) to install Sl
1616
$ composer require slim/slim "^3.0"
1717
```
1818

19-
This will install Slim and all required dependencies. Slim requires PHP 5.5.0 or newer.
19+
This will install Slim and all required dependencies.
20+
21+
## Version compatibility
22+
23+
- Slim version 3.13.0 requires PHP 8.1 or newer.
24+
- Slim version 3.12.x and below requires PHP 5.5 – PHP 8.1.
2025

2126
## Usage
2227

Slim/App.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ public function subRequest(
547547
array $headers = [],
548548
array $cookies = [],
549549
$bodyContent = '',
550-
ResponseInterface $response = null
550+
?ResponseInterface $response = null
551551
) {
552552
$env = $this->container->get('environment');
553553
$uri = Uri::createFromEnvironment($env)->withPath($path)->withQuery($query);
@@ -663,7 +663,7 @@ protected function isEmptyResponse(ResponseInterface $response)
663663
*/
664664
protected function isHeadRequest(RequestInterface $request)
665665
{
666-
return strtoupper($request->getMethod()) === 'HEAD';
666+
return strtoupper((string)$request->getMethod()) === 'HEAD';
667667
}
668668

669669
/**

Slim/Collection.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
* This class provides a common interface used by many other
1717
* classes in a Slim application that manage "collections"
1818
* of data that must be inspected and/or manipulated
19+
*
20+
* @phpstan-consistent-constructor
1921
*/
2022
class Collection implements CollectionInterface
2123
{
@@ -109,6 +111,7 @@ public function clear()
109111
*
110112
* @return bool
111113
*/
114+
#[\ReturnTypeWillChange]
112115
public function offsetExists($key)
113116
{
114117
return $this->has($key);
@@ -121,6 +124,7 @@ public function offsetExists($key)
121124
*
122125
* @return mixed The key's value, or the default value
123126
*/
127+
#[\ReturnTypeWillChange]
124128
public function offsetGet($key)
125129
{
126130
return $this->get($key);
@@ -132,6 +136,7 @@ public function offsetGet($key)
132136
* @param string $key The data key
133137
* @param mixed $value The data value
134138
*/
139+
#[\ReturnTypeWillChange]
135140
public function offsetSet($key, $value)
136141
{
137142
$this->set($key, $value);
@@ -142,6 +147,7 @@ public function offsetSet($key, $value)
142147
*
143148
* @param string $key The data key
144149
*/
150+
#[\ReturnTypeWillChange]
145151
public function offsetUnset($key)
146152
{
147153
$this->remove($key);
@@ -152,6 +158,7 @@ public function offsetUnset($key)
152158
*
153159
* @return int
154160
*/
161+
#[\ReturnTypeWillChange]
155162
public function count()
156163
{
157164
return count($this->data);
@@ -162,6 +169,7 @@ public function count()
162169
*
163170
* @return ArrayIterator
164171
*/
172+
#[\ReturnTypeWillChange]
165173
public function getIterator()
166174
{
167175
return new ArrayIterator($this->data);

Slim/Container.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function get($id)
111111
if ($this->exceptionThrownByContainer($exception)) {
112112
throw new SlimContainerException(
113113
sprintf('Container error while retrieving "%s"', $id),
114-
null,
114+
0,
115115
$exception
116116
);
117117
} else {

Slim/DeferredCallable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class DeferredCallable
2828
* @param callable|string $callable
2929
* @param ContainerInterface $container
3030
*/
31-
public function __construct($callable, ContainerInterface $container = null)
31+
public function __construct($callable, ?ContainerInterface $container = null)
3232
{
3333
$this->callable = $callable;
3434
$this->container = $container;

Slim/Handlers/AbstractHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ abstract class AbstractHandler
3636
*/
3737
protected function determineContentType(ServerRequestInterface $request)
3838
{
39-
$acceptHeader = $request->getHeaderLine('Accept');
39+
$acceptHeader = (string)$request->getHeaderLine('Accept');
4040
$selectedContentTypes = array_intersect(explode(',', $acceptHeader), $this->knownContentTypes);
4141

4242
if (count($selectedContentTypes)) {

Slim/Http/Request.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
* @link https://github.com/php-fig/http-message/blob/master/src/MessageInterface.php
2626
* @link https://github.com/php-fig/http-message/blob/master/src/RequestInterface.php
2727
* @link https://github.com/php-fig/http-message/blob/master/src/ServerRequestInterface.php
28+
*
29+
* @phpstan-consistent-constructor
2830
*/
2931
class Request extends Message implements ServerRequestInterface
3032
{
@@ -490,7 +492,7 @@ public function getRequestTarget()
490492
} else {
491493
$basePath = '';
492494
}
493-
$path = $this->uri->getPath();
495+
$path = (string)$this->uri->getPath();
494496
$path = $basePath . '/' . ltrim($path, '/');
495497

496498
$query = $this->uri->getQuery();
@@ -1011,7 +1013,7 @@ public function getParsedBody()
10111013
return null;
10121014
}
10131015

1014-
$mediaType = $this->getMediaType();
1016+
$mediaType = (string)$this->getMediaType();
10151017

10161018
// Check if this specific media type has a parser registered first
10171019
if (!isset($this->bodyParsers[$mediaType])) {
@@ -1188,7 +1190,7 @@ public function getQueryParam($key, $default = null)
11881190
*
11891191
* @return mixed[]
11901192
*/
1191-
public function getParams(array $only = null)
1193+
public function getParams(?array $only = null)
11921194
{
11931195
$params = $this->getQueryParams();
11941196
$postParams = $this->getParsedBody();

0 commit comments

Comments
 (0)