rector/rules/Php80/NodeAnalyzer/PromotedPropertyResolver.php
Tomas Votruba 934bc262ff Updated Rector to commit 8ed98c17688300b3aa85d978fefc24c88a51f1f3
8ed98c1768 [DX] Use Param->isPromoted() over param->flags !== 0 check on promotion property check (#6646)
2025-01-05 04:12:03 +00:00

31 lines
803 B
PHP

<?php
declare (strict_types=1);
namespace Rector\Php80\NodeAnalyzer;
use PhpParser\Node\Param;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassMethod;
use Rector\ValueObject\MethodName;
final class PromotedPropertyResolver
{
/**
* @return Param[]
*/
public function resolveFromClass(Class_ $class) : array
{
$constructClassMethod = $class->getMethod(MethodName::CONSTRUCT);
if (!$constructClassMethod instanceof ClassMethod) {
return [];
}
$promotedPropertyParams = [];
foreach ($constructClassMethod->getParams() as $param) {
if (!$param->isPromoted()) {
continue;
}
$promotedPropertyParams[] = $param;
}
return $promotedPropertyParams;
}
}