Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] Remove occurrences of E_STRICT #425

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion configdoc/generate.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

if (version_compare(PHP_VERSION, '5.2', '<')) exit('PHP 5.2+ required.');
error_reporting(E_ALL | E_STRICT);
error_reporting(E_ALL);

// load dual-libraries
require_once dirname(__FILE__) . '/../extras/HTMLPurifierExtras.auto.php';
Expand Down
2 changes: 1 addition & 1 deletion library/HTMLPurifier/AttrTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function get($type)
}

if (!isset($this->info[$type])) {
trigger_error('Cannot retrieve undefined attribute type ' . $type, E_USER_ERROR);
throw new Exception('Cannot retrieve undefined attribute type ' . $type);
return;
}
return $this->info[$type]->make($string);
Expand Down
6 changes: 5 additions & 1 deletion library/HTMLPurifier/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,11 @@ protected function triggerError($msg, $no)
break;
}
}
trigger_error($msg . $extra, $no);
if ($no == E_USER_ERROR) {
throw new Exception($msg . $extra);
} else {
trigger_error($msg . $extra, $no);
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion library/HTMLPurifier/DoctypeRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function get($doctype)
$doctype = $this->aliases[$doctype];
}
if (!isset($this->doctypes[$doctype])) {
trigger_error('Doctype ' . htmlspecialchars($doctype) . ' does not exist', E_USER_ERROR);
throw new Exception('Doctype ' . htmlspecialchars($doctype) . ' does not exist');
$anon = new HTMLPurifier_Doctype($doctype);
return $anon;
}
Expand Down
2 changes: 1 addition & 1 deletion library/HTMLPurifier/Encoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ public static function convertToUTF8($str, $config, $context)
$str = self::unsafeIconv($encoding, 'utf-8//IGNORE', $str);
if ($str === false) {
// $encoding is not a valid encoding
trigger_error('Invalid encoding ' . $encoding, E_USER_ERROR);
throw new Exception('Invalid encoding ' . $encoding);
return '';
}
// If the string is bjorked by Shift_JIS or a similar encoding
Expand Down
5 changes: 2 additions & 3 deletions library/HTMLPurifier/HTMLDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,8 @@ protected function setupConfigStuff($config)
if (isset($this->info_content_sets['Block'][$block_wrapper])) {
$this->info_block_wrapper = $block_wrapper;
} else {
trigger_error(
'Cannot use non-block element as block wrapper',
E_USER_ERROR
throw new Exception(
'Cannot use non-block element as block wrapper'
);
}

Expand Down
8 changes: 3 additions & 5 deletions library/HTMLPurifier/HTMLModule/Tidy.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,8 @@ public function makeFixesForLevel($fixes)
return;
}
if (!isset($this->fixesForLevel[$this->defaultLevel])) {
trigger_error(
'Default level ' . $this->defaultLevel . ' does not exist',
E_USER_ERROR
throw new Exception(
'Default level ' . $this->defaultLevel . ' does not exist'
);
return;
}
Expand Down Expand Up @@ -162,8 +161,7 @@ public function populate($fixes)
$e->$type = $fix;
break;
default:
trigger_error("Fix type $type not supported", E_USER_ERROR);
break;
throw new Exception("Fix type $type not supported");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function test_autoload($class)
}

// after external libraries are loaded, turn on compile time errors
error_reporting(E_ALL | E_STRICT);
error_reporting(E_ALL);

// initialize extra HTML Purifier libraries
require '../extras/HTMLPurifierExtras.auto.php';
Expand Down
5 changes: 2 additions & 3 deletions tests/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@
* $test_files) do not have underscores in their names.
*/

// HTML Purifier runs error free on E_STRICT, so if code reports
// errors, we want to know about it.
error_reporting(E_ALL | E_STRICT);
// HTML Purifier runs error free.
error_reporting(E_ALL);

// Because we always want to know about errors, and because SimpleTest
// will notify us about them, logging the errors to stderr is
Expand Down
Loading