mirror of
https://github.com/rectorphp/rector.git
synced 2024-05-31 08:20:53 +00:00
Updated Rector to commit a9b1bbba88
a9b1bbba88
[PHP 8.0] Make Downgrade widening union depend on ClassMethod, the narrow scope (#375)
This commit is contained in:
parent
96365f9a83
commit
1f8149a055
|
@ -5,7 +5,7 @@ namespace RectorPrefix20210704;
|
|||
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\ValueObject\PhpVersion;
|
||||
use Rector\DowngradePhp72\Rector\Class_\DowngradeParameterTypeWideningRector;
|
||||
use Rector\DowngradePhp72\Rector\ClassMethod\DowngradeParameterTypeWideningRector;
|
||||
use Rector\DowngradePhp72\Rector\FuncCall\DowngradePregUnmatchedAsNullConstantRector;
|
||||
use Rector\DowngradePhp72\Rector\FuncCall\DowngradeStreamIsattyRector;
|
||||
use Rector\DowngradePhp72\Rector\FunctionLike\DowngradeObjectTypeDeclarationRector;
|
||||
|
@ -15,7 +15,7 @@ return static function (\Symfony\Component\DependencyInjection\Loader\Configurat
|
|||
$parameters->set(\Rector\Core\Configuration\Option::PHP_VERSION_FEATURES, \Rector\Core\ValueObject\PhpVersion::PHP_71);
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\DowngradePhp72\Rector\FunctionLike\DowngradeObjectTypeDeclarationRector::class);
|
||||
$services->set(\Rector\DowngradePhp72\Rector\Class_\DowngradeParameterTypeWideningRector::class);
|
||||
$services->set(\Rector\DowngradePhp72\Rector\ClassMethod\DowngradeParameterTypeWideningRector::class);
|
||||
$services->set(\Rector\DowngradePhp72\Rector\FuncCall\DowngradePregUnmatchedAsNullConstantRector::class);
|
||||
$services->set(\Rector\DowngradePhp72\Rector\FuncCall\DowngradeStreamIsattyRector::class);
|
||||
};
|
||||
|
|
|
@ -4766,7 +4766,7 @@ Remove the "object" param and return type, add a `@param` and `@return` tags ins
|
|||
|
||||
Change param type to match the lowest type in whole family tree
|
||||
|
||||
- class: [`Rector\DowngradePhp72\Rector\Class_\DowngradeParameterTypeWideningRector`](../rules/DowngradePhp72/Rector/Class_/DowngradeParameterTypeWideningRector.php)
|
||||
- class: [`Rector\DowngradePhp72\Rector\ClassMethod\DowngradeParameterTypeWideningRector`](../rules/DowngradePhp72/Rector/Class_/DowngradeParameterTypeWideningRector.php)
|
||||
|
||||
```diff
|
||||
interface SomeInterface
|
||||
|
|
|
@ -76,7 +76,7 @@ final class PropertyFetchTypeResolver implements \Rector\NodeTypeResolver\Contra
|
|||
if ($classNode instanceof \PhpParser\Node\Stmt\Trait_) {
|
||||
/** @var string $traitName */
|
||||
$traitName = $classNode->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::CLASS_NAME);
|
||||
$scope = $this->traitNodeScopeCollector->getScopeForTraitAndNode($traitName, $node);
|
||||
$scope = $this->traitNodeScopeCollector->getScopeForTrait($traitName);
|
||||
}
|
||||
}
|
||||
if (!$scope instanceof \PHPStan\Analyser\Scope) {
|
||||
|
|
|
@ -90,7 +90,7 @@ final class VariableTypeResolver implements \Rector\NodeTypeResolver\Contract\No
|
|||
if ($classLike instanceof \PhpParser\Node\Stmt\Trait_) {
|
||||
/** @var string $traitName */
|
||||
$traitName = $variable->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::CLASS_NAME);
|
||||
$traitNodeScope = $this->traitNodeScopeCollector->getScopeForTraitAndNode($traitName, $variable);
|
||||
$traitNodeScope = $this->traitNodeScopeCollector->getScopeForTrait($traitName);
|
||||
if ($traitNodeScope !== null) {
|
||||
return $traitNodeScope;
|
||||
}
|
||||
|
|
|
@ -3,44 +3,23 @@
|
|||
declare (strict_types=1);
|
||||
namespace Rector\NodeTypeResolver\PHPStan\Collector;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PHPStan\Analyser\Scope;
|
||||
use PHPStan\Node\VirtualNode;
|
||||
use Rector\Core\PhpParser\Printer\BetterStandardPrinter;
|
||||
final class TraitNodeScopeCollector
|
||||
{
|
||||
/**
|
||||
* @var array<string, Scope>
|
||||
*/
|
||||
private $scopeByTraitNodeHash = [];
|
||||
/**
|
||||
* @var \Rector\Core\PhpParser\Printer\BetterStandardPrinter
|
||||
*/
|
||||
private $betterStandardPrinter;
|
||||
public function __construct(\Rector\Core\PhpParser\Printer\BetterStandardPrinter $betterStandardPrinter)
|
||||
public function addForTrait(string $traitName, \PHPStan\Analyser\Scope $scope) : void
|
||||
{
|
||||
$this->betterStandardPrinter = $betterStandardPrinter;
|
||||
}
|
||||
public function addForTraitAndNode(string $traitName, \PhpParser\Node $node, \PHPStan\Analyser\Scope $scope) : void
|
||||
{
|
||||
if ($node instanceof \PHPStan\Node\VirtualNode) {
|
||||
return;
|
||||
}
|
||||
$traitNodeHash = $this->createHash($traitName, $node);
|
||||
// probably set from another class
|
||||
if (isset($this->scopeByTraitNodeHash[$traitNodeHash])) {
|
||||
if (isset($this->scopeByTraitNodeHash[$traitName])) {
|
||||
return;
|
||||
}
|
||||
$this->scopeByTraitNodeHash[$traitNodeHash] = $scope;
|
||||
$this->scopeByTraitNodeHash[$traitName] = $scope;
|
||||
}
|
||||
public function getScopeForTraitAndNode(string $traitName, \PhpParser\Node $node) : ?\PHPStan\Analyser\Scope
|
||||
public function getScopeForTrait(string $traitName) : ?\PHPStan\Analyser\Scope
|
||||
{
|
||||
$traitNodeHash = $this->createHash($traitName, $node);
|
||||
return $this->scopeByTraitNodeHash[$traitNodeHash] ?? null;
|
||||
}
|
||||
private function createHash(string $traitName, \PhpParser\Node $node) : string
|
||||
{
|
||||
$printedNode = $this->betterStandardPrinter->print($node);
|
||||
return \sha1($traitName . $printedNode);
|
||||
return $this->scopeByTraitNodeHash[$traitName] ?? null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ use PhpParser\Node;
|
|||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\Interface_;
|
||||
use PhpParser\Node\Stmt\Trait_;
|
||||
use PhpParser\NodeTraverser;
|
||||
use PHPStan\AnalysedCodeException;
|
||||
use PHPStan\Analyser\MutatingScope;
|
||||
|
@ -105,10 +106,14 @@ final class PHPStanNodeScopeResolver
|
|||
$nodeCallback = function (\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope) : void {
|
||||
// traversing trait inside class that is using it scope (from referenced) - the trait traversed by Rector is different (directly from parsed file)
|
||||
if ($scope->isInTrait()) {
|
||||
/** @var ClassReflection $classReflection */
|
||||
$classReflection = $scope->getTraitReflection();
|
||||
$traitName = $classReflection->getName();
|
||||
$this->traitNodeScopeCollector->addForTraitAndNode($traitName, $node, $scope);
|
||||
// has just entereted trait, to avoid adding it for ever ynode
|
||||
$parentNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE);
|
||||
if ($parentNode instanceof \PhpParser\Node\Stmt\Trait_) {
|
||||
/** @var ClassReflection $classReflection */
|
||||
$classReflection = $scope->getTraitReflection();
|
||||
$traitName = $classReflection->getName();
|
||||
$this->traitNodeScopeCollector->addForTrait($traitName, $scope);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// the class reflection is resolved AFTER entering to class node
|
||||
|
|
|
@ -124,19 +124,15 @@ final class CurrentAndParentClassMethodComparator
|
|||
}
|
||||
$parentMethodReflection = $classReflection->getMethod($methodName, $scope);
|
||||
// 3rd party code
|
||||
if ($parentMethodReflection !== null) {
|
||||
if (!$parentMethodReflection->isPrivate() && !$parentMethodReflection->isPublic() && $classMethod->isPublic()) {
|
||||
return \true;
|
||||
}
|
||||
if ($parentMethodReflection->isInternal()->yes()) {
|
||||
// we can't know for certain so we assume its a override with purpose
|
||||
return \true;
|
||||
}
|
||||
if ($this->areParameterDefaultsDifferent($classMethod, $parentMethodReflection)) {
|
||||
return \true;
|
||||
}
|
||||
// if ($parentMethodReflection !== null) {
|
||||
if (!$parentMethodReflection->isPrivate() && !$parentMethodReflection->isPublic() && $classMethod->isPublic()) {
|
||||
return \true;
|
||||
}
|
||||
return \false;
|
||||
if ($parentMethodReflection->isInternal()->yes()) {
|
||||
// we can't know for certain so we assume its a override with purpose
|
||||
return \true;
|
||||
}
|
||||
return $this->areParameterDefaultsDifferent($classMethod, $parentMethodReflection);
|
||||
}
|
||||
private function areParameterDefaultsDifferent(\PhpParser\Node\Stmt\ClassMethod $classMethod, \PHPStan\Reflection\MethodReflection $methodReflection) : bool
|
||||
{
|
||||
|
|
|
@ -6,21 +6,21 @@ namespace Rector\DeadCode\Comparator\Parameter;
|
|||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Param;
|
||||
use PHPStan\Reflection\ParameterReflection;
|
||||
use Rector\Core\PhpParser\Node\Value\ValueResolver;
|
||||
use Rector\Core\PhpParser\Comparing\NodeComparator;
|
||||
use Rector\DowngradePhp80\Reflection\DefaultParameterValueResolver;
|
||||
final class ParameterDefaultsComparator
|
||||
{
|
||||
/**
|
||||
* @var \Rector\Core\PhpParser\Node\Value\ValueResolver
|
||||
* @var \Rector\Core\PhpParser\Comparing\NodeComparator
|
||||
*/
|
||||
private $valueResolver;
|
||||
private $nodeComparator;
|
||||
/**
|
||||
* @var \Rector\DowngradePhp80\Reflection\DefaultParameterValueResolver
|
||||
*/
|
||||
private $defaultParameterValueResolver;
|
||||
public function __construct(\Rector\Core\PhpParser\Node\Value\ValueResolver $valueResolver, \Rector\DowngradePhp80\Reflection\DefaultParameterValueResolver $defaultParameterValueResolver)
|
||||
public function __construct(\Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator, \Rector\DowngradePhp80\Reflection\DefaultParameterValueResolver $defaultParameterValueResolver)
|
||||
{
|
||||
$this->valueResolver = $valueResolver;
|
||||
$this->nodeComparator = $nodeComparator;
|
||||
$this->defaultParameterValueResolver = $defaultParameterValueResolver;
|
||||
}
|
||||
public function areDefaultValuesDifferent(\PHPStan\Reflection\ParameterReflection $parameterReflection, \PhpParser\Node\Param $param) : bool
|
||||
|
@ -34,26 +34,8 @@ final class ParameterDefaultsComparator
|
|||
/** @var Expr $paramDefault */
|
||||
$paramDefault = $param->default;
|
||||
$firstParameterValue = $this->defaultParameterValueResolver->resolveFromParameterReflection($parameterReflection);
|
||||
$secondParameterValue = $this->valueResolver->getValue($paramDefault);
|
||||
return $firstParameterValue !== $secondParameterValue;
|
||||
return !$this->nodeComparator->areNodesEqual($paramDefault, $firstParameterValue);
|
||||
}
|
||||
// /**
|
||||
// * @return bool|float|int|string|mixed[]|null
|
||||
// */
|
||||
// public function resolveParameterReflectionDefaultValue(ParameterReflection $parameterReflection)
|
||||
// {
|
||||
// $defaultValue = $parameterReflection->getDefaultValue();
|
||||
// if (! $defaultValue instanceof ConstantType) {
|
||||
// throw new ShouldNotHappenException();
|
||||
// }
|
||||
//
|
||||
// if ($defaultValue instanceof ConstantArrayType) {
|
||||
// return $defaultValue->getAllArrays();
|
||||
// }
|
||||
//
|
||||
// /** @var ConstantStringType|ConstantIntegerType|ConstantFloatType|ConstantBooleanType|NullType $defaultValue */
|
||||
// return $defaultValue->getValue();
|
||||
// }
|
||||
private function isMutuallyExclusiveNull(\PHPStan\Reflection\ParameterReflection $parameterReflection, \PhpParser\Node\Param $param) : bool
|
||||
{
|
||||
if ($parameterReflection->getDefaultValue() === null && $param->default !== null) {
|
||||
|
|
|
@ -4,7 +4,9 @@ declare (strict_types=1);
|
|||
namespace Rector\DeadCode\Rector\ClassMethod;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\StaticCall;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassLike;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
|
@ -61,14 +63,10 @@ CODE_SAMPLE
|
|||
if ($this->shouldSkipClass($classLike)) {
|
||||
return null;
|
||||
}
|
||||
if ($node->stmts === null) {
|
||||
$onlyStmt = $this->matchClassMethodOnlyStmt($node);
|
||||
if ($onlyStmt === null) {
|
||||
return null;
|
||||
}
|
||||
if (\count($node->stmts) !== 1) {
|
||||
return null;
|
||||
}
|
||||
$stmtsValues = \array_values($node->stmts);
|
||||
$onlyStmt = $this->unwrapExpression($stmtsValues[0]);
|
||||
// are both return?
|
||||
if ($this->isMethodReturnType($node, 'void') && !$onlyStmt instanceof \PhpParser\Node\Stmt\Return_) {
|
||||
return null;
|
||||
|
@ -120,4 +118,19 @@ CODE_SAMPLE
|
|||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod);
|
||||
return $phpDocInfo->hasByName('required');
|
||||
}
|
||||
/**
|
||||
* @return null|\PhpParser\Node\Stmt|\PhpParser\Node\Expr
|
||||
*/
|
||||
private function matchClassMethodOnlyStmt(\PhpParser\Node\Stmt\ClassMethod $classMethod)
|
||||
{
|
||||
if ($classMethod->stmts === null) {
|
||||
return null;
|
||||
}
|
||||
if (\count($classMethod->stmts) !== 1) {
|
||||
return null;
|
||||
}
|
||||
// recount empty notes
|
||||
$stmtsValues = \array_values($classMethod->stmts);
|
||||
return $this->unwrapExpression($stmtsValues[0]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,8 +7,11 @@ use PhpParser\Node;
|
|||
use PhpParser\Node\Param;
|
||||
use PHPStan\BetterReflection\Reflection\Adapter\ReflectionParameter;
|
||||
use PHPStan\Reflection\ClassReflection;
|
||||
use PHPStan\Reflection\ParameterReflection;
|
||||
use PHPStan\Type\MixedType;
|
||||
use PHPStan\Type\NullType;
|
||||
use PHPStan\Type\Type;
|
||||
use PHPStan\Type\TypeCombinator;
|
||||
use PHPStan\Type\TypehintHelper;
|
||||
use Rector\StaticTypeMapper\StaticTypeMapper;
|
||||
use RectorPrefix20210704\Symplify\PackageBuilder\Reflection\PrivatesAccessor;
|
||||
|
@ -30,6 +33,17 @@ final class NativeTypeClassTreeResolver
|
|||
public function resolveParameterReflectionType(\PHPStan\Reflection\ClassReflection $classReflection, string $methodName, int $position) : ?\PHPStan\Type\Type
|
||||
{
|
||||
$nativeReflectionClass = $classReflection->getNativeReflection();
|
||||
if (!$classReflection->hasNativeMethod($methodName)) {
|
||||
return null;
|
||||
}
|
||||
$phpstanParameterReflection = null;
|
||||
$methodReflection = $classReflection->getNativeMethod($methodName);
|
||||
foreach ($methodReflection->getVariants() as $parametersAcceptor) {
|
||||
$phpstanParameterReflection = $parametersAcceptor->getParameters()[$position] ?? null;
|
||||
}
|
||||
if (!$phpstanParameterReflection instanceof \PHPStan\Reflection\ParameterReflection) {
|
||||
return null;
|
||||
}
|
||||
$reflectionMethod = $nativeReflectionClass->getMethod($methodName);
|
||||
$parameterReflection = $reflectionMethod->getParameters()[$position] ?? null;
|
||||
if (!$parameterReflection instanceof \ReflectionParameter) {
|
||||
|
@ -37,13 +51,13 @@ final class NativeTypeClassTreeResolver
|
|||
return null;
|
||||
}
|
||||
// "native" reflection from PHPStan removes the type, so we need to check with both reflection and php-paser
|
||||
$nativeType = $this->resolveNativeType($parameterReflection);
|
||||
$nativeType = $this->resolveNativeType($parameterReflection, $phpstanParameterReflection);
|
||||
if (!$nativeType instanceof \PHPStan\Type\MixedType) {
|
||||
return $nativeType;
|
||||
}
|
||||
return \PHPStan\Type\TypehintHelper::decideTypeFromReflection($parameterReflection->getType(), null, $classReflection->getName(), $parameterReflection->isVariadic());
|
||||
}
|
||||
private function resolveNativeType(\ReflectionParameter $reflectionParameter) : \PHPStan\Type\Type
|
||||
private function resolveNativeType(\ReflectionParameter $reflectionParameter, \PHPStan\Reflection\ParameterReflection $parameterReflection) : \PHPStan\Type\Type
|
||||
{
|
||||
if (!$reflectionParameter instanceof \PHPStan\BetterReflection\Reflection\Adapter\ReflectionParameter) {
|
||||
return new \PHPStan\Type\MixedType();
|
||||
|
@ -56,6 +70,18 @@ final class NativeTypeClassTreeResolver
|
|||
if (!$param->type instanceof \PhpParser\Node) {
|
||||
return new \PHPStan\Type\MixedType();
|
||||
}
|
||||
return $this->staticTypeMapper->mapPhpParserNodePHPStanType($param->type);
|
||||
$paramType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($param->type);
|
||||
return $this->joinWithNullTypeIfNullDefaultValue($parameterReflection, $paramType);
|
||||
}
|
||||
private function joinWithNullTypeIfNullDefaultValue(\PHPStan\Reflection\ParameterReflection $parameterReflection, \PHPStan\Type\Type $paramType) : \PHPStan\Type\Type
|
||||
{
|
||||
// nullable type!
|
||||
if (!$parameterReflection->getDefaultValue() instanceof \PHPStan\Type\NullType) {
|
||||
return $paramType;
|
||||
}
|
||||
if (\PHPStan\Type\TypeCombinator::containsNull($paramType)) {
|
||||
return $paramType;
|
||||
}
|
||||
return \PHPStan\Type\TypeCombinator::addNull($paramType);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,24 +1,23 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\DowngradePhp72\Rector\Class_;
|
||||
namespace Rector\DowngradePhp72\Rector\ClassMethod;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Param;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassLike;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Interface_;
|
||||
use PhpParser\Node\Stmt\Trait_;
|
||||
use PHPStan\Analyser\Scope;
|
||||
use PHPStan\Reflection\ClassReflection;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\NodeAnalyzer\ExternalFullyQualifiedAnalyzer;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\DowngradePhp72\NodeAnalyzer\ClassLikeWithTraitsClassMethodResolver;
|
||||
use Rector\DowngradePhp72\NodeAnalyzer\ParamContravariantDetector;
|
||||
use Rector\DowngradePhp72\NodeAnalyzer\ParentChildClassMethodTypeResolver;
|
||||
use Rector\DowngradePhp72\PhpDoc\NativeParamToPhpDocDecorator;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\NodeTypeResolver\PHPStan\Collector\TraitNodeScopeCollector;
|
||||
use Rector\NodeTypeResolver\PHPStan\Type\TypeFactory;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
|
@ -26,7 +25,7 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
|||
* @changelog https://www.php.net/manual/en/migration72.new-features.php#migration72.new-features.param-type-widening
|
||||
* @see https://3v4l.org/fOgSE
|
||||
*
|
||||
* @see \Rector\Tests\DowngradePhp72\Rector\Class_\DowngradeParameterTypeWideningRector\DowngradeParameterTypeWideningRectorTest
|
||||
* @see \Rector\Tests\DowngradePhp72\Rector\ClassMethod\DowngradeParameterTypeWideningRector\DowngradeParameterTypeWideningRectorTest
|
||||
*/
|
||||
final class DowngradeParameterTypeWideningRector extends \Rector\Core\Rector\AbstractRector
|
||||
{
|
||||
|
@ -51,17 +50,17 @@ final class DowngradeParameterTypeWideningRector extends \Rector\Core\Rector\Abs
|
|||
*/
|
||||
private $typeFactory;
|
||||
/**
|
||||
* @var \Rector\Core\NodeAnalyzer\ExternalFullyQualifiedAnalyzer
|
||||
* @var \Rector\NodeTypeResolver\PHPStan\Collector\TraitNodeScopeCollector
|
||||
*/
|
||||
private $externalFullyQualifiedAnalyzer;
|
||||
public function __construct(\Rector\DowngradePhp72\NodeAnalyzer\ClassLikeWithTraitsClassMethodResolver $classLikeWithTraitsClassMethodResolver, \Rector\DowngradePhp72\NodeAnalyzer\ParentChildClassMethodTypeResolver $parentChildClassMethodTypeResolver, \Rector\DowngradePhp72\PhpDoc\NativeParamToPhpDocDecorator $nativeParamToPhpDocDecorator, \Rector\DowngradePhp72\NodeAnalyzer\ParamContravariantDetector $paramContravariantDetector, \Rector\NodeTypeResolver\PHPStan\Type\TypeFactory $typeFactory, \Rector\Core\NodeAnalyzer\ExternalFullyQualifiedAnalyzer $externalFullyQualifiedAnalyzer)
|
||||
private $traitNodeScopeCollector;
|
||||
public function __construct(\Rector\DowngradePhp72\NodeAnalyzer\ClassLikeWithTraitsClassMethodResolver $classLikeWithTraitsClassMethodResolver, \Rector\DowngradePhp72\NodeAnalyzer\ParentChildClassMethodTypeResolver $parentChildClassMethodTypeResolver, \Rector\DowngradePhp72\PhpDoc\NativeParamToPhpDocDecorator $nativeParamToPhpDocDecorator, \Rector\DowngradePhp72\NodeAnalyzer\ParamContravariantDetector $paramContravariantDetector, \Rector\NodeTypeResolver\PHPStan\Type\TypeFactory $typeFactory, \Rector\NodeTypeResolver\PHPStan\Collector\TraitNodeScopeCollector $traitNodeScopeCollector)
|
||||
{
|
||||
$this->classLikeWithTraitsClassMethodResolver = $classLikeWithTraitsClassMethodResolver;
|
||||
$this->parentChildClassMethodTypeResolver = $parentChildClassMethodTypeResolver;
|
||||
$this->nativeParamToPhpDocDecorator = $nativeParamToPhpDocDecorator;
|
||||
$this->paramContravariantDetector = $paramContravariantDetector;
|
||||
$this->typeFactory = $typeFactory;
|
||||
$this->externalFullyQualifiedAnalyzer = $externalFullyQualifiedAnalyzer;
|
||||
$this->traitNodeScopeCollector = $traitNodeScopeCollector;
|
||||
}
|
||||
public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
|
||||
{
|
||||
|
@ -101,14 +100,14 @@ CODE_SAMPLE
|
|||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [\PhpParser\Node\Stmt\Class_::class, \PhpParser\Node\Stmt\Interface_::class];
|
||||
return [\PhpParser\Node\Stmt\ClassMethod::class];
|
||||
}
|
||||
/**
|
||||
* @param Class_|Interface_ $node
|
||||
* @param ClassMethod $node
|
||||
*/
|
||||
public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node
|
||||
{
|
||||
$scope = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE);
|
||||
$scope = $this->resolveScope($node);
|
||||
if (!$scope instanceof \PHPStan\Analyser\Scope) {
|
||||
return null;
|
||||
}
|
||||
|
@ -119,21 +118,18 @@ CODE_SAMPLE
|
|||
if ($this->isEmptyClassReflection($classReflection)) {
|
||||
return null;
|
||||
}
|
||||
if ($this->externalFullyQualifiedAnalyzer->hasExternalFullyQualifieds($node)) {
|
||||
return null;
|
||||
}
|
||||
$hasChanged = \false;
|
||||
/** @var ClassReflection[] $ancestors */
|
||||
$ancestors = $classReflection->getAncestors();
|
||||
$classMethods = $this->classLikeWithTraitsClassMethodResolver->resolve($ancestors);
|
||||
$classLikes = $this->nodeRepository->findClassesAndInterfacesByType($classReflection->getName());
|
||||
$interfaces = $classReflection->getInterfaces();
|
||||
$interfaceClassReflections = $classReflection->getInterfaces();
|
||||
foreach ($classMethods as $classMethod) {
|
||||
if ($this->skipClassMethod($classMethod, $classReflection, $ancestors, $classLikes)) {
|
||||
continue;
|
||||
}
|
||||
// refactor here
|
||||
$changedClassMethod = $this->refactorClassMethod($classMethod, $classReflection, $ancestors, $interfaces);
|
||||
$changedClassMethod = $this->refactorClassMethod($classMethod, $classReflection, $ancestors, $interfaceClassReflections);
|
||||
if ($changedClassMethod !== null) {
|
||||
$hasChanged = \true;
|
||||
}
|
||||
|
@ -213,4 +209,18 @@ CODE_SAMPLE
|
|||
}
|
||||
return \count($classReflection->getAncestors()) === 1;
|
||||
}
|
||||
private function resolveScope(\PhpParser\Node\Stmt\ClassMethod $classMethod) : ?\PHPStan\Analyser\Scope
|
||||
{
|
||||
$scope = $classMethod->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE);
|
||||
if ($scope instanceof \PHPStan\Analyser\Scope) {
|
||||
return $scope;
|
||||
}
|
||||
// fallback to a trait method
|
||||
$classLike = $classMethod->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::CLASS_NODE);
|
||||
if ($classLike instanceof \PhpParser\Node\Stmt\Trait_) {
|
||||
$traitName = $this->getName($classLike);
|
||||
return $this->traitNodeScopeCollector->getScopeForTrait($traitName);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@ use PHPStan\Type\UnionType;
|
|||
final class DetailedTypeAnalyzer
|
||||
{
|
||||
/**
|
||||
* Use this constant to avoid overly detailed long-dragging union types across whole universe
|
||||
* @var int
|
||||
*/
|
||||
private const MAX_NUMBER_OF_TYPES = 3;
|
||||
|
|
|
@ -166,9 +166,6 @@ CODE_SAMPLE
|
|||
if ($newType instanceof \PHPStan\Type\ArrayType && $this->shouldSkipArrayType($newType, $classMethod, $phpDocInfo)) {
|
||||
return \true;
|
||||
}
|
||||
if ($this->detailedTypeAnalyzer->isTooDetailed($newType)) {
|
||||
return \true;
|
||||
}
|
||||
// not an array type
|
||||
if ($newType instanceof \PHPStan\Type\VoidType) {
|
||||
return \true;
|
||||
|
|
|
@ -231,8 +231,10 @@ CODE_SAMPLE
|
|||
if (!$classLike instanceof \PhpParser\Node\Stmt\Class_) {
|
||||
return \false;
|
||||
}
|
||||
$hasExternalClassOrInterfaceOrTrait = $this->externalFullyQualifiedAnalyzer->hasExternalFullyQualifieds($classLike);
|
||||
return $functionLike->returnType === null && $hasExternalClassOrInterfaceOrTrait && $this->isName($inferredReturnNode, 'void');
|
||||
if (!$this->externalFullyQualifiedAnalyzer->hasVendorLocatedDependency($classLike)) {
|
||||
return \false;
|
||||
}
|
||||
return $functionLike->returnType === null && $this->isName($inferredReturnNode, 'void');
|
||||
}
|
||||
private function isNullableTypeSubType(\PHPStan\Type\Type $currentType, \PHPStan\Type\Type $inferedType) : bool
|
||||
{
|
||||
|
|
|
@ -73,7 +73,11 @@ final class PropertyTypeInferer
|
|||
if ($resolvedTypes !== []) {
|
||||
$resolvedType = $this->typeFactory->createMixedPassedOrUnionType($resolvedTypes);
|
||||
} else {
|
||||
// void type is not allowed in properties
|
||||
$resolvedType = $this->varDocPropertyTypeInferer->inferProperty($property);
|
||||
if ($resolvedType instanceof \PHPStan\Type\VoidType) {
|
||||
return new \PHPStan\Type\MixedType();
|
||||
}
|
||||
}
|
||||
// default value type must be added to each resolved type if set
|
||||
$propertyDefaultValue = $property->props[0]->default;
|
||||
|
|
|
@ -52,7 +52,7 @@ final class SilentVoidResolver
|
|||
if ($this->betterNodeFinder->hasInstancesOf((array) $functionLike->stmts, [\PhpParser\Node\Expr\Yield_::class])) {
|
||||
return \false;
|
||||
}
|
||||
if ($classLike instanceof \PhpParser\Node\Stmt\Class_ && $this->externalFullyQualifiedAnalyzer->hasExternalFullyQualifieds($classLike)) {
|
||||
if ($classLike instanceof \PhpParser\Node\Stmt\Class_ && $this->externalFullyQualifiedAnalyzer->hasVendorLocatedDependency($classLike)) {
|
||||
return \false;
|
||||
}
|
||||
/** @var Return_[] $returns */
|
||||
|
|
|
@ -11,10 +11,13 @@ use PHPStan\Type\NeverType;
|
|||
use PHPStan\Type\ObjectType;
|
||||
use PHPStan\Type\StringType;
|
||||
use PHPStan\Type\Type;
|
||||
use PHPStan\Type\TypeTraverser;
|
||||
use PHPStan\Type\UnionType;
|
||||
use Rector\NodeTypeResolver\PHPStan\Type\TypeFactory;
|
||||
use Rector\StaticTypeMapper\TypeFactory\UnionTypeFactory;
|
||||
use Rector\TypeDeclaration\ValueObject\NestedArrayType;
|
||||
use RectorPrefix20210704\Symplify\PackageBuilder\Reflection\PrivatesAccessor;
|
||||
use RectorPrefix20210704\Symplify\SimplePhpDocParser\PhpDocNodeTraverser;
|
||||
/**
|
||||
* @see \Rector\Tests\TypeDeclaration\TypeNormalizerTest
|
||||
*/
|
||||
|
@ -32,10 +35,20 @@ final class TypeNormalizer
|
|||
* @var \Rector\StaticTypeMapper\TypeFactory\UnionTypeFactory
|
||||
*/
|
||||
private $unionTypeFactory;
|
||||
public function __construct(\Rector\NodeTypeResolver\PHPStan\Type\TypeFactory $typeFactory, \Rector\StaticTypeMapper\TypeFactory\UnionTypeFactory $unionTypeFactory)
|
||||
/**
|
||||
* @var \Symplify\PackageBuilder\Reflection\PrivatesAccessor
|
||||
*/
|
||||
private $privatesAccessor;
|
||||
public function __construct(
|
||||
\Rector\NodeTypeResolver\PHPStan\Type\TypeFactory $typeFactory,
|
||||
\Rector\StaticTypeMapper\TypeFactory\UnionTypeFactory $unionTypeFactory,
|
||||
// private PhpDocNodeTraverser $phpDocNodeTraverser,
|
||||
\RectorPrefix20210704\Symplify\PackageBuilder\Reflection\PrivatesAccessor $privatesAccessor
|
||||
)
|
||||
{
|
||||
$this->typeFactory = $typeFactory;
|
||||
$this->unionTypeFactory = $unionTypeFactory;
|
||||
$this->privatesAccessor = $privatesAccessor;
|
||||
}
|
||||
public function convertConstantArrayTypeToArrayType(\PHPStan\Type\Constant\ConstantArrayType $constantArrayType) : ?\PHPStan\Type\ArrayType
|
||||
{
|
||||
|
@ -88,20 +101,32 @@ final class TypeNormalizer
|
|||
*/
|
||||
public function normalizeArrayTypeAndArrayNever(\PHPStan\Type\Type $type) : \PHPStan\Type\Type
|
||||
{
|
||||
if (!$type instanceof \PHPStan\Type\UnionType) {
|
||||
return $type;
|
||||
}
|
||||
$nonNeverTypes = [];
|
||||
foreach ($type->getTypes() as $unionedType) {
|
||||
if (!$unionedType instanceof \PHPStan\Type\ArrayType) {
|
||||
return $type;
|
||||
return \PHPStan\Type\TypeTraverser::map($type, function (\PHPStan\Type\Type $traversedType, callable $traverserCallable) : Type {
|
||||
if ($traversedType instanceof \PHPStan\Type\Constant\ConstantArrayType && $traversedType->getKeyType() instanceof \PHPStan\Type\NeverType && $traversedType->getItemType() instanceof \PHPStan\Type\NeverType) {
|
||||
// not sure why, but with direct new node everything gets nulled to MixedType
|
||||
$this->privatesAccessor->setPrivateProperty($traversedType, 'keyType', new \PHPStan\Type\MixedType());
|
||||
$this->privatesAccessor->setPrivateProperty($traversedType, 'itemType', new \PHPStan\Type\MixedType());
|
||||
return $traversedType;
|
||||
}
|
||||
if ($unionedType->getItemType() instanceof \PHPStan\Type\NeverType) {
|
||||
continue;
|
||||
if ($traversedType instanceof \PHPStan\Type\UnionType) {
|
||||
$collectedTypes = [];
|
||||
foreach ($traversedType->getTypes() as $unionedType) {
|
||||
// basically an empty array - not useful at all
|
||||
if ($this->isArrayNeverType($unionedType)) {
|
||||
continue;
|
||||
}
|
||||
$collectedTypes[] = $unionedType;
|
||||
}
|
||||
// re-create new union types
|
||||
if (\count($traversedType->getTypes()) !== \count($collectedTypes)) {
|
||||
return $this->typeFactory->createMixedPassedOrUnionType($collectedTypes);
|
||||
}
|
||||
}
|
||||
$nonNeverTypes[] = $unionedType;
|
||||
}
|
||||
return $this->typeFactory->createMixedPassedOrUnionType($nonNeverTypes);
|
||||
if ($traversedType instanceof \PHPStan\Type\NeverType) {
|
||||
return new \PHPStan\Type\MixedType();
|
||||
}
|
||||
return $traverserCallable($traversedType, $traverserCallable);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @param array<string|int, Type> $nonConstantValueTypes
|
||||
|
@ -147,4 +172,11 @@ final class TypeNormalizer
|
|||
}
|
||||
return $unionedTypes[0];
|
||||
}
|
||||
private function isArrayNeverType(\PHPStan\Type\Type $type) : bool
|
||||
{
|
||||
if (!$type instanceof \PHPStan\Type\ArrayType) {
|
||||
return \false;
|
||||
}
|
||||
return $type->getKeyType() instanceof \PHPStan\Type\NeverType && $type->getItemType() instanceof \PHPStan\Type\NeverType;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,11 +16,11 @@ final class VersionResolver
|
|||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'ae715161506688e6503775f23cf75a0ac9f0dc57';
|
||||
public const PACKAGE_VERSION = 'a9b1bbba885aa28167e65e5a46063959cf6449a3';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2021-07-04 15:15:47';
|
||||
public const RELEASE_DATE = '2021-07-04 18:11:13';
|
||||
public static function resolvePackageVersion() : string
|
||||
{
|
||||
$process = new \RectorPrefix20210704\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);
|
||||
|
|
|
@ -3,91 +3,36 @@
|
|||
declare (strict_types=1);
|
||||
namespace Rector\Core\NodeAnalyzer;
|
||||
|
||||
use PhpParser\Node\Name\FullyQualified;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassLike;
|
||||
use PhpParser\Node\Stmt\Interface_;
|
||||
use PhpParser\Node\Stmt\TraitUse;
|
||||
use Rector\NodeCollector\NodeCollector\NodeRepository;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use PhpParser\Node;
|
||||
use PHPStan\Analyser\Scope;
|
||||
use PHPStan\Reflection\ClassReflection;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
final class ExternalFullyQualifiedAnalyzer
|
||||
{
|
||||
/**
|
||||
* @var \Rector\NodeNameResolver\NodeNameResolver
|
||||
* Is in a class that depends on a class, interface or trait located in vendor?
|
||||
*/
|
||||
private $nodeNameResolver;
|
||||
/**
|
||||
* @var \Rector\NodeCollector\NodeCollector\NodeRepository
|
||||
*/
|
||||
private $nodeRepository;
|
||||
public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\NodeCollector\NodeCollector\NodeRepository $nodeRepository)
|
||||
public function hasVendorLocatedDependency(\PhpParser\Node $node) : bool
|
||||
{
|
||||
$this->nodeNameResolver = $nodeNameResolver;
|
||||
$this->nodeRepository = $nodeRepository;
|
||||
}
|
||||
public function hasExternalFullyQualifieds(\PhpParser\Node\Stmt\ClassLike $classLike) : bool
|
||||
{
|
||||
if ($classLike instanceof \PhpParser\Node\Stmt\Class_ || $classLike instanceof \PhpParser\Node\Stmt\Interface_) {
|
||||
$extends = $classLike->extends ?? [];
|
||||
} else {
|
||||
$extends = [];
|
||||
}
|
||||
/** @var FullyQualified[] $extends */
|
||||
$extends = $extends instanceof \PhpParser\Node\Name\FullyQualified ? [$extends] : $extends;
|
||||
/** @var FullyQualified[] $implements */
|
||||
$implements = $classLike instanceof \PhpParser\Node\Stmt\Class_ ? $classLike->implements : [];
|
||||
$parentClassesAndInterfaces = \array_merge($extends, $implements);
|
||||
$hasExternalClassOrInterface = $this->hasExternalClassOrInterface($parentClassesAndInterfaces);
|
||||
if ($hasExternalClassOrInterface) {
|
||||
return \true;
|
||||
}
|
||||
/** @var TraitUse[] $traitUses */
|
||||
$traitUses = $classLike->getTraitUses();
|
||||
return $this->hasExternalTrait($traitUses);
|
||||
}
|
||||
/**
|
||||
* @param FullyQualified[] $fullyQualifiedClassLikes
|
||||
*/
|
||||
private function hasExternalClassOrInterface(array $fullyQualifiedClassLikes) : bool
|
||||
{
|
||||
if ($fullyQualifiedClassLikes === []) {
|
||||
$scope = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE);
|
||||
if (!$scope instanceof \PHPStan\Analyser\Scope) {
|
||||
return \false;
|
||||
}
|
||||
foreach ($fullyQualifiedClassLikes as $fullyQualifiedClassLike) {
|
||||
/** @var string $className */
|
||||
$className = $this->nodeNameResolver->getName($fullyQualifiedClassLike);
|
||||
$isClassFound = (bool) $this->nodeRepository->findClass($className);
|
||||
$isInterfaceFound = (bool) $this->nodeRepository->findInterface($className);
|
||||
if ($isClassFound) {
|
||||
continue;
|
||||
}
|
||||
if ($isInterfaceFound) {
|
||||
continue;
|
||||
}
|
||||
return \true;
|
||||
}
|
||||
return \false;
|
||||
}
|
||||
/**
|
||||
* @param TraitUse[] $traitUses
|
||||
*/
|
||||
private function hasExternalTrait(array $traitUses) : bool
|
||||
{
|
||||
if ($traitUses === []) {
|
||||
$classReflection = $scope->getClassReflection();
|
||||
if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) {
|
||||
return \false;
|
||||
}
|
||||
foreach ($traitUses as $traitUse) {
|
||||
$traits = $traitUse->traits;
|
||||
foreach ($traits as $trait) {
|
||||
if (!$trait instanceof \PhpParser\Node\Name\FullyQualified) {
|
||||
return \false;
|
||||
}
|
||||
/** @var string $traitName */
|
||||
$traitName = $this->nodeNameResolver->getName($trait);
|
||||
$isTraitFound = (bool) $this->nodeRepository->findTrait($traitName);
|
||||
if (!$isTraitFound) {
|
||||
return \true;
|
||||
}
|
||||
foreach ($classReflection->getAncestors() as $ancestorClassReflection) {
|
||||
if ($classReflection === $ancestorClassReflection) {
|
||||
continue;
|
||||
}
|
||||
$fileName = $ancestorClassReflection->getFileName();
|
||||
if ($fileName === \false) {
|
||||
continue;
|
||||
}
|
||||
// file is located in vendor → out of modifiable scope
|
||||
if (\strpos($fileName, '/vendor/') !== \false) {
|
||||
return \true;
|
||||
}
|
||||
}
|
||||
return \false;
|
||||
|
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
|
@ -4,4 +4,4 @@
|
|||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit145992c1eaf2e01c7d399b1f11991827::getLoader();
|
||||
return ComposerAutoloaderInit279cd36fd7e6970be92a5a3112a289e3::getLoader();
|
||||
|
|
2
vendor/composer/autoload_classmap.php
vendored
2
vendor/composer/autoload_classmap.php
vendored
|
@ -2138,7 +2138,7 @@ return array(
|
|||
'Rector\\DowngradePhp72\\NodeAnalyzer\\ParamContravariantDetector' => $baseDir . '/rules/DowngradePhp72/NodeAnalyzer/ParamContravariantDetector.php',
|
||||
'Rector\\DowngradePhp72\\NodeAnalyzer\\ParentChildClassMethodTypeResolver' => $baseDir . '/rules/DowngradePhp72/NodeAnalyzer/ParentChildClassMethodTypeResolver.php',
|
||||
'Rector\\DowngradePhp72\\PhpDoc\\NativeParamToPhpDocDecorator' => $baseDir . '/rules/DowngradePhp72/PhpDoc/NativeParamToPhpDocDecorator.php',
|
||||
'Rector\\DowngradePhp72\\Rector\\Class_\\DowngradeParameterTypeWideningRector' => $baseDir . '/rules/DowngradePhp72/Rector/Class_/DowngradeParameterTypeWideningRector.php',
|
||||
'Rector\\DowngradePhp72\\Rector\\ClassMethod\\DowngradeParameterTypeWideningRector' => $baseDir . '/rules/DowngradePhp72/Rector/ClassMethod/DowngradeParameterTypeWideningRector.php',
|
||||
'Rector\\DowngradePhp72\\Rector\\FuncCall\\DowngradePregUnmatchedAsNullConstantRector' => $baseDir . '/rules/DowngradePhp72/Rector/FuncCall/DowngradePregUnmatchedAsNullConstantRector.php',
|
||||
'Rector\\DowngradePhp72\\Rector\\FuncCall\\DowngradeStreamIsattyRector' => $baseDir . '/rules/DowngradePhp72/Rector/FuncCall/DowngradeStreamIsattyRector.php',
|
||||
'Rector\\DowngradePhp72\\Rector\\FunctionLike\\DowngradeObjectTypeDeclarationRector' => $baseDir . '/rules/DowngradePhp72/Rector/FunctionLike/DowngradeObjectTypeDeclarationRector.php',
|
||||
|
|
14
vendor/composer/autoload_real.php
vendored
14
vendor/composer/autoload_real.php
vendored
|
@ -2,7 +2,7 @@
|
|||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit145992c1eaf2e01c7d399b1f11991827
|
||||
class ComposerAutoloaderInit279cd36fd7e6970be92a5a3112a289e3
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,15 +22,15 @@ class ComposerAutoloaderInit145992c1eaf2e01c7d399b1f11991827
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit145992c1eaf2e01c7d399b1f11991827', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit279cd36fd7e6970be92a5a3112a289e3', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit145992c1eaf2e01c7d399b1f11991827', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit279cd36fd7e6970be92a5a3112a289e3', '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\ComposerStaticInit145992c1eaf2e01c7d399b1f11991827::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit279cd36fd7e6970be92a5a3112a289e3::getInitializer($loader));
|
||||
} else {
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
|
@ -42,19 +42,19 @@ class ComposerAutoloaderInit145992c1eaf2e01c7d399b1f11991827
|
|||
$loader->register(true);
|
||||
|
||||
if ($useStaticLoader) {
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit145992c1eaf2e01c7d399b1f11991827::$files;
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit279cd36fd7e6970be92a5a3112a289e3::$files;
|
||||
} else {
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
}
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire145992c1eaf2e01c7d399b1f11991827($fileIdentifier, $file);
|
||||
composerRequire279cd36fd7e6970be92a5a3112a289e3($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
|
||||
function composerRequire145992c1eaf2e01c7d399b1f11991827($fileIdentifier, $file)
|
||||
function composerRequire279cd36fd7e6970be92a5a3112a289e3($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
require $file;
|
||||
|
|
10
vendor/composer/autoload_static.php
vendored
10
vendor/composer/autoload_static.php
vendored
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit145992c1eaf2e01c7d399b1f11991827
|
||||
class ComposerStaticInit279cd36fd7e6970be92a5a3112a289e3
|
||||
{
|
||||
public static $files = array (
|
||||
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
|
||||
|
@ -2493,7 +2493,7 @@ class ComposerStaticInit145992c1eaf2e01c7d399b1f11991827
|
|||
'Rector\\DowngradePhp72\\NodeAnalyzer\\ParamContravariantDetector' => __DIR__ . '/../..' . '/rules/DowngradePhp72/NodeAnalyzer/ParamContravariantDetector.php',
|
||||
'Rector\\DowngradePhp72\\NodeAnalyzer\\ParentChildClassMethodTypeResolver' => __DIR__ . '/../..' . '/rules/DowngradePhp72/NodeAnalyzer/ParentChildClassMethodTypeResolver.php',
|
||||
'Rector\\DowngradePhp72\\PhpDoc\\NativeParamToPhpDocDecorator' => __DIR__ . '/../..' . '/rules/DowngradePhp72/PhpDoc/NativeParamToPhpDocDecorator.php',
|
||||
'Rector\\DowngradePhp72\\Rector\\Class_\\DowngradeParameterTypeWideningRector' => __DIR__ . '/../..' . '/rules/DowngradePhp72/Rector/Class_/DowngradeParameterTypeWideningRector.php',
|
||||
'Rector\\DowngradePhp72\\Rector\\ClassMethod\\DowngradeParameterTypeWideningRector' => __DIR__ . '/../..' . '/rules/DowngradePhp72/Rector/ClassMethod/DowngradeParameterTypeWideningRector.php',
|
||||
'Rector\\DowngradePhp72\\Rector\\FuncCall\\DowngradePregUnmatchedAsNullConstantRector' => __DIR__ . '/../..' . '/rules/DowngradePhp72/Rector/FuncCall/DowngradePregUnmatchedAsNullConstantRector.php',
|
||||
'Rector\\DowngradePhp72\\Rector\\FuncCall\\DowngradeStreamIsattyRector' => __DIR__ . '/../..' . '/rules/DowngradePhp72/Rector/FuncCall/DowngradeStreamIsattyRector.php',
|
||||
'Rector\\DowngradePhp72\\Rector\\FunctionLike\\DowngradeObjectTypeDeclarationRector' => __DIR__ . '/../..' . '/rules/DowngradePhp72/Rector/FunctionLike/DowngradeObjectTypeDeclarationRector.php',
|
||||
|
@ -3848,9 +3848,9 @@ class ComposerStaticInit145992c1eaf2e01c7d399b1f11991827
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit145992c1eaf2e01c7d399b1f11991827::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit145992c1eaf2e01c7d399b1f11991827::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit145992c1eaf2e01c7d399b1f11991827::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit279cd36fd7e6970be92a5a3112a289e3::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit279cd36fd7e6970be92a5a3112a289e3::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit279cd36fd7e6970be92a5a3112a289e3::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
16
vendor/composer/installed.json
vendored
16
vendor/composer/installed.json
vendored
|
@ -502,17 +502,17 @@
|
|||
},
|
||||
{
|
||||
"name": "myclabs\/php-enum",
|
||||
"version": "1.8.1",
|
||||
"version_normalized": "1.8.1.0",
|
||||
"version": "1.8.2",
|
||||
"version_normalized": "1.8.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/myclabs\/php-enum.git",
|
||||
"reference": "55555d31a622b4bc9662664132a0533ae6ef47b1"
|
||||
"reference": "8bef486e885cae67ced6e43257300e8acc3f06ad"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/myclabs\/php-enum\/zipball\/55555d31a622b4bc9662664132a0533ae6ef47b1",
|
||||
"reference": "55555d31a622b4bc9662664132a0533ae6ef47b1",
|
||||
"url": "https:\/\/api.github.com\/repos\/myclabs\/php-enum\/zipball\/8bef486e885cae67ced6e43257300e8acc3f06ad",
|
||||
"reference": "8bef486e885cae67ced6e43257300e8acc3f06ad",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -524,7 +524,7 @@
|
|||
"squizlabs\/php_codesniffer": "1.*",
|
||||
"vimeo\/psalm": "^4.6.2"
|
||||
},
|
||||
"time": "2021-06-29T09:20:05+00:00",
|
||||
"time": "2021-07-04T17:44:39+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
|
@ -549,7 +549,7 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https:\/\/github.com\/myclabs\/php-enum\/issues",
|
||||
"source": "https:\/\/github.com\/myclabs\/php-enum\/tree\/1.8.1"
|
||||
"source": "https:\/\/github.com\/myclabs\/php-enum\/tree\/1.8.2"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
@ -1646,7 +1646,7 @@
|
|||
"symplify\/rule-doc-generator": "^9.3",
|
||||
"tracy\/tracy": "^2.8"
|
||||
},
|
||||
"time": "2021-07-04T05:00:25+00:00",
|
||||
"time": "2021-07-04T13:46:56+00:00",
|
||||
"default-branch": true,
|
||||
"type": "rector-extension",
|
||||
"extra": {
|
||||
|
|
2
vendor/composer/installed.php
vendored
2
vendor/composer/installed.php
vendored
File diff suppressed because one or more lines are too long
|
@ -12,16 +12,18 @@ interface LanguageInflectorFactory
|
|||
* @param bool $reset If true, will unset default inflections for all new rules
|
||||
*
|
||||
* @return $this
|
||||
* @param \Doctrine\Inflector\Rules\Ruleset|null $singularRules
|
||||
*/
|
||||
public function withSingularRules(?\RectorPrefix20210704\Doctrine\Inflector\Rules\Ruleset $singularRules, bool $reset = \false);
|
||||
public function withSingularRules($singularRules, bool $reset = \false);
|
||||
/**
|
||||
* Applies custom rules for pluralisation
|
||||
*
|
||||
* @param bool $reset If true, will unset default inflections for all new rules
|
||||
*
|
||||
* @return $this
|
||||
* @param \Doctrine\Inflector\Rules\Ruleset|null $pluralRules
|
||||
*/
|
||||
public function withPluralRules(?\RectorPrefix20210704\Doctrine\Inflector\Rules\Ruleset $pluralRules, bool $reset = \false);
|
||||
public function withPluralRules($pluralRules, bool $reset = \false);
|
||||
/**
|
||||
* Builds the inflector instance with all applicable rules
|
||||
*/
|
||||
|
|
2
vendor/myclabs/php-enum/src/Enum.php
vendored
2
vendor/myclabs/php-enum/src/Enum.php
vendored
|
@ -86,8 +86,8 @@ abstract class Enum implements \JsonSerializable
|
|||
}
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @psalm-param T $value
|
||||
* @return static
|
||||
* @psalm-return static<T>
|
||||
*/
|
||||
public static function from($value)
|
||||
{
|
||||
|
|
10
vendor/scoper-autoload.php
vendored
10
vendor/scoper-autoload.php
vendored
|
@ -9,8 +9,8 @@ $loader = require_once __DIR__.'/autoload.php';
|
|||
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
|
||||
spl_autoload_call('RectorPrefix20210704\AutoloadIncluder');
|
||||
}
|
||||
if (!class_exists('ComposerAutoloaderInit145992c1eaf2e01c7d399b1f11991827', false) && !interface_exists('ComposerAutoloaderInit145992c1eaf2e01c7d399b1f11991827', false) && !trait_exists('ComposerAutoloaderInit145992c1eaf2e01c7d399b1f11991827', false)) {
|
||||
spl_autoload_call('RectorPrefix20210704\ComposerAutoloaderInit145992c1eaf2e01c7d399b1f11991827');
|
||||
if (!class_exists('ComposerAutoloaderInit279cd36fd7e6970be92a5a3112a289e3', false) && !interface_exists('ComposerAutoloaderInit279cd36fd7e6970be92a5a3112a289e3', false) && !trait_exists('ComposerAutoloaderInit279cd36fd7e6970be92a5a3112a289e3', false)) {
|
||||
spl_autoload_call('RectorPrefix20210704\ComposerAutoloaderInit279cd36fd7e6970be92a5a3112a289e3');
|
||||
}
|
||||
if (!class_exists('Doctrine\Inflector\Inflector', false) && !interface_exists('Doctrine\Inflector\Inflector', false) && !trait_exists('Doctrine\Inflector\Inflector', false)) {
|
||||
spl_autoload_call('RectorPrefix20210704\Doctrine\Inflector\Inflector');
|
||||
|
@ -3308,9 +3308,9 @@ if (!function_exists('print_node')) {
|
|||
return \RectorPrefix20210704\print_node(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('composerRequire145992c1eaf2e01c7d399b1f11991827')) {
|
||||
function composerRequire145992c1eaf2e01c7d399b1f11991827() {
|
||||
return \RectorPrefix20210704\composerRequire145992c1eaf2e01c7d399b1f11991827(...func_get_args());
|
||||
if (!function_exists('composerRequire279cd36fd7e6970be92a5a3112a289e3')) {
|
||||
function composerRequire279cd36fd7e6970be92a5a3112a289e3() {
|
||||
return \RectorPrefix20210704\composerRequire279cd36fd7e6970be92a5a3112a289e3(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('parseArgs')) {
|
||||
|
|
|
@ -19,8 +19,9 @@ interface HelperInterface
|
|||
{
|
||||
/**
|
||||
* Sets the helper set associated with this helper.
|
||||
* @param \Symfony\Component\Console\Helper\HelperSet|null $helperSet
|
||||
*/
|
||||
public function setHelperSet(\RectorPrefix20210704\Symfony\Component\Console\Helper\HelperSet $helperSet = null);
|
||||
public function setHelperSet($helperSet = null);
|
||||
/**
|
||||
* Gets the helper set associated with this helper.
|
||||
*
|
||||
|
|
4
vendor/symfony/console/Output/Output.php
vendored
4
vendor/symfony/console/Output/Output.php
vendored
|
@ -148,6 +148,8 @@ abstract class Output implements \RectorPrefix20210704\Symfony\Component\Console
|
|||
}
|
||||
/**
|
||||
* Writes a message to the output.
|
||||
* @param string $message
|
||||
* @param bool $newline
|
||||
*/
|
||||
protected abstract function doWrite(string $message, bool $newline);
|
||||
protected abstract function doWrite($message, $newline);
|
||||
}
|
||||
|
|
|
@ -199,7 +199,7 @@ class Container implements \RectorPrefix20210704\Symfony\Component\DependencyInj
|
|||
*
|
||||
* @see Reference
|
||||
*/
|
||||
public function get(string $id, int $invalidBehavior = 1)
|
||||
public function get($id, int $invalidBehavior = 1)
|
||||
{
|
||||
return $this->services[$id] ?? $this->services[$id = $this->aliases[$id] ?? $id] ?? ('service_container' === $id ? $this : ($this->factories[$id] ?? [$this, 'make'])($id, $invalidBehavior));
|
||||
}
|
||||
|
|
|
@ -452,7 +452,7 @@ class ContainerBuilder extends \RectorPrefix20210704\Symfony\Component\Dependenc
|
|||
*
|
||||
* @see Reference
|
||||
*/
|
||||
public function get(string $id, int $invalidBehavior = \RectorPrefix20210704\Symfony\Component\DependencyInjection\ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE)
|
||||
public function get($id, int $invalidBehavior = \RectorPrefix20210704\Symfony\Component\DependencyInjection\ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE)
|
||||
{
|
||||
if ($this->isCompiled() && isset($this->removedIds[$id]) && \RectorPrefix20210704\Symfony\Component\DependencyInjection\ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE >= $invalidBehavior) {
|
||||
return parent::get($id);
|
||||
|
|
|
@ -24,8 +24,9 @@ class EnvPlaceholderParameterBag extends \RectorPrefix20210704\Symfony\Component
|
|||
private static $counter = 0;
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @param string $name
|
||||
*/
|
||||
public function get(string $name)
|
||||
public function get($name)
|
||||
{
|
||||
if (0 === \strpos($name, 'env(') && ')' === \substr($name, -1) && 'env()' !== $name) {
|
||||
$env = \substr($name, 4, -1);
|
||||
|
|
|
@ -56,8 +56,9 @@ class ParameterBag implements \RectorPrefix20210704\Symfony\Component\Dependency
|
|||
}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @param string $name
|
||||
*/
|
||||
public function get(string $name)
|
||||
public function get($name)
|
||||
{
|
||||
if (!\array_key_exists($name, $this->parameters)) {
|
||||
if (!$name) {
|
||||
|
@ -100,8 +101,9 @@ class ParameterBag implements \RectorPrefix20210704\Symfony\Component\Dependency
|
|||
}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @param string $name
|
||||
*/
|
||||
public function has(string $name)
|
||||
public function has($name)
|
||||
{
|
||||
return \array_key_exists((string) $name, $this->parameters);
|
||||
}
|
||||
|
|
3
vendor/symfony/http-foundation/Response.php
vendored
3
vendor/symfony/http-foundation/Response.php
vendored
|
@ -247,8 +247,9 @@ class Response
|
|||
* @return static
|
||||
*
|
||||
* @deprecated since Symfony 5.1, use __construct() instead.
|
||||
* @param string|null $content
|
||||
*/
|
||||
public static function create(?string $content = '', int $status = 200, array $headers = [])
|
||||
public static function create($content = '', int $status = 200, array $headers = [])
|
||||
{
|
||||
trigger_deprecation('symfony/http-foundation', '5.1', 'The "%s()" method is deprecated, use "new %s()" instead.', __METHOD__, static::class);
|
||||
return new static($content, $status, $headers);
|
||||
|
|
|
@ -22,8 +22,9 @@ interface DataCollectorInterface extends \RectorPrefix20210704\Symfony\Contracts
|
|||
{
|
||||
/**
|
||||
* Collects data for the given Request and Response.
|
||||
* @param \Throwable|null $exception
|
||||
*/
|
||||
public function collect(\RectorPrefix20210704\Symfony\Component\HttpFoundation\Request $request, \RectorPrefix20210704\Symfony\Component\HttpFoundation\Response $response, \Throwable $exception = null);
|
||||
public function collect(\RectorPrefix20210704\Symfony\Component\HttpFoundation\Request $request, \RectorPrefix20210704\Symfony\Component\HttpFoundation\Response $response, $exception = null);
|
||||
/**
|
||||
* Returns the name of the collector.
|
||||
*
|
||||
|
|
|
@ -27,6 +27,7 @@ interface FragmentUriGeneratorInterface
|
|||
* @param bool $sign Whether to sign the URL or not
|
||||
*
|
||||
* @return string A fragment URI
|
||||
* @param \Symfony\Component\HttpFoundation\Request|null $request
|
||||
*/
|
||||
public function generate(\RectorPrefix20210704\Symfony\Component\HttpKernel\Controller\ControllerReference $controller, \RectorPrefix20210704\Symfony\Component\HttpFoundation\Request $request = null, bool $absolute = \false, bool $strict = \true, bool $sign = \true) : string;
|
||||
public function generate(\RectorPrefix20210704\Symfony\Component\HttpKernel\Controller\ControllerReference $controller, $request = null, bool $absolute = \false, bool $strict = \true, bool $sign = \true) : string;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user