Refactor/deprecate content methods#274
Open
marilenaRM wants to merge 5 commits into
Open
Conversation
added 3 commits
May 19, 2026 11:12
header*, footer* methods move to the new PageMarginalTrait. The original methods remain in ContentTrait as deprecated no-ops (E_USER_DEPRECATED, will be removed in 2.0) for BC, allowing existing code to receive a deprecation warning rather than a runtime error. ChromiumPdfTrait is updated to prefer PageMarginalTrait over the deprecated ContentTrait stubs via insteadof. Screenshot builders keep using ContentTrait directly since Gotenberg does not support headers and footers for screenshots; the deprecated stubs are filtered out of the generated documentation. The deprecation message was corrected: the stubs in ContentTrait are only ever called by builders that do not use PageMarginalTrait (e.g. screenshot builders), so saying "Use PageMarginalTrait instead" would be misleading. The message now states that header/footer support is not available on the current builder.
Since the page body is fetched from the URL itself, content(), contentRaw() and contentFile() are meaningless on URL-based builders. They are now deprecated via DeprecatedBodyContentTrait (no-op + E_USER_DEPRECATED) and will be removed in 2.0.
Three bugs fixed in docs/generate.php: - @example merge: when a method appears in multiple traits (e.g. via insteadof resolution), the @example from the winning trait was silently discarded because the merge loop did not handle the example tag. The last seen @example now wins. - Description merge: a docblock containing only tags (@deprecated, @see, etc.) produces an empty description array [], which is distinct from [''] and incorrectly satisfied the overwrite condition, erasing a previously collected verbose description. The condition now guards against both empty forms. - Deprecated method filtering: public methods whose resolved docblock carries @deprecated are now excluded from the generated output. This prevents no-op stubs from appearing in the documentation without any useful content.
b84f329 to
ca5d371
Compare
Jean-Beru
reviewed
May 20, 2026
| public function header(string $template, array $context = []): static | ||
| { | ||
| return $this->withRenderedPart(Part::Header, $template, $context); | ||
| @trigger_error(\sprintf('Since sensiolabs/gotenberg-bundle 1.2: "%s" is deprecated and will be removed in 2.0. Header/footer support has been moved to "%s"; this builder does not support it.', __METHOD__, PageMarginalTrait::class), \E_USER_DEPRECATED); |
Contributor
There was a problem hiding this comment.
What about https://www.php.net/manual/en/class.deprecated.php ?
Ex:
#[Deprecated(message:'Will be removed in 2.0. Use Sensiolabs\GotenbergBundle\Builder\Behaviors\Chromium\PageMarginalTrait instead', since:'sensiolabs/GotenbergBundle:1.3')]
Jean-Beru
reviewed
Jun 9, 2026
| trait DeprecatedBodyContentTrait | ||
| { | ||
| /** | ||
| * @deprecated since 1.2, will be removed in 2.0. The page body is provided by the URL. |
Contributor
There was a problem hiding this comment.
Suggested change
| * @deprecated since 1.2, will be removed in 2.0. The page body is provided by the URL. | |
| * @deprecated since 1.4, will be removed in 2.0. The page body is provided by the URL. |
This also applies to the following annotations/triggers.
|
|
||
| ### `UrlPdfBuilder` and `UrlScreenshotBuilder`: `content*` methods deprecated | ||
|
|
||
| The `content()`, `contentRaw()` and `contentFile()` methods are deprecated on `UrlPdfBuilder` and `UrlScreenshotBuilder`. Since the page body is provided by the URL itself, these methods have no effect. Use `url()` or `route()` instead. They will be removed in 2.0. |
Contributor
There was a problem hiding this comment.
It should be in the UPGRADE-1.4.md file.
|
|
||
| ### `ContentTrait`: header and footer methods moved to `PageMarginalTrait` | ||
|
|
||
| The `header()`, `headerRaw()`, `headerFile()`, `footer()`, `footerRaw()` and `footerFile()` methods have been moved out of `ContentTrait` into the new dedicated `PageMarginalTrait`. These methods are still accessible through `ContentTrait` in 1.2 but will be removed in 2.0. |
Contributor
There was a problem hiding this comment.
Suggested change
| The `header()`, `headerRaw()`, `headerFile()`, `footer()`, `footerRaw()` and `footerFile()` methods have been moved out of `ContentTrait` into the new dedicated `PageMarginalTrait`. These methods are still accessible through `ContentTrait` in 1.2 but will be removed in 2.0. | |
| The `header()`, `headerRaw()`, `headerFile()`, `footer()`, `footerRaw()` and `footerFile()` methods have been moved out of `ContentTrait` into the new dedicated `PageMarginalTrait`. These methods are still accessible through `ContentTrait` in 1.4 but will be removed in 2.0. |
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.
Description
Summary
no-op stubs appeared in the generated docs without any content
See UPGRADE-1.2.md for migration instructions.
Replaces #266
Test plan