Skip to content

Commit 95329cb

Browse files
Upgrade dependencies to support PHP 8.4 (#22)
1 parent 04b1d05 commit 95329cb

18 files changed

Lines changed: 255 additions & 266 deletions

.github/workflows/ci.yml

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,40 @@ name: CI
33
on: [push, pull_request]
44

55
jobs:
6-
build-test:
7-
runs-on: ubuntu-latest
8-
strategy:
9-
matrix:
10-
php_version: [8.0, 8.1, 8.2]
11-
composer_flags: ['', '--prefer-lowest']
12-
13-
steps:
14-
- uses: actions/checkout@v2
15-
16-
- name: Setup PHP
17-
uses: shivammathur/setup-php@v2
18-
with:
19-
php-version: ${{ matrix.php_version }}
20-
extensions: xdebug
21-
22-
- uses: php-actions/composer@v5
23-
with:
24-
php_version: ${{ matrix.php_version }}
25-
args: ${{ matrix.composer_flags }}
26-
command: update
27-
28-
- name: Run tests
29-
run: ./vendor/bin/phpunit --coverage-clover ./tests/logs/clover.xml
30-
env:
31-
XDEBUG_MODE: coverage
32-
33-
# - name: Submit coverage to Coveralls
34-
# # We use php-coveralls library for this, as the official Coveralls GitHub Action lacks support for clover reports:
35-
# # https://github.com/coverallsapp/github-action/issues/15
36-
# env:
37-
# COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38-
# COVERALLS_PARALLEL: true
39-
# COVERALLS_FLAG_NAME: ${{ github.job }}-PHP-${{ matrix.php_version }} ${{ matrix.composer_flags }}
40-
# run: |
41-
# composer global require php-coveralls/php-coveralls
42-
# ~/.composer/vendor/bin/php-coveralls -v
43-
6+
build-test:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
php_version: [8.1, 8.2, 8.3, 8.4]
11+
composer_flags: ["", "--prefer-lowest"]
12+
13+
steps:
14+
- uses: actions/checkout@v2
15+
16+
- name: Setup PHP
17+
uses: shivammathur/setup-php@v2
18+
with:
19+
php-version: ${{ matrix.php_version }}
20+
extensions: xdebug
21+
22+
- uses: php-actions/composer@v5
23+
with:
24+
php_version: ${{ matrix.php_version }}
25+
args: ${{ matrix.composer_flags }}
26+
command: update
27+
28+
- name: Run tests
29+
run: ./vendor/bin/phpunit --coverage-clover ./tests/logs/clover.xml
30+
env:
31+
XDEBUG_MODE: coverage
32+
33+
# - name: Submit coverage to Coveralls
34+
# # We use php-coveralls library for this, as the official Coveralls GitHub Action lacks support for clover reports:
35+
# # https://github.com/coverallsapp/github-action/issues/15
36+
# env:
37+
# COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
# COVERALLS_PARALLEL: true
39+
# COVERALLS_FLAG_NAME: ${{ github.job }}-PHP-${{ matrix.php_version }} ${{ matrix.composer_flags }}
40+
# run: |
41+
# composer global require php-coveralls/php-coveralls
42+
# ~/.composer/vendor/bin/php-coveralls -v

composer.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@
1616
}
1717
],
1818
"require": {
19-
"php": "^7.3||^8.0",
20-
"altorouter/altorouter": "^2.0.2",
21-
"mindplay/middleman": "^3.0.3",
22-
"php-di/invoker": "^2.3.0",
23-
"psr/container": "^1.0",
24-
"psr/http-message": "^1.0",
19+
"php": ">=8.1",
20+
"altorouter/altorouter": "^2.0.3",
21+
"laminas/laminas-diactoros": "^3.6.0",
22+
"mindplay/middleman": "^4.0.4",
23+
"php-di/invoker": "^2.3.6",
24+
"psr/container": "^2.0.2",
25+
"psr/http-message": "^2.0",
2526
"psr/http-server-middleware": "^1.0",
26-
"spatie/macroable": "^1.0",
27-
"laminas/laminas-diactoros": "^2.4"
27+
"spatie/macroable": "^1.0"
2828
},
2929
"require-dev": {
30-
"php-di/php-di": "^6.3.4",
31-
"phpunit/phpunit": "^9.5",
32-
"php-coveralls/php-coveralls": "^2.4",
3330
"mockery/mockery": "^1.4.3",
31+
"php-coveralls/php-coveralls": "^2.4",
32+
"php-di/php-di": "^7.1.1",
33+
"phpunit/phpunit": "^10.5",
3434
"squizlabs/php_codesniffer": "^3.6.0"
3535
},
3636
"autoload": {
@@ -49,4 +49,4 @@
4949
"config": {
5050
"sort-packages": true
5151
}
52-
}
52+
}

phpunit.xml

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit bootstrap="vendor/autoload.php"
3-
backupGlobals="false"
4-
backupStaticAttributes="false"
5-
colors="true"
6-
verbose="true"
7-
convertErrorsToExceptions="true"
8-
convertNoticesToExceptions="true"
9-
convertWarningsToExceptions="true"
10-
processIsolation="false"
11-
stopOnFailure="false">
12-
<testsuites>
13-
<testsuite name="Rareloop Router Test Suite">
14-
<directory>tests</directory>
15-
</testsuite>
16-
</testsuites>
17-
<filter>
18-
<whitelist>
19-
<directory suffix=".php">src/</directory>
20-
</whitelist>
21-
</filter>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.3/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
3+
<testsuites>
4+
<testsuite name="Rareloop Router Test Suite">
5+
<directory>tests</directory>
6+
</testsuite>
7+
</testsuites>
8+
<source>
9+
<include>
10+
<directory suffix=".php">src/</directory>
11+
</include>
12+
</source>
2213
</phpunit>

src/Route.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ public function __construct(
3535
array $methods,
3636
string $uri,
3737
$action,
38-
Invoker $invoker = null,
39-
MiddlewareResolver $resolver = null
38+
?Invoker $invoker = null,
39+
?MiddlewareResolver $resolver = null
4040
) {
4141
$this->invoker = $invoker;
4242
$this->middlewareResolver = $resolver;
@@ -77,7 +77,7 @@ public function handle(ServerRequest $request, RouteParams $params): ResponseInt
7777
return $this->middlewareResolver->resolve($name);
7878
});
7979

80-
return $dispatcher->dispatch($request);
80+
return $dispatcher->handle($request);
8181
}
8282

8383
private function gatherMiddleware(): array

src/RouteAction.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class RouteAction
2929
* @param mixed $action
3030
* @param Rareloop/Router/Invoker $invoker
3131
*/
32-
public function __construct($action, Invoker $invoker = null)
32+
public function __construct($action, ?Invoker $invoker = null)
3333
{
3434
$this->invoker = $invoker;
3535
$this->callable = $this->createCallableFromAction($action);
@@ -65,7 +65,7 @@ public function invoke(ServerRequestInterface $request, RouteParams $params)
6565
* @param mixed $action
6666
* @return callable
6767
*/
68-
private function createCallableFromAction($action) : callable
68+
private function createCallableFromAction($action): callable
6969
{
7070
// Check if this looks like it could be a class/method string
7171
if (!is_callable($action) && is_string($action)) {
@@ -80,7 +80,7 @@ private function createCallableFromAction($action) : callable
8080
*
8181
* @return boolean
8282
*/
83-
private function isControllerAction() : bool
83+
private function isControllerAction(): bool
8484
{
8585
return !empty($this->controllerName) && !empty($this->controllerMethod);
8686
}
@@ -127,7 +127,7 @@ private function createControllerFromClassName($className)
127127
*
128128
* @return bool
129129
*/
130-
private function providesMiddleware() : bool
130+
private function providesMiddleware(): bool
131131
{
132132
$controller = $this->getController();
133133

@@ -143,7 +143,7 @@ private function providesMiddleware() : bool
143143
*
144144
* @return array
145145
*/
146-
public function getMiddleware() : array
146+
public function getMiddleware(): array
147147
{
148148
if (!$this->providesMiddleware()) {
149149
return [];
@@ -170,7 +170,7 @@ function ($controllerMiddleware) {
170170
* @param string $string e.g. `MyController@myMethod`
171171
* @return Closure
172172
*/
173-
private function convertClassStringToFactory($string) : Closure
173+
private function convertClassStringToFactory($string): Closure
174174
{
175175
$this->controllerName = null;
176176
$this->controllerMethod = null;

src/Router.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Router implements Routable
3636
private $invoker = null;
3737
private $baseMiddleware = [];
3838

39-
public function __construct(ContainerInterface $container = null, MiddlewareResolver $resolver = null)
39+
public function __construct(?ContainerInterface $container = null, ?MiddlewareResolver $resolver = null)
4040
{
4141
if (isset($container)) {
4242
$this->setContainer($container);
@@ -194,7 +194,7 @@ function ($request) use ($route, $params) {
194194
return $this->middlewareResolver->resolve($name);
195195
});
196196

197-
return $dispatcher->dispatch($request);
197+
return $dispatcher->handle($request);
198198
}
199199

200200
public function has(string $name)

tests/ControllerMiddlewareOptionsTest.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44

55
use PHPUnit\Framework\TestCase;
66
use Rareloop\Router\ControllerMiddlewareOptions;
7+
use PHPUnit\Framework\Attributes\Test;
78

89
class ControllerMiddlewareOptionsTest extends TestCase
910
{
10-
/** @test */
11+
#[Test]
1112
public function by_default_no_methods_are_excluded()
1213
{
1314
$options = new ControllerMiddlewareOptions;
@@ -16,15 +17,15 @@ public function by_default_no_methods_are_excluded()
1617
$this->assertFalse($options->excludedForMethod('bar'));
1718
}
1819

19-
/** @test */
20+
#[Test]
2021
public function only_is_chainable()
2122
{
2223
$options = new ControllerMiddlewareOptions;
2324

2425
$this->assertSame($options, $options->only('foo'));
2526
}
2627

27-
/** @test */
28+
#[Test]
2829
public function can_use_only_to_limit_methods()
2930
{
3031
$options = new ControllerMiddlewareOptions;
@@ -35,7 +36,7 @@ public function can_use_only_to_limit_methods()
3536
$this->assertTrue($options->excludedForMethod('bar'));
3637
}
3738

38-
/** @test */
39+
#[Test]
3940
public function can_use_only_to_limit_multiple_methods()
4041
{
4142
$options = new ControllerMiddlewareOptions;
@@ -47,15 +48,15 @@ public function can_use_only_to_limit_multiple_methods()
4748
$this->assertTrue($options->excludedForMethod('baz'));
4849
}
4950

50-
/** @test */
51+
#[Test]
5152
public function except_is_chainable()
5253
{
5354
$options = new ControllerMiddlewareOptions;
5455

5556
$this->assertSame($options, $options->except('foo'));
5657
}
5758

58-
/** @test */
59+
#[Test]
5960
public function can_use_except_to_limit_methods()
6061
{
6162
$options = new ControllerMiddlewareOptions;
@@ -66,7 +67,7 @@ public function can_use_except_to_limit_methods()
6667
$this->assertFalse($options->excludedForMethod('bar'));
6768
}
6869

69-
/** @test */
70+
#[Test]
7071
public function can_use_except_to_limit_multiple_methods()
7172
{
7273
$options = new ControllerMiddlewareOptions;

tests/ControllerMiddlewareTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
use Rareloop\Router\ControllerMiddleware;
77
use Rareloop\Router\ControllerMiddlewareOptions;
88
use Rareloop\Router\Test\Middleware\AddHeaderMiddleware;
9+
use PHPUnit\Framework\Attributes\Test;
910

1011
class ControllerMiddlewareTest extends TestCase
1112
{
12-
/** @test */
13+
#[Test]
1314
public function can_retrieve_middleware()
1415
{
1516
$middleware = new AddHeaderMiddleware('X-Header', 'testing123');
@@ -20,7 +21,7 @@ public function can_retrieve_middleware()
2021
$this->assertSame($middleware, $controllerMiddleware->middleware());
2122
}
2223

23-
/** @test */
24+
#[Test]
2425
public function can_retrieve_options()
2526
{
2627
$middleware = new AddHeaderMiddleware('X-Header', 'testing123');

0 commit comments

Comments
 (0)