Skip to content

Commit 7265d04

Browse files
committed
Upgraded codebase to php 8.4
2 parents a0cb5f8 + 32013e4 commit 7265d04

30 files changed

+149
-107
lines changed

.github/workflows/build.yml

Lines changed: 70 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ name: build
22
on: [push, pull_request]
33

44
jobs:
5-
full-build:
6-
name: "Coding standards & coverage tests"
5+
quality-check:
6+
name: "Coding standards & test coverage"
77
runs-on: ${{ matrix.operating-system }}
88
strategy:
99
matrix:
1010
operating-system: ['ubuntu-latest']
1111
php-versions: ['7.4']
1212
env:
1313
extensions: pcov, dom, json, libxml, mbstring, pdo_sqlite, soap, xml, xmlwriter
14-
key: cache-v2
14+
key: cache-v3
1515
steps:
1616
- name: "Checkout"
17-
uses: actions/checkout@v2
17+
uses: actions/checkout@v3
1818
- name: "Setup PHP extensions cache environment"
1919
id: cache-env
2020
uses: shivammathur/cache-extensions@v1
@@ -23,7 +23,7 @@ jobs:
2323
extensions: ${{ env.extensions }}
2424
key: ${{ env.key }}
2525
- name: "Cache PHP extensions"
26-
uses: actions/cache@v2
26+
uses: actions/cache@v3
2727
with:
2828
path: ${{ steps.cache-env.outputs.dir }}
2929
key: ${{ steps.cache-env.outputs.key }}
@@ -35,49 +35,88 @@ jobs:
3535
coverage: pcov
3636
extensions: ${{ env.extensions }}
3737
ini-values: assert.exception=1, zend.assertions=1
38-
- name: "Validate composer.json"
39-
run: composer validate
40-
- name: "Setup composer cache"
41-
uses: actions/cache@v2
38+
- name: "Install Composer dependencies"
39+
uses: ramsey/composer-install@v2
4240
with:
43-
path: ~/.composer/cache
44-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
45-
restore-keys: ${{ runner.os }}-composer-
46-
- name: "Install highest dependencies"
47-
run: composer update --no-interaction --no-ansi --no-progress --no-suggest --prefer-stable
41+
dependency-versions: highest
42+
composer-options: --prefer-stable
43+
custom-cache-key: composer-${{ runner.os }}-php${{ matrix.php-versions }}-${{ hashFiles('**/composer.json') }}
4844
- name: "Coding standard Php-CS-Fixer checks"
4945
run: vendor/bin/php-cs-fixer --dry-run -v --config=cs-fixer.php.dist --path-mode=intersection fix src tests
5046
- name: "Coding standard CodeSniffer checks"
5147
run: |
52-
vendor/bin/phpcs --extensions=php --standard=vendor/polymorphine/dev/phpcs.xml src
53-
vendor/bin/phpcs --extensions=php --standard=vendor/polymorphine/dev/phpcs.xml --ignore=*/code-samples/* tests
48+
vendor/bin/phpcs --extensions=php --standard=vendor/polymorphine/dev/phpcs.xml --colors src
49+
vendor/bin/phpcs --extensions=php --standard=vendor/polymorphine/dev/phpcs.xml --colors --ignore=*/code-samples/* tests
5450
- name: "Package skeleton validation"
5551
run: vendor/bin/polymorphine-skeleton check
5652
- name: "Run PhpUnit tests with coverage"
5753
run: |
58-
mkdir -p build/logs
59-
vendor/bin/phpunit --coverage-clover build/logs/clover.xml
54+
mkdir -p .dev/logs
55+
vendor/bin/phpunit --coverage-clover .dev/logs/clover.xml
6056
- name: "Send coverage report to coveralls.io"
61-
run: vendor/bin/php-coveralls -v
57+
run: |
58+
composer require php-coveralls/php-coveralls
59+
vendor/bin/php-coveralls -v -o .dev/logs/coveralls-upload.json -x .dev/logs/clover.xml
6260
env:
63-
COVERALLS_RUN_LOCALLY: 1
6461
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
6562

66-
php-os-builds:
67-
name: "PHP 8 tests"
63+
platform-compatibility:
64+
name: "Operating systems"
6865
runs-on: ${{ matrix.operating-system }}
6966
strategy:
7067
matrix:
7168
operating-system: ['ubuntu-latest', 'windows-latest', 'macos-latest']
72-
php-versions: ['8.0', '8.1']
69+
php-versions: ['8.4']
7370
env:
7471
extensions: dom, json, libxml, mbstring, pdo_sqlite, soap, xml, xmlwriter
75-
key: cache-v2
72+
key: cache-v3
7673
steps:
7774
- name: "Turn off git EOL conversion"
7875
run: git config --global core.autocrlf false
7976
- name: "Checkout"
80-
uses: actions/checkout@v2
77+
uses: actions/checkout@v3
78+
- name: "Setup PHP extensions cache environment"
79+
id: cache-env
80+
uses: shivammathur/cache-extensions@v1
81+
with:
82+
php-version: ${{ matrix.php-versions }}
83+
extensions: ${{ env.extensions }}
84+
key: ${{ env.key }}
85+
- name: "Cache PHP extensions"
86+
uses: actions/cache@v3
87+
with:
88+
path: ${{ steps.cache-env.outputs.dir }}
89+
key: ${{ steps.cache-env.outputs.key }}
90+
restore-keys: ${{ steps.cache-env.outputs.key }}
91+
- name: "Install PHP with extensions"
92+
uses: shivammathur/setup-php@v2
93+
with:
94+
php-version: ${{ matrix.php-versions }}
95+
coverage: none
96+
extensions: ${{ env.extensions }}
97+
ini-values: assert.exception=1, zend.assertions=1
98+
- name: "Install Composer dependencies"
99+
uses: ramsey/composer-install@v2
100+
with:
101+
dependency-versions: highest
102+
composer-options: --prefer-stable
103+
custom-cache-key: composer-${{ runner.os }}-php${{ matrix.php-versions }}-${{ hashFiles('**/composer.json') }}
104+
- name: "Run PhpUnit tests (no coverage)"
105+
run: vendor/bin/phpunit --no-coverage
106+
107+
php-versions:
108+
name: "PHP versions"
109+
runs-on: ${{ matrix.operating-system }}
110+
strategy:
111+
matrix:
112+
operating-system: ['ubuntu-latest']
113+
php-versions: ['8.0', '8.1', '8.2', '8.3']
114+
env:
115+
extensions: dom, json, libxml, mbstring, pdo_sqlite, soap, xml, xmlwriter
116+
key: cache-v3
117+
steps:
118+
- name: "Checkout"
119+
uses: actions/checkout@v3
81120
- name: "Setup PHP extensions cache environment"
82121
id: cache-env
83122
uses: shivammathur/cache-extensions@v1
@@ -86,7 +125,7 @@ jobs:
86125
extensions: ${{ env.extensions }}
87126
key: ${{ env.key }}
88127
- name: "Cache PHP extensions"
89-
uses: actions/cache@v2
128+
uses: actions/cache@v3
90129
with:
91130
path: ${{ steps.cache-env.outputs.dir }}
92131
key: ${{ steps.cache-env.outputs.key }}
@@ -98,13 +137,11 @@ jobs:
98137
coverage: none
99138
extensions: ${{ env.extensions }}
100139
ini-values: assert.exception=1, zend.assertions=1
101-
- name: "Setup composer cache"
102-
uses: actions/cache@v2
140+
- name: "Install Composer dependencies"
141+
uses: ramsey/composer-install@v2
103142
with:
104-
path: ~/.composer/cache
105-
key: ${{ runner.os }}-php${{ matrix.php-versions }}-composer-${{ hashFiles('**/composer.json') }}
106-
restore-keys: ${{ runner.os }}-php${{ matrix.php-versions }}-composer-
107-
- name: "Install highest dependencies"
108-
run: composer update --no-interaction --no-ansi --no-progress --no-suggest --prefer-stable
143+
dependency-versions: highest
144+
composer-options: --prefer-stable
145+
custom-cache-key: composer-${{ runner.os }}-php${{ matrix.php-versions }}-${{ hashFiles('**/composer.json') }}
109146
- name: "Run PhpUnit tests (no coverage)"
110147
run: vendor/bin/phpunit --no-coverage

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
"prefer-stable": true,
1414
"require": {
1515
"php": "^7.4 || ^8.0",
16-
"psr/http-message": "^1.0",
17-
"psr/http-factory": "^1.0",
16+
"psr/http-message": "^1.1",
17+
"psr/http-factory": "^1.1",
1818
"psr/http-server-middleware": "^1.0",
19-
"psr/container": "^1.0"
19+
"psr/container": "^1.1"
2020
},
2121
"require-dev": {
22-
"polymorphine/dev": "0.2.*"
22+
"polymorphine/dev": "0.5.*"
2323
},
2424
"autoload": {
2525
"psr-4": {
@@ -34,8 +34,8 @@
3434
"scripts": {
3535
"test-cs": [
3636
"php-cs-fixer --dry-run -v --config=cs-fixer.php.dist --path-mode=intersection fix src tests",
37-
"phpcs --extensions=php --standard=vendor/polymorphine/dev/phpcs.xml src",
38-
"phpcs --extensions=php --standard=vendor/polymorphine/dev/phpcs.xml --ignore=*/code-samples/* tests"
37+
"phpcs --extensions=php --standard=vendor/polymorphine/dev/phpcs.xml --colors src",
38+
"phpcs --extensions=php --standard=vendor/polymorphine/dev/phpcs.xml --colors --ignore=*/code-samples/* tests"
3939
],
4040
"test-php": "phpunit",
4141
"test-skeleton": "polymorphine-skeleton check"

cs-fixer.php.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111

1212
use Polymorphine\Dev\FixerFactory;
1313

14-
return FixerFactory::createFor('Polymorphine/Routing', __DIR__);
14+
return FixerFactory::createFor(__FILE__);

phpunit.xml.dist

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
<phpunit
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
5-
cacheResultFile=".dev/temp/.phpunit.result.cache"
5+
cacheResultFile=".dev/cache/.phpunit.result.cache"
66
colors="true"
77
bootstrap="vendor/autoload.php"
88
>
99
<php>
1010
<ini name="error_reporting" value="-1" />
11+
<env name="DEV_TESTS_DIRECTORY" value=".dev/tests" force="true" />
1112
</php>
1213
<testsuites>
1314
<testsuite name="Polymorphine/Routing tests">

src/Builder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Builder
3939
*
4040
* @param MappedRoutes|null $mappedRoutes
4141
*/
42-
public function __construct(MappedRoutes $mappedRoutes = null)
42+
public function __construct(?MappedRoutes $mappedRoutes = null)
4343
{
4444
$routerCallback = fn () => $this->router;
4545
if ($mappedRoutes && !$mappedRoutes->hasRouterCallback()) {

src/Builder/EndpointRouteBuilder.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function __construct(Context $context)
3838
/**
3939
* Creates CallbackEndpoint with given callback.
4040
*
41-
* @see \Polymorphine\Routing\Route\Endpoint\CallbackEndpoint
41+
* @see Route\Endpoint\CallbackEndpoint
4242
*
4343
* @param callable $callback fn(ServerRequestInterface) => ResponseInterface
4444
*
@@ -53,7 +53,7 @@ public function callback(callable $callback): Route
5353
/**
5454
* Creates HandlerEndpoint with given handler.
5555
*
56-
* @see \Polymorphine\Routing\Route\Endpoint\HandlerEndpoint
56+
* @see Route\Endpoint\HandlerEndpoint
5757
*
5858
* @param RequestHandlerInterface $handler
5959
*
@@ -69,7 +69,7 @@ public function handler(RequestHandlerInterface $handler): Route
6969
* Creates LazyRoute gate that invokes routes with given
7070
* callback on forward request call.
7171
*
72-
* @see \Polymorphine\Routing\Route\Gate\LazyRoute
72+
* @see Route\Gate\LazyRoute
7373
*
7474
* @param callable $routeCallback fn() => Route
7575
*
@@ -89,8 +89,8 @@ public function lazy(callable $routeCallback): Route
8989
* needs to be able to provide Router callback that this endpoint
9090
* depends on - otherwise ConfigException will be thrown.
9191
*
92-
* @see \Polymorphine\Routing\Route\Endpoint\RedirectEndpoint
93-
* @see \Polymorphine\Routing\Builder\MappedRoutes::redirect()
92+
* @see Route\Endpoint\RedirectEndpoint
93+
* @see MappedRoutes::redirect()
9494
*
9595
* @param string $routingPath
9696
* @param int $code
@@ -112,7 +112,7 @@ public function redirect(string $routingPath, int $code = 301): Route
112112
* MappedRoutes has to be defined or ConfigException will
113113
* be thrown.
114114
*
115-
* @see \Polymorphine\Routing\Builder\MappedRoutes::endpoint()
115+
* @see MappedRoutes::endpoint()
116116
*
117117
* @param string $id
118118
*

src/Builder/Node/CallbackSwitchNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
/**
2121
* Builder Node creating and configuring CallbackSwitch route splitter.
2222
*
23-
* @see \Polymorphine\Routing\Route\Splitter\CallbackSwitch
23+
* @see Route\Splitter\CallbackSwitch
2424
*/
2525
class CallbackSwitchNode implements Node
2626
{

src/Builder/Node/GateBuildMethods.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function wrapRouteCallback(callable $routeWrapper): self
4444
*
4545
* @return static
4646
*/
47-
public function method(string $methods, Pattern $pattern = null): self
47+
public function method(string $methods, ?Pattern $pattern = null): self
4848
{
4949
if (isset($pattern)) { $this->pattern($pattern); }
5050
$this->context->addGate(function (Route $route) use ($methods) {
@@ -158,7 +158,7 @@ public function link(&$routeReference): self
158158
*
159159
* @return static
160160
*/
161-
public function get(Pattern $pattern = null): self
161+
public function get(?Pattern $pattern = null): self
162162
{
163163
return $this->method('GET', $pattern);
164164
}
@@ -168,7 +168,7 @@ public function get(Pattern $pattern = null): self
168168
*
169169
* @return static
170170
*/
171-
public function post(Pattern $pattern = null): self
171+
public function post(?Pattern $pattern = null): self
172172
{
173173
return $this->method('POST', $pattern);
174174
}
@@ -178,7 +178,7 @@ public function post(Pattern $pattern = null): self
178178
*
179179
* @return static
180180
*/
181-
public function put(Pattern $pattern = null): self
181+
public function put(?Pattern $pattern = null): self
182182
{
183183
return $this->method('PUT', $pattern);
184184
}
@@ -188,7 +188,7 @@ public function put(Pattern $pattern = null): self
188188
*
189189
* @return static
190190
*/
191-
public function patch(Pattern $pattern = null): self
191+
public function patch(?Pattern $pattern = null): self
192192
{
193193
return $this->method('PATCH', $pattern);
194194
}
@@ -198,7 +198,7 @@ public function patch(Pattern $pattern = null): self
198198
*
199199
* @return static
200200
*/
201-
public function delete(Pattern $pattern = null): self
201+
public function delete(?Pattern $pattern = null): self
202202
{
203203
return $this->method('DELETE', $pattern);
204204
}
@@ -208,7 +208,7 @@ public function delete(Pattern $pattern = null): self
208208
*
209209
* @return static
210210
*/
211-
public function head(Pattern $pattern = null): self
211+
public function head(?Pattern $pattern = null): self
212212
{
213213
return $this->method('HEAD', $pattern);
214214
}
@@ -218,7 +218,7 @@ public function head(Pattern $pattern = null): self
218218
*
219219
* @return static
220220
*/
221-
public function options(Pattern $pattern = null): self
221+
public function options(?Pattern $pattern = null): self
222222
{
223223
return $this->method('OPTIONS', $pattern);
224224
}

src/Builder/Node/MethodSwitchNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* Builder Node creating and configuring MethodSwitch splitter route.
2222
* MethodSwitch route manages automatic OPTIONS resolving.
2323
*
24-
* @see \Polymorphine\Routing\Route\Splitter\MethodSwitch
24+
* @see Route\Splitter\MethodSwitch
2525
*/
2626
class MethodSwitchNode implements Node
2727
{

src/Builder/Node/PathSwitchNode.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
/**
2424
* Builder Node creating and configuring PathSwitch splitter route.
2525
*
26-
* @see \Polymorphine\Routing\Route\Splitter\PathSwitch
26+
* @see Route\Splitter\PathSwitch
2727
*/
2828
class PathSwitchNode implements Node
2929
{
@@ -66,7 +66,7 @@ public function route(string $name): RouteNode
6666
* @param string $name
6767
* @param array $routes
6868
*
69-
* @return Resource\ResourceSwitchNode
69+
* @return ResourceSwitchNode
7070
*/
7171
public function resource(string $name, array $routes = []): ResourceSwitchNode
7272
{
@@ -99,11 +99,10 @@ public function withResourcesFormsPath(string $name): self
9999
}
100100

101101
/**
102-
* Creates builder context for route which URI path ends in
102+
* Creates builder root route context for which URI path ends in
103103
* PathSwitch splitter with no continued path resolution.
104104
*
105-
* @see \Polymorphine\Routing\Route\Splitter\PathSwitch constructor
106-
* description for more information on root route.
105+
* @see Route\Splitter\PathSwitch::__construct()
107106
*
108107
* @return RouteNode
109108
*/

0 commit comments

Comments
 (0)