Updated Rector to commit a5051ff31121d95ac2ccf7db351ea486024a0b3f

a5051ff311 Bump to PHPStan ^1.9.0 (#3033)
This commit is contained in:
Tomas Votruba 2022-11-04 07:12:49 +00:00
parent ecee0c4cb7
commit ce3c134b0d
16 changed files with 116 additions and 110 deletions

View File

@ -7,7 +7,7 @@
],
"require": {
"php": "^7.2|^8.0",
"phpstan/phpstan": "^1.8.7"
"phpstan/phpstan": "^1.9.0"
},
"autoload": {
"files": [

View File

@ -171,11 +171,11 @@ CODE_SAMPLE
}
private function hasNoParamOrVariadic(ObjectType $objectType, string $setterMethodName, Scope $scope) : bool
{
$methodReflection = $objectType->getMethod($setterMethodName, $scope);
if (!$methodReflection instanceof ResolvedMethodReflection) {
$extendedMethodReflection = $objectType->getMethod($setterMethodName, $scope);
if (!$extendedMethodReflection instanceof ResolvedMethodReflection) {
return \false;
}
$parametersAcceptor = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants());
$parametersAcceptor = ParametersAcceptorSelector::selectSingle($extendedMethodReflection->getVariants());
$parameters = $parametersAcceptor->getParameters();
if (\count($parameters) !== 1) {
return \true;

View File

@ -17,12 +17,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '7dae36df19a081561ca342751d9727eff503106b';
public const PACKAGE_VERSION = 'a5051ff31121d95ac2ccf7db351ea486024a0b3f';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2022-11-02 15:41:41';
public const RELEASE_DATE = '2022-11-04 08:08:17';
/**
* @var int
*/
@ -44,7 +44,7 @@ final class VersionResolver
if ($commitHashResultCode !== 0) {
throw new VersionException('Ensure to run compile from composer git repository clone and that git binary is available.');
}
$version = \trim((string) $commitHashExecOutput[0]);
$version = \trim($commitHashExecOutput[0]);
return \trim($version, '"');
}
public static function resolverReleaseDateTime() : DateTime
@ -53,6 +53,6 @@ final class VersionResolver
if ($resultCode !== self::SUCCESS_CODE) {
throw new VersionException('You must ensure to run compile from composer git repository clone and that git binary is available.');
}
return new DateTime(\trim((string) $output[0]));
return new DateTime(\trim($output[0]));
}
}

View File

@ -5,6 +5,7 @@ namespace Rector\Core\PHPStan\Reflection\TypeToCallReflectionResolver;
use PHPStan\Analyser\Scope;
use PHPStan\Reflection\Native\NativeFunctionReflection;
use PHPStan\Reflection\ParametersAcceptorWithPhpDocs;
use PHPStan\TrinaryLogic;
use PHPStan\Type\ClosureType;
use PHPStan\Type\Type;
@ -23,6 +24,8 @@ final class ClosureTypeToCallReflectionResolver implements TypeToCallReflectionR
*/
public function resolve(Type $type, Scope $scope) : NativeFunctionReflection
{
return new NativeFunctionReflection('{closure}', $type->getCallableParametersAcceptors($scope), null, TrinaryLogic::createMaybe(), \false);
/** @var ParametersAcceptorWithPhpDocs[] $parametersAcceptors */
$parametersAcceptors = $type->getCallableParametersAcceptors($scope);
return new NativeFunctionReflection('{closure}', $parametersAcceptors, null, TrinaryLogic::createMaybe(), \false);
}
}

View File

@ -50,11 +50,11 @@ final class ConstantArrayTypeToCallReflectionResolver implements TypeToCallRefle
return null;
}
$constantArrayType = $constantArrayTypeAndMethod->getType();
$methodReflection = $constantArrayType->getMethod($constantArrayTypeAndMethod->getMethod(), $scope);
if (!$scope->canCallMethod($methodReflection)) {
$extendedMethodReflection = $constantArrayType->getMethod($constantArrayTypeAndMethod->getMethod(), $scope);
if (!$scope->canCallMethod($extendedMethodReflection)) {
return null;
}
return $methodReflection;
return $extendedMethodReflection;
}
/**
* @see https://github.com/phpstan/phpstan-src/blob/b1fd47bda2a7a7d25091197b125c0adf82af6757/src/Type/Constant/ConstantArrayType.php#L209

2
vendor/autoload.php vendored
View File

@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInitde365b206cce7c391c5a3a2f6e1ea086::getLoader();
return ComposerAutoloaderInit0e2fb91d7d05030c8ba4453eac5cfbca::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitde365b206cce7c391c5a3a2f6e1ea086
class ComposerAutoloaderInit0e2fb91d7d05030c8ba4453eac5cfbca
{
private static $loader;
@ -22,19 +22,19 @@ class ComposerAutoloaderInitde365b206cce7c391c5a3a2f6e1ea086
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitde365b206cce7c391c5a3a2f6e1ea086', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit0e2fb91d7d05030c8ba4453eac5cfbca', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInitde365b206cce7c391c5a3a2f6e1ea086', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit0e2fb91d7d05030c8ba4453eac5cfbca', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitde365b206cce7c391c5a3a2f6e1ea086::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit0e2fb91d7d05030c8ba4453eac5cfbca::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$includeFiles = \Composer\Autoload\ComposerStaticInitde365b206cce7c391c5a3a2f6e1ea086::$files;
$includeFiles = \Composer\Autoload\ComposerStaticInit0e2fb91d7d05030c8ba4453eac5cfbca::$files;
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequirede365b206cce7c391c5a3a2f6e1ea086($fileIdentifier, $file);
composerRequire0e2fb91d7d05030c8ba4453eac5cfbca($fileIdentifier, $file);
}
return $loader;
@ -46,7 +46,7 @@ class ComposerAutoloaderInitde365b206cce7c391c5a3a2f6e1ea086
* @param string $file
* @return void
*/
function composerRequirede365b206cce7c391c5a3a2f6e1ea086($fileIdentifier, $file)
function composerRequire0e2fb91d7d05030c8ba4453eac5cfbca($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInitde365b206cce7c391c5a3a2f6e1ea086
class ComposerStaticInit0e2fb91d7d05030c8ba4453eac5cfbca
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -3053,9 +3053,9 @@ class ComposerStaticInitde365b206cce7c391c5a3a2f6e1ea086
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitde365b206cce7c391c5a3a2f6e1ea086::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitde365b206cce7c391c5a3a2f6e1ea086::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitde365b206cce7c391c5a3a2f6e1ea086::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit0e2fb91d7d05030c8ba4453eac5cfbca::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit0e2fb91d7d05030c8ba4453eac5cfbca::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit0e2fb91d7d05030c8ba4453eac5cfbca::$classMap;
}, null, ClassLoader::class);
}

View File

@ -69,17 +69,17 @@
},
{
"name": "composer\/pcre",
"version": "3.0.0",
"version_normalized": "3.0.0.0",
"version": "3.0.2",
"version_normalized": "3.0.2.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/composer\/pcre.git",
"reference": "e300eb6c535192decd27a85bc72a9290f0d6b3bd"
"reference": "4482b6409ca6bfc2af043a5711cd21ac3e7a8dfb"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/composer\/pcre\/zipball\/e300eb6c535192decd27a85bc72a9290f0d6b3bd",
"reference": "e300eb6c535192decd27a85bc72a9290f0d6b3bd",
"url": "https:\/\/api.github.com\/repos\/composer\/pcre\/zipball\/4482b6409ca6bfc2af043a5711cd21ac3e7a8dfb",
"reference": "4482b6409ca6bfc2af043a5711cd21ac3e7a8dfb",
"shasum": ""
},
"require": {
@ -90,7 +90,7 @@
"phpstan\/phpstan-strict-rules": "^1.1",
"symfony\/phpunit-bridge": "^5"
},
"time": "2022-02-25T20:21:48+00:00",
"time": "2022-11-03T20:24:16+00:00",
"type": "library",
"extra": {
"branch-alias": {
@ -123,7 +123,7 @@
],
"support": {
"issues": "https:\/\/github.com\/composer\/pcre\/issues",
"source": "https:\/\/github.com\/composer\/pcre\/tree\/3.0.0"
"source": "https:\/\/github.com\/composer\/pcre\/tree\/3.0.2"
},
"funding": [
{
@ -733,17 +733,17 @@
},
{
"name": "phpstan\/phpstan",
"version": "1.8.11",
"version_normalized": "1.8.11.0",
"version": "1.9.0",
"version_normalized": "1.9.0.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/phpstan\/phpstan.git",
"reference": "46e223dd68a620da18855c23046ddb00940b4014"
"reference": "e08de53a5eec983de78a787a88e72518cf8fe43a"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/phpstan\/phpstan\/zipball\/46e223dd68a620da18855c23046ddb00940b4014",
"reference": "46e223dd68a620da18855c23046ddb00940b4014",
"url": "https:\/\/api.github.com\/repos\/phpstan\/phpstan\/zipball\/e08de53a5eec983de78a787a88e72518cf8fe43a",
"reference": "e08de53a5eec983de78a787a88e72518cf8fe43a",
"shasum": ""
},
"require": {
@ -752,7 +752,7 @@
"conflict": {
"phpstan\/phpstan-shim": "*"
},
"time": "2022-10-24T15:45:13+00:00",
"time": "2022-11-03T07:26:48+00:00",
"bin": [
"phpstan",
"phpstan.phar"
@ -775,7 +775,7 @@
],
"support": {
"issues": "https:\/\/github.com\/phpstan\/phpstan\/issues",
"source": "https:\/\/github.com\/phpstan\/phpstan\/tree\/1.8.11"
"source": "https:\/\/github.com\/phpstan\/phpstan\/tree\/1.9.0"
},
"funding": [
{

File diff suppressed because one or more lines are too long

View File

@ -1,17 +0,0 @@
parameters:
ignoreErrors:
-
message: "#^Method Composer\\\\Pcre\\\\Preg\\:\\:matchAll\\(\\) should return int\\<0, max\\> but returns int\\.$#"
count: 1
path: src/Preg.php
-
message: "#^Method Composer\\\\Pcre\\\\Preg\\:\\:matchAllWithOffsets\\(\\) should return int\\<0, max\\> but returns int\\.$#"
count: 1
path: src/Preg.php
-
message: "#^Strict comparison using \\=\\=\\= between int and null will always evaluate to false\\.$#"
count: 2
path: src/Preg.php

View File

@ -19,14 +19,14 @@ class Preg
/**
* @param non-empty-string $pattern
* @param array<string|null> $matches Set by method
* @param int $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
* @param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
* @return 0|1
*
* @param-out array<int|string, string|null> $matches
*/
public static function match(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0) : int
{
if (($flags & \PREG_OFFSET_CAPTURE) !== 0) {
throw new \InvalidArgumentException('PREG_OFFSET_CAPTURE is not supported as it changes the type of $matches, use matchWithOffsets() instead');
}
self::checkOffsetCapture($flags, 'matchWithOffsets');
$result = \preg_match($pattern, $subject, $matches, $flags | \PREG_UNMATCHED_AS_NULL, $offset);
if ($result === \false) {
throw PcreException::fromFunction('preg_match', $pattern);
@ -38,10 +38,10 @@ class Preg
*
* @param non-empty-string $pattern
* @param array<int|string, array{string|null, int}> $matches Set by method
* @param int $flags PREG_UNMATCHED_AS_NULL and PREG_MATCH_OFFSET are always set, no other flags are supported
* @param int-mask<PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE> $flags PREG_UNMATCHED_AS_NULL and PREG_OFFSET_CAPTURE are always set, no other flags are supported
* @return 0|1
*
* @phpstan-param array<int|string, array{string|null, int<-1, max>}> $matches
* @param-out array<int|string, array{string|null, int<-1, max>}> $matches
*/
public static function matchWithOffsets(string $pattern, string $subject, ?array &$matches, int $flags = 0, int $offset = 0) : int
{
@ -54,19 +54,20 @@ class Preg
/**
* @param non-empty-string $pattern
* @param array<int|string, list<string|null>> $matches Set by method
* @param int $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
* @param int-mask<PREG_UNMATCHED_AS_NULL|PREG_SET_ORDER> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
* @return 0|positive-int
*
* @param-out array<int|string, list<string|null>> $matches
*/
public static function matchAll(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0) : int
{
if (($flags & \PREG_OFFSET_CAPTURE) !== 0) {
throw new \InvalidArgumentException('PREG_OFFSET_CAPTURE is not supported as it changes the type of $matches, use matchAllWithOffsets() instead');
}
self::checkOffsetCapture($flags, 'matchAllWithOffsets');
if (($flags & \PREG_SET_ORDER) !== 0) {
throw new \InvalidArgumentException('PREG_SET_ORDER is not supported as it changes the type of $matches');
}
$result = \preg_match_all($pattern, $subject, $matches, $flags | \PREG_UNMATCHED_AS_NULL, $offset);
if ($result === \false || $result === null) {
if (!\is_int($result)) {
// PHP < 8 may return null, 8+ returns int|false
throw PcreException::fromFunction('preg_match_all', $pattern);
}
return $result;
@ -76,7 +77,7 @@ class Preg
*
* @param non-empty-string $pattern
* @param array<int|string, list<array{string|null, int}>> $matches Set by method
* @param int $flags PREG_UNMATCHED_AS_NULL and PREG_MATCH_OFFSET are always set, no other flags are supported
* @param int-mask<PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE> $flags PREG_UNMATCHED_AS_NULL and PREG_MATCH_OFFSET are always set, no other flags are supported
* @return 0|positive-int
*
* @phpstan-param array<int|string, list<array{string|null, int<-1, max>}>> $matches
@ -84,7 +85,8 @@ class Preg
public static function matchAllWithOffsets(string $pattern, string $subject, ?array &$matches, int $flags = 0, int $offset = 0) : int
{
$result = \preg_match_all($pattern, $subject, $matches, $flags | \PREG_UNMATCHED_AS_NULL | \PREG_OFFSET_CAPTURE, $offset);
if ($result === \false || $result === null) {
if (!\is_int($result)) {
// PHP < 8 may return null, 8+ returns int|false
throw PcreException::fromFunction('preg_match_all', $pattern);
}
return $result;
@ -94,6 +96,8 @@ class Preg
* @param string|string[] $replacement
* @param string $subject
* @param int $count Set by method
*
* @param-out int<0, max> $count
*/
public static function replace($pattern, $replacement, $subject, int $limit = -1, int &$count = null) : string
{
@ -111,9 +115,12 @@ class Preg
}
/**
* @param string|string[] $pattern
* @param callable(array<int|string, string|null>): string $replacement
* @param string $subject
* @param int $count Set by method
* @param int $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set
* @param int-mask<PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE> $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set
*
* @param-out int<0, max> $count
*/
public static function replaceCallback($pattern, callable $replacement, $subject, int $limit = -1, int &$count = null, int $flags = 0) : string
{
@ -130,10 +137,12 @@ class Preg
return $result;
}
/**
* @param array<string, callable> $pattern
* @param array<string, callable(array<int|string, string|null>): string> $pattern
* @param string $subject
* @param int $count Set by method
* @param int $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set
* @param int-mask<PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE> $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set
*
* @param-out int<0, max> $count
*/
public static function replaceCallbackArray(array $pattern, $subject, int $limit = -1, int &$count = null, int $flags = 0) : string
{
@ -151,7 +160,7 @@ class Preg
return $result;
}
/**
* @param int $flags PREG_SPLIT_NO_EMPTY or PREG_SPLIT_DELIM_CAPTURE
* @param int-mask<PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_OFFSET_CAPTURE> $flags PREG_SPLIT_NO_EMPTY or PREG_SPLIT_DELIM_CAPTURE
* @return list<string>
*/
public static function split(string $pattern, string $subject, int $limit = -1, int $flags = 0) : array
@ -166,7 +175,7 @@ class Preg
return $result;
}
/**
* @param int $flags PREG_SPLIT_NO_EMPTY or PREG_SPLIT_DELIM_CAPTURE, PREG_SPLIT_OFFSET_CAPTURE is always set
* @param int-mask<PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_OFFSET_CAPTURE> $flags PREG_SPLIT_NO_EMPTY or PREG_SPLIT_DELIM_CAPTURE, PREG_SPLIT_OFFSET_CAPTURE is always set
* @return list<array{string, int}>
* @phpstan-return list<array{string, int<0, max>}>
*/
@ -182,7 +191,7 @@ class Preg
* @template T of string|\Stringable
* @param string $pattern
* @param array<T> $array
* @param int $flags PREG_GREP_INVERT
* @param int-mask<PREG_GREP_INVERT> $flags PREG_GREP_INVERT
* @return array<T>
*/
public static function grep(string $pattern, array $array, int $flags = 0) : array
@ -196,7 +205,9 @@ class Preg
/**
* @param non-empty-string $pattern
* @param array<string|null> $matches Set by method
* @param int $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
* @param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
*
* @param-out array<int|string, string|null> $matches
*/
public static function isMatch(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0) : bool
{
@ -205,7 +216,9 @@ class Preg
/**
* @param non-empty-string $pattern
* @param array<int|string, list<string|null>> $matches Set by method
* @param int $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
* @param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
*
* @param-out array<int|string, list<string|null>> $matches
*/
public static function isMatchAll(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0) : bool
{
@ -216,9 +229,9 @@ class Preg
*
* @param non-empty-string $pattern
* @param array<int|string, array{string|null, int}> $matches Set by method
* @param int $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
* @param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
*
* @phpstan-param array<int|string, array{string|null, int<-1, max>}> $matches
* @param-out array<int|string, array{string|null, int<-1, max>}> $matches
*/
public static function isMatchWithOffsets(string $pattern, string $subject, ?array &$matches, int $flags = 0, int $offset = 0) : bool
{
@ -229,12 +242,18 @@ class Preg
*
* @param non-empty-string $pattern
* @param array<int|string, list<array{string|null, int}>> $matches Set by method
* @param int $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
* @param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
*
* @phpstan-param array<int|string, list<array{string|null, int<-1, max>}>> $matches
* @param-out array<int|string, list<array{string|null, int<-1, max>}>> $matches
*/
public static function isMatchAllWithOffsets(string $pattern, string $subject, ?array &$matches, int $flags = 0, int $offset = 0) : bool
{
return (bool) static::matchAllWithOffsets($pattern, $subject, $matches, $flags, $offset);
}
private static function checkOffsetCapture(int $flags, string $useFunctionName) : void
{
if (($flags & \PREG_OFFSET_CAPTURE) !== 0) {
throw new \InvalidArgumentException('PREG_OFFSET_CAPTURE is not supported as it changes the type of $matches, use ' . $useFunctionName . '() instead');
}
}
}

View File

@ -21,13 +21,11 @@ class Regex
}
/**
* @param non-empty-string $pattern
* @param int $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
* @param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
*/
public static function match(string $pattern, string $subject, int $flags = 0, int $offset = 0) : MatchResult
{
if (($flags & \PREG_OFFSET_CAPTURE) !== 0) {
throw new \InvalidArgumentException('PREG_OFFSET_CAPTURE is not supported as it changes the return type, use matchWithOffsets() instead');
}
self::checkOffsetCapture($flags);
$count = Preg::match($pattern, $subject, $matches, $flags, $offset);
return new MatchResult($count, $matches);
}
@ -35,7 +33,7 @@ class Regex
* Runs preg_match with PREG_OFFSET_CAPTURE
*
* @param non-empty-string $pattern
* @param int $flags PREG_UNMATCHED_AS_NULL and PREG_MATCH_OFFSET are always set, no other flags are supported
* @param int-mask<PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE> $flags PREG_UNMATCHED_AS_NULL and PREG_MATCH_OFFSET are always set, no other flags are supported
*/
public static function matchWithOffsets(string $pattern, string $subject, int $flags = 0, int $offset = 0) : MatchWithOffsetsResult
{
@ -44,13 +42,11 @@ class Regex
}
/**
* @param non-empty-string $pattern
* @param int $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
* @param int-mask<PREG_UNMATCHED_AS_NULL|PREG_SET_ORDER> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
*/
public static function matchAll(string $pattern, string $subject, int $flags = 0, int $offset = 0) : MatchAllResult
{
if (($flags & \PREG_OFFSET_CAPTURE) !== 0) {
throw new \InvalidArgumentException('PREG_OFFSET_CAPTURE is not supported as it changes the return type, use matchAllWithOffsets() instead');
}
self::checkOffsetCapture($flags);
if (($flags & \PREG_SET_ORDER) !== 0) {
throw new \InvalidArgumentException('PREG_SET_ORDER is not supported as it changes the return type');
}
@ -61,7 +57,7 @@ class Regex
* Runs preg_match_all with PREG_OFFSET_CAPTURE
*
* @param non-empty-string $pattern
* @param int $flags PREG_UNMATCHED_AS_NULL and PREG_MATCH_OFFSET are always set, no other flags are supported
* @param int-mask<PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE> $flags PREG_UNMATCHED_AS_NULL and PREG_MATCH_OFFSET are always set, no other flags are supported
*/
public static function matchAllWithOffsets(string $pattern, string $subject, int $flags = 0, int $offset = 0) : MatchAllWithOffsetsResult
{
@ -80,8 +76,9 @@ class Regex
}
/**
* @param string|string[] $pattern
* @param callable(array<int|string, string|null>): string $replacement
* @param string $subject
* @param int $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set
* @param int-mask<PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE> $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set
*/
public static function replaceCallback($pattern, callable $replacement, $subject, int $limit = -1, int $flags = 0) : ReplaceResult
{
@ -89,13 +86,19 @@ class Regex
return new ReplaceResult($count, $result);
}
/**
* @param array<string, callable> $pattern
* @param array<string, callable(array<int|string, string|null>): string> $pattern
* @param string $subject
* @param int $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set
* @param int-mask<PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE> $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set
*/
public static function replaceCallbackArray(array $pattern, $subject, int $limit = -1, int $flags = 0) : ReplaceResult
{
$result = Preg::replaceCallbackArray($pattern, $subject, $limit, $count, $flags);
return new ReplaceResult($count, $result);
}
private static function checkOffsetCapture(int $flags) : void
{
if (($flags & \PREG_OFFSET_CAPTURE) !== 0) {
throw new \InvalidArgumentException('PREG_OFFSET_CAPTURE is not supported as it changes the return type, use matchWithOffsets() instead');
}
}
}

View File

@ -54,10 +54,8 @@ can be checked before you run the actual line.
<br>
<a href="https://www.worksome.com/"><img src="https://i.imgur.com/TQKSwOl.png" alt="Worksome" width="283" height="64"></a>
&nbsp;&nbsp;&nbsp;
<a href="https://www.campoint.net/"><img src="https://i.imgur.com/fR6eMUm.png" alt="campoint AG" width="283" height="64"></a>
<br>
<a href="https://www.crisp.nl/"><img src="https://i.imgur.com/jRJyPve.png" alt="Crisp.nl" width="283" height="64"></a>
&nbsp;&nbsp;&nbsp;
<br>
<a href="https://inviqa.com/"><img src="https://i.imgur.com/G99rj45.png" alt="Inviqa" width="254" height="65"></a>

Binary file not shown.

View File

@ -1,16 +1,16 @@
-----BEGIN PGP SIGNATURE-----
iQIzBAABCgAdFiEE0yaA1ZV9xxFr4pwUzxoQjQ565yAFAmNWsvsACgkQzxoQjQ56
5yDRxBAAjWCLhtqGMBf/5UB8lDTa8+jKeeeXw7tdRQtsEIL5KdRVCFGrpPDWA0pi
/F9akCBG1gYCPxAX5gD6khEWgSxQ6PItxupskpQWRYlYqHC0EA3CyYGecpBb6F9l
jRHQIlSzrAiuVI3hTX5EAUHxbPxhTC0zO+wKcvM0jLsOCtUQrWWSp12Nr7GZTxWw
6IM3IKRdPnAMHwuoVWOcocR01NAkvpoWK1GtTfhu4E0c2XLsUpbW1rtiZQvf3W/H
yT47rran+dYOy9scE4sxNRtB4NZ6Bk5GKwR8XzUu1N7X5dL+/NPax4p0CKthyG+n
/VZdsIv8LnWCqXOOg1cjfYy/zlT8NUB/wmXpWDyxsw/T7Tc81QzJ1oqXcHq1oBXQ
OqbYAuZzk+nXSt6KhybYgKx1VyG6L4Xchu30ly5hlEHexoZCzWm8BZM2Ii3mT5gT
dSBDVghNs0dmgP7hRI5uBNtyE+Mnip23Nj3d4/Hg4AFSkmUOkugbWr7Gl8H6rKwi
w5p2i/RCQ6F+UwmSCd+/ZeL88heHO/loR6O2Cj/lCbEXP1djZuIiyv+gZ3FnB4Mr
s6sB1lQ2ocOyD20B8DLOg5IVdoIAsCtZ3PViZp4NG7oh9N117HQ/+H83GHjmZZn6
eVW3iw6stdGR6FpIZKdMsaKKPHCfNmuogVDpd8nabmbxl+GlH2g=
=TOxZ
iQIzBAABCgAdFiEE0yaA1ZV9xxFr4pwUzxoQjQ565yAFAmNjbSoACgkQzxoQjQ56
5yDmXg//d5XNlGLjSj0SImpc7IebKvVWuDYUhrZOldBPb+O7h2QUNMEfys7JT5yZ
dSVQ+kznxcCisCrMWVUT797XszHUNRtV/K1p+bVVSAS8m2LX1zHoacE07RIworW7
19gXDRo9bbr3MWeHj47g7nDDv0dyN1uwhIgBxKsZtkztTVBVZ2/+vWz5uLOAXV0/
1pDlnr7hb1yKh/OtQ5JXLTA0RRCwyCJqjSgUquBYdi0K91ewJ7xu+jUKBvA3XFd/
5RdsSCr9s0MYtD2ib5/vQxIOTMcxVgyhmWkExkP8QpP8lBsKbzbUMyVPU1ADf2uU
RspY/fXE+7oIj8UQtBa25F1rQxGUQtst1C85MflhNsusby8CE7R5OngOyJupkkLV
5DVU8g6P2KmBaR9SMiMYWlluGANMtH8DEFDtZxvPcbXDMScCFUvYd+6ilarAzmke
COJF0xMBHhNu6OEXKgXYg99Vqop4G73Vzmgp10TUYTz4e+aSooChFVGLgpQOYAWw
m76C1lnQMZOf5R5Hsk4LsFkkZFvH9bLb5WbDDOa+WONQMpEXZWWXjhJZ3ije2TDr
I5rtqSzZO5IwpEhTl4lZ85X74cVYuGtm4qI1PwBzNuMot7lNFreGZQWwYqeKtH/Q
lYrGh/aq0+SM+JMdlLe/8gYInqriQRrWHHCbVmIk79TQSVPhYl0=
=DBl+
-----END PGP SIGNATURE-----