Is it possible define param type from class variable with phpdoc in PHP

51 views Asked by At

now I have this:

class UserProvider
{
    protected string $className = User::class;

    /**
     * @param User $entity
     */
    public function getData($entity): array
    {
        $data['name'] = $entity->getName();

        return $data;
    }
}

but I am looking for something like this:

class UserProvider
{
    protected string $className = User::class;

    /**
     * @param [UserProvider->className] $entity
     */
    public function getData($entity): array
    {
        $data['name'] = $entity->getName();

        return $data;
    }
}

any ideas?

0

There are 0 answers