mirror of
https://github.com/rectorphp/rector.git
synced 2024-05-29 23:40:52 +00:00
2a46c820ee
141a94aa49
[Performance] [Php74] Reduce ClassReflection lookup from property on PropertyTypeChangeGuard (#4545)
27 lines
791 B
PHP
27 lines
791 B
PHP
<?php
|
|
|
|
declare (strict_types=1);
|
|
namespace Rector\Php74\Guard;
|
|
|
|
use PhpParser\Node\Stmt\Property;
|
|
use PHPStan\Reflection\ClassReflection;
|
|
final class MakePropertyTypedGuard
|
|
{
|
|
/**
|
|
* @readonly
|
|
* @var \Rector\Php74\Guard\PropertyTypeChangeGuard
|
|
*/
|
|
private $propertyTypeChangeGuard;
|
|
public function __construct(\Rector\Php74\Guard\PropertyTypeChangeGuard $propertyTypeChangeGuard)
|
|
{
|
|
$this->propertyTypeChangeGuard = $propertyTypeChangeGuard;
|
|
}
|
|
public function isLegal(Property $property, ClassReflection $classReflection, bool $inlinePublic = \true) : bool
|
|
{
|
|
if ($property->type !== null) {
|
|
return \false;
|
|
}
|
|
return $this->propertyTypeChangeGuard->isLegal($property, $classReflection, $inlinePublic);
|
|
}
|
|
}
|