docs(php-modernization): strict-rule bans (short-ternary, @-suppression, mixed cast)#73
Conversation
…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>
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
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.
…ve (review) Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
|



Adds a "Strict-Rule Bans" subsection to
references/phpstan-compliance.mdunder 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=== falsecheck.ergebnis.noErrorSuppression:@→try/catcharound the warning-emitter (also catches error-handler→exception) +is_file()guards.cast.string:(string) $mixed→is_string($v) ? $v : ''.Docs-only.