Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change inline node deprecation and fix deprecations in the codebase #1184

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

wouterj
Copy link
Contributor

@wouterj wouterj commented Nov 30, 2024

After upgrading to the latest guide for the first time since a long time, I saw quite some deprecations of #1162 coming from Guides itself. This PR enables deprecations in the testsuite, so that any deprecated usage in the library is noticed and fixed.

While working on that, I discovered we can take #1162 one step further. That PR adds a array $children parameter to some inline nodes that must be used instead of the existing $value parameter, but it doesn't actually deprecate the $value parameter.
This PR:

  • Replaces the $value parameter with the new $children parameter (in a BC matter)
  • Deprecates the old $children parameter location

At last, enabling deprecations showed a couple other deprecations that I've fixed as well to make sure the tests are green.


Sorry for the slightly chaotic PR contents. I hope it all makes sense now and happy to elaborate further if needed.

The `string $content` parameter is a legacy from before Markdown. It is
redundant and replaced by `array $children`.
@wouterj wouterj force-pushed the inline-content-deprecation branch from 37f375b to 2397209 Compare November 30, 2024 13:10
phpunit.xml.dist Outdated Show resolved Hide resolved
@wouterj wouterj force-pushed the inline-content-deprecation branch from 2397209 to 49312b9 Compare December 1, 2024 15:00
@wouterj wouterj force-pushed the inline-content-deprecation branch from 49312b9 to 10f7ca1 Compare December 1, 2024 15:15
@wouterj wouterj force-pushed the inline-content-deprecation branch from 10f7ca1 to a1cc381 Compare December 1, 2024 15:16
We cannot fix these PHP deprecations, as these are happening in third
party code (and fixing them requires a major version bump of Flysystem).

PHPUnit 11 distinguishes direct and indirect deprecations, allowing us
to automatically ignore all indirect deprecations. However, this version
requires PHP 8.2, while this library still supports PHP 8.1.
@wouterj wouterj force-pushed the inline-content-deprecation branch from a1cc381 to 832f346 Compare December 1, 2024 17:20
Copy link
Member

@jaapio jaapio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for your changes. It's good to see that you are still trying to align with us. I do the improvements you did. But I do have a question about how you look at backward compatibility, and templates.

@@ -1 +1 @@
*{{- node.value|raw -}}*
*{{- node|plaintext -}}*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I introduced the inline nested nodes I did use the value because that would not require a change in the templates. As templates can be overwritten by consuming projects. I did see that as a backward compatibility issue.

This was the reason to try to be backwards compatible and accept the issues in our pipeline. How do you see that? Bc in templates is a very complex problem as I experienced in the past. But maybe I will try to be too strict about this project?

Copy link
Contributor Author

@wouterj wouterj Dec 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I can follow you. The original content still works, but triggers a deprecation. Are you thinking of a case where the user overrides getValue() of a node that now has a BC break because it isn't called anymore?

You can use Deprecation::triggerIfCalledFromOutside() in getValue() then (or the Symfony tactic: add a virtual new boolean parameter to getValue() that determines whether the deprecation should be triggered). This should not produce a deprecation when called from a Guides template, but does when called by a user.

In general, deprecations are most useful if all of them can be fixed by a user without upgrading the package triggering the deprecation. If Guides triggers a deprecation from itself, I would never know if I can safely upgrade to 2.0.

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.

3 participants