rector/rules/Php74/Guard/MakePropertyTypedGuard.php
Tomas Votruba 2a46c820ee Updated Rector to commit 141a94aa49a3f64e78e3dd2f2a4b1d91de425b8b
141a94aa49 [Performance] [Php74] Reduce ClassReflection lookup from property on PropertyTypeChangeGuard (#4545)
2023-07-20 07:24:15 +00:00

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);
}
}