Skip to content

Commit 119ed8f

Browse files
authored
Merge pull request #261 from jeremykendall/feature/remove-php71-support
Feature/remove php71 support
2 parents f6a54a9 + 8247f98 commit 119ed8f

32 files changed

+621
-507
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ docs
77
build
88
.idea
99
.php_cs.cache
10+
.phpunit.result.cache

.travis.yml

Lines changed: 55 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,63 @@
11
language: php
2-
32
sudo: false
4-
53
cache:
6-
directories:
7-
- $HOME/.composer/cache
8-
9-
env:
10-
global:
11-
- COMPOSER_ARGS="--no-interaction --prefer-source --no-suggest"
12-
4+
directories:
5+
- "$HOME/.composer/cache"
136
matrix:
14-
include:
15-
- php: 7.0
16-
env:
17-
- VALIDATE_CODING_STYLE=false
18-
- RUN_PHPSTAN=false
19-
- IGNORE_PLATFORMS=false
20-
- php: 7.1
21-
env:
22-
- VALIDATE_CODING_STYLE=false
23-
- RUN_PHPSTAN=false
24-
- IGNORE_PLATFORMS=false
25-
- php: 7.2
26-
env:
27-
- VALIDATE_CODING_STYLE=true
28-
- RUN_PHPSTAN=true
29-
- IGNORE_PLATFORMS=false
30-
- php: 7.3
31-
env:
32-
- VALIDATE_CODING_STYLE=false
33-
- RUN_PHPSTAN=false
34-
- IGNORE_PLATFORMS=true
35-
- php: 7.4
36-
env:
37-
- COLLECT_COVERAGE=false
38-
- VALIDATE_CODING_STYLE=false
39-
- RUN_PHPSTAN=false
40-
- IGNORE_PLATFORMS=true
41-
- php: nightly
42-
env:
43-
- COLLECT_COVERAGE=false
44-
- IGNORE_PLATFORMS=true
45-
- RUN_PHPSTAN=false
46-
- VALIDATE_CODING_STYLE=false
47-
allow_failures:
48-
- php: nightly
49-
fast_finish: true
50-
7+
include:
8+
- php: 7.2
9+
env:
10+
- COLLECT_COVERAGE=false
11+
- COMPOSER_ARGS="--no-interaction --no-suggest --prefer-source --prefer-lowest --prefer-stable"
12+
- RUN_PHPSTAN=false
13+
- VALIDATE_CODING_STYLE=false
14+
- php: 7.2
15+
env:
16+
- COLLECT_COVERAGE=true
17+
- COMPOSER_ARGS="--no-interaction --no-suggest --prefer-source"
18+
- RUN_PHPSTAN=true
19+
- VALIDATE_CODING_STYLE=true
20+
- php: 7.3
21+
env:
22+
- COLLECT_COVERAGE=false
23+
- COMPOSER_ARGS="--no-interaction --no-suggest --prefer-source --prefer-lowest --prefer-stable"
24+
- RUN_PHPSTAN=false
25+
- VALIDATE_CODING_STYLE=false
26+
- php: 7.3
27+
env:
28+
- COLLECT_COVERAGE=true
29+
- COMPOSER_ARGS="--no-interaction --no-suggest --prefer-source"
30+
- RUN_PHPSTAN=true
31+
- VALIDATE_CODING_STYLE=true
32+
- php: 7.4
33+
env:
34+
- COLLECT_COVERAGE=false
35+
- COMPOSER_ARGS="--no-interaction --no-suggest --prefer-source --prefer-lowest --prefer-stable"
36+
- RUN_PHPSTAN=false
37+
- VALIDATE_CODING_STYLE=false
38+
- php: 7.4
39+
env:
40+
- COLLECT_COVERAGE=true
41+
- COMPOSER_ARGS="--no-interaction --no-suggest --prefer-source"
42+
- RUN_PHPSTAN=true
43+
- VALIDATE_CODING_STYLE=true
44+
- php: nightly
45+
env:
46+
- COLLECT_COVERAGE=false
47+
- COMPOSER_ARGS="--no-interaction --no-suggest --prefer-source --ignore-platform-reqs"
48+
- RUN_PHPSTAN=false
49+
- VALIDATE_CODING_STYLE=false
50+
allow_failures:
51+
- php: nightly
52+
fast_finish: true
5153
before_install:
52-
- travis_retry composer self-update
53-
54+
- travis_retry composer self-update
5455
install:
55-
- if [ "$IGNORE_PLATFORMS" == "true" ]; then travis_retry composer update $COMPOSER_ARGS --ignore-platform-reqs; fi
56-
- if [ "$IGNORE_PLATFORMS" == "false" ]; then travis_retry composer update $COMPOSER_ARGS; fi
57-
56+
- travis_retry composer update $COMPOSER_ARGS
5857
script:
59-
- if [ "$RUN_PHPSTAN" == "true" ]; then composer phpstan; fi
60-
- if [ "$VALIDATE_CODING_STYLE" == "true" ]; then composer phpcs; fi
61-
- composer phpunit
62-
58+
- if [ "$VALIDATE_CODING_STYLE" == "true" ]; then composer phpcs; fi
59+
- if [ "$RUN_PHPSTAN" == "true" ]; then composer phpstan; fi
60+
- composer phpunit
6361
after_script:
64-
- if [ "$COLLECT_COVERAGE" == "true" ]; then wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover build/clover.xml; fi
62+
- if [ "$COLLECT_COVERAGE" == "true" ]; then wget https://scrutinizer-ci.com/ocular.phar
63+
&& php ocular.phar code-coverage:upload --format=php-clover build/clover.xml; fi

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ System Requirements
2727

2828
You need:
2929

30-
- **PHP >= 7.0** but the latest stable version of PHP is recommended
30+
- **PHP >= 7.2.5** but the latest stable version of PHP is recommended
3131
- the `intl` extension
3232

3333
Dependencies

composer.json

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,30 +28,33 @@
2828
],
2929
"keywords": [
3030
"Public Suffix List",
31+
"Top Level Domains",
3132
"domain parsing",
3233
"icann",
34+
"iana",
3335
"idn",
36+
"tld",
3437
"psl"
3538
],
3639
"require": {
37-
"php": ">=7.0",
40+
"php": "^7.2.5",
3841
"ext-intl": "*",
3942
"psr/log": "^1.1",
4043
"psr/simple-cache": "^1.0.1"
4144
},
4245
"require-dev": {
4346
"composer/composer": "^1.6",
44-
"friendsofphp/php-cs-fixer": "^2.7",
45-
"mikey179/vfsstream": "^1.6",
46-
"phpstan/phpstan": "^0.9.2",
47-
"phpstan/phpstan-phpunit": "^0.9.4",
48-
"phpstan/phpstan-strict-rules": "^0.9.0",
49-
"phpunit/phpunit": "^6.3"
47+
"friendsofphp/php-cs-fixer": "^2.16",
48+
"mikey179/vfsstream": "^1.6.7",
49+
"phpstan/phpstan": "^0.12",
50+
"phpstan/phpstan-phpunit": "^0.12",
51+
"phpstan/phpstan-strict-rules": "^0.12",
52+
"phpunit/phpunit": "^8.0"
5053
},
5154
"suggest": {
5255
"psr/simple-cache-implementation": "To enable using other cache providers",
5356
"ext-curl": "To use the package http client",
54-
"league/uri-parser": "To parse URL and validate host"
57+
"league/uri": "To parse URL and validate host"
5558
},
5659
"autoload": {
5760
"psr-4": {

data/pdp-PSL_FULL_5a3cc7f81795bb2e48e848af42d287b4.cache

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

data/pdp-RZD_FULL_f18a70477d29d525b9220612e2115345.cache

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

phpstan.src.neon

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,17 @@
11
includes:
2-
- vendor/phpstan/phpstan-strict-rules/rules.neon
2+
- vendor/phpstan/phpstan-strict-rules/rules.neon
3+
parameters:
4+
checkMissingIterableValueType: false
5+
checkGenericClassInNonGenericObjectType: false
6+
ignoreErrors:
7+
- message: '#Call to function is_iterable\(\) with iterable will always evaluate to true.#'
8+
path: src/Cache.php
9+
- message: '#Call to function is_string\(\) with string will always evaluate to true.#'
10+
path: src/Cache.php
11+
- message: '#Call to function is_object\(\) with \*NEVER\* will always evaluate to true.#'
12+
path: src/Cache.php
13+
- message: '#Else branch is unreachable because ternary operator condition is always true.#'
14+
path: src/Cache.php
15+
- message: '#Property Pdp\\TopLevelDomains::\$modifiedDate \(DateTimeImmutable\) does not accept DateTimeInterface.#'
16+
path: src/TopLevelDomains.php
17+
reportUnmatchedIgnoredErrors: true

phpstan.tests.neon

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,24 @@ includes:
22
- vendor/phpstan/phpstan-strict-rules/rules.neon
33
- vendor/phpstan/phpstan-phpunit/extension.neon
44
- vendor/phpstan/phpstan-phpunit/rules.neon
5-
- vendor/phpstan/phpstan-phpunit/strictRules.neon
5+
parameters:
6+
checkMissingIterableValueType: false
7+
ignoreErrors:
8+
- message: '#Parameter \#1 \$exception of method PHPUnit\\Framework\\TestCase::expectException\(\) expects class-string<Throwable>, string given\.#'
9+
path: tests/CacheTest.php
10+
- message: '#Parameter \#1 \$key of method Pdp\\Cache::get\(\) expects string, null given\.#'
11+
path: tests/CacheTest.php
12+
- message: '#Parameter \#3 \$ttl of method Pdp\\Cache::set\(\) expects DateInterval\|int\|null, DateTime\|false given\.#'
13+
path: tests/CacheTest.php
14+
- message: '#Parameter \#1 \$key of method Pdp\\Cache::set\(\) expects string, null given\.#'
15+
path: tests/CacheTest.php
16+
- message: '#Parameter \#1 \$key of method Pdp\\Cache::delete\(\) expects string, null given\.#'
17+
path: tests/CacheTest.php
18+
- message: '#Parameter \#1 \$key of method Pdp\\Cache::has\(\) expects string, null given\.#'
19+
path: tests/CacheTest.php
20+
- message: '#Parameter \#1 \$values of method Pdp\\Cache::setMultiple\(\) expects iterable, null given\.#'
21+
path: tests/CacheTest.php
22+
- message: '#Parameter \#1 \$keys of method Pdp\\Cache::getMultiple\(\) expects iterable, null given\.#'
23+
path: tests/CacheTest.php
24+
- message: '#Parameter \#1 \$keys of method Pdp\\Cache::deleteMultiple\(\) expects iterable, null given\.#'
25+
path: tests/CacheTest.php

phpunit.xml.dist

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,20 @@
1212
stopOnFailure="false">
1313

1414
<testsuites>
15-
<testsuite name="Uri Hostname Parser Test Suite">
15+
<testsuite name="PHP Domain Parser Test Suite">
1616
<directory>tests</directory>
1717
</testsuite>
1818
</testsuites>
1919

2020
<filter>
2121
<whitelist>
2222
<directory suffix=".php">src</directory>
23-
<exclude>
24-
<directory suffix="include.php">src</directory>
25-
</exclude>
26-
<exclude>src/Installer</exclude>
2723
</whitelist>
2824
</filter>
2925

3026
<logging>
3127
<log type="junit" target="build/report.junit.xml"/>
32-
<log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/>
28+
<log type="coverage-html" target="build/coverage"/>
3329
<log type="coverage-text" target="build/coverage.txt"/>
3430
<log type="coverage-clover" target="build/clover.xml"/>
3531
</logging>

src/Cache.php

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,20 @@
1616
namespace Pdp;
1717

1818
use DateInterval;
19+
use DateTimeImmutable;
1920
use FilesystemIterator;
2021
use Generator;
2122
use InvalidArgumentException;
2223
use Psr\SimpleCache\CacheInterface;
23-
use Traversable;
2424
use function chmod;
25-
use function date_create_immutable;
2625
use function dirname;
2726
use function file_exists;
2827
use function file_get_contents;
2928
use function filemtime;
3029
use function get_class;
3130
use function gettype;
32-
use function is_array;
3331
use function is_int;
32+
use function is_iterable;
3433
use function is_object;
3534
use function is_writable;
3635
use function mkdir;
@@ -83,6 +82,7 @@ final class Cache implements CacheInterface
8382
public function __construct(string $cache_path = '')
8483
{
8584
if ('' === $cache_path) {
85+
/** @var string $cache_path */
8686
$cache_path = realpath(dirname(__DIR__).DIRECTORY_SEPARATOR.'data');
8787
}
8888

@@ -182,7 +182,9 @@ private function getExpireAt($ttl): int
182182
}
183183

184184
if ($ttl instanceof DateInterval) {
185-
return date_create_immutable('@'.time())->add($ttl)->getTimestamp();
185+
$now = new DateTimeImmutable('@'.time());
186+
187+
return $now->add($ttl)->getTimestamp();
186188
}
187189

188190
throw new CacheException(sprintf('Expected TTL to be an int, a DateInterval or null; received "%s"', is_object($ttl) ? get_class($ttl) : gettype($ttl)));
@@ -218,13 +220,13 @@ public function clear()
218220
*/
219221
public function getMultiple($keys, $default = null)
220222
{
221-
if (!is_array($keys) && !$keys instanceof Traversable) {
223+
if (!is_iterable($keys)) {
222224
throw new CacheException('keys must be either of type array or Traversable');
223225
}
224226

225227
$values = [];
226228
foreach ($keys as $key) {
227-
$values[$key] = $this->get($key) ?: $default;
229+
$values[$key] = $this->get($key) ?? $default;
228230
}
229231

230232
return $values;
@@ -235,7 +237,7 @@ public function getMultiple($keys, $default = null)
235237
*/
236238
public function setMultiple($values, $ttl = null)
237239
{
238-
if (!is_array($values) && !$values instanceof Traversable) {
240+
if (!is_iterable($values)) {
239241
throw new CacheException('keys must be either of type array or Traversable');
240242
}
241243

@@ -252,22 +254,28 @@ public function setMultiple($values, $ttl = null)
252254
/**
253255
* {@inheritdoc}
254256
*/
255-
public function deleteMultiple($keys)
257+
public function deleteMultiple($keys): bool
256258
{
257-
if (!is_array($keys) && !$keys instanceof Traversable) {
259+
if (!is_iterable($keys)) {
258260
throw new CacheException('keys must be either of type array or Traversable');
259261
}
260262

263+
$successful = false;
261264
foreach ($keys as $key) {
262265
$this->validateKey($key);
263-
$this->delete($key);
266+
$successful = $this->delete($key);
267+
if (false === $successful) {
268+
break;
269+
}
264270
}
271+
272+
return $successful;
265273
}
266274

267275
/**
268276
* {@inheritdoc}
269277
*/
270-
public function has($key)
278+
public function has($key): bool
271279
{
272280
return $this->get($key, $this) !== $this;
273281
}
@@ -288,16 +296,14 @@ private function getPath($key): string
288296
return $this->cache_path.DIRECTORY_SEPARATOR.self::FILE_PREFIX.$key.self::FILE_EXTENSION;
289297
}
290298

291-
/**
292-
* @return Generator|string[]
293-
*/
294299
private function listPaths(): Generator
295300
{
296301
$iterator = new FilesystemIterator(
297302
$this->cache_path,
298303
FilesystemIterator::CURRENT_AS_PATHNAME | FilesystemIterator::SKIP_DOTS
299304
);
300305

306+
/** @var string $path */
301307
foreach ($iterator as $path) {
302308
if (!is_dir($path)) {
303309
yield $path;
@@ -310,7 +316,7 @@ private function listPaths(): Generator
310316
*
311317
* @throws CacheException
312318
*/
313-
private function validateKey($key)
319+
private function validateKey($key): void
314320
{
315321
if (!is_string($key)) {
316322
throw new CacheException(sprintf('Expected key to be a string; received "%s"', is_object($key) ? get_class($key) : gettype($key)));
@@ -326,7 +332,7 @@ private function validateKey($key)
326332
*
327333
* @param string $path absolute directory path
328334
*/
329-
private function mkdir($path)
335+
private function mkdir($path): void
330336
{
331337
$parent_path = dirname($path);
332338

0 commit comments

Comments
 (0)