mirror of
https://github.com/rectorphp/rector.git
synced 2024-05-28 23:10:51 +00:00
Updated Rector to commit 39a530c1f5
39a530c1f5
[DX] Add strict PHPStan rules - step #2 (#1330)
This commit is contained in:
parent
0562d594e0
commit
3d98187ea1
|
@ -113,12 +113,12 @@ CODE_SAMPLE
|
|||
return null;
|
||||
}
|
||||
/**
|
||||
* @param array<string, ArgumentAdder[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$addedArguments = $configuration[self::ADDED_ARGUMENTS] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($addedArguments, \Rector\Arguments\ValueObject\ArgumentAdder::class);
|
||||
$addedArguments = $configuration[self::ADDED_ARGUMENTS] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($addedArguments, \Rector\Arguments\ValueObject\ArgumentAdder::class);
|
||||
$this->addedArguments = $addedArguments;
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -72,12 +72,12 @@ CODE_SAMPLE
|
|||
return $node;
|
||||
}
|
||||
/**
|
||||
* @param array<string, ReplaceArgumentDefaultValue[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$replacedArguments = $configuration[self::REPLACED_ARGUMENTS] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($replacedArguments, \Rector\Arguments\ValueObject\ReplaceArgumentDefaultValue::class);
|
||||
$replacedArguments = $configuration[self::REPLACED_ARGUMENTS] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($replacedArguments, \Rector\Arguments\ValueObject\ReplaceArgumentDefaultValue::class);
|
||||
$this->replacedArguments = $replacedArguments;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,12 +67,12 @@ CODE_SAMPLE
|
|||
return $node;
|
||||
}
|
||||
/**
|
||||
* @param array<string, ReplaceFuncCallArgumentDefaultValue[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$replacedArguments = $configuration[self::REPLACED_ARGUMENTS] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($replacedArguments, \Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue::class);
|
||||
$replacedArguments = $configuration[self::REPLACED_ARGUMENTS] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($replacedArguments, \Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue::class);
|
||||
$this->replacedArguments = $replacedArguments;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,12 +84,12 @@ CODE_SAMPLE
|
|||
return null;
|
||||
}
|
||||
/**
|
||||
* @param array<string, SwapFuncCallArguments[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$functionArgumentSwaps = $configuration[self::FUNCTION_ARGUMENT_SWAPS] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($functionArgumentSwaps, \Rector\Arguments\ValueObject\SwapFuncCallArguments::class);
|
||||
$functionArgumentSwaps = $configuration[self::FUNCTION_ARGUMENT_SWAPS] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($functionArgumentSwaps, \Rector\Arguments\ValueObject\SwapFuncCallArguments::class);
|
||||
$this->functionArgumentSwaps = $functionArgumentSwaps;
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -82,11 +82,12 @@ CODE_SAMPLE
|
|||
return null;
|
||||
}
|
||||
/**
|
||||
* @param array<string, string[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$groupNamesBySuffix = $configuration[self::GROUP_NAMES_BY_SUFFIX] ?? ($configuration ?: []);
|
||||
$groupNamesBySuffix = $configuration[self::GROUP_NAMES_BY_SUFFIX] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::isArray($groupNamesBySuffix);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allString($groupNamesBySuffix);
|
||||
$this->groupNamesBySuffix = $groupNamesBySuffix;
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ CODE_SAMPLE
|
|||
return null;
|
||||
}
|
||||
/**
|
||||
* @param array<string, mixed> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
|
|
|
@ -77,11 +77,11 @@ CODE_SAMPLE
|
|||
return $node;
|
||||
}
|
||||
/**
|
||||
* @param array<string, mixed> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$attributesOrder = $configuration[self::ATTRIBUTES_ORDER] ?? ($configuration ?: []);
|
||||
$attributesOrder = $configuration[self::ATTRIBUTES_ORDER] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::isArray($attributesOrder);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allString($attributesOrder);
|
||||
$this->attributesOrderByName = \array_flip($attributesOrder);
|
||||
|
|
|
@ -108,12 +108,12 @@ CODE_SAMPLE
|
|||
return $node;
|
||||
}
|
||||
/**
|
||||
* @param array<string, ReturnArrayClassMethodToYield[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$methodsToYields = $configuration[self::METHODS_TO_YIELDS] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($methodsToYields, \Rector\CodingStyle\ValueObject\ReturnArrayClassMethodToYield::class);
|
||||
$methodsToYields = $configuration[self::METHODS_TO_YIELDS] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($methodsToYields, \Rector\CodingStyle\ValueObject\ReturnArrayClassMethodToYield::class);
|
||||
$this->methodsToYields = $methodsToYields;
|
||||
}
|
||||
private function collectReturnArrayNodesFromClassMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod) : ?\PhpParser\Node\Expr\Array_
|
||||
|
|
|
@ -89,7 +89,7 @@ CODE_SAMPLE
|
|||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$typeToPreference = $configuration[self::TYPE_TO_PREFERENCE] ?? ($configuration ?: []);
|
||||
$typeToPreference = $configuration[self::TYPE_TO_PREFERENCE] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($typeToPreference, \Rector\CodingStyle\Enum\PreferenceSelfThis::class);
|
||||
$this->typeToPreference = $typeToPreference;
|
||||
}
|
||||
|
|
|
@ -53,12 +53,12 @@ CODE_SAMPLE
|
|||
, [self::PACKAGES_AND_VERSIONS => [new \Rector\Composer\ValueObject\PackageAndVersion('symfony/console', '^3.4')]])]);
|
||||
}
|
||||
/**
|
||||
* @param array<string, PackageAndVersion[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$packagesAndVersions = $configuration[self::PACKAGES_AND_VERSIONS] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($packagesAndVersions, \Rector\Composer\ValueObject\PackageAndVersion::class);
|
||||
$packagesAndVersions = $configuration[self::PACKAGES_AND_VERSIONS] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($packagesAndVersions, \Rector\Composer\ValueObject\PackageAndVersion::class);
|
||||
$this->versionGuard->validate($packagesAndVersions);
|
||||
$this->packagesAndVersions = $packagesAndVersions;
|
||||
}
|
||||
|
|
|
@ -53,12 +53,12 @@ CODE_SAMPLE
|
|||
, [self::PACKAGES_AND_VERSIONS => [new \Rector\Composer\ValueObject\PackageAndVersion('symfony/console', '^3.4')]])]);
|
||||
}
|
||||
/**
|
||||
* @param array<string, PackageAndVersion[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$packagesAndVersions = $configuration[self::PACKAGES_AND_VERSIONS] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($packagesAndVersions, \Rector\Composer\ValueObject\PackageAndVersion::class);
|
||||
$packagesAndVersions = $configuration[self::PACKAGES_AND_VERSIONS] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($packagesAndVersions, \Rector\Composer\ValueObject\PackageAndVersion::class);
|
||||
$this->versionGuard->validate($packagesAndVersions);
|
||||
$this->packageAndVersions = $packagesAndVersions;
|
||||
}
|
||||
|
|
|
@ -56,12 +56,12 @@ CODE_SAMPLE
|
|||
, [self::PACKAGES_AND_VERSIONS => [new \Rector\Composer\ValueObject\PackageAndVersion('symfony/console', '^4.4')]])]);
|
||||
}
|
||||
/**
|
||||
* @param array<string, PackageAndVersion[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$packagesAndVersions = $configuration[self::PACKAGES_AND_VERSIONS] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($packagesAndVersions, \Rector\Composer\ValueObject\PackageAndVersion::class);
|
||||
$packagesAndVersions = $configuration[self::PACKAGES_AND_VERSIONS] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($packagesAndVersions, \Rector\Composer\ValueObject\PackageAndVersion::class);
|
||||
$this->versionGuard->validate($packagesAndVersions);
|
||||
$this->packagesAndVersions = $packagesAndVersions;
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ CODE_SAMPLE
|
|||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$packagesNames = $configuration[self::PACKAGE_NAMES] ?? ($configuration ?: []);
|
||||
$packagesNames = $configuration[self::PACKAGE_NAMES] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::isArray($packagesNames);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allString($packagesNames);
|
||||
$this->packageNames = $packagesNames;
|
||||
|
|
|
@ -54,12 +54,12 @@ CODE_SAMPLE
|
|||
, [self::RENAME_PACKAGES => [new \Rector\Composer\ValueObject\RenamePackage('rector/rector', 'rector/rector-src')]])]);
|
||||
}
|
||||
/**
|
||||
* @param array<string, RenamePackage[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$renamePackages = $configuration[self::RENAME_PACKAGES] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($renamePackages, \Rector\Composer\ValueObject\RenamePackage::class);
|
||||
$renamePackages = $configuration[self::RENAME_PACKAGES] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($renamePackages, \Rector\Composer\ValueObject\RenamePackage::class);
|
||||
$this->renamePackages = $renamePackages;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,12 +56,12 @@ CODE_SAMPLE
|
|||
, [self::REPLACE_PACKAGES_AND_VERSIONS => [new \Rector\Composer\ValueObject\ReplacePackageAndVersion('symfony/console', 'symfony/http-kernel', '^4.4')]])]);
|
||||
}
|
||||
/**
|
||||
* @param array<string, ReplacePackageAndVersion[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$replacePackagesAndVersions = $configuration[self::REPLACE_PACKAGES_AND_VERSIONS] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($replacePackagesAndVersions, \Rector\Composer\ValueObject\ReplacePackageAndVersion::class);
|
||||
$replacePackagesAndVersions = $configuration[self::REPLACE_PACKAGES_AND_VERSIONS] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($replacePackagesAndVersions, \Rector\Composer\ValueObject\ReplacePackageAndVersion::class);
|
||||
$this->versionGuard->validate($replacePackagesAndVersions);
|
||||
$this->replacePackagesAndVersions = $replacePackagesAndVersions;
|
||||
}
|
||||
|
|
|
@ -84,11 +84,12 @@ CODE_SAMPLE
|
|||
return null;
|
||||
}
|
||||
/**
|
||||
* @param array<string, string[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$annotationsToRemove = $configuration[self::ANNOTATIONS_TO_REMOVE] ?? ($configuration ?: []);
|
||||
$annotationsToRemove = $configuration[self::ANNOTATIONS_TO_REMOVE] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::isArray($annotationsToRemove);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allString($annotationsToRemove);
|
||||
$this->annotationsToRemove = $annotationsToRemove;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ final class RemovePhpVersionIdCheckRector extends \Rector\Core\Rector\AbstractRe
|
|||
$this->phpVersionFactory = $phpVersionFactory;
|
||||
}
|
||||
/**
|
||||
* @param array<string, int|string> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
|
|
|
@ -91,7 +91,7 @@ CODE_SAMPLE
|
|||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$methodsByParentTypes = $configuration[self::METHODS_BY_PARENT_TYPES] ?? ($configuration ?: []);
|
||||
$methodsByParentTypes = $configuration[self::METHODS_BY_PARENT_TYPES] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allString(\array_keys($methodsByParentTypes));
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allString($methodsByParentTypes);
|
||||
/** @var array<string, string> $methodsByParentTypes */
|
||||
|
|
|
@ -137,15 +137,15 @@ CODE_SAMPLE
|
|||
return $this->processRemoveParamTypeFromMethod($classReflection, $node);
|
||||
}
|
||||
/**
|
||||
* @param array<string, mixed> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$safeTypes = $configuration[self::SAFE_TYPES] ?? ($configuration ?: []);
|
||||
$safeTypes = $configuration[self::SAFE_TYPES] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::isArray($safeTypes);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allString($safeTypes);
|
||||
$this->safeTypes = $safeTypes;
|
||||
$safeTypesToMethods = $configuration[self::SAFE_TYPES_TO_METHODS] ?? ($configuration ?: []);
|
||||
$safeTypesToMethods = $configuration[self::SAFE_TYPES_TO_METHODS] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::isArray($safeTypesToMethods);
|
||||
foreach ($safeTypesToMethods as $key => $value) {
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::string($key);
|
||||
|
|
|
@ -104,12 +104,12 @@ CODE_SAMPLE
|
|||
return $node;
|
||||
}
|
||||
/**
|
||||
* @param array<string, DowngradeAttributeToAnnotation[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$attributesToAnnotations = $configuration[self::ATTRIBUTE_TO_ANNOTATION] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($attributesToAnnotations, \Rector\DowngradePhp80\ValueObject\DowngradeAttributeToAnnotation::class);
|
||||
$attributesToAnnotations = $configuration[self::ATTRIBUTE_TO_ANNOTATION] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($attributesToAnnotations, \Rector\DowngradePhp80\ValueObject\DowngradeAttributeToAnnotation::class);
|
||||
$this->attributesToAnnotations = $attributesToAnnotations;
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -116,7 +116,7 @@ CODE_SAMPLE
|
|||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$makeClassMethodGenerics = $configuration[self::GENERIC_CLASS_METHOD_PARAMS] ?? ($configuration ?: []);
|
||||
$makeClassMethodGenerics = $configuration[self::GENERIC_CLASS_METHOD_PARAMS] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($makeClassMethodGenerics, \Rector\Generics\ValueObject\GenericClassMethodParam::class);
|
||||
$this->genericClassMethodParams = $makeClassMethodGenerics;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,9 @@ declare (strict_types=1);
|
|||
namespace Rector\Naming\Contract\Guard;
|
||||
|
||||
use Rector\Naming\Contract\RenameValueObjectInterface;
|
||||
/**
|
||||
* @template TRename as RenameValueObjectInterface
|
||||
*/
|
||||
interface ConflictingNameGuardInterface
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -11,6 +11,9 @@ use Rector\Naming\Contract\RenameValueObjectInterface;
|
|||
use Rector\Naming\ValueObject\PropertyRename;
|
||||
use Rector\NodeTypeResolver\NodeTypeResolver;
|
||||
use Rector\PHPStanStaticTypeMapper\Utils\TypeUnwrapper;
|
||||
/**
|
||||
* @implements ConflictingNameGuardInterface<PropertyRename>
|
||||
*/
|
||||
final class DateTimeAtNamingConventionGuard implements \Rector\Naming\Contract\Guard\ConflictingNameGuardInterface
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -7,6 +7,9 @@ use PHPStan\Reflection\ReflectionProvider;
|
|||
use Rector\Naming\Contract\Guard\ConflictingNameGuardInterface;
|
||||
use Rector\Naming\Contract\RenameValueObjectInterface;
|
||||
use Rector\Naming\ValueObject\PropertyRename;
|
||||
/**
|
||||
* @implements ConflictingNameGuardInterface<PropertyRename>
|
||||
*/
|
||||
final class HasMagicGetSetGuard implements \Rector\Naming\Contract\Guard\ConflictingNameGuardInterface
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -6,6 +6,9 @@ namespace Rector\Naming\Guard;
|
|||
use Rector\Naming\Contract\Guard\ConflictingNameGuardInterface;
|
||||
use Rector\Naming\Contract\RenameValueObjectInterface;
|
||||
use Rector\Naming\ValueObject\PropertyRename;
|
||||
/**
|
||||
* @implements ConflictingNameGuardInterface<PropertyRename>
|
||||
*/
|
||||
final class NotPrivatePropertyGuard implements \Rector\Naming\Contract\Guard\ConflictingNameGuardInterface
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -8,6 +8,9 @@ use Rector\Naming\Contract\Guard\ConflictingNameGuardInterface;
|
|||
use Rector\Naming\Contract\RenameValueObjectInterface;
|
||||
use Rector\Naming\ValueObject\PropertyRename;
|
||||
use Rector\NodeTypeResolver\NodeTypeResolver;
|
||||
/**
|
||||
* @implements ConflictingNameGuardInterface<PropertyRename>
|
||||
*/
|
||||
final class RamseyUuidInterfaceGuard implements \Rector\Naming\Contract\Guard\ConflictingNameGuardInterface
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
declare (strict_types=1);
|
||||
namespace Rector\Naming\PhpArray;
|
||||
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
final class ArrayFilter
|
||||
{
|
||||
/**
|
||||
|
@ -20,9 +19,6 @@ final class ArrayFilter
|
|||
if ($count < 2) {
|
||||
continue;
|
||||
}
|
||||
if (!\is_string($value)) {
|
||||
throw new \Rector\Core\Exception\ShouldNotHappenException();
|
||||
}
|
||||
$duplicatedValues[] = $value;
|
||||
}
|
||||
return $duplicatedValues;
|
||||
|
|
|
@ -102,11 +102,12 @@ CODE_SAMPLE
|
|||
return new \PhpParser\Node\Expr\ClassConstFetch($fullyQualified, 'class');
|
||||
}
|
||||
/**
|
||||
* @param array<string, string[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$classesToSkip = $configuration[self::CLASSES_TO_SKIP] ?? ($configuration ?: []);
|
||||
$classesToSkip = $configuration[self::CLASSES_TO_SKIP] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::isArray($classesToSkip);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allString($classesToSkip);
|
||||
$this->classesToSkip = $classesToSkip;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ use RectorPrefix20211128\Nette\Utils\Strings;
|
|||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\BinaryOp\Concat;
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\PhpParser\Node\Value\ValueResolver;
|
||||
final class RegexMatcher
|
||||
{
|
||||
|
@ -37,9 +36,6 @@ final class RegexMatcher
|
|||
return null;
|
||||
}
|
||||
$delimiter = $pattern[0];
|
||||
if (!\is_string($delimiter)) {
|
||||
throw new \Rector\Core\Exception\ShouldNotHappenException();
|
||||
}
|
||||
/** @var string $modifiers */
|
||||
$modifiers = \RectorPrefix20211128\Nette\Utils\Strings::after($pattern, $delimiter, -1);
|
||||
if (\strpos($modifiers, 'e') === \false) {
|
||||
|
|
|
@ -70,7 +70,7 @@ CODE_SAMPLE
|
|||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$reservedKeywordsToReplacements = $configuration[self::RESERVED_KEYWORDS_TO_REPLACEMENTS] ?? ($configuration ?: []);
|
||||
$reservedKeywordsToReplacements = $configuration[self::RESERVED_KEYWORDS_TO_REPLACEMENTS] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::isArray($reservedKeywordsToReplacements);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allString(\array_keys($reservedKeywordsToReplacements));
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allString($reservedKeywordsToReplacements);
|
||||
|
|
|
@ -68,12 +68,12 @@ CODE_SAMPLE
|
|||
/** @var FuncCall $eachFuncCall */
|
||||
$eachFuncCall = $node->expr;
|
||||
// only key: list($key, ) = each($values);
|
||||
if ($listNode->items[0] && $listNode->items[1] === null) {
|
||||
if ($listNode->items[0] instanceof \PhpParser\Node\Expr\ArrayItem && $listNode->items[1] === null) {
|
||||
$keyFuncCall = $this->nodeFactory->createFuncCall('key', $eachFuncCall->args);
|
||||
return new \PhpParser\Node\Expr\Assign($listNode->items[0]->value, $keyFuncCall);
|
||||
}
|
||||
// only value: list(, $value) = each($values);
|
||||
if ($listNode->items[1] && $listNode->items[0] === null) {
|
||||
if ($listNode->items[1] instanceof \PhpParser\Node\Expr\ArrayItem && $listNode->items[0] === null) {
|
||||
$nextFuncCall = $this->nodeFactory->createFuncCall('next', $eachFuncCall->args);
|
||||
$this->nodesToAddCollector->addNodeAfterNode($nextFuncCall, $node);
|
||||
$currentFuncCall = $this->nodeFactory->createFuncCall('current', $eachFuncCall->args);
|
||||
|
|
|
@ -96,7 +96,7 @@ CODE_SAMPLE
|
|||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$reservedNamesToNewOnes = $configuration[self::RESERVED_NAMES_TO_NEW_ONES] ?? ($configuration ?: []);
|
||||
$reservedNamesToNewOnes = $configuration[self::RESERVED_NAMES_TO_NEW_ONES] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allString(\array_keys($reservedNamesToNewOnes));
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allString($reservedNamesToNewOnes);
|
||||
/** @var array<string, string> $reservedNamesToNewOnes */
|
||||
|
|
|
@ -45,7 +45,7 @@ final class AddLiteralSeparatorToNumberRector extends \Rector\Core\Rector\Abstra
|
|||
*/
|
||||
private $limitValue = self::DEFAULT_LIMIT_VALUE;
|
||||
/**
|
||||
* @param array<string, int> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
|
|
|
@ -156,7 +156,7 @@ CODE_SAMPLE
|
|||
if ($methodCall->var instanceof \PhpParser\Node\Expr\Variable) {
|
||||
$variableName = $this->getName($methodCall->var);
|
||||
$methodName = $this->getName($methodCall->name);
|
||||
if (!$variableName) {
|
||||
if (!\is_string($variableName)) {
|
||||
return;
|
||||
}
|
||||
if (!$methodName) {
|
||||
|
|
|
@ -184,7 +184,7 @@ CODE_SAMPLE
|
|||
return $node;
|
||||
}
|
||||
/**
|
||||
* @param array<string, bool> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
|
|
|
@ -4,14 +4,15 @@ declare (strict_types=1);
|
|||
namespace Rector\Php80\Contract;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\BinaryOp;
|
||||
use PhpParser\Node\Expr\BinaryOp\Identical;
|
||||
use PhpParser\Node\Expr\BinaryOp\NotIdentical;
|
||||
use PhpParser\Node\Expr\BooleanNot;
|
||||
use PhpParser\Node\Expr\FuncCall;
|
||||
use Rector\Php80\ValueObject\StrStartsWith;
|
||||
interface StrStartWithMatchAndRefactorInterface
|
||||
{
|
||||
/**
|
||||
* @param \PhpParser\Node\Expr\BinaryOp $binaryOp
|
||||
* @param \PhpParser\Node\Expr\BinaryOp\Identical|\PhpParser\Node\Expr\BinaryOp\NotIdentical $binaryOp
|
||||
*/
|
||||
public function match($binaryOp) : ?\Rector\Php80\ValueObject\StrStartsWith;
|
||||
/**
|
||||
|
|
|
@ -5,7 +5,6 @@ namespace Rector\Php80\MatchAndRefactor\StrStartsWithMatchAndRefactor;
|
|||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Arg;
|
||||
use PhpParser\Node\Expr\BinaryOp;
|
||||
use PhpParser\Node\Expr\BinaryOp\Identical;
|
||||
use PhpParser\Node\Expr\BinaryOp\NotIdentical;
|
||||
use PhpParser\Node\Expr\FuncCall;
|
||||
|
@ -53,7 +52,7 @@ final class StrncmpMatchAndRefactor implements \Rector\Php80\Contract\StrStartWi
|
|||
$this->argsAnalyzer = $argsAnalyzer;
|
||||
}
|
||||
/**
|
||||
* @param \PhpParser\Node\Expr\BinaryOp $binaryOp
|
||||
* @param \PhpParser\Node\Expr\BinaryOp\Identical|\PhpParser\Node\Expr\BinaryOp\NotIdentical $binaryOp
|
||||
*/
|
||||
public function match($binaryOp) : ?\Rector\Php80\ValueObject\StrStartsWith
|
||||
{
|
||||
|
|
|
@ -43,7 +43,7 @@ final class StrposMatchAndRefactor implements \Rector\Php80\Contract\StrStartWit
|
|||
$this->argsAnalyzer = $argsAnalyzer;
|
||||
}
|
||||
/**
|
||||
* @param \PhpParser\Node\Expr\BinaryOp $binaryOp
|
||||
* @param \PhpParser\Node\Expr\BinaryOp\Identical|\PhpParser\Node\Expr\BinaryOp\NotIdentical $binaryOp
|
||||
*/
|
||||
public function match($binaryOp) : ?\Rector\Php80\ValueObject\StrStartsWith
|
||||
{
|
||||
|
|
|
@ -5,7 +5,6 @@ namespace Rector\Php80\MatchAndRefactor\StrStartsWithMatchAndRefactor;
|
|||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Arg;
|
||||
use PhpParser\Node\Expr\BinaryOp;
|
||||
use PhpParser\Node\Expr\BinaryOp\Identical;
|
||||
use PhpParser\Node\Expr\BinaryOp\NotIdentical;
|
||||
use PhpParser\Node\Expr\FuncCall;
|
||||
|
@ -49,7 +48,7 @@ final class SubstrMatchAndRefactor implements \Rector\Php80\Contract\StrStartWit
|
|||
$this->argsAnalyzer = $argsAnalyzer;
|
||||
}
|
||||
/**
|
||||
* @param \PhpParser\Node\Expr\BinaryOp $binaryOp
|
||||
* @param \PhpParser\Node\Expr\BinaryOp\Identical|\PhpParser\Node\Expr\BinaryOp\NotIdentical $binaryOp
|
||||
*/
|
||||
public function match($binaryOp) : ?\Rector\Php80\ValueObject\StrStartsWith
|
||||
{
|
||||
|
|
|
@ -88,7 +88,7 @@ CODE_SAMPLE
|
|||
*/
|
||||
public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node
|
||||
{
|
||||
$isAlreadySorted = $node->getAttribute(self::ALREADY_SORTED);
|
||||
$isAlreadySorted = (bool) $node->getAttribute(self::ALREADY_SORTED, \false);
|
||||
if ($isAlreadySorted) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -125,12 +125,12 @@ CODE_SAMPLE
|
|||
return $node;
|
||||
}
|
||||
/**
|
||||
* @param array<string, AnnotationToAttribute[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$annotationsToAttributes = $configuration[self::ANNOTATION_TO_ATTRIBUTE] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($annotationsToAttributes, \Rector\Php80\ValueObject\AnnotationToAttribute::class);
|
||||
$annotationsToAttributes = $configuration[self::ANNOTATION_TO_ATTRIBUTE] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($annotationsToAttributes, \Rector\Php80\ValueObject\AnnotationToAttribute::class);
|
||||
$this->annotationsToAttributes = $annotationsToAttributes;
|
||||
}
|
||||
public function provideMinPhpVersion() : int
|
||||
|
|
|
@ -156,7 +156,7 @@ CODE_SAMPLE
|
|||
return $node;
|
||||
}
|
||||
/**
|
||||
* @param array<string, bool> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
|
|
|
@ -39,11 +39,11 @@ final class AssertMethodCallFactory
|
|||
{
|
||||
$this->isBoolAssert = \false;
|
||||
// special case with bool!
|
||||
if ($expected !== null) {
|
||||
if ($expected instanceof \PhpParser\Node\Expr) {
|
||||
$name = $this->resolveBoolMethodName($name, $expected);
|
||||
}
|
||||
$assetMethodCall = $this->nodeFactory->createMethodCall('this', $name);
|
||||
if (!$this->isBoolAssert && $expected) {
|
||||
if (!$this->isBoolAssert && $expected instanceof \PhpParser\Node\Expr) {
|
||||
$assetMethodCall->args[] = new \PhpParser\Node\Arg($this->thisToTestedObjectPropertyFetch($expected, $testedObjectPropertyFetch));
|
||||
}
|
||||
$assetMethodCall->args[] = new \PhpParser\Node\Arg($this->thisToTestedObjectPropertyFetch($value, $testedObjectPropertyFetch));
|
||||
|
|
|
@ -70,7 +70,7 @@ final class PhpSpecClassToPHPUnitClassRector extends \Rector\PhpSpecToPHPUnit\Re
|
|||
if (!$this->isInPhpSpecBehavior($node)) {
|
||||
return null;
|
||||
}
|
||||
$isAlreadyRenamedToTest = $node->getAttribute(self::ALREADY_RENAMED_TO_TEST);
|
||||
$isAlreadyRenamedToTest = (bool) $node->getAttribute(self::ALREADY_RENAMED_TO_TEST, \false);
|
||||
if ($isAlreadyRenamedToTest) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -90,11 +90,11 @@ CODE_SAMPLE
|
|||
return null;
|
||||
}
|
||||
/**
|
||||
* @param array<string, mixed[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$this->replaceStringWithClassConstants = $configuration[self::REPLACE_STRING_WITH_CLASS_CONSTANT] ?? ($configuration ?: []);
|
||||
$this->replaceStringWithClassConstants = $configuration[self::REPLACE_STRING_WITH_CLASS_CONSTANT] ?? $configuration;
|
||||
}
|
||||
private function matchArg(\PhpParser\Node\Expr\MethodCall $methodCall, \Rector\Privatization\ValueObject\ReplaceStringWithClassConstant $replaceStringWithClassConstant) : ?\PhpParser\Node\Arg
|
||||
{
|
||||
|
|
|
@ -65,12 +65,12 @@ CODE_SAMPLE
|
|||
return $node;
|
||||
}
|
||||
/**
|
||||
* @param array<string, ArgumentRemover[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$removedArguments = $configuration[self::REMOVED_ARGUMENTS] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($removedArguments, \Rector\Removing\ValueObject\ArgumentRemover::class);
|
||||
$removedArguments = $configuration[self::REMOVED_ARGUMENTS] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($removedArguments, \Rector\Removing\ValueObject\ArgumentRemover::class);
|
||||
$this->removedArguments = $removedArguments;
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -64,7 +64,7 @@ CODE_SAMPLE
|
|||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$interfacesToRemove = $configuration[self::INTERFACES_TO_REMOVE] ?? ($configuration ?: []);
|
||||
$interfacesToRemove = $configuration[self::INTERFACES_TO_REMOVE] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allString($interfacesToRemove);
|
||||
/** @var string[] $interfacesToRemove */
|
||||
$this->interfacesToRemove = $interfacesToRemove;
|
||||
|
|
|
@ -81,7 +81,7 @@ CODE_SAMPLE
|
|||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$parentTypesToRemove = $configuration[self::PARENT_TYPES_TO_REMOVE] ?? ($configuration ?: []);
|
||||
$parentTypesToRemove = $configuration[self::PARENT_TYPES_TO_REMOVE] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::isArray($parentTypesToRemove);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allString($parentTypesToRemove);
|
||||
$this->parentClassesToRemove = $parentTypesToRemove;
|
||||
|
|
|
@ -78,7 +78,7 @@ CODE_SAMPLE
|
|||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$traitsToRemove = $configuration[self::TRAITS_TO_REMOVE] ?? ($configuration ?: []);
|
||||
$traitsToRemove = $configuration[self::TRAITS_TO_REMOVE] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allString($traitsToRemove);
|
||||
/** @var string[] $traitsToRemove */
|
||||
$this->traitsToRemove = $traitsToRemove;
|
||||
|
|
|
@ -64,12 +64,12 @@ CODE_SAMPLE
|
|||
return $node;
|
||||
}
|
||||
/**
|
||||
* @param array<string, RemoveFuncCallArg[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$removedFunctionArguments = $configuration[self::REMOVED_FUNCTION_ARGUMENTS] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($removedFunctionArguments, \Rector\Removing\ValueObject\RemoveFuncCallArg::class);
|
||||
$removedFunctionArguments = $configuration[self::REMOVED_FUNCTION_ARGUMENTS] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($removedFunctionArguments, \Rector\Removing\ValueObject\RemoveFuncCallArg::class);
|
||||
$this->removedFunctionArguments = $removedFunctionArguments;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,12 +72,12 @@ CODE_SAMPLE
|
|||
return null;
|
||||
}
|
||||
/**
|
||||
* @param array<string, RemoveFuncCall[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$removeFuncCalls = $configuration[self::REMOVE_FUNC_CALLS] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($removeFuncCalls, \Rector\Removing\ValueObject\RemoveFuncCall::class);
|
||||
$removeFuncCalls = $configuration[self::REMOVE_FUNC_CALLS] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($removeFuncCalls, \Rector\Removing\ValueObject\RemoveFuncCall::class);
|
||||
$this->removeFuncCalls = $removeFuncCalls;
|
||||
}
|
||||
private function refactorFuncCallsWithPositions(\PhpParser\Node\Expr\FuncCall $funcCall, \Rector\Removing\ValueObject\RemoveFuncCall $removeFuncCall) : void
|
||||
|
|
|
@ -62,7 +62,7 @@ CODE_SAMPLE
|
|||
)]);
|
||||
}
|
||||
/**
|
||||
* @return class-string[]
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
|
|
|
@ -151,7 +151,7 @@ final class ClassRenamer
|
|||
{
|
||||
$stringName = $this->nodeNameResolver->getName($name);
|
||||
$newName = $oldToNewClasses[$stringName] ?? null;
|
||||
if (!$newName) {
|
||||
if ($newName === null) {
|
||||
return null;
|
||||
}
|
||||
if (!$this->isClassToInterfaceValidChange($name, $newName)) {
|
||||
|
@ -231,7 +231,7 @@ final class ClassRenamer
|
|||
$this->renameClassImplements($classLike, $oldToNewClasses);
|
||||
$className = (string) $this->nodeNameResolver->getName($classLike);
|
||||
$newName = $oldToNewClasses[$className] ?? null;
|
||||
if (!$newName) {
|
||||
if ($newName === null) {
|
||||
return null;
|
||||
}
|
||||
// prevents re-iterating same class in endless loop
|
||||
|
@ -248,7 +248,7 @@ final class ClassRenamer
|
|||
$classLike->name = new \PhpParser\Node\Identifier($newClassNamePart);
|
||||
$classNamingGetNamespace = $this->classNaming->getNamespace($className);
|
||||
// Old class did not have any namespace, we need to wrap class with Namespace_ node
|
||||
if ($newNamespacePart && !$classNamingGetNamespace) {
|
||||
if ($newNamespacePart !== null && $classNamingGetNamespace === null) {
|
||||
$this->changeNameToFullyQualifiedName($classLike);
|
||||
$name = new \PhpParser\Node\Name($newNamespacePart);
|
||||
return new \PhpParser\Node\Stmt\Namespace_($name, [$classLike]);
|
||||
|
|
|
@ -69,12 +69,12 @@ CODE_SAMPLE
|
|||
return null;
|
||||
}
|
||||
/**
|
||||
* @param array<string, RenameClassConstFetchInterface[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$renameClassConstFetches = $configuration[self::CLASS_CONSTANT_RENAME] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($renameClassConstFetches, \Rector\Renaming\Contract\RenameClassConstFetchInterface::class);
|
||||
$renameClassConstFetches = $configuration[self::CLASS_CONSTANT_RENAME] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($renameClassConstFetches, \Rector\Renaming\Contract\RenameClassConstFetchInterface::class);
|
||||
$this->renameClassConstFetches = $renameClassConstFetches;
|
||||
}
|
||||
private function createClassAndConstFetch(\Rector\Renaming\ValueObject\RenameClassAndConstFetch $renameClassAndConstFetch) : \PhpParser\Node\Expr\ClassConstFetch
|
||||
|
|
|
@ -87,12 +87,12 @@ CODE_SAMPLE
|
|||
return $node;
|
||||
}
|
||||
/**
|
||||
* @param array<string, RenameAnnotation[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$renamedAnnotationsInTypes = $configuration[self::RENAMED_ANNOTATIONS_IN_TYPES] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($renamedAnnotationsInTypes, \Rector\Renaming\ValueObject\RenameAnnotation::class);
|
||||
$renamedAnnotationsInTypes = $configuration[self::RENAMED_ANNOTATIONS_IN_TYPES] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($renamedAnnotationsInTypes, \Rector\Renaming\ValueObject\RenameAnnotation::class);
|
||||
$this->renamedAnnotations = $renamedAnnotationsInTypes;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ CODE_SAMPLE
|
|||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$oldToNewConstants = $configuration[self::OLD_TO_NEW_CONSTANTS] ?? ($configuration ?: []);
|
||||
$oldToNewConstants = $configuration[self::OLD_TO_NEW_CONSTANTS] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allString(\array_keys($oldToNewConstants));
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allString($oldToNewConstants);
|
||||
/** @var array<string, string> $oldToNewConstants */
|
||||
|
|
|
@ -84,7 +84,7 @@ CODE_SAMPLE
|
|||
$stmts = $this->refactorStmts($node->stmts);
|
||||
$node->stmts = $stmts;
|
||||
// add a new namespace?
|
||||
if ($this->newNamespace) {
|
||||
if ($this->newNamespace !== null) {
|
||||
$namespace = new \PhpParser\Node\Stmt\Namespace_(new \PhpParser\Node\Name($this->newNamespace));
|
||||
$namespace->stmts = $stmts;
|
||||
return $namespace;
|
||||
|
@ -97,12 +97,12 @@ CODE_SAMPLE
|
|||
return null;
|
||||
}
|
||||
/**
|
||||
* @param array<string, PseudoNamespaceToNamespace[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$namespacePrefixesWithExcludedClasses = $configuration[self::NAMESPACE_PREFIXES_WITH_EXCLUDED_CLASSES] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($namespacePrefixesWithExcludedClasses, \Rector\Renaming\ValueObject\PseudoNamespaceToNamespace::class);
|
||||
$namespacePrefixesWithExcludedClasses = $configuration[self::NAMESPACE_PREFIXES_WITH_EXCLUDED_CLASSES] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($namespacePrefixesWithExcludedClasses, \Rector\Renaming\ValueObject\PseudoNamespaceToNamespace::class);
|
||||
$this->pseudoNamespacesToNamespaces = $namespacePrefixesWithExcludedClasses;
|
||||
}
|
||||
/**
|
||||
|
@ -143,7 +143,7 @@ CODE_SAMPLE
|
|||
continue;
|
||||
}
|
||||
$excludedClasses = $pseudoNamespaceToNamespace->getExcludedClasses();
|
||||
if (\is_array($excludedClasses) && $this->isNames($node, $excludedClasses)) {
|
||||
if ($excludedClasses !== [] && $this->isNames($node, $excludedClasses)) {
|
||||
return null;
|
||||
}
|
||||
if ($node instanceof \PhpParser\Node\Name) {
|
||||
|
@ -156,9 +156,7 @@ CODE_SAMPLE
|
|||
private function processName(\PhpParser\Node\Name $name) : \PhpParser\Node\Name
|
||||
{
|
||||
$nodeName = $this->getName($name);
|
||||
if ($nodeName !== null) {
|
||||
$name->parts = \explode('_', $nodeName);
|
||||
}
|
||||
$name->parts = \explode('_', $nodeName);
|
||||
return $name;
|
||||
}
|
||||
private function processIdentifier(\PhpParser\Node\Identifier $identifier) : ?\PhpParser\Node\Identifier
|
||||
|
|
|
@ -47,7 +47,7 @@ final class RenameFunctionRector extends \Rector\Core\Rector\AbstractRector impl
|
|||
continue;
|
||||
}
|
||||
// not to refactor here
|
||||
$isVirtual = $node->name->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::VIRTUAL_NODE);
|
||||
$isVirtual = (bool) $node->name->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::VIRTUAL_NODE, \false);
|
||||
if ($isVirtual) {
|
||||
continue;
|
||||
}
|
||||
|
@ -57,13 +57,14 @@ final class RenameFunctionRector extends \Rector\Core\Rector\AbstractRector impl
|
|||
return null;
|
||||
}
|
||||
/**
|
||||
* @param array<string, mixed[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$oldFunctionToNewFunction = $configuration[self::OLD_FUNCTION_TO_NEW_FUNCTION] ?? $configuration ?: [];
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allString($oldFunctionToNewFunction);
|
||||
$oldFunctionToNewFunction = $configuration[self::OLD_FUNCTION_TO_NEW_FUNCTION] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::isArray($oldFunctionToNewFunction);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allString(\array_values($oldFunctionToNewFunction));
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allString($oldFunctionToNewFunction);
|
||||
$this->oldFunctionToNewFunction = $oldFunctionToNewFunction;
|
||||
}
|
||||
private function createName(string $newFunction) : \PhpParser\Node\Name
|
||||
|
|
|
@ -94,12 +94,12 @@ CODE_SAMPLE
|
|||
return null;
|
||||
}
|
||||
/**
|
||||
* @param array<string, MethodCallRenameInterface[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$methodCallRenames = $configuration[self::METHOD_CALL_RENAMES] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($methodCallRenames, \Rector\Renaming\Contract\MethodCallRenameInterface::class);
|
||||
$methodCallRenames = $configuration[self::METHOD_CALL_RENAMES] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($methodCallRenames, \Rector\Renaming\Contract\MethodCallRenameInterface::class);
|
||||
$this->methodCallRenames = $methodCallRenames;
|
||||
$this->methodCallRenameCollector->addMethodCallRenames($methodCallRenames);
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ CODE_SAMPLE
|
|||
return $this->processCleanUpUse($node, $oldToNewClasses);
|
||||
}
|
||||
/**
|
||||
* @param array<string, mixed[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
|
@ -108,7 +108,7 @@ CODE_SAMPLE
|
|||
private function processCleanUpUse(\PhpParser\Node\Stmt\Use_ $use, array $oldToNewClasses) : ?\PhpParser\Node\Stmt\Use_
|
||||
{
|
||||
foreach ($use->uses as $useUse) {
|
||||
if ($useUse->name instanceof \PhpParser\Node\Name && !$useUse->alias instanceof \PhpParser\Node\Identifier && isset($oldToNewClasses[$useUse->name->toString()])) {
|
||||
if (!$useUse->alias instanceof \PhpParser\Node\Identifier && isset($oldToNewClasses[$useUse->name->toString()])) {
|
||||
$this->removeNode($use);
|
||||
return $use;
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ CODE_SAMPLE
|
|||
return null;
|
||||
}
|
||||
/**
|
||||
* @param array<string, string> $oldToNewClasses
|
||||
* @param mixed[] $oldToNewClasses
|
||||
*/
|
||||
private function addOldToNewClasses(array $oldToNewClasses) : void
|
||||
{
|
||||
|
|
|
@ -100,7 +100,7 @@ final class RenameNamespaceRector extends \Rector\Core\Rector\AbstractRector imp
|
|||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$oldToNewNamespaces = $configuration[self::OLD_TO_NEW_NAMESPACES] ?? ($configuration ?: []);
|
||||
$oldToNewNamespaces = $configuration[self::OLD_TO_NEW_NAMESPACES] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allString(\array_keys($oldToNewNamespaces));
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allString($oldToNewNamespaces);
|
||||
/** @var array<string, string> $oldToNewNamespaces */
|
||||
|
|
|
@ -53,12 +53,12 @@ final class RenamePropertyRector extends \Rector\Core\Rector\AbstractRector impl
|
|||
return $this->processFromPropertyFetch($node);
|
||||
}
|
||||
/**
|
||||
* @param array<string, RenameProperty[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$renamedProperties = $configuration[self::RENAMED_PROPERTIES] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($renamedProperties, \Rector\Renaming\ValueObject\RenameProperty::class);
|
||||
$renamedProperties = $configuration[self::RENAMED_PROPERTIES] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($renamedProperties, \Rector\Renaming\ValueObject\RenameProperty::class);
|
||||
$this->renamedProperties = $renamedProperties;
|
||||
}
|
||||
private function processFromClassLike(\PhpParser\Node\Stmt\ClassLike $classLike) : \PhpParser\Node\Stmt\ClassLike
|
||||
|
|
|
@ -60,12 +60,12 @@ final class RenameStaticMethodRector extends \Rector\Core\Rector\AbstractRector
|
|||
return null;
|
||||
}
|
||||
/**
|
||||
* @param array<string, RenameStaticMethod[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$oldToNewMethodsByClasses = $configuration[self::OLD_TO_NEW_METHODS_BY_CLASSES];
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($oldToNewMethodsByClasses, \Rector\Renaming\ValueObject\RenameStaticMethod::class);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($oldToNewMethodsByClasses, \Rector\Renaming\ValueObject\RenameStaticMethod::class);
|
||||
$this->staticMethodRenames = $oldToNewMethodsByClasses;
|
||||
}
|
||||
private function rename(\PhpParser\Node\Expr\StaticCall $staticCall, \Rector\Renaming\ValueObject\RenameStaticMethod $renameStaticMethod) : \PhpParser\Node\Expr\StaticCall
|
||||
|
|
|
@ -68,13 +68,14 @@ CODE_SAMPLE
|
|||
return null;
|
||||
}
|
||||
/**
|
||||
* @param array<string, array<string, string>> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$stringChanges = $configuration[self::STRING_CHANGES] ?? ($configuration ?: []);
|
||||
$stringChanges = $configuration[self::STRING_CHANGES] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::isArray($stringChanges);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allString(\array_keys($stringChanges));
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allString($stringChanges);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allString(\array_values($stringChanges));
|
||||
$this->stringChanges = $stringChanges;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,12 +81,12 @@ CODE_SAMPLE
|
|||
return $node;
|
||||
}
|
||||
/**
|
||||
* @param array<string, CompleteImportForPartialAnnotation[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$useImportsToRestore = $configuration[self::USE_IMPORTS_TO_RESTORE] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($useImportsToRestore, \Rector\Restoration\ValueObject\CompleteImportForPartialAnnotation::class);
|
||||
$useImportsToRestore = $configuration[self::USE_IMPORTS_TO_RESTORE] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($useImportsToRestore, \Rector\Restoration\ValueObject\CompleteImportForPartialAnnotation::class);
|
||||
$default = [new \Rector\Restoration\ValueObject\CompleteImportForPartialAnnotation('Doctrine\\ORM\\Mapping', 'ORM'), new \Rector\Restoration\ValueObject\CompleteImportForPartialAnnotation('Symfony\\Component\\Validator\\Constraints', 'Assert'), new \Rector\Restoration\ValueObject\CompleteImportForPartialAnnotation('JMS\\Serializer\\Annotation', 'Serializer')];
|
||||
$this->useImportsToRestore = \array_merge($useImportsToRestore, $default);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ abstract class AbstractFalsyScalarRuleFixerRector extends \Rector\Core\Rector\Ab
|
|||
*/
|
||||
protected $treatAsNonEmpty = \false;
|
||||
/**
|
||||
* @param array<string, mixed> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
|
|
|
@ -86,12 +86,12 @@ CODE_SAMPLE
|
|||
return new \PhpParser\Node\Expr\MethodCall($arrayDimFetch->var, $dimFetchAssignToMethodCall->getAddMethod(), $node->expr->args);
|
||||
}
|
||||
/**
|
||||
* @param array<string, DimFetchAssignToMethodCall[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$dimFetchAssignToMethodCalls = $configuration[self::DIM_FETCH_ASSIGN_TO_METHOD_CALL] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($dimFetchAssignToMethodCalls, \Rector\Transform\ValueObject\DimFetchAssignToMethodCall::class);
|
||||
$dimFetchAssignToMethodCalls = $configuration[self::DIM_FETCH_ASSIGN_TO_METHOD_CALL] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($dimFetchAssignToMethodCalls, \Rector\Transform\ValueObject\DimFetchAssignToMethodCall::class);
|
||||
$this->dimFetchAssignToMethodCalls = $dimFetchAssignToMethodCalls;
|
||||
}
|
||||
private function findDimFetchAssignToMethodCall(\PhpParser\Node\Expr\Assign $assign) : ?\Rector\Transform\ValueObject\DimFetchAssignToMethodCall
|
||||
|
|
|
@ -82,7 +82,7 @@ CODE_SAMPLE
|
|||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$getAndSetToMethodCalls = $configuration[self::TYPE_TO_METHOD_CALLS] ?? ($configuration ?: []);
|
||||
$getAndSetToMethodCalls = $configuration[self::TYPE_TO_METHOD_CALLS] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($getAndSetToMethodCalls, \Rector\Transform\ValueObject\GetAndSetToMethodCall::class);
|
||||
$this->getAndSetToMethodCalls = $getAndSetToMethodCalls;
|
||||
}
|
||||
|
|
|
@ -68,12 +68,12 @@ CODE_SAMPLE
|
|||
return $node;
|
||||
}
|
||||
/**
|
||||
* @param array<string, PropertyAssignToMethodCall[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$propertyAssignsToMethodCalls = $configuration[self::PROPERTY_ASSIGNS_TO_METHODS_CALLS] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($propertyAssignsToMethodCalls, \Rector\Transform\ValueObject\PropertyAssignToMethodCall::class);
|
||||
$propertyAssignsToMethodCalls = $configuration[self::PROPERTY_ASSIGNS_TO_METHODS_CALLS] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($propertyAssignsToMethodCalls, \Rector\Transform\ValueObject\PropertyAssignToMethodCall::class);
|
||||
$this->propertyAssignsToMethodCalls = $propertyAssignsToMethodCalls;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,12 +68,12 @@ CODE_SAMPLE
|
|||
return null;
|
||||
}
|
||||
/**
|
||||
* @param array<string, PropertyFetchToMethodCall[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$propertiesToMethodCalls = $configuration[self::PROPERTIES_TO_METHOD_CALLS] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($propertiesToMethodCalls, \Rector\Transform\ValueObject\PropertyFetchToMethodCall::class);
|
||||
$propertiesToMethodCalls = $configuration[self::PROPERTIES_TO_METHOD_CALLS] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($propertiesToMethodCalls, \Rector\Transform\ValueObject\PropertyFetchToMethodCall::class);
|
||||
$this->propertiesToMethodCalls = $propertiesToMethodCalls;
|
||||
}
|
||||
private function processSetter(\PhpParser\Node\Expr\Assign $assign) : ?\PhpParser\Node
|
||||
|
|
|
@ -90,7 +90,7 @@ CODE_SAMPLE
|
|||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$attributeKeysToClassConstFetches = $configuration[self::ATTRIBUTE_KEYS_TO_CLASS_CONST_FETCHES] ?? ($configuration ?: []);
|
||||
$attributeKeysToClassConstFetches = $configuration[self::ATTRIBUTE_KEYS_TO_CLASS_CONST_FETCHES] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($attributeKeysToClassConstFetches, \Rector\Transform\ValueObject\AttributeKeyToClassConstFetch::class);
|
||||
$this->attributeKeysToClassConstFetches = $attributeKeysToClassConstFetches;
|
||||
}
|
||||
|
|
|
@ -54,12 +54,12 @@ final class ClassConstFetchToValueRector extends \Rector\Core\Rector\AbstractRec
|
|||
return $node;
|
||||
}
|
||||
/**
|
||||
* @param array<string, ClassConstFetchToValue[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$classConstFetchesToValues = $configuration[self::CLASS_CONST_FETCHES_TO_VALUES] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($classConstFetchesToValues, \Rector\Transform\ValueObject\ClassConstFetchToValue::class);
|
||||
$classConstFetchesToValues = $configuration[self::CLASS_CONST_FETCHES_TO_VALUES] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($classConstFetchesToValues, \Rector\Transform\ValueObject\ClassConstFetchToValue::class);
|
||||
$this->classConstFetchesToValues = $classConstFetchesToValues;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,12 +96,12 @@ CODE_SAMPLE
|
|||
return null;
|
||||
}
|
||||
/**
|
||||
* @param array<string, SingleToManyMethod[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$singleToManyMethods = $configuration[self::SINGLES_TO_MANY_METHODS] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($singleToManyMethods, \Rector\Transform\ValueObject\SingleToManyMethod::class);
|
||||
$singleToManyMethods = $configuration[self::SINGLES_TO_MANY_METHODS] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($singleToManyMethods, \Rector\Transform\ValueObject\SingleToManyMethod::class);
|
||||
$this->singleToManyMethods = $singleToManyMethods;
|
||||
}
|
||||
private function keepOldReturnTypeInDocBlock(\PhpParser\Node\Stmt\ClassMethod $classMethod) : void
|
||||
|
|
|
@ -68,7 +68,7 @@ CODE_SAMPLE
|
|||
if (!$this->isName($node, $typeMethodWrap->getMethod())) {
|
||||
continue;
|
||||
}
|
||||
if (!$node->stmts) {
|
||||
if ($node->stmts === null) {
|
||||
continue;
|
||||
}
|
||||
return $this->wrap($node, $typeMethodWrap->isArrayWrap());
|
||||
|
@ -76,12 +76,12 @@ CODE_SAMPLE
|
|||
return $node;
|
||||
}
|
||||
/**
|
||||
* @param array<string, WrapReturn[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$typeMethodWraps = $configuration[self::TYPE_METHOD_WRAPS] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($typeMethodWraps, \Rector\Transform\ValueObject\WrapReturn::class);
|
||||
$typeMethodWraps = $configuration[self::TYPE_METHOD_WRAPS] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($typeMethodWraps, \Rector\Transform\ValueObject\WrapReturn::class);
|
||||
$this->typeMethodWraps = $typeMethodWraps;
|
||||
}
|
||||
private function wrap(\PhpParser\Node\Stmt\ClassMethod $classMethod, bool $isArrayWrap) : ?\PhpParser\Node\Stmt\ClassMethod
|
||||
|
|
|
@ -83,7 +83,7 @@ CODE_SAMPLE
|
|||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$interfaceByParent = $configuration[self::INTERFACE_BY_PARENT] ?? ($configuration ?: []);
|
||||
$interfaceByParent = $configuration[self::INTERFACE_BY_PARENT] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::isArray($interfaceByParent);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allString(\array_keys($interfaceByParent));
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allString($interfaceByParent);
|
||||
|
|
|
@ -76,11 +76,11 @@ CODE_SAMPLE
|
|||
}
|
||||
/**
|
||||
* @todo complex configuration, introduce value object!
|
||||
* @param array<string, array<string, string>> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$interfaceByTrait = $configuration[self::INTERFACE_BY_TRAIT] ?? ($configuration ?: []);
|
||||
$interfaceByTrait = $configuration[self::INTERFACE_BY_TRAIT] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::isArray($interfaceByTrait);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allString(\array_keys($interfaceByTrait));
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allString($interfaceByTrait);
|
||||
|
|
|
@ -70,11 +70,12 @@ CODE_SAMPLE
|
|||
return $node;
|
||||
}
|
||||
/**
|
||||
* @param array<string, array<string, string>> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$oldToNewInterfaces = $configuration[self::OLD_TO_NEW_INTERFACES] ?? ($configuration ?: []);
|
||||
$oldToNewInterfaces = $configuration[self::OLD_TO_NEW_INTERFACES] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::isArray($oldToNewInterfaces);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allString(\array_keys($oldToNewInterfaces));
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allString($oldToNewInterfaces);
|
||||
$this->oldToNewInterfaces = $oldToNewInterfaces;
|
||||
|
|
|
@ -89,12 +89,12 @@ CODE_SAMPLE
|
|||
return null;
|
||||
}
|
||||
/**
|
||||
* @param array<string, ParentClassToTraits[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$parentClassToTraits = $configuration[self::PARENT_CLASS_TO_TRAITS] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($parentClassToTraits, \Rector\Transform\ValueObject\ParentClassToTraits::class);
|
||||
$parentClassToTraits = $configuration[self::PARENT_CLASS_TO_TRAITS] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($parentClassToTraits, \Rector\Transform\ValueObject\ParentClassToTraits::class);
|
||||
$this->parentClassToTraits = $parentClassToTraits;
|
||||
}
|
||||
private function removeParentClass(\PhpParser\Node\Stmt\Class_ $class) : void
|
||||
|
|
|
@ -129,15 +129,15 @@ CODE_SAMPLE
|
|||
return null;
|
||||
}
|
||||
/**
|
||||
* @param array<string, array<ArgumentFuncCallToMethodCall|ArrayFuncCallToMethodCall>> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$functionToMethodCalls = $configuration[self::FUNCTIONS_TO_METHOD_CALLS] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($functionToMethodCalls, \Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall::class);
|
||||
$functionToMethodCalls = $configuration[self::FUNCTIONS_TO_METHOD_CALLS] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($functionToMethodCalls, \Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall::class);
|
||||
$this->argumentFuncCallToMethodCalls = $functionToMethodCalls;
|
||||
$arrayFunctionsToMethodCalls = $configuration[self::ARRAY_FUNCTIONS_TO_METHOD_CALLS] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($arrayFunctionsToMethodCalls, \Rector\Transform\ValueObject\ArrayFuncCallToMethodCall::class);
|
||||
$arrayFunctionsToMethodCalls = $configuration[self::ARRAY_FUNCTIONS_TO_METHOD_CALLS] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($arrayFunctionsToMethodCalls, \Rector\Transform\ValueObject\ArrayFuncCallToMethodCall::class);
|
||||
$this->arrayFunctionsToMethodCalls = $arrayFunctionsToMethodCalls;
|
||||
}
|
||||
private function shouldSkipFuncCall(\PhpParser\Node\Expr\FuncCall $funcCall) : bool
|
||||
|
@ -192,11 +192,8 @@ CODE_SAMPLE
|
|||
*/
|
||||
private function refactorEmptyFuncCallArgs(\Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall $argumentFuncCallToMethodCall, \PhpParser\Node\Expr\PropertyFetch $propertyFetch)
|
||||
{
|
||||
if ($argumentFuncCallToMethodCall->getMethodIfNoArgs()) {
|
||||
if ($argumentFuncCallToMethodCall->getMethodIfNoArgs() !== null) {
|
||||
$methodName = $argumentFuncCallToMethodCall->getMethodIfNoArgs();
|
||||
if (!\is_string($methodName)) {
|
||||
throw new \Rector\Core\Exception\ShouldNotHappenException();
|
||||
}
|
||||
return new \PhpParser\Node\Expr\MethodCall($propertyFetch, $methodName);
|
||||
}
|
||||
return $propertyFetch;
|
||||
|
@ -219,15 +216,12 @@ CODE_SAMPLE
|
|||
if (!$funcCall->args[0] instanceof \PhpParser\Node\Arg) {
|
||||
return null;
|
||||
}
|
||||
if ($arrayFuncCallToMethodCall->getArrayMethod() && $this->arrayTypeAnalyzer->isArrayType($funcCall->args[0]->value)) {
|
||||
if ($this->arrayTypeAnalyzer->isArrayType($funcCall->args[0]->value)) {
|
||||
return new \PhpParser\Node\Expr\MethodCall($propertyFetch, $arrayFuncCallToMethodCall->getArrayMethod(), $funcCall->args);
|
||||
}
|
||||
if ($arrayFuncCallToMethodCall->getNonArrayMethod() === '') {
|
||||
return null;
|
||||
}
|
||||
if ($this->arrayTypeAnalyzer->isArrayType($funcCall->args[0]->value)) {
|
||||
return null;
|
||||
}
|
||||
return new \PhpParser\Node\Expr\MethodCall($propertyFetch, $arrayFuncCallToMethodCall->getNonArrayMethod(), $funcCall->args);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ CODE_SAMPLE
|
|||
public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node
|
||||
{
|
||||
$functionName = $this->getName($node);
|
||||
if (!$functionName) {
|
||||
if (!\is_string($functionName)) {
|
||||
return null;
|
||||
}
|
||||
if (!\array_key_exists($functionName, $this->functionsToConstants)) {
|
||||
|
@ -69,11 +69,12 @@ CODE_SAMPLE
|
|||
return new \PhpParser\Node\Expr\ConstFetch(new \PhpParser\Node\Name($this->functionsToConstants[$functionName]));
|
||||
}
|
||||
/**
|
||||
* @param array<string, string[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$functionsToConstants = $configuration[self::FUNCTIONS_TO_CONSTANTS] ?? ($configuration ?: []);
|
||||
$functionsToConstants = $configuration[self::FUNCTIONS_TO_CONSTANTS] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::isArray($functionsToConstants);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allString($functionsToConstants);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allString(\array_keys($functionsToConstants));
|
||||
/** @var array<string, string> $functionsToConstants */
|
||||
|
|
|
@ -100,13 +100,13 @@ CODE_SAMPLE
|
|||
return null;
|
||||
}
|
||||
/**
|
||||
* @param array<string, FuncCallToMethodCall[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$funcCallsToClassMethodCalls = $configuration[self::FUNC_CALL_TO_CLASS_METHOD_CALL] ?? ($configuration ?: []);
|
||||
$funcCallsToClassMethodCalls = $configuration[self::FUNC_CALL_TO_CLASS_METHOD_CALL] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::isArray($funcCallsToClassMethodCalls);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($funcCallsToClassMethodCalls, \Rector\Transform\ValueObject\FuncCallToMethodCall::class);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($funcCallsToClassMethodCalls, \Rector\Transform\ValueObject\FuncCallToMethodCall::class);
|
||||
$this->funcNameToMethodCallNames = $funcCallsToClassMethodCalls;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
|
|||
use Rector\Core\Rector\AbstractRector;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
use RectorPrefix20211128\Webmozart\Assert\Assert;
|
||||
/**
|
||||
* @see \Rector\Tests\Transform\Rector\FuncCall\FuncCallToNewRector\FuncCallToNewRectorTest
|
||||
*/
|
||||
|
@ -67,10 +68,13 @@ CODE_SAMPLE
|
|||
return null;
|
||||
}
|
||||
/**
|
||||
* @param array<string, mixed> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$this->functionToNew = $configuration[self::FUNCTIONS_TO_NEWS] ?? ($configuration ?: []);
|
||||
$functionsToNews = $configuration[self::FUNCTIONS_TO_NEWS] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::isArray($functionsToNews);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allString($functionsToNews);
|
||||
$this->functionToNew = $functionsToNews;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,12 +49,13 @@ final class FuncCallToStaticCallRector extends \Rector\Core\Rector\AbstractRecto
|
|||
return null;
|
||||
}
|
||||
/**
|
||||
* @param array<string, FuncCallToStaticCall[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$funcCallsToStaticCalls = $configuration[self::FUNC_CALLS_TO_STATIC_CALLS] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($funcCallsToStaticCalls, \Rector\Transform\ValueObject\FuncCallToStaticCall::class);
|
||||
$funcCallsToStaticCalls = $configuration[self::FUNC_CALLS_TO_STATIC_CALLS] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::isArray($funcCallsToStaticCalls);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($funcCallsToStaticCalls, \Rector\Transform\ValueObject\FuncCallToStaticCall::class);
|
||||
$this->funcCallsToStaticCalls = $funcCallsToStaticCalls;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,12 +70,13 @@ CODE_SAMPLE
|
|||
return null;
|
||||
}
|
||||
/**
|
||||
* @param array<string, UnsetAndIssetToMethodCall[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$issetUnsetToMethodCalls = $configuration[self::ISSET_UNSET_TO_METHOD_CALL] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($issetUnsetToMethodCalls, \Rector\Transform\ValueObject\UnsetAndIssetToMethodCall::class);
|
||||
$issetUnsetToMethodCalls = $configuration[self::ISSET_UNSET_TO_METHOD_CALL] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::isArray($issetUnsetToMethodCalls);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($issetUnsetToMethodCalls, \Rector\Transform\ValueObject\UnsetAndIssetToMethodCall::class);
|
||||
$this->issetUnsetToMethodCalls = $issetUnsetToMethodCalls;
|
||||
}
|
||||
private function processArrayDimFetchNode(\PhpParser\Node $node, \PhpParser\Node\Expr\ArrayDimFetch $arrayDimFetch, \Rector\Transform\ValueObject\UnsetAndIssetToMethodCall $unsetAndIssetToMethodCall) : ?\PhpParser\Node
|
||||
|
|
|
@ -102,12 +102,13 @@ CODE_SAMPLE
|
|||
return null;
|
||||
}
|
||||
/**
|
||||
* @param array<string, CallableInMethodCallToVariable[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$callableInMethodCallToVariable = $configuration[self::CALLABLE_IN_METHOD_CALL_TO_VARIABLE] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($callableInMethodCallToVariable, \Rector\Transform\ValueObject\CallableInMethodCallToVariable::class);
|
||||
$callableInMethodCallToVariable = $configuration[self::CALLABLE_IN_METHOD_CALL_TO_VARIABLE] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::isArray($callableInMethodCallToVariable);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($callableInMethodCallToVariable, \Rector\Transform\ValueObject\CallableInMethodCallToVariable::class);
|
||||
$this->callableInMethodCallToVariable = $callableInMethodCallToVariable;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,12 +63,13 @@ CODE_SAMPLE
|
|||
return null;
|
||||
}
|
||||
/**
|
||||
* @param array<string, MethodCallToAnotherMethodCallWithArguments[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$methodCallRenamesWithAddedArguments = $configuration[self::METHOD_CALL_RENAMES_WITH_ADDED_ARGUMENTS] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($methodCallRenamesWithAddedArguments, \Rector\Transform\ValueObject\MethodCallToAnotherMethodCallWithArguments::class);
|
||||
$methodCallRenamesWithAddedArguments = $configuration[self::METHOD_CALL_RENAMES_WITH_ADDED_ARGUMENTS] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::isArray($methodCallRenamesWithAddedArguments);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($methodCallRenamesWithAddedArguments, \Rector\Transform\ValueObject\MethodCallToAnotherMethodCallWithArguments::class);
|
||||
$this->methodCallRenamesWithAddedArguments = $methodCallRenamesWithAddedArguments;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ CODE_SAMPLE
|
|||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$methodCallsToMethodsCalls = $configuration[self::METHOD_CALLS_TO_METHOD_CALLS] ?? ($configuration ?: []);
|
||||
$methodCallsToMethodsCalls = $configuration[self::METHOD_CALLS_TO_METHOD_CALLS] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($methodCallsToMethodsCalls, \Rector\Transform\ValueObject\MethodCallToMethodCall::class);
|
||||
$this->methodCallsToMethodsCalls = $methodCallsToMethodsCalls;
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ CODE_SAMPLE
|
|||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$methodCallToPropertyFetchCollection = $configuration[self::METHOD_CALL_TO_PROPERTY_FETCHES] ?? ($configuration ?: []);
|
||||
$methodCallToPropertyFetchCollection = $configuration[self::METHOD_CALL_TO_PROPERTY_FETCHES] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allString(\array_keys($methodCallToPropertyFetchCollection));
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allString($methodCallToPropertyFetchCollection);
|
||||
/** @var array<string, string> $methodCallToPropertyFetchCollection */
|
||||
|
|
|
@ -84,12 +84,13 @@ CODE_SAMPLE
|
|||
return null;
|
||||
}
|
||||
/**
|
||||
* @param array<string, MethodCallToStaticCall[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$methodCallsToStaticCalls = $configuration[self::METHOD_CALLS_TO_STATIC_CALLS] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($methodCallsToStaticCalls, \Rector\Transform\ValueObject\MethodCallToStaticCall::class);
|
||||
$methodCallsToStaticCalls = $configuration[self::METHOD_CALLS_TO_STATIC_CALLS] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::isArray($methodCallsToStaticCalls);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($methodCallsToStaticCalls, \Rector\Transform\ValueObject\MethodCallToStaticCall::class);
|
||||
$this->methodCallsToStaticCalls = $methodCallsToStaticCalls;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,12 +71,12 @@ CODE_SAMPLE
|
|||
return null;
|
||||
}
|
||||
/**
|
||||
* @param array<string, ReplaceParentCallByPropertyCall[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$parentCallToProperties = $configuration[self::PARENT_CALLS_TO_PROPERTIES] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($parentCallToProperties, \Rector\Transform\ValueObject\ReplaceParentCallByPropertyCall::class);
|
||||
$parentCallToProperties = $configuration[self::PARENT_CALLS_TO_PROPERTIES] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($parentCallToProperties, \Rector\Transform\ValueObject\ReplaceParentCallByPropertyCall::class);
|
||||
$this->parentCallToProperties = $parentCallToProperties;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -154,12 +154,13 @@ CODE_SAMPLE
|
|||
return $node;
|
||||
}
|
||||
/**
|
||||
* @param array<string, ServiceGetterToConstructorInjection[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$methodCallToServices = $configuration[self::METHOD_CALL_TO_SERVICES] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($methodCallToServices, \Rector\Transform\ValueObject\ServiceGetterToConstructorInjection::class);
|
||||
$methodCallToServices = $configuration[self::METHOD_CALL_TO_SERVICES] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::isArray($methodCallToServices);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($methodCallToServices, \Rector\Transform\ValueObject\ServiceGetterToConstructorInjection::class);
|
||||
$this->methodCallToServices = $methodCallToServices;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,12 +83,13 @@ CODE_SAMPLE
|
|||
return null;
|
||||
}
|
||||
/**
|
||||
* @param array<string, NewArgToMethodCall[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$newArgsToMethodCalls = $configuration[self::NEW_ARGS_TO_METHOD_CALLS] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($newArgsToMethodCalls, \Rector\Transform\ValueObject\NewArgToMethodCall::class);
|
||||
$newArgsToMethodCalls = $configuration[self::NEW_ARGS_TO_METHOD_CALLS] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::isArray($newArgsToMethodCalls);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($newArgsToMethodCalls, \Rector\Transform\ValueObject\NewArgToMethodCall::class);
|
||||
$this->newArgsToMethodCalls = $newArgsToMethodCalls;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ use Rector\PostRector\ValueObject\PropertyMetadata;
|
|||
use Rector\Transform\NodeFactory\PropertyFetchFactory;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
use RectorPrefix20211128\Webmozart\Assert\Assert;
|
||||
/**
|
||||
* @see \Rector\Tests\Transform\Rector\New_\NewToConstructorInjectionRector\NewToConstructorInjectionRectorTest
|
||||
*/
|
||||
|
@ -113,11 +114,12 @@ CODE_SAMPLE
|
|||
return null;
|
||||
}
|
||||
/**
|
||||
* @param array<string, mixed[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$typesToConstructorInjections = $configuration[self::TYPES_TO_CONSTRUCTOR_INJECTION] ?? ($configuration ?: []);
|
||||
$typesToConstructorInjections = $configuration[self::TYPES_TO_CONSTRUCTOR_INJECTION] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::isArray($typesToConstructorInjections);
|
||||
foreach ($typesToConstructorInjections as $typeToConstructorInjection) {
|
||||
$this->constructorInjectionObjectTypes[] = new \PHPStan\Type\ObjectType($typeToConstructorInjection);
|
||||
}
|
||||
|
|
|
@ -112,12 +112,13 @@ CODE_SAMPLE
|
|||
return $node;
|
||||
}
|
||||
/**
|
||||
* @param array<string, NewToMethodCall[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$newsToMethodCalls = $configuration[self::NEWS_TO_METHOD_CALLS] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($newsToMethodCalls, \Rector\Transform\ValueObject\NewToMethodCall::class);
|
||||
$newsToMethodCalls = $configuration[self::NEWS_TO_METHOD_CALLS] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::isArray($newsToMethodCalls);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($newsToMethodCalls, \Rector\Transform\ValueObject\NewToMethodCall::class);
|
||||
$this->newsToMethodCalls = $newsToMethodCalls;
|
||||
}
|
||||
private function getExistingFactoryPropertyName(\PhpParser\Node\Stmt\Class_ $class, \PHPStan\Type\ObjectType $factoryObjectType) : ?string
|
||||
|
|
|
@ -67,12 +67,13 @@ CODE_SAMPLE
|
|||
return null;
|
||||
}
|
||||
/**
|
||||
* @param array<string, NewToStaticCall[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$typeToStaticCalls = $configuration[self::TYPE_TO_STATIC_CALLS] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($typeToStaticCalls, \Rector\Transform\ValueObject\NewToStaticCall::class);
|
||||
$typeToStaticCalls = $configuration[self::TYPE_TO_STATIC_CALLS] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::isArray($typeToStaticCalls);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($typeToStaticCalls, \Rector\Transform\ValueObject\NewToStaticCall::class);
|
||||
$this->typeToStaticCalls = $typeToStaticCalls;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,12 +61,13 @@ final class StaticCallToFuncCallRector extends \Rector\Core\Rector\AbstractRecto
|
|||
return null;
|
||||
}
|
||||
/**
|
||||
* @param array<string, StaticCallToFuncCall[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$staticCallsToFunctions = $configuration[self::STATIC_CALLS_TO_FUNCTIONS] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($staticCallsToFunctions, \Rector\Transform\ValueObject\StaticCallToFuncCall::class);
|
||||
$staticCallsToFunctions = $configuration[self::STATIC_CALLS_TO_FUNCTIONS] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::isArray($staticCallsToFunctions);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($staticCallsToFunctions, \Rector\Transform\ValueObject\StaticCallToFuncCall::class);
|
||||
$this->staticCallsToFunctions = $staticCallsToFunctions;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,13 +117,13 @@ CODE_SAMPLE
|
|||
return $node;
|
||||
}
|
||||
/**
|
||||
* @param array<string, StaticCallToMethodCall[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$staticCallsToMethodCalls = $configuration[self::STATIC_CALLS_TO_METHOD_CALLS] ?? ($configuration ?: []);
|
||||
$staticCallsToMethodCalls = $configuration[self::STATIC_CALLS_TO_METHOD_CALLS] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::isArray($staticCallsToMethodCalls);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($staticCallsToMethodCalls, \Rector\Transform\ValueObject\StaticCallToMethodCall::class);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($staticCallsToMethodCalls, \Rector\Transform\ValueObject\StaticCallToMethodCall::class);
|
||||
$this->staticCallsToMethodCalls = $staticCallsToMethodCalls;
|
||||
}
|
||||
private function refactorToInstanceCall(\PhpParser\Node\Expr\StaticCall $staticCall, \Rector\Transform\ValueObject\StaticCallToMethodCall $staticCallToMethodCall) : \PhpParser\Node\Expr\MethodCall
|
||||
|
|
|
@ -82,7 +82,7 @@ CODE_SAMPLE
|
|||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$staticCallsToNews = $configuration[self::STATIC_CALLS_TO_NEWS] ?? ($configuration ?: []);
|
||||
$staticCallsToNews = $configuration[self::STATIC_CALLS_TO_NEWS] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($staticCallsToNews, \Rector\Transform\ValueObject\StaticCallToNew::class);
|
||||
$this->staticCallsToNews = $staticCallsToNews;
|
||||
}
|
||||
|
|
|
@ -67,12 +67,13 @@ CODE_SAMPLE
|
|||
return $node;
|
||||
}
|
||||
/**
|
||||
* @param array<string, StringToClassConstant[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$stringToClassConstants = $configuration[self::STRINGS_TO_CLASS_CONSTANTS] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($stringToClassConstants, \Rector\Transform\ValueObject\StringToClassConstant::class);
|
||||
$stringToClassConstants = $configuration[self::STRINGS_TO_CLASS_CONSTANTS] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::isArray($stringToClassConstants);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsAOf($stringToClassConstants, \Rector\Transform\ValueObject\StringToClassConstant::class);
|
||||
$this->stringsToClassConstants = $stringToClassConstants;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ CODE_SAMPLE
|
|||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$methodNamesByType = $configuration[self::METHOD_NAMES_BY_TYPE] ?? ($configuration ?: []);
|
||||
$methodNamesByType = $configuration[self::METHOD_NAMES_BY_TYPE] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allString(\array_keys($methodNamesByType));
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allString($methodNamesByType);
|
||||
/** @var array<string, string> $methodNamesByType */
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user