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

[PHPUnitBridge] Improved deprecations display #35271

Merged
merged 1 commit into from
Jan 29, 2020

Conversation

greg0ire
Copy link
Contributor

@greg0ire greg0ire commented Jan 8, 2020

Q A
Branch? master for features
Bug fix? no
New feature? yes
Deprecations? no
Tickets n/a
License MIT
Doc PR todo
  • Ignore verbose when the build fails because of deprecations
  • Add per-group verbosity : it is now possible to make the report a lot quieter, by specifying which groups should become quiet, like this: quiet[]=indirect&quiet[]=direct

Might add more improvements to that branch if people suggest some.

Copy link
Contributor

@OskarStark OskarStark left a comment

Choose a reason for hiding this comment

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

👍🏻😃

@nicolas-grekas nicolas-grekas added this to the next milestone Jan 9, 2020
Copy link
Contributor

@ostrolucky ostrolucky left a comment

Choose a reason for hiding this comment

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

Yay, continuous refactoring, a.k.a leaving the place better than before. I do the same. This bridge especially needs it. Few more like this in future should hopefully come.

++$this->count;
}

public function countsByCaller()
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public function countsByCaller()
public function getMethodOccurences()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The method where the deprecation is triggered is not to be confused with the method that calls that method, and countsByCallingMethod seems a bit long, WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know, they seem symmetric to me so I would expect similar name. I guess we need 3rd opinion.

Copy link
Member

Choose a reason for hiding this comment

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

getCountsByCaller?

@greg0ire greg0ire force-pushed the improved-deprecations-display branch 4 times, most recently from aafa219 to dbffb71 Compare January 20, 2020 18:50
@greg0ire greg0ire marked this pull request as ready for review January 20, 2020 19:02
@greg0ire
Copy link
Contributor Author

I added per-group verbosity, the usage is verbose[direct]=0|1, but maybe I should use verbose[]=direct, tell me what you think.

@ostrolucky
Copy link
Contributor

ostrolucky commented Jan 20, 2020

usage is verbose[direct]=0|1, but maybe I should use verbose[]=direct, tell me what you think.

[key]=int is more consistent with what we have now

@greg0ire greg0ire force-pushed the improved-deprecations-display branch 2 times, most recently from 9970c33 to 8d56650 Compare January 25, 2020 11:09
@greg0ire greg0ire force-pushed the improved-deprecations-display branch from 8d56650 to e775a6d Compare January 26, 2020 11:50
@greg0ire
Copy link
Contributor Author

I just pushed a version with a test case that makes more sense. Also, I added a commit to remove the "remaining" prefix

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

Thanks, here are my comments.
Can you please add a line in the changelog of the bridge?
Can you please also update to the description of the PR so that it documents what this is about? I had to review in details to get it, the ppl that will write the doc and/or the blog post about this need help too.

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php Outdated Show resolved Hide resolved
src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php Outdated Show resolved Hide resolved
src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php Outdated Show resolved Hide resolved
++$this->count;
}

public function countsByCaller()
Copy link
Member

Choose a reason for hiding this comment

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

getCountsByCaller?

@@ -33,7 +33,7 @@ require __DIR__.'/fake_vendor/acme/outdated-lib/outdated_file.php';

?>
--EXPECTF--
Remaining indirect deprecation notices (1)
Indirect deprecation notices (1)
Copy link
Member

Choose a reason for hiding this comment

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

Why remove the "remaining" prefix? It made the output more friendly to me, I see no reasons to drop it.

Copy link
Contributor

Choose a reason for hiding this comment

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

It was my suggestion, check #35271 (comment). Remaining implies non-remaining ones are displayed somewhere else. Please help us see how it improves friendliness using that word.

Copy link
Member

@nicolas-grekas nicolas-grekas Jan 27, 2020

Choose a reason for hiding this comment

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

When you're in the process of fixing deprecations - ie when you look at those reports, these are the "remaining deprecations" triggered by your code, until you fix them all. I don't read "remaining" as you and thus I don't see the confusion. Writing "Indirect deprecation notices (1)" feels too... direct. "Remaining" gives a direction to the cold fact, thus helps humans (because human don't know what to do with cold facts, but that's going off topic :) )

Copy link
Contributor

Choose a reason for hiding this comment

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

Why not „Deprecations you can fix“ and „Vendor Deprecations“?
Another wording is fine too, you get my point... hopefully 🙂

Copy link
Member

Choose a reason for hiding this comment

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

Unless there is an issue with the current wording, reducing merge conflicts is my priority, thanks for understanding :)

Copy link
Contributor

Choose a reason for hiding this comment

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

We can say the same about normal failing phpunit test cases. They are supposed/waiting to be fixed, but phpunit doesn't say "remainig failures". AFAIK nowhere else than phpunit bridge is this concept used like this.

Also, in practice user can't fix Indirect deprecations, but they are "remaining". So there is nothing to fix for user similar as "legacy" deprecations, but unlike legacy deprecations they are for some reason marked as "remaining".

To me whole remaining concept just makes things more confusing. But since we disagree, I guess this should be extracted to separate PR/issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@OskarStark also, "remaining" was also used for vendor deprecations :P

Copy link
Member

@nicolas-grekas nicolas-grekas Jan 28, 2020

Choose a reason for hiding this comment

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

"vendor" deprecations are not a thing.

"indirect" are - YOU are always responsible for them, all of them. It could be because YOU decided to use this package or YOU didn't contribute the fix yet, or YOU are using the package in a deprecated way.

Let's stop the wrong narrative about "it's them, not me".

@greg0ire
Copy link
Contributor Author

Can you please also update to the description of the PR so that it documents what this is about? I had to review in details to get it, the ppl that will write the doc and/or the blog post about this need help too.

Sorry for not doing that sooner, now that I wrote it guess the usage is a bit confusing, maybe the behavior should be changed, and it people should rather say which groups should be made quiet with verbose[indirect]=0?

@nicolas-grekas
Copy link
Member

quiet=foo,bar,baz?

@nicolas-grekas
Copy link
Member

or quiet[]=foo&quiet[]=bar, as you prefer :)

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Jan 27, 2020

ouch, I'm going again in the other alternative not suggested by @ostrolucky, sorry...
I feel like [key]=int might create confusion: "what does 2 mean?", that's why I proposed these.

@greg0ire
Copy link
Contributor Author

Yeah, also, only one of 1 like right now or 0 (if we default to verbose groups) would ever be actually used. The syntax you proposed leaves less room for errors and confusion I think.

@greg0ire greg0ire force-pushed the improved-deprecations-display branch from e775a6d to 5782a1e Compare January 27, 2020 22:08
@greg0ire
Copy link
Contributor Author

@nicolas-grekas what should happen if we have verbose=0&quiet[]=indirect? throw an exception telling the user not to use both options together?

@nicolas-grekas
Copy link
Member

Nothing special to me.

@greg0ire greg0ire force-pushed the improved-deprecations-display branch 2 times, most recently from d4b9c32 to f56fc61 Compare January 27, 2020 22:41
@greg0ire
Copy link
Contributor Author

@nicolas-grekas implemented :)

@greg0ire
Copy link
Contributor Author

reducing merge conflicts is my priority,

@nicolas-grekas should I contribute the first commit to a lower branch first? It's a refactoring (and a big one).

@nicolas-grekas
Copy link
Member

should I contribute the first commit to a lower branch first? It's a refactoring

nope, refacto are always for master: reducing the risk of introducing regressions has an even higher priority.

@greg0ire greg0ire force-pushed the improved-deprecations-display branch from f56fc61 to dac6ad7 Compare January 28, 2020 12:23
@greg0ire
Copy link
Contributor Author

Ok, I just dropped the last commit (about "remaining")

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

Some minor comments and good to me (I didn't run the PR so I'm counting on you to fix any issues we missed during review ;) )

* whether to display a stack trace
* @param bool $verboseOutput
* @param string $regex Will be matched against messages,
* to decide whether to display a stack trace
Copy link
Member

Choose a reason for hiding this comment

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

unneeded diff

@@ -72,7 +72,15 @@ private function __construct(array $thresholds = [], $regex = '', $verboseOutput
}
}
$this->regex = $regex;
$this->verboseOutput = $verboseOutput;

$this->verboseOutput = array_fill_keys(['unsilenced', 'direct', 'indirect', 'self', 'other'], true);
Copy link
Member

Choose a reason for hiding this comment

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

Generally speaking, this still has runtime overhead, whereas declaring the resulting array is free. Also, I doubt this is more readable since it requires knowing what array_fill_keys() does.


namespace Symfony\Bridge\PhpUnit\DeprecationErrorHandler;

final class DeprecationGroup
Copy link
Member

Choose a reason for hiding this comment

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

let's mark all new classes as @internal

final class DeprecationNotice
{
/**
* @var int
Copy link
Member

Choose a reason for hiding this comment

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

ping

@greg0ire
Copy link
Contributor Author

Some minor comments and good to me (I didn't run the PR so I'm counting on you to fix any issues we missed during review ;) )

I just tested on SonataAdminBundle, and I couldn't find any issues 😛

@fabpot fabpot force-pushed the improved-deprecations-display branch from ef62255 to c55a89e Compare January 29, 2020 14:00
@fabpot
Copy link
Member

fabpot commented Jan 29, 2020

Thank you @greg0ire.

@fabpot fabpot closed this in 7ecb5aa Jan 29, 2020
@fabpot fabpot merged commit c55a89e into symfony:master Jan 29, 2020
xabbuh added a commit that referenced this pull request Mar 28, 2020
This PR was merged into the 5.1-dev branch.

Discussion
----------

[Typo] Rename occurence to occurrence

| Q             | A
| ------------- | ---
| Branch?       | master (5.1)
| Bug fix?      | yes (typo)
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #36242
| License       | MIT
| Doc PR        | Not needed

This PR will fix correct spelling of methods containing the word occurrence implemented with PR :
- [PHPUnitBridge] Improved deprecations display #35271

This changes are on master branch, because the original PR is a new feature for Symfony 5.1.

Commits
-------

11f746a [Typo] Rename occurence to occurrence
@nicolas-grekas nicolas-grekas modified the milestones: next, 5.1 May 4, 2020
@fabpot fabpot mentioned this pull request May 5, 2020
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.

None yet

6 participants