Compare commits

..

No commits in common. "d5e203a6e9fd986c04e2a489083b9766d4381a4d" and "09acbdda133f818e6eeb610fc56d54e7426bb3e3" have entirely different histories.

4 changed files with 9 additions and 27 deletions

View File

@ -3,7 +3,6 @@
declare (strict_types=1);
namespace Rector\DeadCode\NodeAnalyzer;
use PhpParser\Node\Expr\NullsafeMethodCall;
use PhpParser\Node;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr\Array_;
@ -122,7 +121,7 @@ final class IsClassMethodUsedAnalyzer
{
$className = (string) $this->nodeNameResolver->getName($class);
/** @var Node\Expr\NullsafeMethodCall[] $methodCalls */
$methodCalls = $this->betterNodeFinder->findInstanceOf($class, NullsafeMethodCall::class);
$methodCalls = $this->betterNodeFinder->findInstanceOf($class, Node\Expr\NullsafeMethodCall::class);
return $this->callCollectionAnalyzer->isExists($methodCalls, $classMethodName, $className);
}
private function isInArrayMap(Class_ $class, Array_ $array) : bool

View File

@ -3,7 +3,6 @@
declare (strict_types=1);
namespace Rector\Naming\Naming;
use DateTimeInterface;
use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Expr\MethodCall;
@ -94,9 +93,6 @@ final class ExpectedNameResolver
}
$className = $this->nodeNameResolver->getName($new->class);
$fullyQualifiedObjectType = new FullyQualifiedObjectType($className);
if ($fullyQualifiedObjectType->isInstanceOf(DateTimeInterface::class)->yes()) {
return null;
}
$expectedName = $this->propertyNaming->getExpectedNameFromType($fullyQualifiedObjectType);
if (!$expectedName instanceof ExpectedName) {
return null;

View File

@ -19,9 +19,7 @@ use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassConst;
use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\ReflectionProvider;
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
use Rector\Rector\AbstractRector;
use Rector\StaticTypeMapper\StaticTypeMapper;
use Rector\ValueObject\PhpVersionFeature;
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
@ -36,15 +34,9 @@ final class AddTypeToConstRector extends AbstractRector implements MinPhpVersion
* @var \PHPStan\Reflection\ReflectionProvider
*/
private $reflectionProvider;
/**
* @readonly
* @var \Rector\StaticTypeMapper\StaticTypeMapper
*/
private $staticTypeMapper;
public function __construct(ReflectionProvider $reflectionProvider, StaticTypeMapper $staticTypeMapper)
public function __construct(ReflectionProvider $reflectionProvider)
{
$this->reflectionProvider = $reflectionProvider;
$this->staticTypeMapper = $staticTypeMapper;
}
public function getRuleDefinition() : RuleDefinition
{
@ -141,16 +133,11 @@ CODE_SAMPLE
if ($expr instanceof DNumber) {
return new Identifier('float');
}
if ($expr instanceof ConstFetch) {
if ($expr->name->toLowerString() === 'null') {
return new Identifier('null');
}
$type = $this->nodeTypeResolver->getNativeType($expr);
$nodeType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($type, TypeKind::PROPERTY);
if (!$nodeType instanceof Identifier) {
return null;
}
return $nodeType;
if ($expr instanceof ConstFetch && $expr->name->toLowerString() !== 'null') {
return new Identifier('bool');
}
if ($expr instanceof ConstFetch && $expr->name->toLowerString() === 'null') {
return new Identifier('null');
}
if ($expr instanceof Array_) {
return new Identifier('array');

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'd5069f0fccf649646eeea05b5291c0ac34e511d6';
public const PACKAGE_VERSION = '6eac87db32eff9308a037fb32ce973ccf905fc92';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2024-04-23 19:08:22';
public const RELEASE_DATE = '2024-04-22 16:33:11';
/**
* @var int
*/