Skip to content

Update PHPStan to 1.10 #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"phpdocumentor/reflection-docblock": "*",
"phpstan/phpdoc-parser": "*",
"phpunit/phpunit": "^7.3 || ^8.4",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan": "^1.10",
"friendsofphp/php-cs-fixer": "^2.12"
}
}
54 changes: 2 additions & 52 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,40 +1,5 @@
parameters:
ignoreErrors:
-
message: "#^PHPDoc tag @param references unknown parameter\\: \\$iteratee$#"
count: 1
path: src/Array/differenceBy.php

-
message: "#^PHPDoc tag @param references unknown parameter\\: \\$comparator$#"
count: 1
path: src/Array/differenceWith.php

-
message: "#^PHPDoc tag @param references unknown parameter\\: \\$iteratee$#"
count: 1
path: src/Array/intersectionBy.php

-
message: "#^PHPDoc tag @param references unknown parameter\\: \\$comparator$#"
count: 1
path: src/Array/intersectionWith.php

-
message: "#^PHPDoc tag @param references unknown parameter\\: \\$iteratee$#"
count: 1
path: src/Array/unionBy.php

-
message: "#^PHPDoc tag @param references unknown parameter\\: \\$comparator$#"
count: 1
path: src/Array/unionWith.php

-
message: "#^PHPDoc tag @param references unknown parameter\\: \\$iteratee$#"
count: 1
path: src/Array/zipWith.php

-
message: "#^Unreachable statement \\- code above always terminates\\.$#"
count: 1
Expand All @@ -56,27 +21,12 @@ parameters:
path: src/String/startsWith.php

-
message: "#^Comparison operation \"\\>\" between int\\<0, max\\> and \\-1 is always true\\.$#"
count: 1
path: src/String/truncate.php

-
message: "#^Call to function is_array\\(\\) with object will always evaluate to false\\.$#"
message: "#^Offset mixed on \\*NEVER\\* in isset\\(\\) always exists and is not nullable\\.$#"
count: 1
path: src/internal/isIterateeCall.php

-
message: "#^Result of \\|\\| is always true\\.$#"
count: 1
path: src/internal/isIterateeCall.php
path: src/internal/baseIntersection.php

-
message: "#^Unreachable statement \\- code above always terminates\\.$#"
count: 1
path: src/internal/isIterateeCall.php

-
message: "#^Regex pattern is invalid\\: Delimiter must not be alphanumeric or backslash in pattern\\: \\\\x\\{e83c\\}\\[\\\\x\\{effb\\}\\-\\\\x\\{efff\\}\\]\\(\\?\\=\\\\x\\{e83c\\}\\[\\\\x\\{effb\\}\\-\\\\x\\{efff\\}\\]\\)\\|\\(\\?\\:\\[\\^\\\\x\\{e800\\}\\-\\\\x\\{efff\\}\\]\\[\\\\x\\{0300\\}\\-\\\\x\\{036f\\}\\\\x\\{fe20\\}\\-\\\\x\\{fe2f\\}\\\\x\\{20d0\\}\\-\\\\x\\{20ff\\}\\]\\?\\|\\[\\\\x\\{0300\\}\\-\\\\x\\{036f\\}\\\\x\\{fe20\\}\\-\\\\x\\{fe2f\\}\\\\x\\{20d0\\}\\-\\\\x\\{20ff\\}\\]\\|\\(\\?\\:\\\\x\\{e83c\\}\\[\\\\x\\{ede6\\}\\-\\\\x\\{edff\\}\\]\\)\\{2\\}\\|\\[\\\\x\\{e800\\}\\-\\\\x\\{ebff\\}\\]\\[\\\\x\\{ec00\\}\\-\\\\x\\{efff\\}\\]\\|\\[\\\\x\\{e800\\}\\-\\\\x\\{efff\\}\\]\\)\\[\\\\x\\{fe0e\\}\\\\x\\{fe0f\\}\\]\\?\\(\\?\\:\\[\\\\x\\{0300\\}\\-\\\\x\\{036f\\}\\\\x\\{fe20\\}\\-\\\\x\\{fe2f\\}\\\\x\\{20d0\\}\\-\\\\x\\{20ff\\}\\]\\|\\\\x\\{e83c\\}\\[\\\\x\\{effb\\}\\-\\\\x\\{efff\\}\\]\\)\\?\\(\\?\\:\\\\x\\{200d\\}\\(\\?\\:\\[\\^\\\\x\\{e800\\}\\-\\\\x\\{efff\\}\\]\\|\\(\\?\\:\\\\x\\{e83c\\}\\[\\\\x\\{ede6\\}\\-\\\\x\\{edff\\}\\]\\)\\{2\\}\\|\\[\\\\x\\{e800\\}\\-\\\\x\\{ebff\\}\\]\\[\\\\x\\{ec00\\}\\-\\\\x\\{efff\\}\\]\\)\\[\\\\x\\{fe0e\\}\\\\x\\{fe0f\\}\\]\\?\\(\\?\\:\\[\\\\x\\{0300\\}\\-\\\\x\\{036f\\}\\\\x\\{fe20\\}\\-\\\\x\\{fe2f\\}\\\\x\\{20d0\\}\\-\\\\x\\{20ff\\}\\]\\|\\\\x\\{e83c\\}\\[\\\\x\\{effb\\}\\-\\\\x\\{efff\\}\\]\\)\\?\\)\\*$#"
count: 1
path: src/internal/unicodeSize.php

6 changes: 4 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ includes:
parameters:
paths:
- src
bootstrap: %rootDir%/../../../src/bootstrap.php
bootstrapFiles:
- src/bootstrap.php
level: 5
excludes_analyse:
excludePaths:
- src/compiled.php
- src/Lodash.php
- src/internal/memoizeCapped.php # Exclude internal function due to dynamic class usage
ignoreErrors:
- "#Callable '.*internal.*' invoked with \\d+ parameters, [\\d-]+ required.#"
- "#^PHPDoc tag \\@param references unknown parameter\\: \\$[a-zA-Z]+$#"
2 changes: 1 addition & 1 deletion src/String/split.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
function split(string $string, string $separator, int $limit = 0): array
{
if (\preg_match(reRegExpChar, $separator)) {
return \preg_split($separator, $string, $limit ?? -1, PREG_SPLIT_DELIM_CAPTURE) ?: [];
return \preg_split($separator, $string, $limit ?: -1, PREG_SPLIT_DELIM_CAPTURE) ?: [];
}

/** @var array $result */
Expand Down
12 changes: 9 additions & 3 deletions src/String/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ function template(string $string, array $options = []): callable
]);

$string = \preg_replace_callback('#'.$reDelimiters.'#u', function ($matches) {
list(,
[,
$escapeValue,
$interpolateValue,
$esTemplateValue,
$evaluateValue,
) = \array_merge($matches, \array_fill(\count($matches), 5 - \count($matches), null));
] = \array_merge($matches, \array_fill(\count($matches), 5 - \count($matches), null));

$interpolateValue = $interpolateValue ?: $esTemplateValue;

Expand All @@ -128,7 +128,7 @@ function template(string $string, array $options = []): callable
}

if ($interpolateValue) {
$interpolateValue = \trim($interpolateValue ?? $esTemplateValue);
$interpolateValue = \trim($interpolateValue);
$interpolateValue = \preg_replace('#^([\p{L}\p{N}_]+)$#u', '$$1', $interpolateValue);
$source .= "<?={$interpolateValue};?>";
}
Expand All @@ -145,8 +145,14 @@ function template(string $string, array $options = []): callable
return new class($string, $imports) {
public $source;

/**
* @var array<string, string>
*/
private $imports;

/**
* @param array<string, string> $imports
*/
public function __construct(string $source, array $imports)
{
$this->source = $source;
Expand Down
2 changes: 1 addition & 1 deletion src/String/truncate.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function truncate($string, array $options = [])
}
} elseif (\strpos($string, $separator) !== $end) {
$index = \strrpos($result, $separator);
if (false !== $index && $index > -1) {
if (false !== $index) {
$result = \substr($result, 0, $index);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/internal/isIterateeCall.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
function isIterateeCall($value, $index = null, $object = null)
{
if (!\is_object($object) || !\is_array($object)) {
if (!\is_object($object) && !\is_array($object)) {
return false;
}

Expand Down