1.2.77. Avoid set_error_handler $context Argument

Avoid configuring set_error_handler() with a method that accepts 5 arguments. The last argument, $errcontext, is deprecated since PHP 7.2, and will be removed later.

<?php

// setting error_handler with an incorrect closure
set_error_handler(function($errno, $errstr, $errfile, $errline) {});

// setting error_handler with an incorrect closure
set_error_handler(function($errno, $errstr, $errfile, $errline, $errcontext) {});

?>

See also set_error_handler().

1.2.77.1. Suggestions

  • Remove the 6th argument of registered handlers.

1.2.77.2. Specs

Short name

Php/AvoidSetErrorHandlerContextArg

Rulesets

All, Changed Behavior, CompatibilityPHP72

Exakat since

1.0.4

PHP Version

All

Severity

Major

Time To Fix

Slow (1 hour)

Precision

High

Features

error-handler

Examples

shopware, Vanilla

Available in

Entreprise Edition, Exakat Cloud