Skip to content

Fix examples whose documented output doesn't match Run code#5718

Open
KentarouTakeda wants to merge 5 commits into
php:masterfrom
KentarouTakeda:fix-screen-mismatch-mechanical
Open

Fix examples whose documented output doesn't match Run code#5718
KentarouTakeda wants to merge 5 commits into
php:masterfrom
KentarouTakeda:fix-screen-mismatch-mechanical

Conversation

@KentarouTakeda

@KentarouTakeda KentarouTakeda commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Every example that has a Run code button and declares its output with &example.outputs; (832 of them) was run and compared against its <screen>.

This PR is the subset where the fix needs no judgement: each hunk can be confirmed by clicking Run code on the page.

One commit per group:

  • Broken examples: two have no <?php so Run code prints the source instead of running it, one calls getName() on the getShortName() page.
  • DOM XML declaration: saveXML() emits it, the screen drops it or drops the encoding the document declares.
  • Formatting var_dump()/print_r() never produce: indentation, [0] => for [0]=>, hand alignment, spaces where the data holds tabs.
  • Wrong values: stale line numbers and offsets, a wrong ordering, a dropped semicolon, output split across lines that is really printed on one.
  • One example read date('T') with no timestamp, so the page was right only half the year; the timestamp is now pinned and the screen is unchanged.
Pages to reproduce this on

Click any page and press Run code: the output that appears is what this PR puts in the <screen>. The static <screen> still shown on these pages is the "before" side of the diff, until the manual is rebuilt.

Fix two broken examples

Fix the XML declaration in DOM blocks

Use the formatting var_dump() and print_r() actually produce

Fix values that do not match the actual output

Pin the timestamp in the date('T') example

withfragment.xml had no opening <?php, so pressing Run code printed the
source instead of running it.

getshortname.xml called getName() on the ReflectionConstant::getShortName()
page, so it printed the fully qualified name.
saveXML() emits the declaration, but these screens either drop it
entirely or drop the encoding the document declares.
These screens use indentation, spacing or a layout the functions never
emit: "[0] => " where var_dump() writes "[0]=>" on its own line, hand
alignment print_r() does not pad, and spaces where the data holds tabs.
Each of these differs from what the example prints: stale line numbers
and offsets, a wrong ordering, a dropped semicolon, a missing line,
screens quoting the example's own strings wrongly, and output split
across lines that is really printed on one.
date('T') with no timestamp follows daylight saving, so the page showed
PST for half the year and PDT for the other half. Pinning a winter
moment makes the documented output true all year, so the <screen> is
unchanged.
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.

1 participant