[TASK] Migrate HyperLinkNode/ReferenceNode constructor calls to array children form#1244
Closed
CybotTM wants to merge 3 commits into
Closed
[TASK] Migrate HyperLinkNode/ReferenceNode constructor calls to array children form#1244CybotTM wants to merge 3 commits into
CybotTM wants to merge 3 commits into
Conversation
… children form Upstream phpDocumentor/guides deprecated the string-form first/second argument of HyperLinkNode and ReferenceNode constructors in favor of an array of InlineNodeInterface instances (see phpDocumentor/guides#1161). The BC bridge still works but emits a Doctrine\Deprecations trigger on every call. This migrates all local theme call sites mechanically: each site now passes either an empty array (when the children value is the empty string) or [new PlainTextInlineNode($value)] (otherwise) — exactly mirroring the BC bridge's internal wrapping. No behavior change. Test fixtures unchanged. PHPStan clean. Unit/integration/rendertest pass. Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
Refines the inline-node constructor migration from the previous commit: - TextRoles: switch from the verbose strict-equality wrap (`$x === '' ? [] : [new PlainTextInlineNode($x)]`) to the truthy-compact form (`$x ? [new PlainTextInlineNode($x)] : []`) used throughout upstream (ReferenceTextRole, ApiClassTextRole, ReferenceRule, Markdown LinkParser). Removes intermediate `$label` temp variables. For sites with a guaranteed non-empty fallback (`?? 'Forge'`, `?? sprintf(...)`, `?? 'EXT:' . $extKey`) the ternary is dropped entirely as the empty branch is unreachable. - NodeTransformers: stop calling the deprecated `BCInlineNodeBehavior::getValue()` to flatten an inline tree to a string just to rewrap that string as a single PlainTextInlineNode. Pass `\$node->getChildren()` through directly. Bit-identical for plain-text content (the entire TYPO3 corpus); preserves inline structure (emphasis, code, nested refs) for any future content that has it. In ReplacePermalinksNodeTransformer the conditional label-reset (when the visible label equals the URL) now uses `\$node->toString()` for the comparison instead of the deprecated `getValue()`. Removes the only remaining call sites of the deprecated `getValue()` in this codebase. Same upstream issue: phpDocumentor/guides#1161. Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
…eNode parent ctor Three TextRoles have private `createNodeWithInterlink` helpers that took `string|null $referenceName` and did the wrap-as-PlainTextInlineNode dance internally. Push the wrap up to the upstream-imposed `createNode` boundary instead, so the private helpers operate on the upstream data model (`list<InlineNodeInterface>`) directly: - `ViewhelperTextRole`: helper now takes `array $children`. Wrap once in createNode, both branches of the interlink-regex switch pass the same children array. - `ViewhelperArgumentTextRole`: same pattern. - `FileTextRole`: helper signature changes from `string|null $referenceName` to `string $fileLabel` (non-null). The `?? $referenceTarget` fallback moves to createNode. FileInlineNode's own constructor surface is intentionally left unchanged — that's a separate concern. Plus one drive-by silence-fix in `FileInlineNode::__construct`: it called the 4-arg BC form of `AbstractLinkInlineNode::__construct(type, ref, string, array)`, which triggers the same TYPO3-Documentation#1161 deprecation we're cleaning up everywhere else (the BC bridge sees a string as 3rd positional and fires the deprecation regardless of the array as 4th positional). Switch to the 3-arg form `(type, ref, array)` — no BC bridge, no trigger. Refs phpDocumentor/guides#1161. Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
Contributor
Author
|
Closing this voluntarily — on reflection, this PR is preparatory cleanup with no user-facing benefit at this point in time:
The branch is preserved on my fork ( The companion PR #1243 — which actually fixes the rendering bug from #1236 — stays open and is unaffected by this closure. The two were always independent (different branches, both based on Sorry for the noise. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Upstream phpDocumentor/guides#1161 deprecated the string-form first argument of
HyperLinkNode::__construct()and the string-form second argument ofReferenceNode::__construct()in favor of an array ofInlineNodeInterfaceinstances. The BC bridge still works but emits aDoctrine\Deprecationstrigger on every call. Pre-existing tech debt — not introduced by any recent bump.This PR removes every deprecated call site (constructor +
BCInlineNodeBehavior::getValue()) in the theme, then carries the upstream data model (children aslist<InlineNodeInterface>) through the local code so private helpers and node ctors stop passing flat strings around. Independent of #1243 — branched fromorigin/main.Commits
665aa4b6Mechanical migration to array-form constructors. Each call site passes either[]or[new PlainTextInlineNode($value)]— mirroring the BC bridge's internal wrapping. Behavior-preserving.233d9004Adopt upstream style +getChildren()passthrough.$x ? [new PlainTextInlineNode($x)] : [](as in upstreamReferenceTextRole,ApiClassTextRole,ReferenceRule, MarkdownLinkParser). Where the source has a guaranteed-non-empty fallback, the ternary is dropped entirely.BCInlineNodeBehavior::getValue()to flatten an inline tree just to rewrap it. Pass$node->getChildren()through directly. Bit-identical for plain-text content (entire TYPO3 corpus); preserves inline structure (emphasis, code, nested refs) for any future content. Removes the last remainingBCInlineNodeBehavior::getValue()call sites in the codebase.b4f2ba88Push the children-array form through private helpers andFileInlineNode's parent ctor.ViewhelperTextRole,ViewhelperArgumentTextRole,FileTextRole) had privatecreateNodeWithInterlinkhelpers that still tookstring|null $referenceNameand did the wrap-as-PlainTextInlineNodedance internally. Wrap once at the upstream-imposedcreateNodeboundary instead, so the private helpers operate on the upstream data model directly (array $childrentypedlist<InlineNodeInterface>for the two Viewhelper roles; non-nullablestring $fileLabelforFileTextRole, sinceFileInlineNode's public surface is intentionally out of scope).FileInlineNode::__constructsilenced a hidden [TASK]: Bump friendsofphp/php-cs-fixer from 3.93.0 to 3.93.1 #1161 deprecation trigger: it called the 4-arg BC formparent::__construct(type, ref, string, array)— the BC bridge sees a string as 3rd positional and fires the deprecation regardless of the array as 4th positional. Switch to the 3-arg form(type, ref, array).Test plan
All run locally with
PHP_BIN=phpon host PHP 8.5 after each commit:make phpstan→[OK] No errorsmake test-unit→OK (83 tests, 183 assertions)make test-integration→Tests: 113, Assertions: 1131, Deprecations: 3, Skipped: 2(the 3 deprecations are pre-existing PHP 8.5curl_closewarnings in vendor code, identical toorigin/main)make test-rendertest→ completed, no fixture diffs (53 + 35 + 4 + 4 SINGLEPAGE files)make test-docs→ completed (14 SINGLEPAGE files)No expected-fixture HTML changed across any of the three commits, confirming the migration is behavior-preserving.