package com.daveme.intellij.chocolatecakephp;

import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import org.jetbrains.annotations.NotNull;

import java.util.Collection;
import java.util.HashSet;

public class PsiUtil {

    @NotNull
    public static Collection<PsiFile> convertVirtualFilesToPsiFiles(@NotNull Project project, @NotNull Collection<VirtualFile> files) {

        Collection<PsiFile> psiFiles = new HashSet<>();

        PsiManager psiManager = null;
        for (VirtualFile file : files) {

            if(psiManager == null) {
                psiManager = PsiManager.getInstance(project);
            }

            PsiFile psiFile = psiManager.findFile(file);
            if(psiFile != null) {
                psiFiles.add(psiFile);
            }
        }

        return psiFiles;
    }
}

@@ -528,17 +528,16 @@
 et%3C%3E();%0A
-%0A
         
@@ -563,122 +563,8 @@
 er =
- null;%0A        for (VirtualFile file : files) %7B%0A%0A            if(psiManager == null) %7B%0A                psiManager =
  Psi
@@ -593,24 +593,25 @@
 oject);%0A
+%0A
         
     %7D%0A%0A 
@@ -598,30 +598,56 @@
 );%0A%0A        
-    %7D%0A
+for (VirtualFile file : files) %7B
 %0A           

Remove extra if statement