Update to PHPStan 2.x

This commit is contained in:
Dylan K. Taylor
2025-01-07 22:34:43 +00:00
parent d25ec58a6f
commit 9633b7d8a7
18 changed files with 876 additions and 344 deletions

View File

@ -51,9 +51,8 @@ final class CommandStringHelper{
foreach($matches[0] as $k => $_){
for($i = 1; $i <= 2; ++$i){
if($matches[$i][$k] !== ""){
/** @var string $match */ //phpstan can't understand preg_match and friends by itself :(
$match = $matches[$i][$k];
$args[(int) $k] = preg_replace('/\\\\([\\\\"])/u', '$1', $match) ?? throw new AssumptionFailedError(preg_last_error_msg());
$args[] = preg_replace('/\\\\([\\\\"])/u', '$1', $match) ?? throw new AssumptionFailedError(preg_last_error_msg());
break;
}
}

View File

@ -167,6 +167,7 @@ final class Utils{
/**
* @phpstan-return \Closure(object) : object
* @deprecated
*/
public static function cloneCallback() : \Closure{
return static function(object $o){
@ -179,15 +180,13 @@ final class Utils{
* @phpstan-template TValue of object
*
* @param object[] $array
* @phpstan-param array<TKey, TValue> $array
* @phpstan-param array<TKey, TValue>|list<TValue> $array
*
* @return object[]
* @phpstan-return array<TKey, TValue>
* @phpstan-return ($array is list<TValue> ? list<TValue> : array<TKey, TValue>)
*/
public static function cloneObjectArray(array $array) : array{
/** @phpstan-var \Closure(TValue) : TValue $callback */
$callback = self::cloneCallback();
return array_map($callback, $array);
return array_map(fn(object $o) => clone $o, $array);
}
/**

View File

@ -215,6 +215,9 @@ abstract class RegionWorldProvider extends BaseWorldProvider{
return null;
}
/**
* @phpstan-return \RegexIterator<mixed, string, \FilesystemIterator>
*/
private function createRegionIterator() : \RegexIterator{
return new \RegexIterator(
new \FilesystemIterator(

View File

@ -117,7 +117,7 @@ final class FlatGeneratorOptions{
}
}
}
$options[(string) $option] = $params;
$options[$option] = $params;
}
return new self($structure, $biomeId, $options);
}