Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

I'm working on a CI/CD pipeline where I want to catch deprecation notices and fail the build before deploying to production. However, I've discovered that Symfony's ErrorHandler explicitly excludes E_DEPRECATED and E_USER_DEPRECATED from being thrown as exceptions.

In /symfony/error-handler/ErrorHandler.php, the throwAt() method has this logic:

public function throwAt(int $levels, bool $replace = false): int
{
    $prev = $this->thrownErrors;
    $this->thrownErrors = ($levels | \E_RECOVERABLE_ERROR | \E_USER_ERROR) & ~\E_USER_DEPRECATED & ~\E_DEPRECATED;
    if (!$replace) {
        $this->thrownErrors |= $prev;
    }
    $this->reRegister($prev | $this->loggedErrors);

    return $prev;
}

The & ~\E_USER_DEPRECATED & ~\E_DEPRECATED part explicitly prevents deprecations from being thrown as exceptions.

My use case:

  • I have a GitHub Actions workflow that builds my Symfony application
  • I want to detect deprecation notices during the build process
  • If any deprecations are found, I want the build to fail (exit code != 0)
  • This ensures deprecated code never reaches production

Questions:
Is there a recommended way to make deprecations throw exceptions in specific environments (like build or test)? Or are there alternative approaches I should consider for CI/CD deprecation detection?

I understand that deprecations are typically meant to be warnings rather than fatal errors in normal operation, but for CI/CD purposes, having them fail builds would be extremely valuable for maintaining code quality.

Thanks for any guidance!

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
1 participant
Morty Proxy This is a proxified and sanitized view of the page, visit original site.