lundi 10 février 2020

ReflectionMethod::getReturnType()

I am facing an issue, I hope you guys are able to help me.

Basically I need to check a class method and get the return type class name.

Since PHP 7.0 is no longer possible cast (string)ReflectionMethod::getReturnType() to string, we get an error.

However the getReturnType() return an instance of ReflectionNamedType, with Laravel helper dd() I got the following:

ReflectionNamedType {
  name: "Illuminate\Database\Eloquent\Relations\BelongsTo"
  allowsNull: false
  isBuiltin: false
}

The question is, since I cannot cast... how I can be able to get the name?

Thank you!





Aucun commentaire:

Enregistrer un commentaire