3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
24 * Reference-counted warning suppression
28 function suppressWarnings( $end = false ) {
29 static $suppressCount = 0;
30 static $originalLevel = false;
33 if ( $suppressCount ) {
35 if ( !$suppressCount ) {
36 error_reporting( $originalLevel );
40 if ( !$suppressCount ) {
41 $originalLevel = error_reporting( E_ALL & ~(
56 * Restore error level to previous value
58 function restoreWarnings() {
59 suppressWarnings( true );
64 * Call the callback given by the first parameter, suppressing any warnings.
66 * @param callable $callback
69 function quietCall( $callback /*, parameters... */ ) {
70 $args = array_slice( func_get_args(), 1 );
72 $rv = call_user_func_array( $callback, $args );