Skip to content

[PHPUnitBridge] fail only for "new" deprecations / "baseline" feature #34496

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
dmaicher opened this issue Nov 21, 2019 · 2 comments
Closed

[PHPUnitBridge] fail only for "new" deprecations / "baseline" feature #34496

dmaicher opened this issue Nov 21, 2019 · 2 comments
Labels
Feature Help wanted Issues and PRs which are looking for volunteers to complete them. PhpUnitBridge

Comments

@dmaicher
Copy link
Contributor

Description
On a big work project (that started with Symfony 2.1 and is now on 4.3) we recently introduced the PHPUnitBridge to keep track of deprecations.

Unfortunately it currently reports a variety (> 2000) of deprecations trigged in our own code-base. We are slowly fixing those but this will take some time.

While we are still fixing those deprecations unfortunately whenever new code is merged it might introduce more/new deprecations again 😢

I was thinking it would be really nice to be able to make our CI build fail only for new deprecations reported by the bridge.

This is similar to the phpstan baseline feature maybe: https://medium.com/@ondrejmirtes/phpstans-baseline-feature-lets-you-hold-new-code-to-a-higher-standard-e77d815a5dff

WDYT? Is this something that might be interesting and not too complex to implement?

@dmaicher dmaicher changed the title [PHPUnitBridge] fail only or "new" deprecations / "baseline" feature [PHPUnitBridge] fail only for "new" deprecations / "baseline" feature Nov 21, 2019
@nicolas-grekas
Copy link
Member

Generating a baseline could be a nice idea - setting some option in the SYMFONY_DEPRECATIONS_HELPER to record it, and use it later.
PR welcome.

@nicolas-grekas nicolas-grekas added the Help wanted Issues and PRs which are looking for volunteers to complete them. label Nov 24, 2019
@ruudk
Copy link
Contributor

ruudk commented Dec 2, 2019

I really like how PHPStan does this. Especially since it will error again if you ignore an error that is not triggered, urging you to update your ignored error list.

This is something I really mis right now. In my project I have one external dependency that triggers a A tree builder without a root node is deprecated message. If I can just tell PHPUnitBridge that this one is fine, I can prevent future deprecations immediately.

@fabpot fabpot closed this as completed Oct 7, 2020
fabpot added a commit that referenced this issue Oct 7, 2020
…ecation testing (alexpott)

This PR was submitted for the master branch but it was squashed and merged into the 5.x branch instead.

Discussion
----------

[PhpUnitBridge] Add ability to set a baseline for deprecation testing

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | Fix #37715, #34496
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->

This PR allows you set new options for `SYMFONY_DEPRECATIONS_HELPER` env var:
* `generateBaseline` - if this is set to TRUE any deprecations that occur will be written to the file defined in the `baselineFile` option
* `baselineFile` a path to a file that contains a json encoded array of deprecations that will be skipped.

### Questions
* If you set `generateBaseline` without also setting `baselineFile` an exception is thrown. We could use a default filename if one is not provided (like PHPStan).
* How much error checking should we do around the `baselineFile` variable - should we check if it is readable or should we rely on `file_get_contents`()?

### Still @todo
Add proper end-to-end testing using a .phpt test

Commits
-------

483236f [PhpUnitBridge] Add ability to set a baseline for deprecation testing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Help wanted Issues and PRs which are looking for volunteers to complete them. PhpUnitBridge
Projects
None yet
Development

No branches or pull requests

5 participants