Skip to content

Code quality: enforce No-Shorthand house rules (alt PHP syntax, ternary/Elvis, JS shorthand) across shared and Component A/B/C #117

@Salem874

Description

@Salem874

Problem

patterns.md bans PHP alternative/template syntax (if():/endif;), ternary (? :) and Elvis (?:) operators, JS ternaries / || default short-circuit assignment / braceless single-line if, and ?? with a function-call operand. Multiple verified deviations exist:

  • PHP alt syntax: web/Go2My.Link/_admin/public_html/pages/security/breach-response.php (lines 148, 172, 190, 199, 204, 209, 320 — the only Component A page using template syntax); eight email templates under web/_includes/email_templates/ (e.g. verify_email.php:68,73; same in password_changed.php, password_reset.php, new_login_alert.php, org_invitation.php, breach_notification.php, data_export_ready.php, data_deletion_requested.php).
  • Ternary: web/_functions/org.php:460-461,667; breach_response.php:518; account_types.php:359; breach-response.php:113,166,313; contact/index.php:110.
  • Elvis (?:): org.php:151,316,763,988,1174; account_types.php:104,463; breach_response.php:323 (double Elvis); profile/sessions/index.php:220.
  • JS shorthand: js/cookie-consent.js:28,31,92,142-144,151; js/app.js:87,165,250; js/theme.js:173,178; header.php:197-199 inline script; landing pages (Go2My.Link 377/379, Lnks.page 381, validating.php 104/231/246, expired.php 105/215, 404.php 79).
  • ?? with function call: $currentYear = $currentYear ?? date('Y'); across ~22 HTML/AMP email templates.

This is style-rule conformance (not a vulnerability), but it is the largest cluster of repeated house-rule deviations and is worth one coordinated cleanup pass.

Recommended fix

Convert each construct to its full form per patterns.md: if () { } else { } blocks (incl. HTML-template context), temporary variables assigned via if/else instead of ternary/Elvis, explicit JS if/else with braces, and if (!isset(...)) { ... = date('Y'); } for the year default. Consider adding Generic.ControlStructures/Generic.Functions sniffs so phpcs flags future regressions.

Acceptance criteria

  • No if():/endif;/foreach(): etc. in the listed PHP files
  • No ? : or ?: operators in the listed PHP files
  • No JS ternary, || default assignment, or braceless if in the listed JS/inline scripts
  • ?? date(...) replaced with if (!isset(...)) in the email templates
  • (Optional) phpcs sniff added to catch future deviations

Filed from the 2026-06-04 deployment-readiness audit — see docs/AUDIT_2026-06-04.md.

Metadata

Metadata

Assignees

No one assigned

    Labels

    component-AComponent A: Main Website (go2my.link)component-BComponent B: Shortlink Domain (g2my.link)component-CComponent C: LinksPage (lnks.page)component-sharedShared infrastructure across all componentspriority-lowLow priority - nice to have

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions