Repository navigation
Redesign the playground and homepage - #143
Conversation
… status bars The editor sits left and the output right, below a bar holding the PHP version select, Settings and Share, above a status bar with the run state and Psalm version. Markup is shared by the homepage and snippet pages via includes/playground.php, and the styles live in a hand-written assets/css/playground.css that overrides the legacy rules in site.css. Expand/Shrink are gone; their functions are kept as no-ops.
Drag, arrow keys or double-click (reset) on the splitter; the split is kept in localStorage when it is available.
Cmd/Ctrl+Enter re-runs the analysis, Cmd/Ctrl+S shares, F8 and Shift+F8 jump to the next and previous issue (wrapping). Issue locations in the output also jump to the issue.
…efaults Settings open as a right-hand column instead of replacing the output, split into Unused code, Inference and Checks, with a Reset button. The Settings button reads "Settings · N changed" when the settings differ from Settings::defaultValues(). Toggling no longer rebuilds the panel, so keyboard focus stays on the checkbox.
…tus bar Jumping to an issue scrolls only the output pane and marks the issue with a black rule. Below 600px the status items wrap onto their own lines.
… and report in the status bar
#L5 or #L5-L12 highlights editor lines on / and /r/<hash>; clicking a line number sets the fragment (Shift+click extends, re-click clears) via replaceState. The highlight follows edits through CodeMirror line handles, Share keeps the fragment in the copied link and address bar, and popstate no longer reloads when only the fragment changed.
- Share is the only filled button and shows "Copied ✓", "Copy failed" or "Share failed" for 2s; the status bar message stays. - Fix code becomes a ghost button. It is kept: it rewrites the code, while the "fixable issue(s)" link in the results opens the docs. - Config on the left (compact "PHP 8.6" picker, Settings next to it), actions on the right; the full explanation moves to the picker's title and aria-label, and the drawer header shows the version. - Slow runs (>150ms) dim the output and show "running…" in the tabs bar. - An empty editor says "Write some PHP to analyse". - "Skip to editor" link on playground pages; Share tooltip names the platform shortcut.
…nd page The homepage playground sits next to the intro again (stacked editor over output) with an Expand/Shrink toggle that keeps code, results, settings and the #L fragment. /playground and /r/<hash> open expanded and have no toggle. expandCode() and shrinkCode() work again on the homepage and stay no-ops elsewhere.
Tighten the gap between nav items so seven links fit on one row at 1024px.
/playground now shows only the nav and the playground, which fills the viewport (no heading, no footer). Each setting in the drawer links to its psalm.xml option in the configuration docs, the status bar links the issues, annotations, types, taint analysis and configuration docs, and issue type links get a title.
/check already returns Psalm's IssueData::error_level (the issue class ERROR_LEVEL), so this is client side only. Each issue shows a muted "level N", "any level" (-1, 8) or "feature" (-2) linking to its section of the error levels docs, with a tooltip saying at which errorLevel it is an error. Bug reports include it too.
Per-setting docs links and issue type links stay.
Psalm reports issues in analysis order. The list showed that order while F8 jumped by position, so the highlight hopped around the list, and F8 with the cursor on an issue skipped it. Issues are now sorted by line, column, errors before info, then type, and the list, F8/Shift+F8, lint markers and bug reports all use that order.
…n the status bar Uses the version_tag, version_compare_url and version_commit fields from psalm#127; falls back to version_label when no tag was resolved.
Text nodes directly inside the flex status item became anonymous flex items and lost their leading and trailing spaces, so it read "Psalm7.0.0+2(ca4690d)". Render the label inside one inline wrapper.
…the toolbar Share, Fix code and Report bug on the left; the PHP picker, Settings (above its drawer) and Expand/Shrink on the right. On narrow screens the actions row comes first.
The playground always ran at errorLevel 2, Psalm's default when psalm.xml has none, and never said so. Settings now offer levels 1 to 8 with 2 as the default, sent as `level` to /check and /add_code and kept in ?level= like ?php=. Snippets store the level in a new nullable `error_level` column; NULL (older snippets) runs at 2. The default level is left out of the snippet hash, so existing links still dedupe. /r/<hash>.json returns the stored level and /r/<hash>/results accepts ?level=.
The toolbar picker right above already shows it.
/playground, /r, /demo, /try and /sandbox redirect to /play. The nav is now Docs, Playground, Plugins, Blog, Paid support and a GitHub icon; "Get started" moves to a button on the homepage.
asset_url() appends ?v=<mtime>, replacing the hand-bumped ?N keys.
The homepage is 1024px wide again with a 492px playground widget, as on the old site. Articles from the last 14 days (up to three) are listed under the widget, or under the intro on narrow screens.
"Paid support for Psalm" on /support, "Blog - Psalm" for the blog index and "Psalm documentation" for the docs home.
views/play.php only set $playground_page and required index.php, so Psalm analysed index.php with that variable fixed to true and reported every homepage branch as dead. The baseline now also lists the template variables that includes/playground.php reads from its includer.
…te request input Clears the Psalm alerts the PR's code scanning raised on touched lines: the include-scope variables become function parameters, check.php rejects non-string code/settings and parses the fix flag as a boolean, and the signature label no longer concatenates a nullable method name.
The not-found branch now exits explicitly, so Psalm knows $result is the row array afterwards instead of mixed.
It bypassed the error-level validation and lacked the navigation data, and its hash matches neither the current nor the previous homepage example.
Rollback replays change() to record what to invert, so the existing-column guard must only apply when migrating up.
…ed symbol field Functions Psalm knows only from its callmap (e.g. ctype_digit) have no FunctionStorage; fall back to the callmap entry.
…te consistent - Non-ASCII text before an issue no longer shifts markers, links and hints - Share saves the PHP version and level it sent, even if changed meanwhile - A stale failed fix request no longer overwrites the run state - Rename navigation to codeNavigation so it does not shadow window.navigation
Also fixes the Expand button disappearing at 1000-1021px widths.
|
Seems good! One thing to discuss though, there used to be a specific cache for the code example on the root page. It disappears with this PR. That cache was persistent so it was never checked, this could be an issue for long period of times but it could probably put in a CI somewhere instead. Without this cache, the number of analysis is bound to increase a lot |
|
Good catch, but that cache wasn't being hit: its hash (6ca8d27d...) doesn't match the homepage example on master ( I agree the homepage example is worth caching though. I'll add a small cache in |
Every homepage view analyzes the same example. Its results are now stored in a temp-dir file keyed by settings, PHP version, level, fix flag, the installed Psalm version and the checker's mtime, so they refresh on their own after a Psalm update or deploy. The example code moves to HomepageExample::CODE so the page and the check share one copy.
Arbitrary settings keys from a client would otherwise create unlimited cache files. The playground always sends every known setting as a boolean, so its requests still hit the cache.
Production deploys don't run composer scripts, so the codes.error_level migration from psalm#143 has most likely not run; add_code.php writes that column, so saving snippets needs it.
Production deploys don't run composer scripts, so the codes.error_level migration from #143 has most likely not run; add_code.php writes that column, so saving snippets needs it.
Redesigns the playground and the homepage.
?level=on/checkand snippet result URLs; snippet JSON includeserror_level. A non-default level is part of the snippet hash, so default-level links are unchanged.#L5-L12line links. Psalm's byte offsets are converted to character offsets, so issue markers no longer shift after non-ASCII text./playground,/demo,/try,/sandboxand bare/rredirect there (/r/<hash>is unchanged).?Nkeys.Deploy: run the phinx migration (
codes.error_level) before deploying the code; saving snippets needs the column.Known gap:
MixedAssignmentand a few other Mixed issues as info (forced inOnlineChecker).