Skip to content

docs(php-modernization): strict-rule bans (short-ternary, @-suppression, mixed cast)#73

Merged
CybotTM merged 2 commits into
mainfrom
docs/phpstan-l10-quickfixes
Jul 16, 2026
Merged

docs(php-modernization): strict-rule bans (short-ternary, @-suppression, mixed cast)#73
CybotTM merged 2 commits into
mainfrom
docs/phpstan-l10-quickfixes

Conversation

@CybotTM

@CybotTM CybotTM commented Jul 16, 2026

Copy link
Copy Markdown
Member

Adds a "Strict-Rule Bans" subsection to references/phpstan-compliance.md under Common Error Fixes.

Why: level 9/10 + a strict ruleset (phpstan-strict-rules / ergebnis) reject three idioms that pass at lower levels, and new code trips them repeatedly. Real case: a fresh renderer/extractor class failed CI on all three in one pass.

What it adds — the compliant rewrites:

  • ternary.shortNotAllowed: ?: → explicit === false check.
  • ergebnis.noErrorSuppression: @try/catch around the warning-emitter (also catches error-handler→exception) + is_file() guards.
  • cast.string: (string) $mixedis_string($v) ? $v : ''.
  • Plus: run the analyzer after adding tests (tests are analyzed too).

Docs-only.

…on, mixed cast)

Add a "Strict-Rule Bans" subsection to phpstan-compliance.md: the compliant
rewrites for three idioms level 9/10 + strict rules (phpstan-strict-rules /
ergebnis) reject — short ternary ?:, the @ operator, and (string) $mixed — plus
the reminder to run the analyzer after adding tests (tests are analyzed too).

Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
Copilot AI review requested due to automatic review settings July 16, 2026 19:47
@github-actions

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@github-actions github-actions Bot added documentation Improvements or additions to documentation skill labels Jul 16, 2026
github-actions[bot]
github-actions Bot previously approved these changes Jul 16, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request updates the phpstan-compliance.md documentation to include guidelines on handling strict-rule bans for short-ternary operators, error suppression, and mixed-to-string casting. The review feedback identifies a potential undefined variable issue in the error suppression example and suggests a more flexible approach for handling scalar-to-string conversions using is_scalar().

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread skills/php-modernization/references/phpstan-compliance.md Outdated
Comment thread skills/php-modernization/references/phpstan-compliance.md Outdated
…ve (review)

Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
@sonarqubecloud

Copy link
Copy Markdown

@CybotTM
CybotTM merged commit d73f256 into main Jul 16, 2026
20 checks passed
@CybotTM
CybotTM deleted the docs/phpstan-l10-quickfixes branch July 16, 2026 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation skill

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants