Skip to content

SONARPHP-1922 Remove deprecated custom rules API - #1801

Merged
karim-ouerghemmi-sonarsource merged 3 commits into
masterfrom
SONARPHP-1922-remove-deprecated-api
Sep 10, 2026
Merged

SONARPHP-1922 Remove deprecated custom rules API#1801
karim-ouerghemmi-sonarsource merged 3 commits into
masterfrom
SONARPHP-1922-remove-deprecated-api

Conversation

@malte-skoruppa-sonarsource

@malte-skoruppa-sonarsource malte-skoruppa-sonarsource commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • remove deprecated custom-rules API members scheduled for the 4.0 cleanup
  • delete ExpressionListStatementTree and related visitor/kind/CFG handling
  • update internal anonymous-class argument traversal, tests, and README migration notes

Verification

  • ./gradlew :php-frontend:test --tests org.sonar.php.tree.impl.expression.FunctionCallTreeTest --tests org.sonar.php.tree.impl.expression.AnonymousClassTreeTest --tests org.sonar.php.tree.impl.declaration.ParameterTreeTest --tests org.sonar.php.tree.impl.declaration.FunctionDeclarationTreeTest --tests org.sonar.php.tree.impl.declaration.MethodDeclarationTreeTest --tests org.sonar.php.tree.impl.declaration.ClassPropertyDeclarationTreeTest --tests org.sonar.php.tree.impl.declaration.ClassDeclarationTreeTest --tests org.sonar.php.tree.impl.declaration.EnumDeclarationTreeTest --tests org.sonar.php.tree.impl.statement.EchoTagStatementTreeTest --tests org.sonar.php.parser.statement.ExpressionListTest --tests org.sonar.php.tree.symbols.UsagesTest --tests org.sonar.plugins.php.api.cfg.ControlFlowGraphTest
  • rg sweep for removed API names and deprecated markers in Java sources
  • git diff --check
  • ./gradlew build
  • ./gradlew :php-frontend:publishToMavenLocal
  • mvn package in php-custom-rules-plugin

Should be merged after https://github.com/SonarSource/sonar-security/pull/7491

@hashicorp-vault-sonar-prod

hashicorp-vault-sonar-prod Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

SONARPHP-1922

Comment thread README.md Outdated
@malte-skoruppa-sonarsource
malte-skoruppa-sonarsource force-pushed the SONARPHP-1922-remove-deprecated-api branch from 290ea9b to e9a0963 Compare September 9, 2026 10:25
@gitar-bot

gitar-bot Bot commented Sep 9, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 1 resolved / 1 findings

Removes deprecated custom rules API members scheduled for the 4.0 cleanup, including ExpressionListStatementTree and related visitor/kind/CFG handling. Internal anonymous-class argument traversal, tests, and README migration notes have been updated accordingly, with the modifierToken() migration note clarified to reflect semantic differences. No issues found.

✅ 1 resolved
Quality: Migration note for modifierToken() omits semantic difference

📄 README.md:61 📄 php-frontend/src/main/java/org/sonar/php/tree/impl/declaration/ClassDeclarationTreeImpl.java:73-82 📄 php-frontend/src/test/java/org/sonar/php/tree/impl/declaration/ClassDeclarationTreeTest.java:153-154
The removed ClassDeclarationTreeImpl.modifierToken() filtered the modifier list down to abstract/final only, so it returned null for readonly class A. modifiersToken() returns every modifier, including readonly — exactly what the updated assertion at ClassDeclarationTreeTest:154 now shows (isNull() became containsExactly("readonly")). The README's 4.0 note says only "Use modifiersToken() and the existing modifier helpers instead", so a custom rule author doing the obvious mechanical migration (e.g. modifiersToken().get(0) or a null/empty check) will silently get different results on readonly classes; the note should call out that the replacement is not a drop-in equivalent and point at isAbstract()/isFinal()/isReadOnly().

Implementation Status ✅ 9 of 9 objectives covered
SONARPHP-1922 - 9 of 9 objectives covered

This PR covers all objectives to remove deprecated custom rules API elements including ExpressionListStatementTree, arguments, type, typeAnnotation, and modifierToken methods across the relevant classes and interfaces in php-frontend.

✅ 9 covered here
  • ✅ Remove internal usages and tests relying on the removed deprecated APIs from php-frontend
  • ✅ Remove deprecated VisitorCheck#visitExpressionListStatement method, ExpressionListStatementTree, and Tree.Kind.EXPRESSION_LIST_STATEMENT
  • ✅ Remove deprecated arguments method from FunctionCallTree and FunctionCallTreeImpl, and use callArguments instead
  • ✅ Remove deprecated arguments method from AnonymousClassTree and AnonymousClassTreeImpl, and use callArguments instead
  • ✅ Remove deprecated type method from ParameterTree and ParameterTreeImpl, and use declaredType instead
  • ✅ Remove deprecated type method from ReturnTypeClauseTree and ReturnTypeClauseTreeImpl, and use declaredType instead
  • ✅ Remove deprecated typeAnnotation method from ClassPropertyDeclarationTree and ClassPropertyDeclarationTreeImpl, and use declaredType instead
  • ✅ Remove deprecated modifierToken method from ClassDeclarationTree and ClassDeclarationTreeImpl, and use modifiersToken instead
  • ✅ Remove deprecated modifierToken method from EnumDeclarationTree, and use modifiersToken instead
Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Counting what did not apply, without listing it.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@sonarqube-next

sonarqube-next Bot commented Sep 9, 2026

Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Nice cleanup!

@karim-ouerghemmi-sonarsource
karim-ouerghemmi-sonarsource merged commit c387ef8 into master Sep 10, 2026
23 checks passed
@karim-ouerghemmi-sonarsource
karim-ouerghemmi-sonarsource deleted the SONARPHP-1922-remove-deprecated-api branch September 10, 2026 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants