This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
Nicolas Grekas 70c70e2d9f bug #27312 Supress deprecation notices thrown when getting private servies from container in tests (arderyp)
This PR was submitted for the master branch but it was squashed and merged into the 4.1 branch instead (closes #27312).

Discussion
----------

Supress deprecation notices thrown when getting private servies from container in tests

| Q             | A
| ------------- | ---
| Branch?       | 4.1
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #27037
| License       | MIT
| Doc PR        | na

This is my first attempt at fixing #27037.

This approach works for me, and I believe it will work globally, but I am not entirely sure if it is the "right" way to do this.  Its not that I think it's the "wrong" way to do it, its just that the `phpunit-bridge` code structure is not the type of code structure that I'm used to, and I'm still new to this project, so I don't know all of the ins and outs, or if there might be a more ideal place to inject the logic we want.

Also, I think my code may be a bit redundant, and I was hoping to get feedback on that.  @nicolas-grekas  (or anyone else), do you think it is safe to simply check if the deprecation message contains the substring ` service is private, getting it from the container...`? if so, then I think we can simply get rid of my `$isNoticeForContainerGetUsage` bit altogether.  If I am understanding things properly, `$isNoticeForContainerGetUsage` will always be true if `$isPrivateServiceNotice` is true, thus we can safely remove the former (as the later is more intuitive, IMO).

The last thing I wanted to confirm was my interpretation of the stack trace, as detailed in my code comment. If the bit after `NOTE` is not correct, this code might not be a proper solution.  I tested various contexts where the error should be suppressed (from within tests) and also where it should not (from within controllers, etc), which is what I based my `NOTE` comment on.

Commits
-------

00603bf010 Supress deprecation notices thrown when getting private servies from container in tests
2018-05-21 11:19:02 +02:00
.composer Drop hirak/prestissimo 2016-05-12 07:44:15 -05:00
.github minor #27079 Added .github/CODEOWNERS (lyrixx) 2018-04-30 12:11:06 -07:00
src/Symfony Supress deprecation notices thrown when getting private servies from container in tests 2018-05-21 11:18:50 +02:00
.editorconfig Add EditorConfig File 2012-06-16 14:08:15 +02:00
.gitignore Add appveyor.yml for C.I. on Windows 2015-08-25 23:41:37 +02:00
.php_cs.dist [DI] Service decoration: autowire the inner service 2018-03-20 19:23:30 +01:00
.travis.yml [Messenger] Add AMQP adapter 2018-04-12 09:15:52 +01:00
appveyor.yml Merge branch '3.4' into 4.0 2018-04-26 18:12:06 +02:00
CHANGELOG-4.0.md updated CHANGELOG for 4.0.9 2018-04-30 21:45:53 +02:00
CHANGELOG-4.1.md updated CHANGELOG for 4.1.0-BETA1 2018-05-07 17:29:57 +02:00
composer.json Merge branch '4.0' 2018-05-01 16:02:13 -07:00
CONTRIBUTING.md Mention the community review guide 2016-12-18 22:02:35 +01:00
CONTRIBUTORS.md update CONTRIBUTORS for 2.7.46 2018-04-27 07:41:29 +02:00
LICENSE fixed years in copyright 2018-01-03 08:23:28 +01:00
link [DI] Minor performance tweak in PriorityTaggedServiceTrait 2018-05-03 17:03:52 -07:00
phpunit Force phpunit-bridge update (bis) 2017-11-22 10:25:38 +01:00
phpunit.xml.dist [Cache] Rely on mock for Doctrine ArrayCache 2018-03-19 23:12:11 +01:00
README.md Prefer composer install instead for using Symfony Installer 2018-01-10 18:56:50 +01:00
UPGRADE-4.0.md [Form] Fix typo in Upgrade 3.4/4.0 2018-04-06 07:20:49 +02:00
UPGRADE-4.1.md [Workflow] "clear()" instead of "reset()" 2018-04-29 09:31:06 -07:00
UPGRADE-5.0.md [Workflow] "clear()" instead of "reset()" 2018-04-29 09:31:06 -07:00

Symfony is a PHP framework for web applications and a set of reusable PHP components. Symfony is used by thousands of web applications (including BlaBlaCar.com and Spotify.com) and most of the popular PHP projects (including Drupal and Magento).

Installation

Documentation

Community

Contributing

Symfony is an Open Source, community-driven project with thousands of contributors. Join them contributing code or contributing documentation.

Security Issues

If you discover a security vulnerability within Symfony, please follow our disclosure procedure.

About Us

Symfony development is sponsored by SensioLabs, led by the Symfony Core Team and supported by Symfony contributors.