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

Skip to content

[PhpUnitBridge] make "numbered" deprecation mode count only vendor deprecations #28048

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
nicolas-grekas opened this issue Jul 23, 2018 · 9 comments
Labels
RFC RFC = Request For Comments (proposals about features that you want to be discussed)

Comments

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Jul 23, 2018

When a deprecation is thrown inside your very src/, you want it to always make your CI fail, don't you?
I propose to update the behavior of the SYMFONY_DEPRECATIONS_HELPER=123456 mode to make it mean:

make the CI fail if vendors throw more than 123456 deprecations (and make it always fail if any deprecations are thrown by my src/.)

This would be a more powerful alternative to weak_vendor , which could be deprecated.

WDYT?

(#27006 could converge with this RFC I suppose.)

@nicolas-grekas nicolas-grekas changed the title [PhpUnitBridge] make "numbered" deprecation mode fail count only vendor deprecations [PhpUnitBridge] make "numbered" deprecation mode count only vendor deprecations Jul 23, 2018
@greg0ire
Copy link
Contributor

I know that some library maintainers like @dbu like the weak_vendors mode because it freed them from bumping that number every once in a while, would be great to hear from them…

@nicolas-grekas
Copy link
Member Author

nicolas-grekas commented Jul 23, 2018

Or maybe even better: keep the current behavior as is, but handle setting the max numbers of deprecations triggered "inside src/" vs "directly by src/" vs "indirectly (by src/ or config/)".
Could be e.g. just numbers separated by commas, in the above order:
SYMFONY_DEPRECATIONS_HELPER=999,0,888
This meaning: 999 deprecations max, 0 triggered inside src/, and max 888 directly.

@dbu
Copy link
Contributor

dbu commented Jul 24, 2018

when maintaining a library, errors on vendors triggering deprecations of other vendors is not much of a concern. i want to support a wide range of dependencies if possible. those deprecations are the concern of the users of my library, but not mine as library maintainer.

i like the idea to be more precise. using comma separated will not make it more obvious what is going on (its quite cryptic already) but having 3 separate constants is not awesome either.

i was going to say we should not change the semantics of the old syntax in minor versions, but as the symfony bundle test configuration matrix usually specify which symfony version to test with, its easy to use a different constant definition for different configurations.

@nicolas-grekas nicolas-grekas added the RFC RFC = Request For Comments (proposals about features that you want to be discussed) label Jul 25, 2018
@nicolas-grekas
Copy link
Member Author

What about using an url-encoded string for configuration? Looks like the most flexible to me given the number of options people would like to have and we might want to add in the future.
E.g. SYMFONY_DEPRECATIONS_HELPER="max[total]=1234&max[direct]=10&max[internal]=0"

@greg0ire
Copy link
Contributor

This sounds great! For the sake of completeness, I would have 4 keys:

SYMFONY_DEPRECATIONS_HELPER="max[total]=1234&max[indirect]=42&max[direct]=10&max[internal]=0"

This would mean:

  • no more than 1234 deprecations in total
  • no more than 42 deprecations where both the caller and the callee are in vendors
  • no more than 10 deprecations where the caller is in src and the callee is in vendors
  • no deprecations where both the caller and the callee are in src

And every key would default to 999999.
Would we get rid of the weak and strict modes too according to this plan? What about the SYMFONY_DEPRECATIONS_HELPER=42 mode? And what about the regex mode?

@nicolas-grekas
Copy link
Member Author

Correct! I'm just wondering if "direct" should count internal too? They are also "direct calls to deprecated methods". Or we could be keep only direct (would include internal) and indirect. WDYT ?

The regexp mode is absolutely required to debug deprecations, I'd keep it as is. The others we can think about simplifying. We could also have summary=0/1 (default to 1).

@greg0ire
Copy link
Contributor

greg0ire commented Aug 10, 2018

I have written #24867 so that when we use sentences that use the words "caller" or "callees", we refer to packages, not to methods. Any stack trace can be divided into function calls, and those calls can be grouped by package easily if psr-0 or 4 is assumed (I hope that's a safe assumption to make).

With that in mind, internal would have no notion of direct or indirect calls, because there would be no calls to external packages involved here (I'm overlooking the case where you have src -> vendor -> src, which I don't know yet how to handle properly).

Or we could be keep only direct (would include internal) and indirect. WDYT ?

I think @alexpott and other library maintainers would not want us to have direct include internal and make internal disappear.

Also, I have witnessed a use case in a project in my company where you would want to forbid direct calls but allow internal deprecations because of the following scenario, which happen to me:

  1. remove something, and all references to it;
  2. make a PR;
  3. wait a long time because your reviewers are busy;
  4. someone in another team merges a PR which introduces a new reference to the thing you removed;
  5. your PR is finally merged;
  6. 💥

Another scenario is that you could want to deprecate something internally in your project that is used in many places and migrate from it step by step, while keeping direct calls to 0.

A final argument against this would be that having direct include internal and not have indirect include direct and internal would be a bit disturbing. I would be one step close to have the nice total ⊂ indirect ⊂ direct ⊂ internal, somewhat frustrating.

@greg0ire
Copy link
Contributor

greg0ire commented Aug 11, 2018

Here is how existing modes would translate:

  • strict: SYMFONY_DEPRECATIONS_HELPER="max[total]=0"
  • weak_vendors: SYMFONY_DEPRECATIONS_HELPER="max[internal]=0"
  • weak: SYMFONY_DEPRECATIONS_HELPER="max[any_valid_key]=999999"

@greg0ire
Copy link
Contributor

greg0ire commented Aug 13, 2018

I have written #24867 so that when we use sentences that use the words "caller" or "callees", we refer to packages, not to methods.

This decision can of course be challenged, especially in the light that some people like @lcobucci think it should be ok for a package to deprecate calls from outside, while expecting no error when calling something deprecated internally, see doctrine/orm#6728 (comment)

Nobody should be bothered if we're using internally our own deprecated items (this already happens with ClassMetadata and ClassMetadataInfo btw).

greg0ire added a commit to greg0ire/symfony that referenced this issue Sep 4, 2018
greg0ire added a commit to greg0ire/symfony that referenced this issue Sep 5, 2018
greg0ire added a commit to greg0ire/symfony that referenced this issue Sep 5, 2018
greg0ire added a commit to greg0ire/symfony that referenced this issue Sep 6, 2018
greg0ire added a commit to greg0ire/symfony that referenced this issue Sep 6, 2018
greg0ire added a commit to greg0ire/symfony that referenced this issue Oct 7, 2018
greg0ire added a commit to greg0ire/symfony that referenced this issue Nov 11, 2018
greg0ire added a commit to greg0ire/symfony that referenced this issue Nov 13, 2018
greg0ire added a commit to greg0ire/symfony that referenced this issue Nov 19, 2018
greg0ire added a commit to greg0ire/symfony that referenced this issue Nov 19, 2018
greg0ire added a commit to greg0ire/symfony that referenced this issue Nov 24, 2018
greg0ire added a commit to greg0ire/symfony that referenced this issue Nov 24, 2018
greg0ire added a commit to greg0ire/symfony-docs that referenced this issue Nov 24, 2018
greg0ire added a commit to greg0ire/symfony that referenced this issue Nov 24, 2018
greg0ire added a commit to greg0ire/symfony that referenced this issue Nov 25, 2018
greg0ire added a commit to greg0ire/symfony that referenced this issue Dec 2, 2018
greg0ire added a commit to greg0ire/symfony that referenced this issue Jan 27, 2019
greg0ire added a commit to greg0ire/symfony that referenced this issue Mar 29, 2019
greg0ire added a commit to greg0ire/symfony that referenced this issue Mar 29, 2019
llaakkkk pushed a commit to llaakkkk/symfony-docs that referenced this issue Apr 6, 2019
llaakkkk pushed a commit to llaakkkk/symfony-docs that referenced this issue Apr 6, 2019
llaakkkk pushed a commit to llaakkkk/symfony-docs that referenced this issue Apr 7, 2019
@fabpot fabpot closed this as completed Apr 12, 2019
fabpot added a commit that referenced this issue Apr 12, 2019
… (greg0ire)

This PR was merged into the 4.3-dev branch.

Discussion
----------

[PhpUnitBridge] Url encoded deprecations helper config

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets | #28048
| License       | MIT
| Doc PR        | symfony/symfony-docs#10701

First stab at implementing a new way of configuring the deprecation error handler. Includes a refactoring to keep things manageable.

Rework of #24867, blocked by #29718

TODO:

- [x] make the code 5.5 compatible 😢
- [x] add more tests
- [x] deprecate modes (using echo :P)
- [x] test this on real life projects and add some screenshots
- [x] docs PR
- [x] handle `strict`
- [x] adapt existing CI config

# Quiet configuration

![quiet](https://user-images.githubusercontent.com/657779/49341318-fa78c900-f64b-11e8-9504-a8a9eac4baf8.png)

# Default configuration

![verbose](https://user-images.githubusercontent.com/657779/49341322-10868980-f64c-11e8-9d90-dc3f6a18c335.png)

Commits
-------

1c73f9c [PhpUnitBridge] Url encoded deprecations helper config
javiereguiluz added a commit to symfony/symfony-docs that referenced this issue May 31, 2019
…ire, llaakkkk)

This PR was submitted for the master branch but it was merged into the 4.3 branch instead (closes #11323).

Discussion
----------

Document changes in the deprecation error handler

See symfony/symfony#29211
See symfony/symfony#28048

Closes #10701

Commits
-------

64141fc fixup! Document changes in the deprecation error handler
dd7eb0b fixup! Document changes in the deprecation error handler
b2a7744 fixup! Document changes in the deprecation error handler
988badf fixup! Document changes in the deprecation error handler
2a750ea Document changes in the deprecation error handler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFC RFC = Request For Comments (proposals about features that you want to be discussed)
Projects
None yet
Development

No branches or pull requests

4 participants