Skip to content

Commit 99696a3

Browse files
committed
Updated PHPStan; min PHP version is 7.4
1 parent 6e569c3 commit 99696a3

File tree

9 files changed

+32
-18
lines changed

9 files changed

+32
-18
lines changed

build/PHPStan/phpstan.neon

+8
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ parameters:
3838
-
3939
message: '~Negated boolean expression is always true~'
4040
path: "../../src/common/lists/ImmutableArray.php"
41+
-
42+
message: '~Strict comparison using === between \*NEVER\* and 0 will always evaluate to false~'
43+
path: "../../tests/src/Http/responder.php"
44+
45+
# Re flags & WTFs
46+
- '~Parameter #4 \$flags of function preg_match expects TFlags of 0|256|512|768, int given.~'
47+
- '~Method Dogma\\Re::match\(\) should return array<string>\|null but returns array<array<int, int\|string\|null>\|string\|null>.~'
48+
- '~Method Dogma\\Re::submatch\(\) should return string\|null but returns array<int, int\|string\|null>\|string\|null.~'
4149

4250
# interface
4351
- '~^PHPDoc tag @return with type Dogma\\Language\\Locale\\LocaleCollationOption is not subtype of native type Dogma\\Enum\\StringEnum~'

composer.json

+6-12
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
}
1212
],
1313
"require": {
14-
"php": "^7.2|^8.0",
14+
"php": "^7.4|^8.0",
1515
"ext-calendar":"*",
1616
"nette/http": "~2.4|~3.0",
1717
"nette/utils": "~2.4|~3.0|~4.0"
1818
},
1919
"require-dev": {
2020
"dogma/dogma-dev": "0.1.29",
21-
"phpstan/phpstan": "1.8.2"
21+
"phpstan/phpstan": "1.10.2"
2222
},
2323
"suggest": {
2424
"ext-dom": "for Dom (basic functionality)",
@@ -76,9 +76,7 @@
7676
"php82 vendor/nette/tester/src/tester tests -c tests --colors 1",
7777
"php81 vendor/nette/tester/src/tester tests -c tests --colors 1",
7878
"php80 vendor/nette/tester/src/tester tests -c tests --colors 1",
79-
"php74 vendor/nette/tester/src/tester tests -c tests --colors 1",
80-
"php73 vendor/nette/tester/src/tester tests -c tests --colors 1",
81-
"php72 vendor/nette/tester/src/tester tests -c tests --colors 1"
79+
"php74 vendor/nette/tester/src/tester tests -c tests --colors 1"
8280
],
8381
"tests:coverage": "php vendor/nette/tester/src/tester tests -c tests --colors 1 -p phpdbg --coverage tests/coverage.html --coverage-src src",
8482

@@ -87,19 +85,15 @@
8785
"php82 vendor/phpstan/phpstan/phpstan analyse --memory-limit 256M -c build/PHPStan/phpstan.neon",
8886
"php81 vendor/phpstan/phpstan/phpstan analyse --memory-limit 256M -c build/PHPStan/phpstan.neon",
8987
"php80 vendor/phpstan/phpstan/phpstan analyse --memory-limit 256M -c build/PHPStan/phpstan.neon",
90-
"php74 vendor/phpstan/phpstan/phpstan analyse --memory-limit 256M -c build/PHPStan/phpstan.neon",
91-
"php73 vendor/phpstan/phpstan/phpstan analyse --memory-limit 256M -c build/PHPStan/phpstan.neon",
92-
"php72 vendor/phpstan/phpstan/phpstan analyse --memory-limit 256M -c build/PHPStan/phpstan.neon"
88+
"php74 vendor/phpstan/phpstan/phpstan analyse --memory-limit 256M -c build/PHPStan/phpstan.neon"
9389
],
9490

9591
"lint:php": "php vendor/php-parallel-lint/php-parallel-lint/parallel-lint src tests",
9692
"lint:php-all": [
9793
"php82 vendor/php-parallel-lint/php-parallel-lint/parallel-lint src tests",
9894
"php81 vendor/php-parallel-lint/php-parallel-lint/parallel-lint src tests",
9995
"php80 vendor/php-parallel-lint/php-parallel-lint/parallel-lint src tests",
100-
"php74 vendor/php-parallel-lint/php-parallel-lint/parallel-lint src tests",
101-
"php73 vendor/php-parallel-lint/php-parallel-lint/parallel-lint src tests",
102-
"php72 vendor/php-parallel-lint/php-parallel-lint/parallel-lint src tests"
96+
"php74 vendor/php-parallel-lint/php-parallel-lint/parallel-lint src tests"
10397
],
10498

10599
"phpcs:all": [
@@ -156,7 +150,7 @@
156150
"config": {
157151
"allow-plugins": {
158152
"dealerdirect/phpcodesniffer-composer-installer": false,
159-
"sllh/composer-versions-check": true
153+
"sllh/composer-versions-check": false
160154
}
161155
}
162156
}

src/Dom/NodeList.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
use DOMNode;
1616
use DOMNodeList;
1717
use Iterator;
18+
use ReturnTypeWillChange;
1819

1920
/**
20-
* @implements Iterator<int, DOMNode>
21+
* @implements Iterator<int, Element|DOMNode>
2122
*/
2223
class NodeList implements Countable, Iterator
2324
{
@@ -65,6 +66,7 @@ public function count(): int
6566
/**
6667
* @return Element|DOMNode
6768
*/
69+
#[ReturnTypeWillChange]
6870
public function current()
6971
{
7072
/** @var DOMNode $item */

src/Io/Filesystem/DirectoryIterator.php

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace Dogma\Io\Filesystem;
1111

1212
use FilesystemIterator;
13+
use ReturnTypeWillChange;
1314
use UnexpectedValueException;
1415

1516
class DirectoryIterator extends FilesystemIterator
@@ -53,6 +54,7 @@ public function setFlags($flags = null): void
5354
/**
5455
* @return FileInfo|mixed
5556
*/
57+
#[ReturnTypeWillChange]
5658
public function current()
5759
{
5860
if (!($this->flags & FilesystemIterator::CURRENT_AS_PATHNAME) && !($this->flags & FilesystemIterator::CURRENT_AS_SELF)) {

src/Io/Filesystem/RecursiveDirectoryIterator.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
use FilesystemIterator;
1313
use RecursiveDirectoryIterator as PhpRecursiveDirectoryIterator;
14+
use ReturnTypeWillChange;
1415
use UnexpectedValueException;
1516

1617
class RecursiveDirectoryIterator extends PhpRecursiveDirectoryIterator
@@ -44,7 +45,7 @@ public function __construct(string $path, ?int $flags = null)
4445
public function setFlags($flags = null): void
4546
{
4647
$this->flags = $flags;
47-
if ($flags & FilesystemIterator::CURRENT_AS_FILEINFO) {
48+
if (!($flags & FilesystemIterator::CURRENT_AS_PATHNAME) && !($flags & FilesystemIterator::CURRENT_AS_SELF)) {
4849
parent::setFlags($flags | FilesystemIterator::CURRENT_AS_PATHNAME);
4950
} else {
5051
parent::setFlags($flags);
@@ -54,9 +55,10 @@ public function setFlags($flags = null): void
5455
/**
5556
* @return FileInfo|mixed
5657
*/
58+
#[ReturnTypeWillChange]
5759
public function current()
5860
{
59-
if ($this->flags & FilesystemIterator::CURRENT_AS_FILEINFO) {
61+
if (!($this->flags & FilesystemIterator::CURRENT_AS_PATHNAME) && !($this->flags & FilesystemIterator::CURRENT_AS_SELF)) {
6062
/** @var string $path */
6163
$path = parent::current();
6264

src/Mapping/MappingIterator.php

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Dogma\Type;
1616
use Iterator;
1717
use IteratorAggregate;
18+
use ReturnTypeWillChange;
1819
use function is_array;
1920

2021
/**
@@ -77,6 +78,7 @@ public function valid(): bool
7778
/**
7879
* @return mixed|null
7980
*/
81+
#[ReturnTypeWillChange]
8082
public function current()
8183
{
8284
if ($this->reverse) {

src/common/Str.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@
1414

1515
use Collator as PhpCollator;
1616
use Dogma\Language\Collator;
17-
use Dogma\Language\Encoding;
1817
use Dogma\Language\Locale\Locale;
1918
use Dogma\Language\Transliterator;
2019
use Dogma\Language\UnicodeCharacterCategory;
2120
use Error;
2221
use Nette\Utils\Strings;
2322
use UConverter;
24-
use const MB_CASE_TITLE;
2523
use function array_keys;
2624
use function array_pop;
2725
use function array_shift;
@@ -53,6 +51,7 @@
5351
use function strrpos;
5452
use function strtolower;
5553
use function substr;
54+
use const MB_CASE_TITLE;
5655

5756
/**
5857
* UTF-8 strings manipulation

tests/src/Http/responder.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@
143143
if ($request['time']) {
144144
$chunkSize = (int) ($request['size'] / $request['time']);
145145
for ($n = 0; $n < $request['size']; $n++) {
146-
if ($n % $chunkSize === 0) {
146+
if (($n % $chunkSize) === 0) {
147147
sleep(1);
148148
}
149149
if ($n % 100 === 0) {

tests/src/common/Re.phpt

+5
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,8 @@ pos:
1212
Assert::same(Re::pos('abc@def', '~#~'), null);
1313
Assert::same(Re::pos('abc@def', '~@~'), 3);
1414
Assert::same(Re::pos('abc@def', '~@([def])~'), 3);
15+
16+
submatch:
17+
Assert::same(Re::submatch('abc@def', '~(abc)~'), 'abc');
18+
Assert::same(Re::submatch('abc@def', '~(def)~'), 'def');
19+
Assert::same(Re::submatch('abc@def', '~(foo)~'), null);

0 commit comments

Comments
 (0)