Skip to content

Commit 71b139e

Browse files
committed
Merge branch '1.x' into bug/cache-hit-still-sends-body
2 parents 5693234 + f608f39 commit 71b139e

File tree

6 files changed

+45
-36
lines changed

6 files changed

+45
-36
lines changed

.github/workflows/tests.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Tests
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
tests:
7+
name: Tests PHP ${{ matrix.php }}
8+
runs-on: ubuntu-latest
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
php: [7.4, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5]
13+
include:
14+
- php: 8.4
15+
analysis: true
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Set up PHP ${{ matrix.php }}
22+
uses: shivammathur/setup-php@v2
23+
with:
24+
php-version: ${{ matrix.php }}
25+
coverage: xdebug
26+
27+
- name: Install dependencies
28+
run: composer install --prefer-dist --no-progress
29+
30+
- name: Coding standards
31+
if: matrix.analysis
32+
run: vendor/bin/phpcs
33+
34+
- name: Tests
35+
run: vendor/bin/phpunit --coverage-clover clover.xml
36+

.travis.yml

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

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Slim Framework HTTP Cache
22

3-
[![Build Status](https://travis-ci.com/slimphp/Slim-HttpCache.svg?branch=1.x)](https://travis-ci.com/slimphp/Slim-HttpCache)
3+
[![Build Status](https://github.com/slimphp/Slim-HttpCache/actions/workflows/tests.yml/badge.svg?branch=1.x)](https://github.com/slimphp/Slim-HttpCache/actions)
44
[![Coverage Status](https://coveralls.io/repos/github/slimphp/Slim-HttpCache/badge.svg?branch=1.x)](https://coveralls.io/github/slimphp/Slim-HttpCache?branch=1.x)
5-
[![Latest Stable Version](https://poser.pugx.org/slim/http-cache/v)](//packagist.org/packages/slim/http-cache)
5+
[![Latest Stable Version](https://poser.pugx.org/slim/http-cache/v)](https://packagist.org/packages/slim/http-cache)
66
[![License](https://poser.pugx.org/slim/http-cache/license)](https://packagist.org/packages/slim/http-cache)
77

88
This repository contains a Slim Framework HTTP cache middleware and service provider.
@@ -11,7 +11,7 @@ This repository contains a Slim Framework HTTP cache middleware and service prov
1111

1212
Via Composer
1313

14-
``` bash
14+
```bash
1515
$ composer require slim/http-cache
1616
```
1717

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
],
2020
"require": {
2121
"php": "^7.2 || ^8.0",
22-
"psr/http-message": "^1.0",
22+
"psr/http-message": "^1.1 || ^2.0",
2323
"psr/http-server-middleware": "^1.0"
2424
},
2525
"require-dev": {

src/CacheProvider.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use function gmdate;
1616
use function in_array;
1717
use function is_integer;
18-
use function is_null;
1918
use function strtotime;
2019
use function time;
2120

@@ -43,7 +42,7 @@ public function allowCache(
4342
}
4443
$headerValue = $type;
4544
if ($maxAge || is_integer($maxAge)) {
46-
if (!is_integer($maxAge) && !is_null($maxAge)) {
45+
if (!is_integer($maxAge) && $maxAge !== null) {
4746
$maxAge = strtotime($maxAge) - time();
4847
}
4948
$headerValue = $headerValue.', max-age='.$maxAge;

tests/CacheTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ protected function createResponse(): ResponseInterface
5050
*
5151
* @return RequestHandlerInterface
5252
*/
53-
protected function createRequestHandler(ResponseInterface $response = null): RequestHandlerInterface
53+
protected function createRequestHandler(?ResponseInterface $response): RequestHandlerInterface
5454
{
5555
$response = $response ?? $this->createResponse();
5656

@@ -74,7 +74,7 @@ public function testCacheControlHeader()
7474
$cache = $this->createCache('public', 86400);
7575
$req = $this->requestFactory();
7676

77-
$res = $cache->process($req, $this->createRequestHandler());
77+
$res = $cache->process($req, $this->createRequestHandler(null));
7878

7979
$cacheControl = $res->getHeaderLine('Cache-Control');
8080

@@ -86,7 +86,7 @@ public function testCacheControlHeaderWithMustRevalidate()
8686
$cache = $this->createCache('private', 86400, true);
8787
$req = $this->requestFactory();
8888

89-
$res = $cache->process($req, $this->createRequestHandler());
89+
$res = $cache->process($req, $this->createRequestHandler(null));
9090

9191
$cacheControl = $res->getHeaderLine('Cache-Control');
9292

@@ -98,7 +98,7 @@ public function testCacheControlHeaderWithZeroMaxAge()
9898
$cache = $this->createCache('private', 0, false);
9999
$req = $this->requestFactory();
100100

101-
$res = $cache->process($req, $this->createRequestHandler());
101+
$res = $cache->process($req, $this->createRequestHandler(null));
102102

103103
$cacheControl = $res->getHeaderLine('Cache-Control');
104104

0 commit comments

Comments
 (0)