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

Skip to content

[PhpUnitBridge] SYMFONY_DEPRECATIONS_HELPER and DeprecationErrorHandler #38239

Closed
@shehi

Description

@shehi

Symfony version(s) affected: 5.1.5

Description
This line, where DeprecationErrorHandler is being registered, relies on the fact that a SYMFONY_DEPRECATIONS_HELPER env value exists in $_ENV. Problem is, this bootstrapping happens while inside Composer autoloader:

image

At this point, phpunit.xml file hasn't even been loaded, as a result, the aforementioned env value which is provided there isn't put into $_ENV yet. This technically invalidates the point of this line in the code if you don't provide the env value via command shell.

Once autoloader is loaded (at this point we are past the point of loading DeprecationErrorHandler) env values are loaded from phpunit.xml:

image

How to reproduce

  1. phpunit.xml file has line: <env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled" />
  2. Create some test with deprecated usage triggerable.
  3. Run tests and you still will get THE ERROR HANDLER HAS CHANGED! error at the end of the test, which is emitted by DeprecationErrorHandler.
    image
  4. Run the same tests with env variable passed in command shell: SYMFONY_DEPRECATIONS_HELPER="disabled" phpunit and no errors will be emitted.
    image

And guys... All caps?! Seriously?!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions