Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add a table to summarize the modes #10067

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

Closed
wants to merge 1 commit into from
Closed

Conversation

greg0ire
Copy link
Contributor

Looks like people have a hard time knowing when to use which mode. Undocumented thing I have witnessed on a real-life project: people will use weak_vendors mode even if it makes little sense on a project (as opposed to a library), rather than the weak mode, because weak_vendors displays the deprecations.

+----------------+-----------------------------------------------------+
| weak | Not recommended; will probably lead to |
| | a big refactoring. |
+----------------+-----------------------------------------------------+
Copy link
Member

Choose a reason for hiding this comment

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

I like this new table! But, which mode should I use in my project? Most projects either:

A) Have deprecations & know about them... and just want to report them at the bottom of their tests (but not cause failures)

B) Do not have deprecations and want to keep it that way. New deprecations should cause the tests to fail.

What should I have for (A)? And is (B) strict? Or would weak_vendors be better (i.e. only tell me about my deprecations)?

Copy link
Contributor Author

@greg0ire greg0ire Jul 17, 2018

Choose a reason for hiding this comment

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

Right now, weak is not good for A, because it does not display deprecations, and I couldn't convince people to change this. At work, I observed that people are using weak_vendors to achieve A, although it's not meant for that. For B, you should use strict if you can. If you're a library and i turns out not to be realistic, for instance if the build fails on your contributors PRs because of unrelated changes in new minor versions of your dependencies, you might be better off with weak_vendors, which will let you focus on your deprecations (trigger_error calls you make in code you should no longer call), and slightly postpone fixing deprecations in your dependencies because of calls you should change.

@xabbuh xabbuh added this to the 3.4 milestone Aug 7, 2018
+----------------+-----------------------------------------------------+
| <some integer> | Recommended for projects that you cannot |
| | immediately fix but don't want to make worse. |
| | Can be used to transition from one mode to another. |
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we have a bit more information about what integers you can use here? ie. What's the min/max? Is a lower number more strict or less strict?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This column shows no description, even for other modes. It only shows a recommendation. That particular mode is already documented above.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah fair enough. As long as it's documented somewhere πŸ‘

@javiereguiluz
Copy link
Member

Let's use a specific example to try to understand the different modes:

  • ACME App depends on two third-party bundles called FooBundle and BarBundle
  • Deprecation 1: ACME App has a controller extending from the deprecated base Controller. This controller is created and used by the app. Code doesn't belong to any third-party bundle.
  • Deprecation 2: FooBundle provides a Form extension which doesn't include the new public static function getExtendedTypes() method. ACME App uses that form extension directly in its code.
  • Deprecation 3: BarBundle includes a Twig template with the deprecated transchoice filter. ACME App DOESN'T use that Twig template anywhere in its own code or config.

@greg0ire please, fill in the following descriptions:

  • _________ mode shows deprecation 1) only
  • _________ mode shows deprecations 1) and 2)
  • _________ mode shows deprecations 1), 2) and 3)
  • Using an integer as the deprecation mode is a special behaviour. It behaves as the __________ mode but only triggers an error if the total number of deprecations is higher than the provided number.

Thanks!

@greg0ire
Copy link
Contributor Author

greg0ire commented Dec 29, 2018

Hey @javiereguiluz ! Thanks for your review!

I'm going to have a hard time filling the blanks though, for several reasons. For starters, modes rarely change the output a lot, and they will not hide one type of deprecations over the other. The only mode that changes the output a lot is the weak mode, because it does not show a detailed output of the deprecations, only a summary. Modes are mostly about the exit code, rather than the output. Second, none of your examples show deprecations where both the calling code and the deprecated code are in src, and this is what weak_vendors is all about. You are using an application as an example, but it will be hard to find a valid use case for that mode inside an application, it is more useful for libraries.

So, let's take the example of a library Foo, that depends on another Bar library. Inside Foo\deprecated_function, you can find a call to @trigger_error('some message', E_USER_DEPRECATED); but, and this is key, you cannot find a call to Foo\deprecated_function() in Foo's src directory, because the person who deprecated Foo\deprecated_function() changed all the calls to Foo\shiny_new_function(). Inside that src directory, you can find a call to Bar\deprecated_function(), which is part of the deprecated API of Bar.

  1. strict mode will let the build exit with a non-zero exit code. πŸ’₯
  2. weak_vendors mode will let the build exit with a zero exit code. πŸ‘
  3. weak mode will let the build exit with a zero exit code. πŸ‘

Now let's say the contributor forgets one call to Foo\deprecated_function() somewhere in Foo

  1. strict mode will let the build exit with a non-zero exit code. πŸ’₯
  2. weak_vendors mode will let the build exit with a non-zero exit code. πŸ’₯
  3. weak mode will let the build exit with a zero exit code. πŸ‘

What's next?

symfony/symfony#28048, implemented in symfony/symfony#29211 and documented in #10701 is a big revamp of all this, and will introduce a way for an application to only care about deprecation that can be fixed directly within itself, meaning they will be able to call Foo even if Foo calls Bar\deprecated_function().

@greg0ire
Copy link
Contributor Author

I'm closing this since I deprecated the weak_vendors mode recently.

@greg0ire greg0ire closed this May 30, 2019
@greg0ire greg0ire deleted the mode_table branch May 30, 2019 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants