Skip to content

SONARPHP-1889 Add null checks to prevent NPE and suppress warning#1767

Merged
karim-ouerghemmi-sonarsource merged 3 commits into
masterfrom
rob/fix-qg
Jul 17, 2026
Merged

SONARPHP-1889 Add null checks to prevent NPE and suppress warning#1767
karim-ouerghemmi-sonarsource merged 3 commits into
masterfrom
rob/fix-qg

Conversation

@roberto-orlandi-sonarsource

@roberto-orlandi-sonarsource roberto-orlandi-sonarsource commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Part of


Summary by Gitar

  • Null safety improvements:
    • Added @Nullable annotations and explicit null checks to TokenVisitor methods prevToken and nextToken.
    • Updated ControlStructureSpacingCheck helper methods to handle null tokens gracefully.
  • Code maintenance:
    • Suppressed unnecessary recursion warning in PHPGrammar with @SuppressWarnings.
  • Testing:
    • Added TokenVisitorTest to verify token navigation logic and edge cases including null inputs.

This will update automatically on new commits.

@hashicorp-vault-sonar-prod hashicorp-vault-sonar-prod Bot changed the title Add null checks to prevent NPE and suppress warning SONARPHP-1889 Add null checks to prevent NPE and suppress warning Jul 16, 2026
@hashicorp-vault-sonar-prod

hashicorp-vault-sonar-prod Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

SONARPHP-1889

@sonarqube-next

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!

@karim-ouerghemmi-sonarsource
karim-ouerghemmi-sonarsource merged commit db39126 into master Jul 17, 2026
22 checks passed
@karim-ouerghemmi-sonarsource
karim-ouerghemmi-sonarsource deleted the rob/fix-qg branch July 17, 2026 12:03
@gitar-bot

gitar-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

Adds null checks and nullable annotations to TokenVisitor and ControlStructureSpacingCheck to prevent NPEs, alongside a recursion warning suppression in PHPGrammar. New unit tests confirm the updated token navigation logic.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing less information.

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

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