Skip to content

Commit

Permalink
fix #259 Incorrect Doctrine deprecation flagged on OpenApi attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
Haehnchen committed Jun 10, 2023
1 parent f4f69bd commit 510982e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ private static String getContentIfTypeValid(@NotNull PsiElement psiElement, @Not
PsiElement attributeNamePsi = PhpPsiUtil.getPrevSibling(psiElement, psiElement1 -> psiElement1 instanceof PsiWhiteSpace || psiElement1.getNode().getElementType() == PhpTokenTypes.opCOLON);
if (attributeNamePsi != null && attributeNamePsi.getNode().getElementType() == PhpTokenTypes.IDENTIFIER) {
String text = attributeNamePsi.getText();
if (text.equals("type")) {
if (property.equals(text)) {
PhpAttribute phpAttribute = PsiTreeUtil.getParentOfType(psiElement, PhpAttribute.class);
if (phpAttribute != null) {
String fqn = phpAttribute.getFQN();
if (fqn != null) {
if (PhpLangUtil.equalsClassNames(clazz, fqn)) {
return ((StringLiteralExpression) psiElement).getContents();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,14 @@ public void testThatDeprecatedInspectionIsDisplayedDoctrineColumnTypesForAttribu
"}",
"[Annotations] Deprecated: Use JsonType instead"
);

assertLocalInspectionIsEmpty("test.php", "<?php\n" +
"use Doctrine\\ORM\\Mapping as ORM;\n" +
"\n" +
"#[ORM\\Foobar(type: 'json<caret>_array')]\n" +
"class Foo\n" +
"{\n" +
"}"
);
}
}

0 comments on commit 510982e

Please sign in to comment.