Php Open API - get referenced class or type



Is there a way in Php open API to find the PHP class or type from the reference?


So for example when i have a PhpReference I would like to know if it refers to a class and which class it is.


What I discovered so far was doing something like this would give me the type

if(reference.getFirstPsiChild() instanceof PhpTypedElement) {
PhpTypedElement typedElement = (PhpTypedElement) reference.getFirstPsiChild();
.forEach(phpClazz -> {

This does however not work if there are multiple possible types, like in this example

* @return Test|User
function createTest() : Test{
return new Test();

So what I am looking for is a way to get all the known return types.


1 comment

My bad, did not realise that a type had a getTypes method.


Please sign in to leave a comment.