8000 Allow listed deprecations to be skipped · Issue #37715 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Allow listed deprecations to be skipped #37715

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
alexpott opened this issue Jul 31, 2020 · 4 comments · Fixed by #37733
Closed

Allow listed deprecations to be skipped #37715

alexpott opened this issue Jul 31, 2020 · 4 comments · Fixed by #37733

Comments

@alexpott
Copy link
Contributor

Description
Drupal is using Symfony's PHPUnit bridge to detect usages of deprecated code during tests. This has proved amazing useful in managing our technical debt and has helped us prepare for Symfony 4 and 5. One problem we've faced because of Drupal's size is that it is not always possible to address new deprecations at the same time as upgrading a dependency. In order to handle this we've added the ability to skip specific deprecations which we can then handle in a separate issue.

When skipping a deprecation we can either match the entire message or use a regex for a dynamic deprecation message.

Example
For example, Drupal 9 is using Symfony 4 and we're skipping the The "Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser" class is deprecated since Symfony 4.3, use "Symfony\Component\Mime\MimeTypes" instead. deprecation notice and handling the changes we need to make to Drupal in https://www.drupal.org/project/drupal/issues/3055193

@nicolas-grekas
Copy link
Member

What about allowing one to snapshot the current deprecations and use that as a base for next runs? This could be implemented via some option to the SYMFONY_DEPRECATIONS_HELPER

@alexpott
Copy link
Contributor Author

@nicolas-grekas that does seem an interesting functionality - we could build on top of this to do that.

@stof
Copy link
Member
stof commented Jul 31, 2020

yeah, having a baseline file (the name is taken from the phpstan feature) seems interesting.

@dmaicher
Copy link
Contributor

See #34496 😊 I also thought about that a while back and found it useful

@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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants
0