for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace FRZB\Component\RequestMapper\Helper;
use Fp\Collections\ArrayList;
use FRZB\Component\RequestMapper\Attribute\ArrayType;
final class PropertyHelper
{
public static function getTypeName(\ReflectionProperty $property): string
$typeName = $property->getType()?->/** @scrutinizer ignore-call */ getName();
return match ($typeName) {
'array' => self::getAttribute($property, ArrayType::class)?->type ?? $typeName,
default => $typeName,
};
}
/**
* @template T
*
* @param class-string<T> $attribute
class-string<T>
0
* @return null|T
*/
public static function getAttribute(\ReflectionProperty $property, string $attribute): ?object
return ArrayList::collect($property->getAttributes($attribute, \ReflectionAttribute::IS_INSTANCEOF))
->firstElement()
->get()
?->newInstance()
;