mirror of
https://github.com/rectorphp/rector.git
synced 2025-04-13 03:52:15 +02:00
Updated Rector to commit 457927353525b5f87771493eaa7f79523383b071
4579273535
[TypedPropertyFromAssignsRector] Handle parse_url() native function with second arg on TypedPropertyFromAssignsRector (#6562)
This commit is contained in:
parent
97f68f2790
commit
7f2e323f76
@ -120,10 +120,13 @@ final class AssignToPropertyTypeInferer
|
||||
return null;
|
||||
}
|
||||
$inferredType = $this->typeFactory->createMixedPassedOrUnionType($assignedExprTypes);
|
||||
// to compare with default value, constant type must not be kept
|
||||
// eg, use more general bool over false or true
|
||||
if ($this->shouldSkipWithDifferentDefaultValueType($defaultPropertyValue, $inferredType)) {
|
||||
return null;
|
||||
}
|
||||
return $inferredType;
|
||||
// returns with constant as final result
|
||||
return $this->typeFactory->createMixedPassedOrUnionType($assignedExprTypes, \true);
|
||||
}
|
||||
private function shouldSkipWithDifferentDefaultValueType(?Expr $expr, Type $inferredType) : bool
|
||||
{
|
||||
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '1c9f2321754a7592a17f21b817c7c83548050e76';
|
||||
public const PACKAGE_VERSION = '457927353525b5f87771493eaa7f79523383b071';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2024-12-12 05:31:26';
|
||||
public const RELEASE_DATE = '2024-12-12 07:46:01';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
@ -36,10 +36,10 @@ final class ExprAnalyzer
|
||||
return \true;
|
||||
}
|
||||
$nativeType = $scope->getNativeType($expr);
|
||||
if ($nativeType instanceof MixedType && !$nativeType->isExplicitMixed()) {
|
||||
$type = $scope->getType($expr);
|
||||
if ($nativeType instanceof MixedType && !$nativeType->isExplicitMixed() || $nativeType instanceof MixedType && !$type instanceof MixedType) {
|
||||
return \true;
|
||||
}
|
||||
$type = $scope->getType($expr);
|
||||
if ($nativeType instanceof ObjectWithoutClassType && !$type instanceof ObjectWithoutClassType) {
|
||||
return \true;
|
||||
}
|
||||
|
@ -8,11 +8,13 @@ use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\ArrayDimFetch;
|
||||
use PhpParser\Node\Expr\BinaryOp\Coalesce;
|
||||
use PhpParser\Node\Expr\ClassConstFetch;
|
||||
use PhpParser\Node\Expr\FuncCall;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Expr\New_;
|
||||
use PhpParser\Node\Expr\NullsafeMethodCall;
|
||||
use PhpParser\Node\Expr\StaticCall;
|
||||
use PhpParser\Node\Expr\Ternary;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\NullableType;
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use PhpParser\Node\Stmt\ClassConst;
|
||||
@ -22,6 +24,7 @@ use PhpParser\Node\UnionType as NodeUnionType;
|
||||
use PHPStan\Analyser\Scope;
|
||||
use PHPStan\Broker\ClassAutoloadingException;
|
||||
use PHPStan\Reflection\ClassReflection;
|
||||
use PHPStan\Reflection\Native\NativeFunctionReflection;
|
||||
use PHPStan\Reflection\ReflectionProvider;
|
||||
use PHPStan\Type\ArrayType;
|
||||
use PHPStan\Type\Constant\ConstantArrayType;
|
||||
@ -472,6 +475,19 @@ final class NodeTypeResolver
|
||||
return $scope->getType($expr);
|
||||
}
|
||||
}
|
||||
if ($expr instanceof FuncCall) {
|
||||
if (!$expr->name instanceof Name) {
|
||||
return $scope->getNativeType($expr);
|
||||
}
|
||||
if (!$this->reflectionProvider->hasFunction($expr->name, $scope)) {
|
||||
return $scope->getNativeType($expr);
|
||||
}
|
||||
$functionReflection = $this->reflectionProvider->getFunction($expr->name, $scope);
|
||||
if (!$functionReflection instanceof NativeFunctionReflection) {
|
||||
return $scope->getNativeType($expr);
|
||||
}
|
||||
return $scope->getType($expr);
|
||||
}
|
||||
return $scope->getNativeType($expr);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user