Skip to content

Commit 434510c

Browse files
authored
Merge pull request #156 from Krinkle/fix-php84-trigger
Throw `new Error` instead of E_USER_ERROR on PHP 7.0+
2 parents b87af5d + 3834a4c commit 434510c

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

PEAR.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,13 @@ function _PEAR() {
216216
public function __call($method, $arguments)
217217
{
218218
if (!isset(self::$bivalentMethods[$method])) {
219-
trigger_error(
220-
'Call to undefined method PEAR::' . $method . '()', E_USER_ERROR
221-
);
219+
if (PHP_VERSION_ID < 70000) {
220+
trigger_error(
221+
'Call to undefined method PEAR::' . $method . '()', E_USER_ERROR
222+
);
223+
} else {
224+
throw new Error('Call to undefined method PEAR::' . $method . '()');
225+
}
222226
}
223227
return call_user_func_array(
224228
array(__CLASS__, '_' . $method),
@@ -229,9 +233,13 @@ public function __call($method, $arguments)
229233
public static function __callStatic($method, $arguments)
230234
{
231235
if (!isset(self::$bivalentMethods[$method])) {
232-
trigger_error(
233-
'Call to undefined method PEAR::' . $method . '()', E_USER_ERROR
234-
);
236+
if (PHP_VERSION_ID < 70000) {
237+
trigger_error(
238+
'Call to undefined method PEAR::' . $method . '()', E_USER_ERROR
239+
);
240+
} else {
241+
throw new Error('Call to undefined method PEAR::' . $method . '()');
242+
}
235243
}
236244
return call_user_func_array(
237245
array(__CLASS__, '_' . $method),

PEAR/Frontend/CLI.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,11 @@ function userDialog($command, $prompts, $types = array(), $defaults = array(), $
357357

358358
function userConfirm($prompt, $default = 'yes')
359359
{
360-
trigger_error("PEAR_Frontend_CLI::userConfirm not yet converted", E_USER_ERROR);
360+
if (PHP_VERSION_ID < 70000) {
361+
trigger_error("PEAR_Frontend_CLI::userConfirm not yet converted", E_USER_ERROR);
362+
} else {
363+
throw new Error('PEAR_Frontend_CLI::userConfirm not yet converted');
364+
}
361365
static $positives = array('y', 'yes', 'on', '1');
362366
static $negatives = array('n', 'no', 'off', '0');
363367
print "$this->lp$prompt [$default] : ";

0 commit comments

Comments
 (0)