use of com.jetbrains.php.lang.psi.elements.impl.VariableImpl in project yii2support by nvlad.
the class YiiTypeProvider method getArrayCreationByVariableRef.
@NotNull
private PhpPsiElement getArrayCreationByVariableRef(PhpPsiElement firstParam) {
Collection<? extends PhpNamedElement> localResolvedVariables = ((VariableImpl) firstParam).resolveLocal();
PhpNamedElement firstElem = localResolvedVariables.iterator().next();
if (firstElem instanceof Variable) {
Variable variableDecl = (Variable) firstElem;
if (variableDecl.getParent() != null) {
PsiElement array = variableDecl.getParent().getLastChild();
if (array instanceof ArrayCreationExpression) {
firstParam = (ArrayCreationExpression) array;
}
}
}
return firstParam;
}
use of com.jetbrains.php.lang.psi.elements.impl.VariableImpl in project idea-php-typo3-plugin by cedricziel.
the class PhpGlobalsTypeProvider method getType.
@Nullable
@Override
public PhpType getType(PsiElement psiElement) {
// $GLOBALS['TYPO3_DB']
if (!(psiElement instanceof ArrayAccessExpression)) {
return null;
}
VariableImpl variable = PsiTreeUtil.getChildOfType(psiElement, VariableImpl.class);
if (variable == null || !variable.getName().equals("GLOBALS")) {
return null;
}
ArrayIndex arrayIndex = PsiTreeUtil.getChildOfType(psiElement, ArrayIndex.class);
if (arrayIndex == null) {
return null;
}
StringLiteralExpression arrayIndexName = PsiTreeUtil.getChildOfType(arrayIndex, StringLiteralExpressionImpl.class);
if (arrayIndexName == null) {
return null;
}
switch(arrayIndexName.getContents()) {
case "TYPO3_DB":
return new PhpType().add("#C\\TYPO3\\CMS\\Core\\Database\\DatabaseConnection");
case "TSFE":
return new PhpType().add("#C\\TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController");
case "BE_USER":
return new PhpType().add("#C\\TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication");
case "LANG":
return new PhpType().add("#C\\TYPO3\\CMS\\Lang\\LanguageService");
default:
return null;
}
}
Aggregations