Skip to content

Commit 50ba091

Browse files
committed
Merge branch 'php-8.1'
Closes #33
2 parents 90c38ef + b935f5d commit 50ba091

File tree

5 files changed

+26
-17
lines changed

5 files changed

+26
-17
lines changed

.github/workflows/unit-tests.yml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,12 @@ jobs:
1212

1313
strategy:
1414
matrix:
15-
dependencies:
16-
- "lowest"
17-
- "highest"
1815
php-version:
1916
- "7.2"
2017
- "7.3"
2118
- "7.4"
2219
- "8.0"
20+
- "8.1"
2321
operating-system:
2422
- "ubuntu-latest"
2523

@@ -43,15 +41,10 @@ jobs:
4341
path: |
4442
~/.composer/cache
4543
vendor
46-
key: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}"
47-
restore-keys: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}"
48-
49-
- name: "Install lowest dependencies"
50-
if: ${{ matrix.dependencies == 'lowest' }}
51-
run: "composer update --prefer-lowest --no-interaction --no-progress --no-suggest"
44+
key: "php-${{ matrix.php-version }}"
45+
restore-keys: "php-${{ matrix.php-version }}"
5246

5347
- name: "Install highest dependencies"
54-
if: ${{ matrix.dependencies == 'highest' }}
5548
run: "composer update --no-interaction --no-progress --no-suggest"
5649

5750
- name: "Tests"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
build
22
vendor
33
composer.lock
4+
.phpunit.result.cache

phpunit.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

33
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.7/phpunit.xsd"
4+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
55
backupGlobals="false"
66
backupStaticAttributes="false"
77
beStrictAboutTestsThatDoNotTestAnything="true"
@@ -20,9 +20,9 @@
2020
<directory>./tests/</directory>
2121
</testsuite>
2222
</testsuites>
23-
<filter>
24-
<whitelist processUncoveredFilesFromWhitelist="true">
23+
<coverage processUncoveredFiles="true">
24+
<include>
2525
<directory suffix=".php">./src</directory>
26-
</whitelist>
27-
</filter>
28-
</phpunit>
26+
</include>
27+
</coverage>
28+
</phpunit>

src/IpAddress.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public function __invoke(ServerRequestInterface $request, ResponseInterface $res
162162
*/
163163
protected function determineClientIpAddress($request)
164164
{
165-
$ipAddress = null;
165+
$ipAddress = '';
166166

167167
$serverParams = $request->getServerParams();
168168
if (isset($serverParams['REMOTE_ADDR'])) {
@@ -234,6 +234,10 @@ protected function determineClientIpAddress($request)
234234
}
235235
}
236236

237+
if (empty($ipAddress)) {
238+
$ipAddress = null;
239+
}
240+
237241
return $ipAddress;
238242
}
239243

tests/IpAddressTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,17 @@ public function testIpIsNullIfMissing()
128128
$this->assertNull($ipAddress);
129129
}
130130

131+
public function testIpIsNullIfMissingAndProxiesAreConfigured()
132+
{
133+
error_reporting(-1);
134+
$middleware = new IPAddress(true, ['*'], 'IP');
135+
$env = [];
136+
$ipAddress = $this->simpleRequest($middleware, $env, 'IP');
137+
138+
$this->assertSame(null, $ipAddress);
139+
}
140+
141+
131142
public function testXForwardedForIp()
132143
{
133144
$middleware = new IPAddress(true, []);

0 commit comments

Comments
 (0)