Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
Errors
n/a
0 / 0
n/a
0 / 0
5
n/a
0 / 0
 catch_errors
n/a
0 / 0
n/a
0 / 0
5
1<?php
2/**
3 * An errors utility class for Jetpack.
4 *
5 * @package automattic/jetpack-status
6 */
7
8// phpcs:disable WordPress.PHP.IniSet.display_errors_Disallowed
9// phpcs:disable WordPress.PHP.NoSilencedErrors.Discouraged
10// phpcs:disable WordPress.PHP.DevelopmentFunctions.prevent_path_disclosure_error_reporting
11// phpcs:disable WordPress.PHP.DiscouragedPHPFunctions.runtime_configuration_error_reporting
12
13namespace Automattic\Jetpack;
14
15/**
16 * Erros class.
17 *
18 * @deprecated since 3.2.0
19 */
20class Errors {
21    /**
22     * Catches PHP errors.  Must be used in conjunction with output buffering.
23     *
24     * @deprecated since 3.2.0
25     * @param bool $catch True to start catching, False to stop.
26     *
27     * @static
28     */
29    public function catch_errors( $catch ) {
30        _deprecated_function( __METHOD__, '3.2.0' );
31        static $display_errors, $error_reporting;
32
33        if ( $catch ) {
34            // Force error reporting and output, store original values.
35            $display_errors  = @ini_set( 'display_errors', 1 );
36            $error_reporting = @error_reporting( E_ALL );
37            if ( class_exists( 'Jetpack' ) ) {
38                add_action( 'shutdown', array( 'Jetpack', 'catch_errors_on_shutdown' ), 0 );
39            }
40        } else {
41            // Restore the original values for error reporting and output.
42            @ini_set( 'display_errors', $display_errors );
43            if ( $error_reporting !== null ) {
44                @error_reporting( $error_reporting );
45            }
46            if ( class_exists( 'Jetpack' ) ) {
47                remove_action( 'shutdown', array( 'Jetpack', 'catch_errors_on_shutdown' ), 0 );
48            }
49        }
50    }
51}