diff --git a/packages/BetterPhpDocParser/PhpDocParser/PhpDocFromTypeDeclarationDecorator.php b/packages/BetterPhpDocParser/PhpDocParser/PhpDocFromTypeDeclarationDecorator.php index 9492b3d4384..a1cc8b7ed74 100644 --- a/packages/BetterPhpDocParser/PhpDocParser/PhpDocFromTypeDeclarationDecorator.php +++ b/packages/BetterPhpDocParser/PhpDocParser/PhpDocFromTypeDeclarationDecorator.php @@ -19,6 +19,7 @@ use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger; use Rector\NodeNameResolver\NodeNameResolver; use Rector\PHPStanStaticTypeMapper\Utils\TypeUnwrapper; use Rector\StaticTypeMapper\StaticTypeMapper; +use Rector\VendorLocker\ParentClassMethodTypeOverrideGuard; final class PhpDocFromTypeDeclarationDecorator { /** @@ -46,13 +47,19 @@ final class PhpDocFromTypeDeclarationDecorator * @var \Rector\PHPStanStaticTypeMapper\Utils\TypeUnwrapper */ private $typeUnwrapper; - public function __construct(\Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger, \Rector\PHPStanStaticTypeMapper\Utils\TypeUnwrapper $typeUnwrapper) + /** + * @readonly + * @var \Rector\VendorLocker\ParentClassMethodTypeOverrideGuard + */ + private $parentClassMethodTypeOverrideGuard; + public function __construct(\Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger, \Rector\PHPStanStaticTypeMapper\Utils\TypeUnwrapper $typeUnwrapper, \Rector\VendorLocker\ParentClassMethodTypeOverrideGuard $parentClassMethodTypeOverrideGuard) { $this->staticTypeMapper = $staticTypeMapper; $this->phpDocInfoFactory = $phpDocInfoFactory; $this->nodeNameResolver = $nodeNameResolver; $this->phpDocTypeChanger = $phpDocTypeChanger; $this->typeUnwrapper = $typeUnwrapper; + $this->parentClassMethodTypeOverrideGuard = $parentClassMethodTypeOverrideGuard; } /** * @param \PhpParser\Node\Expr\ArrowFunction|\PhpParser\Node\Expr\Closure|\PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $functionLike @@ -62,9 +69,15 @@ final class PhpDocFromTypeDeclarationDecorator if ($functionLike->returnType === null) { return; } - $type = $this->staticTypeMapper->mapPhpParserNodePHPStanType($functionLike->returnType); - $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($functionLike); - $this->phpDocTypeChanger->changeReturnType($phpDocInfo, $type); + if ($functionLike instanceof \PhpParser\Node\Stmt\ClassMethod && !$this->parentClassMethodTypeOverrideGuard->isReturnTypeChangeAllowed($functionLike)) { + $returnType = $this->parentClassMethodTypeOverrideGuard->getParentClassMethodNodeType($functionLike); + if ($returnType !== null) { + $functionLike->returnType = $returnType; + $this->changePhpDocReturnType($functionLike); + return; + } + } + $this->changePhpDocReturnType($functionLike); $functionLike->returnType = null; } /** @@ -111,6 +124,17 @@ final class PhpDocFromTypeDeclarationDecorator $this->decorate($functionLike); return \true; } + /** + * @param \PhpParser\Node\Expr\ArrowFunction|\PhpParser\Node\Expr\Closure|\PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $functionLike + */ + private function changePhpDocReturnType($functionLike) : void + { + /** @var ComplexType|Identifier|Name $returnType $returnType */ + $returnType = $functionLike->returnType; + $type = $this->staticTypeMapper->mapPhpParserNodePHPStanType($returnType); + $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($functionLike); + $this->phpDocTypeChanger->changeReturnType($phpDocInfo, $type); + } /** * @param \PhpParser\Node\ComplexType|\PhpParser\Node\Identifier|\PhpParser\Node\Name $typeNode */ diff --git a/packages/VendorLocker/ParentClassMethodTypeOverrideGuard.php b/packages/VendorLocker/ParentClassMethodTypeOverrideGuard.php index ca40e520d65..7cbfbcfa4a0 100644 --- a/packages/VendorLocker/ParentClassMethodTypeOverrideGuard.php +++ b/packages/VendorLocker/ParentClassMethodTypeOverrideGuard.php @@ -3,6 +3,9 @@ declare (strict_types=1); namespace Rector\VendorLocker; +use PhpParser\Node\ComplexType; +use PhpParser\Node\Identifier; +use PhpParser\Node\Name; use PhpParser\Node\Stmt\ClassMethod; use PHPStan\Analyser\Scope; use PHPStan\Reflection\ClassReflection; @@ -10,10 +13,13 @@ use PHPStan\Reflection\FunctionVariantWithPhpDocs; use PHPStan\Reflection\MethodReflection; use PHPStan\Reflection\ParametersAcceptorSelector; use PHPStan\Type\MixedType; +use PHPStan\Type\NonexistentParentClassType; use PHPStan\Type\Type; use Rector\Core\PhpParser\AstResolver; use Rector\NodeNameResolver\NodeNameResolver; use Rector\NodeTypeResolver\Node\AttributeKey; +use Rector\PHPStanStaticTypeMapper\Enum\TypeKind; +use Rector\StaticTypeMapper\StaticTypeMapper; use Rector\TypeDeclaration\TypeInferer\ParamTypeInferer; use RectorPrefix20211205\Symplify\SmartFileSystem\Normalizer\PathNormalizer; final class ParentClassMethodTypeOverrideGuard @@ -38,12 +44,18 @@ final class ParentClassMethodTypeOverrideGuard * @var \Rector\TypeDeclaration\TypeInferer\ParamTypeInferer */ private $paramTypeInferer; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \RectorPrefix20211205\Symplify\SmartFileSystem\Normalizer\PathNormalizer $pathNormalizer, \Rector\Core\PhpParser\AstResolver $astResolver, \Rector\TypeDeclaration\TypeInferer\ParamTypeInferer $paramTypeInferer) + /** + * @readonly + * @var \Rector\StaticTypeMapper\StaticTypeMapper + */ + private $staticTypeMapper; + public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \RectorPrefix20211205\Symplify\SmartFileSystem\Normalizer\PathNormalizer $pathNormalizer, \Rector\Core\PhpParser\AstResolver $astResolver, \Rector\TypeDeclaration\TypeInferer\ParamTypeInferer $paramTypeInferer, \Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper) { $this->nodeNameResolver = $nodeNameResolver; $this->pathNormalizer = $pathNormalizer; $this->astResolver = $astResolver; $this->paramTypeInferer = $paramTypeInferer; + $this->staticTypeMapper = $staticTypeMapper; } public function isReturnTypeChangeAllowed(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool { @@ -54,8 +66,11 @@ final class ParentClassMethodTypeOverrideGuard return \true; } $parametersAcceptor = \PHPStan\Reflection\ParametersAcceptorSelector::selectSingle($parentClassMethodReflection->getVariants()); - if ($parametersAcceptor instanceof \PHPStan\Reflection\FunctionVariantWithPhpDocs && !$parametersAcceptor->getNativeReturnType() instanceof \PHPStan\Type\MixedType) { - return \false; + if ($parametersAcceptor instanceof \PHPStan\Reflection\FunctionVariantWithPhpDocs) { + $parentNativeReturnType = $parametersAcceptor->getNativeReturnType(); + if (!$parentNativeReturnType instanceof \PHPStan\Type\MixedType && $classMethod->returnType !== null) { + return \false; + } } $classReflection = $parentClassMethodReflection->getDeclaringClass(); $fileName = $classReflection->getFileName(); @@ -63,8 +78,45 @@ final class ParentClassMethodTypeOverrideGuard if ($fileName === null) { return \false; } + /* + * Below verify that both current file name and parent file name is not in the /vendor/, if yes, then allowed. + * This can happen when rector run into /vendor/ directory while child and parent both are there. + */ + /** @var Scope $scope */ + $scope = $classMethod->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); + /** @var ClassReflection $currentClassReflection */ + $currentClassReflection = $scope->getClassReflection(); + /** @var string $currentFileName */ + $currentFileName = $currentClassReflection->getFileName(); + // child (current) + $normalizedCurrentFileName = $this->pathNormalizer->normalizePath($currentFileName); + $isCurrentNotInVendor = \strpos($normalizedCurrentFileName, '/vendor/') === \false; + // parent $normalizedFileName = $this->pathNormalizer->normalizePath($fileName); - return \strpos($normalizedFileName, '/vendor/') === \false; + $isParentNotInVendor = \strpos($normalizedFileName, '/vendor/') === \false; + return $isCurrentNotInVendor && $isParentNotInVendor; + } + /** + * @return \PhpParser\Node\ComplexType|\PhpParser\Node\Identifier|\PhpParser\Node\Name|null + */ + public function getParentClassMethodNodeType(\PhpParser\Node\Stmt\ClassMethod $classMethod) + { + $parentClassMethodReflection = $this->getParentClassMethod($classMethod); + if (!$parentClassMethodReflection instanceof \PHPStan\Reflection\MethodReflection) { + return null; + } + $parametersAcceptor = \PHPStan\Reflection\ParametersAcceptorSelector::selectSingle($parentClassMethodReflection->getVariants()); + if (!$parametersAcceptor instanceof \PHPStan\Reflection\FunctionVariantWithPhpDocs) { + return null; + } + $parentNativeReturnType = $parametersAcceptor->getNativeReturnType(); + if ($parentNativeReturnType instanceof \PHPStan\Type\MixedType) { + return null; + } + if ($parentNativeReturnType instanceof \PHPStan\Type\NonexistentParentClassType) { + return null; + } + return $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($parentNativeReturnType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::RETURN()); } public function hasParentClassMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool { diff --git a/rules/Naming/ValueObject/ParamRename.php b/rules/Naming/ValueObject/ParamRename.php index fc67854ad36..a0f5711c9f9 100644 --- a/rules/Naming/ValueObject/ParamRename.php +++ b/rules/Naming/ValueObject/ParamRename.php @@ -56,9 +56,9 @@ final class ParamRename implements \Rector\Naming\Contract\RenameParamValueObjec return $this->expectedName; } /** - * @return \PhpParser\Node\Expr\Closure|\PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ + * @return \PhpParser\Node\FunctionLike */ - public function getFunctionLike() + public function getFunctionLike() : \PhpParser\Node\FunctionLike { return $this->functionLike; } diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index a1b61d1bc84..48bfb11c6ba 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -16,11 +16,11 @@ final class VersionResolver /** * @var string */ - public const PACKAGE_VERSION = '2d24210c3f0bd9ae33d74c4ba429b357d5f5d193'; + public const PACKAGE_VERSION = '96cf57b15bbc4e3b9d5f2f4b58820460c7de448e'; /** * @var string */ - public const RELEASE_DATE = '2021-12-05 00:20:18'; + public const RELEASE_DATE = '2021-12-05 16:40:15'; public static function resolvePackageVersion() : string { $process = new \RectorPrefix20211205\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__); diff --git a/vendor/autoload.php b/vendor/autoload.php index 9252d111cdb..2db9457f8f0 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInit1944a655981f1ebe826ad68bf0e4dfb6::getLoader(); +return ComposerAutoloaderInit6c14fae2b8a0952c99a8fda9b3e3d035::getLoader(); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index d2dd8033478..a3a285279cf 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit1944a655981f1ebe826ad68bf0e4dfb6 +class ComposerAutoloaderInit6c14fae2b8a0952c99a8fda9b3e3d035 { private static $loader; @@ -22,15 +22,15 @@ class ComposerAutoloaderInit1944a655981f1ebe826ad68bf0e4dfb6 return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit1944a655981f1ebe826ad68bf0e4dfb6', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit6c14fae2b8a0952c99a8fda9b3e3d035', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__))); - spl_autoload_unregister(array('ComposerAutoloaderInit1944a655981f1ebe826ad68bf0e4dfb6', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit6c14fae2b8a0952c99a8fda9b3e3d035', 'loadClassLoader')); $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); if ($useStaticLoader) { require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInit1944a655981f1ebe826ad68bf0e4dfb6::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInit6c14fae2b8a0952c99a8fda9b3e3d035::getInitializer($loader)); } else { $classMap = require __DIR__ . '/autoload_classmap.php'; if ($classMap) { @@ -42,19 +42,19 @@ class ComposerAutoloaderInit1944a655981f1ebe826ad68bf0e4dfb6 $loader->register(true); if ($useStaticLoader) { - $includeFiles = Composer\Autoload\ComposerStaticInit1944a655981f1ebe826ad68bf0e4dfb6::$files; + $includeFiles = Composer\Autoload\ComposerStaticInit6c14fae2b8a0952c99a8fda9b3e3d035::$files; } else { $includeFiles = require __DIR__ . '/autoload_files.php'; } foreach ($includeFiles as $fileIdentifier => $file) { - composerRequire1944a655981f1ebe826ad68bf0e4dfb6($fileIdentifier, $file); + composerRequire6c14fae2b8a0952c99a8fda9b3e3d035($fileIdentifier, $file); } return $loader; } } -function composerRequire1944a655981f1ebe826ad68bf0e4dfb6($fileIdentifier, $file) +function composerRequire6c14fae2b8a0952c99a8fda9b3e3d035($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { require $file; diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 03a649ce8c2..c9241b5e1b5 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInit1944a655981f1ebe826ad68bf0e4dfb6 +class ComposerStaticInit6c14fae2b8a0952c99a8fda9b3e3d035 { public static $files = array ( 'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php', @@ -3798,9 +3798,9 @@ class ComposerStaticInit1944a655981f1ebe826ad68bf0e4dfb6 public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInit1944a655981f1ebe826ad68bf0e4dfb6::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInit1944a655981f1ebe826ad68bf0e4dfb6::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInit1944a655981f1ebe826ad68bf0e4dfb6::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInit6c14fae2b8a0952c99a8fda9b3e3d035::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit6c14fae2b8a0952c99a8fda9b3e3d035::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInit6c14fae2b8a0952c99a8fda9b3e3d035::$classMap; }, null, ClassLoader::class); } diff --git a/vendor/rector/rector-nette/src/Rector/Neon/RenameMethodNeonRector.php b/vendor/rector/rector-nette/src/Rector/Neon/RenameMethodNeonRector.php index f23bee89ade..c84a9b4a99d 100644 --- a/vendor/rector/rector-nette/src/Rector/Neon/RenameMethodNeonRector.php +++ b/vendor/rector/rector-nette/src/Rector/Neon/RenameMethodNeonRector.php @@ -50,7 +50,7 @@ CODE_SAMPLE * @param SetupMethodCall $node * @return \Nette\Neon\Node|null */ - public function enterNode(\RectorPrefix20211205\Nette\Neon\Node $node) + public function enterNode(\RectorPrefix20211205\Nette\Neon\Node $node) : ?\RectorPrefix20211205\Nette\Neon\Node { foreach ($this->methodCallRenameCollector->getMethodCallRenames() as $methodCallRename) { if (!\is_a($node->className, $methodCallRename->getClass(), \true)) { diff --git a/vendor/scoper-autoload.php b/vendor/scoper-autoload.php index f4fd56fb75b..2e72ec39190 100644 --- a/vendor/scoper-autoload.php +++ b/vendor/scoper-autoload.php @@ -12,8 +12,8 @@ if (!class_exists('GenerateChangelogCommand', false) && !interface_exists('Gener if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) { spl_autoload_call('RectorPrefix20211205\AutoloadIncluder'); } -if (!class_exists('ComposerAutoloaderInit1944a655981f1ebe826ad68bf0e4dfb6', false) && !interface_exists('ComposerAutoloaderInit1944a655981f1ebe826ad68bf0e4dfb6', false) && !trait_exists('ComposerAutoloaderInit1944a655981f1ebe826ad68bf0e4dfb6', false)) { - spl_autoload_call('RectorPrefix20211205\ComposerAutoloaderInit1944a655981f1ebe826ad68bf0e4dfb6'); +if (!class_exists('ComposerAutoloaderInit6c14fae2b8a0952c99a8fda9b3e3d035', false) && !interface_exists('ComposerAutoloaderInit6c14fae2b8a0952c99a8fda9b3e3d035', false) && !trait_exists('ComposerAutoloaderInit6c14fae2b8a0952c99a8fda9b3e3d035', false)) { + spl_autoload_call('RectorPrefix20211205\ComposerAutoloaderInit6c14fae2b8a0952c99a8fda9b3e3d035'); } if (!class_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !interface_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !trait_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false)) { spl_autoload_call('RectorPrefix20211205\Helmich\TypoScriptParser\Parser\AST\Statement'); @@ -81,9 +81,9 @@ if (!function_exists('print_node')) { return \RectorPrefix20211205\print_node(...func_get_args()); } } -if (!function_exists('composerRequire1944a655981f1ebe826ad68bf0e4dfb6')) { - function composerRequire1944a655981f1ebe826ad68bf0e4dfb6() { - return \RectorPrefix20211205\composerRequire1944a655981f1ebe826ad68bf0e4dfb6(...func_get_args()); +if (!function_exists('composerRequire6c14fae2b8a0952c99a8fda9b3e3d035')) { + function composerRequire6c14fae2b8a0952c99a8fda9b3e3d035() { + return \RectorPrefix20211205\composerRequire6c14fae2b8a0952c99a8fda9b3e3d035(...func_get_args()); } } if (!function_exists('scanPath')) { diff --git a/vendor/symfony/string/AbstractUnicodeString.php b/vendor/symfony/string/AbstractUnicodeString.php index 067d9a2bc69..24c15acb6cf 100644 --- a/vendor/symfony/string/AbstractUnicodeString.php +++ b/vendor/symfony/string/AbstractUnicodeString.php @@ -134,10 +134,7 @@ abstract class AbstractUnicodeString extends \RectorPrefix20211205\Symfony\Compo $str->string .= $s; return $str; } - /** - * @return $this - */ - public function camel() + public function camel() : self { $str = clone $this; $str->string = \str_replace(' ', '', \preg_replace_callback('/\\b./u', static function ($m) use(&$i) { @@ -162,10 +159,9 @@ abstract class AbstractUnicodeString extends \RectorPrefix20211205\Symfony\Compo return $codePoints; } /** - * @return $this * @param bool $compat */ - public function folded($compat = \true) + public function folded($compat = \true) : self { $str = clone $this; if (!$compat || !\defined('Normalizer::NFKC_CF')) { @@ -177,11 +173,10 @@ abstract class AbstractUnicodeString extends \RectorPrefix20211205\Symfony\Compo return $str; } /** - * @return $this * @param mixed[] $strings * @param string|null $lastGlue */ - public function join($strings, $lastGlue = null) + public function join($strings, $lastGlue = null) : self { $str = clone $this; $tail = null !== $lastGlue && 1 < \count($strings) ? $lastGlue . \array_pop($strings) : ''; @@ -191,10 +186,7 @@ abstract class AbstractUnicodeString extends \RectorPrefix20211205\Symfony\Compo } return $str; } - /** - * @return $this - */ - public function lower() + public function lower() : self { $str = clone $this; $str->string = \mb_strtolower(\str_replace('İ', 'i̇', $str->string), 'UTF-8'); @@ -248,11 +240,10 @@ abstract class AbstractUnicodeString extends \RectorPrefix20211205\Symfony\Compo return $str; } /** - * @return $this * @param int $length * @param string $padStr */ - public function padBoth($length, $padStr = ' ') + public function padBoth($length, $padStr = ' ') : self { if ('' === $padStr || !\preg_match('//u', $padStr)) { throw new \RectorPrefix20211205\Symfony\Component\String\Exception\InvalidArgumentException('Invalid UTF-8 string.'); @@ -262,11 +253,10 @@ abstract class AbstractUnicodeString extends \RectorPrefix20211205\Symfony\Compo return $this->pad($length, $pad, \STR_PAD_BOTH); } /** - * @return $this * @param int $length * @param string $padStr */ - public function padEnd($length, $padStr = ' ') + public function padEnd($length, $padStr = ' ') : self { if ('' === $padStr || !\preg_match('//u', $padStr)) { throw new \RectorPrefix20211205\Symfony\Component\String\Exception\InvalidArgumentException('Invalid UTF-8 string.'); @@ -276,11 +266,10 @@ abstract class AbstractUnicodeString extends \RectorPrefix20211205\Symfony\Compo return $this->pad($length, $pad, \STR_PAD_RIGHT); } /** - * @return $this * @param int $length * @param string $padStr */ - public function padStart($length, $padStr = ' ') + public function padStart($length, $padStr = ' ') : self { if ('' === $padStr || !\preg_match('//u', $padStr)) { throw new \RectorPrefix20211205\Symfony\Component\String\Exception\InvalidArgumentException('Invalid UTF-8 string.'); @@ -291,10 +280,9 @@ abstract class AbstractUnicodeString extends \RectorPrefix20211205\Symfony\Compo } /** * @param callable|string $to - * @return $this * @param string $fromRegexp */ - public function replaceMatches($fromRegexp, $to) + public function replaceMatches($fromRegexp, $to) : self { if ($this->ignoreCase) { $fromRegexp .= 'i'; @@ -333,29 +321,22 @@ abstract class AbstractUnicodeString extends \RectorPrefix20211205\Symfony\Compo $str->string = $string; return $str; } - /** - * @return $this - */ - public function reverse() + public function reverse() : self { $str = clone $this; $str->string = \implode('', \array_reverse(\preg_split('/(\\X)/u', $str->string, -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY))); return $str; } - /** - * @return $this - */ - public function snake() + public function snake() : self { $str = $this->camel()->title(); $str->string = \mb_strtolower(\preg_replace(['/(\\p{Lu}+)(\\p{Lu}\\p{Ll})/u', '/([\\p{Ll}0-9])(\\p{Lu})/u'], 'RectorPrefix20211205\\1_\\2', $str->string), 'UTF-8'); return $str; } /** - * @return $this * @param bool $allWords */ - public function title($allWords = \false) + public function title($allWords = \false) : self { $str = clone $this; $limit = $allWords ? -1 : 1; @@ -365,10 +346,9 @@ abstract class AbstractUnicodeString extends \RectorPrefix20211205\Symfony\Compo return $str; } /** - * @return $this * @param string $chars */ - public function trim($chars = " \t\n\r\0\v\f ") + public function trim($chars = " \t\n\r\0\v\f ") : self { if (" \t\n\r\0\v\f " !== $chars && !\preg_match('//u', $chars)) { throw new \RectorPrefix20211205\Symfony\Component\String\Exception\InvalidArgumentException('Invalid UTF-8 chars.'); @@ -379,10 +359,9 @@ abstract class AbstractUnicodeString extends \RectorPrefix20211205\Symfony\Compo return $str; } /** - * @return $this * @param string $chars */ - public function trimEnd($chars = " \t\n\r\0\v\f ") + public function trimEnd($chars = " \t\n\r\0\v\f ") : self { if (" \t\n\r\0\v\f " !== $chars && !\preg_match('//u', $chars)) { throw new \RectorPrefix20211205\Symfony\Component\String\Exception\InvalidArgumentException('Invalid UTF-8 chars.'); @@ -392,10 +371,7 @@ abstract class AbstractUnicodeString extends \RectorPrefix20211205\Symfony\Compo $str->string = \preg_replace("{[{$chars}]++\$}uD", '', $str->string); return $str; } - /** - * @return $this - */ - public function trimPrefix($prefix) + public function trimPrefix($prefix) : self { if (!$this->ignoreCase) { return parent::trimPrefix($prefix); @@ -411,10 +387,9 @@ abstract class AbstractUnicodeString extends \RectorPrefix20211205\Symfony\Compo return $str; } /** - * @return $this * @param string $chars */ - public function trimStart($chars = " \t\n\r\0\v\f ") + public function trimStart($chars = " \t\n\r\0\v\f ") : self { if (" \t\n\r\0\v\f " !== $chars && !\preg_match('//u', $chars)) { throw new \RectorPrefix20211205\Symfony\Component\String\Exception\InvalidArgumentException('Invalid UTF-8 chars.'); @@ -424,10 +399,7 @@ abstract class AbstractUnicodeString extends \RectorPrefix20211205\Symfony\Compo $str->string = \preg_replace("{^[{$chars}]++}uD", '', $str->string); return $str; } - /** - * @return $this - */ - public function trimSuffix($suffix) + public function trimSuffix($suffix) : self { if (!$this->ignoreCase) { return parent::trimSuffix($suffix); @@ -442,10 +414,7 @@ abstract class AbstractUnicodeString extends \RectorPrefix20211205\Symfony\Compo $str->string = \preg_replace("{(?:{$suffix})\$}iuD", '', $this->string); return $str; } - /** - * @return $this - */ - public function upper() + public function upper() : self { $str = clone $this; $str->string = \mb_strtoupper($str->string, 'UTF-8'); diff --git a/vendor/symfony/string/ByteString.php b/vendor/symfony/string/ByteString.php index acfefa4b43c..16e645734ff 100644 --- a/vendor/symfony/string/ByteString.php +++ b/vendor/symfony/string/ByteString.php @@ -88,19 +88,15 @@ class ByteString extends \RectorPrefix20211205\Symfony\Component\String\Abstract return '' === $str ? [] : [\ord($str)]; } /** - * @return $this * @param string ...$suffix */ - public function append(...$suffix) + public function append(...$suffix) : self { $str = clone $this; $str->string .= 1 >= \count($suffix) ? $suffix[0] ?? '' : \implode('', $suffix); return $str; } - /** - * @return $this - */ - public function camel() + public function camel() : self { $str = clone $this; $str->string = \lcfirst(\str_replace(' ', '', \ucwords(\preg_replace('/[^a-zA-Z0-9\\x7f-\\xff]++/', ' ', $this->string)))); @@ -152,10 +148,7 @@ class ByteString extends \RectorPrefix20211205\Symfony\Component\String\Abstract } return $string === $this->string; } - /** - * @return $this - */ - public function folded() + public function folded() : self { $str = clone $this; $str->string = \strtolower($str->string); @@ -200,11 +193,10 @@ class ByteString extends \RectorPrefix20211205\Symfony\Component\String\Abstract return '' === $this->string || \preg_match('//u', $this->string); } /** - * @return $this * @param mixed[] $strings * @param string|null $lastGlue */ - public function join($strings, $lastGlue = null) + public function join($strings, $lastGlue = null) : self { $str = clone $this; $tail = null !== $lastGlue && 1 < \count($strings) ? $lastGlue . \array_pop($strings) : ''; @@ -215,10 +207,7 @@ class ByteString extends \RectorPrefix20211205\Symfony\Component\String\Abstract { return \strlen($this->string); } - /** - * @return $this - */ - public function lower() + public function lower() : self { $str = clone $this; $str->string = \strtolower($str->string); @@ -259,54 +248,49 @@ class ByteString extends \RectorPrefix20211205\Symfony\Component\String\Abstract return $matches; } /** - * @return $this * @param int $length * @param string $padStr */ - public function padBoth($length, $padStr = ' ') + public function padBoth($length, $padStr = ' ') : self { $str = clone $this; $str->string = \str_pad($this->string, $length, $padStr, \STR_PAD_BOTH); return $str; } /** - * @return $this * @param int $length * @param string $padStr */ - public function padEnd($length, $padStr = ' ') + public function padEnd($length, $padStr = ' ') : self { $str = clone $this; $str->string = \str_pad($this->string, $length, $padStr, \STR_PAD_RIGHT); return $str; } /** - * @return $this * @param int $length * @param string $padStr */ - public function padStart($length, $padStr = ' ') + public function padStart($length, $padStr = ' ') : self { $str = clone $this; $str->string = \str_pad($this->string, $length, $padStr, \STR_PAD_LEFT); return $str; } /** - * @return $this * @param string ...$prefix */ - public function prepend(...$prefix) + public function prepend(...$prefix) : self { $str = clone $this; $str->string = (1 >= \count($prefix) ? $prefix[0] ?? '' : \implode('', $prefix)) . $str->string; return $str; } /** - * @return $this * @param string $from * @param string $to */ - public function replace($from, $to) + public function replace($from, $to) : self { $str = clone $this; if ('' !== $from) { @@ -316,10 +300,9 @@ class ByteString extends \RectorPrefix20211205\Symfony\Component\String\Abstract } /** * @param callable|string $to - * @return $this * @param string $fromRegexp */ - public function replaceMatches($fromRegexp, $to) + public function replaceMatches($fromRegexp, $to) : self { if ($this->ignoreCase) { $fromRegexp .= 'i'; @@ -345,42 +328,34 @@ class ByteString extends \RectorPrefix20211205\Symfony\Component\String\Abstract $str->string = $string; return $str; } - /** - * @return $this - */ - public function reverse() + public function reverse() : self { $str = clone $this; $str->string = \strrev($str->string); return $str; } /** - * @return $this * @param int $start * @param int|null $length */ - public function slice($start = 0, $length = null) + public function slice($start = 0, $length = null) : self { $str = clone $this; $str->string = (string) \substr($this->string, $start, $length ?? \PHP_INT_MAX); return $str; } - /** - * @return $this - */ - public function snake() + public function snake() : self { $str = $this->camel()->title(); $str->string = \strtolower(\preg_replace(['/([A-Z]+)([A-Z][a-z])/', '/([a-z\\d])([A-Z])/'], 'RectorPrefix20211205\\1_\\2', $str->string)); return $str; } /** - * @return $this * @param string $replacement * @param int $start * @param int|null $length */ - public function splice($replacement, $start = 0, $length = null) + public function splice($replacement, $start = 0, $length = null) : self { $str = clone $this; $str->string = \substr_replace($this->string, $replacement, $start, $length ?? \PHP_INT_MAX); @@ -423,10 +398,9 @@ class ByteString extends \RectorPrefix20211205\Symfony\Component\String\Abstract return '' !== $prefix && 0 === ($this->ignoreCase ? \strncasecmp($this->string, $prefix, \strlen($prefix)) : \strncmp($this->string, $prefix, \strlen($prefix))); } /** - * @return $this * @param bool $allWords */ - public function title($allWords = \false) + public function title($allWords = \false) : self { $str = clone $this; $str->string = $allWords ? \ucwords($str->string) : \ucfirst($str->string); @@ -472,39 +446,33 @@ class ByteString extends \RectorPrefix20211205\Symfony\Component\String\Abstract return $u; } /** - * @return $this * @param string $chars */ - public function trim($chars = " \t\n\r\0\v\f") + public function trim($chars = " \t\n\r\0\v\f") : self { $str = clone $this; $str->string = \trim($str->string, $chars); return $str; } /** - * @return $this * @param string $chars */ - public function trimEnd($chars = " \t\n\r\0\v\f") + public function trimEnd($chars = " \t\n\r\0\v\f") : self { $str = clone $this; $str->string = \rtrim($str->string, $chars); return $str; } /** - * @return $this * @param string $chars */ - public function trimStart($chars = " \t\n\r\0\v\f") + public function trimStart($chars = " \t\n\r\0\v\f") : self { $str = clone $this; $str->string = \ltrim($str->string, $chars); return $str; } - /** - * @return $this - */ - public function upper() + public function upper() : self { $str = clone $this; $str->string = \strtoupper($str->string); diff --git a/vendor/symfony/string/CodePointString.php b/vendor/symfony/string/CodePointString.php index d58be21cc87..0345f984549 100644 --- a/vendor/symfony/string/CodePointString.php +++ b/vendor/symfony/string/CodePointString.php @@ -30,10 +30,9 @@ class CodePointString extends \RectorPrefix20211205\Symfony\Component\String\Abs $this->string = $string; } /** - * @return $this * @param string ...$suffix */ - public function append(...$suffix) + public function append(...$suffix) : self { $str = clone $this; $str->string .= 1 >= \count($suffix) ? $suffix[0] ?? '' : \implode('', $suffix); @@ -147,10 +146,9 @@ class CodePointString extends \RectorPrefix20211205\Symfony\Component\String\Abs return \mb_strlen($this->string, 'UTF-8'); } /** - * @return $this * @param string ...$prefix */ - public function prepend(...$prefix) + public function prepend(...$prefix) : self { $str = clone $this; $str->string = (1 >= \count($prefix) ? $prefix[0] ?? '' : \implode('', $prefix)) . $this->string; @@ -160,11 +158,10 @@ class CodePointString extends \RectorPrefix20211205\Symfony\Component\String\Abs return $str; } /** - * @return $this * @param string $from * @param string $to */ - public function replace($from, $to) + public function replace($from, $to) : self { $str = clone $this; if ('' === $from || !\preg_match('//u', $from)) { @@ -181,23 +178,21 @@ class CodePointString extends \RectorPrefix20211205\Symfony\Component\String\Abs return $str; } /** - * @return $this * @param int $start * @param int|null $length */ - public function slice($start = 0, $length = null) + public function slice($start = 0, $length = null) : self { $str = clone $this; $str->string = \mb_substr($this->string, $start, $length, 'UTF-8'); return $str; } /** - * @return $this * @param string $replacement * @param int $start * @param int|null $length */ - public function splice($replacement, $start = 0, $length = null) + public function splice($replacement, $start = 0, $length = null) : self { if (!\preg_match('//u', $replacement)) { throw new \RectorPrefix20211205\Symfony\Component\String\Exception\InvalidArgumentException('Invalid UTF-8 string.'); diff --git a/vendor/symfony/string/UnicodeString.php b/vendor/symfony/string/UnicodeString.php index 0d0f852bf33..97d59fbaaf0 100644 --- a/vendor/symfony/string/UnicodeString.php +++ b/vendor/symfony/string/UnicodeString.php @@ -38,10 +38,9 @@ class UnicodeString extends \RectorPrefix20211205\Symfony\Component\String\Abstr } } /** - * @return $this * @param string ...$suffix */ - public function append(...$suffix) + public function append(...$suffix) : self { $str = clone $this; $str->string = $this->string . (1 >= \count($suffix) ? $suffix[0] ?? '' : \implode('', $suffix)); @@ -164,11 +163,10 @@ class UnicodeString extends \RectorPrefix20211205\Symfony\Component\String\Abstr return \false === $i ? null : $i; } /** - * @return $this * @param mixed[] $strings * @param string|null $lastGlue */ - public function join($strings, $lastGlue = null) + public function join($strings, $lastGlue = null) : self { $str = parent::join($strings, $lastGlue); \normalizer_is_normalized($str->string) ?: ($str->string = \normalizer_normalize($str->string)); @@ -179,10 +177,9 @@ class UnicodeString extends \RectorPrefix20211205\Symfony\Component\String\Abstr return \grapheme_strlen($this->string); } /** - * @return $this * @param int $form */ - public function normalize($form = self::NFC) + public function normalize($form = self::NFC) : self { $str = clone $this; if (\in_array($form, [self::NFC, self::NFKC], \true)) { @@ -196,10 +193,9 @@ class UnicodeString extends \RectorPrefix20211205\Symfony\Component\String\Abstr return $str; } /** - * @return $this * @param string ...$prefix */ - public function prepend(...$prefix) + public function prepend(...$prefix) : self { $str = clone $this; $str->string = (1 >= \count($prefix) ? $prefix[0] ?? '' : \implode('', $prefix)) . $this->string; @@ -210,11 +206,10 @@ class UnicodeString extends \RectorPrefix20211205\Symfony\Component\String\Abstr return $str; } /** - * @return $this * @param string $from * @param string $to */ - public function replace($from, $to) + public function replace($from, $to) : self { $str = clone $this; \normalizer_is_normalized($from) ?: ($from = \normalizer_normalize($from)); @@ -237,33 +232,30 @@ class UnicodeString extends \RectorPrefix20211205\Symfony\Component\String\Abstr } /** * @param callable|string $to - * @return $this * @param string $fromRegexp */ - public function replaceMatches($fromRegexp, $to) + public function replaceMatches($fromRegexp, $to) : self { $str = parent::replaceMatches($fromRegexp, $to); \normalizer_is_normalized($str->string) ?: ($str->string = \normalizer_normalize($str->string)); return $str; } /** - * @return $this * @param int $start * @param int|null $length */ - public function slice($start = 0, $length = null) + public function slice($start = 0, $length = null) : self { $str = clone $this; $str->string = (string) \grapheme_substr($this->string, $start, $length ?? 2147483647); return $str; } /** - * @return $this * @param string $replacement * @param int $start * @param int|null $length */ - public function splice($replacement, $start = 0, $length = null) + public function splice($replacement, $start = 0, $length = null) : self { $str = clone $this; $start = $start ? \strlen(\grapheme_substr($this->string, 0, $start)) : 0;