diff options
author | Dmitry Stogov <dmitry@zend.com> | 2015-03-09 13:57:15 +0100 |
---|---|---|
committer | Nikita Popov <nikic@php.net> | 2015-03-09 14:01:32 +0100 |
commit | 1c94ff0595bbe6f3df8058aff7252bda09dc4a15 (patch) | |
tree | efe488bc3292d544657fca92c4347c9b872931eb /Zend/tests | |
parent | 2f156c61f19a889c8ed39fe8eb3b3220555db647 (diff) | |
download | php-git-1c94ff0595bbe6f3df8058aff7252bda09dc4a15.tar.gz |
Implement engine exceptions
RFC: https://wiki.php.net/rfc/engine_exceptions_for_php7
Pending changes regarding naming of BaseException and whether it
should be an interface.
Diffstat (limited to 'Zend/tests')
30 files changed, 99 insertions, 568 deletions
diff --git a/Zend/tests/030.phpt b/Zend/tests/030.phpt index 8afcb66bd8..cff21d4935 100644 --- a/Zend/tests/030.phpt +++ b/Zend/tests/030.phpt @@ -34,7 +34,7 @@ $test->bar(); object(Exception)#%d (7) { ["message":protected]=> string(3) "foo" - ["string":"Exception":private]=> + ["string":"BaseException":private]=> string(0) "" ["code":protected]=> int(0) @@ -42,7 +42,7 @@ object(Exception)#%d (7) { string(%d) "%s030.php" ["line":protected]=> int(%d) - ["trace":"Exception":private]=> + ["trace":"BaseException":private]=> array(1) { [0]=> array(6) { @@ -61,7 +61,7 @@ object(Exception)#%d (7) { } } } - ["previous":"Exception":private]=> + ["previous":"BaseException":private]=> NULL } 'test' => '0' diff --git a/Zend/tests/arg_unpack/string_keys.phpt b/Zend/tests/arg_unpack/string_keys.phpt index 443a882941..51db52e146 100644 --- a/Zend/tests/arg_unpack/string_keys.phpt +++ b/Zend/tests/arg_unpack/string_keys.phpt @@ -7,14 +7,18 @@ set_error_handler(function($errno, $errstr) { var_dump($errstr); }); -var_dump(...[1, 2, "foo" => 3, 4]); -var_dump(...new ArrayIterator([1, 2, "foo" => 3, 4])); +try { + var_dump(...[1, 2, "foo" => 3, 4]); +} catch (EngineException $ex) { + var_dump($ex->getMessage()); +} +try { + var_dump(...new ArrayIterator([1, 2, "foo" => 3, 4])); +} catch (EngineException $ex) { + var_dump($ex->getMessage()); +} ?> --EXPECTF-- string(36) "Cannot unpack array with string keys" -int(1) -int(2) string(42) "Cannot unpack Traversable with string keys" -int(1) -int(2) diff --git a/Zend/tests/bug37251.phpt b/Zend/tests/bug37251.phpt index 320d544ce5..2b545a530f 100644 --- a/Zend/tests/bug37251.phpt +++ b/Zend/tests/bug37251.phpt @@ -2,18 +2,16 @@ Bug #37251 (deadlock when custom error handler is to catch array type hint error) --FILE-- <?php -function error_handler($errno, $errstr, $errfile, $errline, $context) { - echo 'OK'; -} - -set_error_handler('error_handler'); - class Foo { function bar(array $foo) { } } -$foo = new Foo(); -$foo->bar(); +try { + $foo = new Foo(); + $foo->bar(); +} catch (EngineException $e) { + echo 'OK'; +} --EXPECT-- OK diff --git a/Zend/tests/bug48693.phpt b/Zend/tests/bug48693.phpt index e5f7ce8f45..d2baf2a695 100644 --- a/Zend/tests/bug48693.phpt +++ b/Zend/tests/bug48693.phpt @@ -3,26 +3,43 @@ Bug #48693 (Double declaration of __lambda_func when lambda wrongly formatted) --FILE-- <?php -$x = create_function('', 'return 1; }'); -$y = create_function('', 'function a() { }; return 2;'); -$z = create_function('', '{'); -$w = create_function('', 'return 3;'); +try { + $x = create_function('', 'return 1; }'); +} catch (ParseException $e) { + echo "$e\n\n"; +} +try { + $y = create_function('', 'function a() { }; return 2;'); +} catch (ParseException $e) { + echo "$e\n\n"; +} +try { + $z = create_function('', '{'); +} catch (ParseException $e) { + echo "$e\n\n"; +} +try { + $w = create_function('', 'return 3;'); +} catch (ParseException $e) { + echo "$e\n\n"; +} var_dump( - $x, $y(), - $z, - $w(), - $y != $z + $w() ); ?> --EXPECTF-- -Parse error: %s in %s(%d) : runtime-created function on line 1 +exception 'ParseException' with message 'syntax error, unexpected '}', expecting end of file' in %sbug48693.php(4) : runtime-created function:1 +Stack trace: +#0 %sbug48693.php(4): create_function('', 'return 1; }') +#1 {main} + +exception 'ParseException' with message 'syntax error, unexpected end of file' in %sbug48693.php(14) : runtime-created function:1 +Stack trace: +#0 %sbug48693.php(14): create_function('', '{') +#1 {main} -Parse error: %s %s(%d) : runtime-created function on line 1 -bool(false) int(2) -bool(false) int(3) -bool(true) diff --git a/Zend/tests/bug64135.phpt b/Zend/tests/bug64135.phpt index 1c7b1500a2..53bcba1d0d 100644 --- a/Zend/tests/bug64135.phpt +++ b/Zend/tests/bug64135.phpt @@ -10,7 +10,7 @@ function exception_error_handler() { set_error_handler("exception_error_handler"); try { $undefined->undefined(); -} catch(Exception $e) { +} catch(BaseException $e) { echo "Exception is thrown"; } --EXPECT-- diff --git a/Zend/tests/bug64966.phpt b/Zend/tests/bug64966.phpt index c1cdbbf812..931460ba60 100644 --- a/Zend/tests/bug64966.phpt +++ b/Zend/tests/bug64966.phpt @@ -2,11 +2,12 @@ Bug #64966 (segfault in zend_do_fcall_common_helper_SPEC) --FILE-- <?php -error_reporting(E_ALL); -set_error_handler(function($error) { throw new Exception(); }, E_RECOVERABLE_ERROR); - function test($func) { - $a = $func(""); + try { + $a = $func(""); + } catch (EngineException $e) { + throw new Exception(); + } return true; } class A { @@ -20,11 +21,9 @@ $a = new A(); $a->b(); ?> --EXPECTF-- -Fatal error: Uncaught exception 'Exception' in %sbug64966.php:3 +Fatal error: Uncaught exception 'Exception' in %sbug64966.php:6 Stack trace: -#0 [internal function]: {closure}(4096, 'Argument 1 pass...', '%s', 6, Array) -#1 %sbug64966.php(6): iterator_apply('') -#2 %sbug64966.php(12): test('iterator_apply') -#3 %sbug64966.php(17): A->b() -#4 {main} - thrown in %sbug64966.php on line 3 +#0 %sbug64966.php(13): test('iterator_apply') +#1 %sbug64966.php(18): A->b() +#2 {main} + thrown in %sbug64966.php on line 6 diff --git a/Zend/tests/closure_031.phpt b/Zend/tests/closure_031.phpt index dace4a4e73..6b4586e8b0 100644 --- a/Zend/tests/closure_031.phpt +++ b/Zend/tests/closure_031.phpt @@ -8,9 +8,12 @@ function foo($errno, $errstr, $errfile, $errline) { set_error_handler('foo'); $foo = function() { }; -var_dump($foo->a); +try { + var_dump($foo->a); +} catch (EngineException $ex) { + echo "Error: {$ex->getMessage()}\n"; +} ?> --EXPECT-- Error: Closure object cannot have properties -NULL diff --git a/Zend/tests/exception_010.phpt b/Zend/tests/exception_010.phpt index 6bff8c6e5e..d67cddab58 100644 --- a/Zend/tests/exception_010.phpt +++ b/Zend/tests/exception_010.phpt @@ -15,16 +15,16 @@ $x->getcode(1); ?> --EXPECTF-- -Warning: Exception::getTraceAsString() expects exactly 0 parameters, 1 given in %s on line %d +Warning: BaseException::getTraceAsString() expects exactly 0 parameters, 1 given in %s on line %d -Warning: Exception::__toString() expects exactly 0 parameters, 1 given in %s on line %d +Warning: BaseException::__toString() expects exactly 0 parameters, 1 given in %s on line %d -Warning: Exception::getTrace() expects exactly 0 parameters, 1 given in %s on line %d +Warning: BaseException::getTrace() expects exactly 0 parameters, 1 given in %s on line %d -Warning: Exception::getLine() expects exactly 0 parameters, 1 given in %s on line %d +Warning: BaseException::getLine() expects exactly 0 parameters, 1 given in %s on line %d -Warning: Exception::getFile() expects exactly 0 parameters, 1 given in %s on line %d +Warning: BaseException::getFile() expects exactly 0 parameters, 1 given in %s on line %d -Warning: Exception::getMessage() expects exactly 0 parameters, 1 given in %s on line %d +Warning: BaseException::getMessage() expects exactly 0 parameters, 1 given in %s on line %d -Warning: Exception::getCode() expects exactly 0 parameters, 1 given in %s on line %d +Warning: BaseException::getCode() expects exactly 0 parameters, 1 given in %s on line %d diff --git a/Zend/tests/exception_before_fatal.phpt b/Zend/tests/exception_before_fatal.phpt index 608d65094b..1109097e1f 100644 --- a/Zend/tests/exception_before_fatal.phpt +++ b/Zend/tests/exception_before_fatal.phpt @@ -10,38 +10,38 @@ set_error_handler("exception_error_handler"); try { $foo->a(); -} catch(Exception $e) { +} catch(BaseException $e) { var_dump($e->getMessage()); } try { new $foo(); -} catch(Exception $e) { +} catch(BaseException $e) { var_dump($e->getMessage()); } try { throw $foo; -} catch(Exception $e) { +} catch(BaseException $e) { var_dump($e->getMessage()); } try { $foo(); -} catch(Exception $e) { +} catch(BaseException $e) { var_dump($e->getMessage()); } try { $foo::b(); -} catch(Exception $e) { +} catch(BaseException $e) { var_dump($e->getMessage()); } try { $b = clone $foo; -} catch(Exception $e) { +} catch(BaseException $e) { var_dump($e->getMessage()); } @@ -50,7 +50,7 @@ class b { try { b::$foo(); -} catch(Exception $e) { +} catch(BaseException $e) { var_dump($e->getMessage()); } ?> diff --git a/Zend/tests/generators/bug67497.phpt b/Zend/tests/generators/bug67497.phpt index 483857b96c..63e535d331 100644 --- a/Zend/tests/generators/bug67497.phpt +++ b/Zend/tests/generators/bug67497.phpt @@ -8,7 +8,10 @@ function gen() { yield $a; } -@eval('abc'); +try { + eval('abc'); +} catch (ParseException $ex) { +} $values = gen(); $values->next(); diff --git a/Zend/tests/methods-on-non-objects-args-catch.phpt b/Zend/tests/methods-on-non-objects-args-catch.phpt deleted file mode 100644 index 853d2d5602..0000000000 --- a/Zend/tests/methods-on-non-objects-args-catch.phpt +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -Catch method calls on non-objects raise recoverable errors ---FILE-- -<?php -set_error_handler(function($code, $message) { - var_dump($code, $message); -}); - -$x= null; -var_dump($x->method(1, 2, 3)); -echo "Alive\n"; -?> ---EXPECTF-- - -int(4096) -string(%d) "Call to a member function method() on null" -NULL -Alive diff --git a/Zend/tests/methods-on-non-objects-array-access.phpt b/Zend/tests/methods-on-non-objects-array-access.phpt deleted file mode 100755 index be87457c6c..0000000000 --- a/Zend/tests/methods-on-non-objects-array-access.phpt +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -Catch method calls on non-objects inside array access ---FILE-- -<?php -set_error_handler(function($code, $message) { - var_dump($code, $message); -}); - -$x= null; -$a= [null => 'OK']; -var_dump($a[$x->method()]); -echo "Alive\n"; -?> ---EXPECTF-- -int(4096) -string(%d) "Call to a member function method() on null" -string(2) "OK" -Alive
\ No newline at end of file diff --git a/Zend/tests/methods-on-non-objects-array-creation.phpt b/Zend/tests/methods-on-non-objects-array-creation.phpt deleted file mode 100755 index 74cbb9c179..0000000000 --- a/Zend/tests/methods-on-non-objects-array-creation.phpt +++ /dev/null @@ -1,35 +0,0 @@ ---TEST-- -Catch method calls on non-objects inside array creation ---FILE-- -<?php -set_error_handler(function($code, $message) { - var_dump($code, $message); -}); - -$x= null; -var_dump([$x->method() => 'OK']); -var_dump([$x->method(), $x->method(), $x->method()]); -echo "Alive\n"; -?> ---EXPECTF-- -int(4096) -string(%d) "Call to a member function method() on null" -array(1) { - [""]=> - string(2) "OK" -} -int(4096) -string(%d) "Call to a member function method() on null" -int(4096) -string(%d) "Call to a member function method() on null" -int(4096) -string(%d) "Call to a member function method() on null" -array(3) { - [0]=> - NULL - [1]=> - NULL - [2]=> - NULL -} -Alive
\ No newline at end of file diff --git a/Zend/tests/methods-on-non-objects-as-arg.phpt b/Zend/tests/methods-on-non-objects-as-arg.phpt deleted file mode 100755 index 13b83cb06e..0000000000 --- a/Zend/tests/methods-on-non-objects-as-arg.phpt +++ /dev/null @@ -1,47 +0,0 @@ ---TEST-- -Catch method calls on non-objects as argument ---FILE-- -<?php -function nesting() { - return func_get_args(); -} -set_error_handler(function($code, $message) { - static $i= 0; - echo 'Called #'.(++$i)."\n"; -}); - -$x= null; -var_dump(nesting($x->method())); -var_dump(nesting(nesting($x->method()))); -var_dump(nesting($x->method(nesting($x->method())))); -var_dump(nesting($x->method(), $x->method())); -echo "Alive\n"; -?> ---EXPECTF-- -Called #1 -array(1) { - [0]=> - NULL -} -Called #2 -array(1) { - [0]=> - array(1) { - [0]=> - NULL - } -} -Called #3 -array(1) { - [0]=> - NULL -} -Called #4 -Called #5 -array(2) { - [0]=> - NULL - [1]=> - NULL -} -Alive diff --git a/Zend/tests/methods-on-non-objects-catch.phpt b/Zend/tests/methods-on-non-objects-catch.phpt index bbfadac107..b38da3657b 100644 --- a/Zend/tests/methods-on-non-objects-catch.phpt +++ b/Zend/tests/methods-on-non-objects-catch.phpt @@ -7,12 +7,15 @@ set_error_handler(function($code, $message) { }); $x= null; -var_dump($x->method()); +try { + var_dump($x->method()); +} catch (EngineException $e) { + var_dump($e->getCode(), $e->getMessage()); +} echo "Alive\n"; ?> --EXPECTF-- int(4096) string(%d) "Call to a member function method() on null" -NULL Alive diff --git a/Zend/tests/methods-on-non-objects-chain.phpt b/Zend/tests/methods-on-non-objects-chain.phpt deleted file mode 100644 index 30da254cd5..0000000000 --- a/Zend/tests/methods-on-non-objects-chain.phpt +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -Catch chained method calls on non-objects raise recoverable errors ---FILE-- -<?php -set_error_handler(function($code, $message) { - var_dump($code, $message); -}); - -$x= null; -var_dump($x->method()->chained()->invocations()); -echo "Alive\n"; -?> ---EXPECTF-- - -int(4096) -string(%d) "Call to a member function method() on null" -int(4096) -string(%d) "Call to a member function chained() on null" -int(4096) -string(%d) "Call to a member function invocations() on null" -NULL -Alive diff --git a/Zend/tests/methods-on-non-objects-concat.phpt b/Zend/tests/methods-on-non-objects-concat.phpt deleted file mode 100755 index 4ff47aa454..0000000000 --- a/Zend/tests/methods-on-non-objects-concat.phpt +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -Catch method calls on non-objects inside concatenation ---FILE-- -<?php -set_error_handler(function($code, $message) { - var_dump($code, $message); -}); - -$x= null; -echo "Before\n".$x->method()."After\n"; -echo "Alive\n"; -?> ---EXPECTF-- -int(4096) -string(%d) "Call to a member function method() on null" -Before -After -Alive
\ No newline at end of file diff --git a/Zend/tests/methods-on-non-objects-dynamic.phpt b/Zend/tests/methods-on-non-objects-dynamic.phpt deleted file mode 100755 index 11c5c9f44b..0000000000 --- a/Zend/tests/methods-on-non-objects-dynamic.phpt +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -Catch method calls on non-objects with dynamic lookups ---FILE-- -<?php -set_error_handler(function($code, $message) { - static $i= 0; - echo 'Called #'.(++$i)."\n"; -}); - -$arr= [null, 'method']; -var_dump($arr[0]->{$arr[1]}()); - -$fun= function() { return null; }; -var_dump($fun()->{'method'}()); - -echo "Alive\n"; -?> ---EXPECTF-- -Called #1 -NULL -Called #2 -NULL -Alive diff --git a/Zend/tests/methods-on-non-objects-eval.phpt b/Zend/tests/methods-on-non-objects-eval.phpt deleted file mode 100644 index 8ee494c434..0000000000 --- a/Zend/tests/methods-on-non-objects-eval.phpt +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -Indirect call inside eval to member function on non-object ---FILE-- -<?php -set_error_handler(function($code, $message) { - var_dump($code, $message); -}); - -$x= null; -var_dump(eval('$x->method(1, 2, 3);')); -echo "Alive\n"; -?> ---EXPECTF-- - -int(4096) -string(%d) "Call to a member function method() on null" -NULL -Alive diff --git a/Zend/tests/methods-on-non-objects-in-echo.phpt b/Zend/tests/methods-on-non-objects-in-echo.phpt deleted file mode 100755 index a0267c0ea5..0000000000 --- a/Zend/tests/methods-on-non-objects-in-echo.phpt +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -Catch method calls on non-objects inside echo ---FILE-- -<?php -set_error_handler(function($code, $message) { - var_dump($code, $message); -}); - -$x= null; -echo "Before\n", $x->method(), "After\n"; -echo "Alive\n"; -?> ---EXPECTF-- -Before -int(4096) -string(%d) "Call to a member function method() on null" -After -Alive
\ No newline at end of file diff --git a/Zend/tests/methods-on-non-objects-nested-calls-dyn.phpt b/Zend/tests/methods-on-non-objects-nested-calls-dyn.phpt deleted file mode 100755 index 267104f1b3..0000000000 --- a/Zend/tests/methods-on-non-objects-nested-calls-dyn.phpt +++ /dev/null @@ -1,37 +0,0 @@ ---TEST-- -Catch method calls on non-objects with nested dynamic calls ---FILE-- -<?php -function nested() { - throw new LogicException('Should not be called'); -} -set_error_handler(function($code, $message) { - static $i= 0; - echo 'Called #'.(++$i)."\n"; -}); - -$x= null; - -$closure= function() { return nested(); }; -var_dump($x->method($closure())); - -$lambda= create_function('', 'return nested();'); -var_dump($x->method($lambda())); - -$func= 'nested'; -var_dump($x->method($func())); - -var_dump($x->method(call_user_func('nested'))); - -echo "Alive\n"; -?> ---EXPECTF-- -Called #1 -NULL -Called #2 -NULL -Called #3 -NULL -Called #4 -NULL -Alive diff --git a/Zend/tests/methods-on-non-objects-nested-calls-new.phpt b/Zend/tests/methods-on-non-objects-nested-calls-new.phpt deleted file mode 100755 index d8e3dd21bf..0000000000 --- a/Zend/tests/methods-on-non-objects-nested-calls-new.phpt +++ /dev/null @@ -1,37 +0,0 @@ ---TEST-- -Catch method calls on non-objects with nested calls to new ---FILE-- -<?php -class Nesting { -} -set_error_handler(function($code, $message) { - static $i= 0; - echo 'Called #'.(++$i)."\n"; -}); - -$x= null; -var_dump($x->method(new Nesting())); -var_dump($x->method(new Nesting(), new Nesting())); -var_dump($x->method(new Nesting(new Nesting()))); -var_dump($x->method(new Nesting($x->nested()))); -var_dump($x->method(new Nesting($x->nested(new Nesting())))); -var_dump($x->method($x->nested(new Nesting($x->deep())))); -var_dump($x->method([new Nesting()])); -echo "Alive\n"; -?> ---EXPECTF-- -Called #1 -NULL -Called #2 -NULL -Called #3 -NULL -Called #4 -NULL -Called #5 -NULL -Called #6 -NULL -Called #7 -NULL -Alive diff --git a/Zend/tests/methods-on-non-objects-nested-calls-nonct.phpt b/Zend/tests/methods-on-non-objects-nested-calls-nonct.phpt deleted file mode 100755 index a4529eecdc..0000000000 --- a/Zend/tests/methods-on-non-objects-nested-calls-nonct.phpt +++ /dev/null @@ -1,43 +0,0 @@ ---TEST-- -Catch method calls on non-objects with nested non-compile-time-resolveable calls ---FILE-- -<?php -require('methods-on-non-objects-nested.inc'); - -set_error_handler(function($code, $message) { - static $i= 0; - echo 'Called #'.(++$i)."\n"; -}); - -$x= null; - -var_dump($x->method(nested())); - -$closure= function() { return nested(); }; -var_dump($x->method($closure())); - -$lambda= create_function('', 'return nested();'); -var_dump($x->method($lambda())); - -$func= 'nested'; -var_dump($x->method($func())); - -var_dump($x->method(call_user_func('nested'))); -var_dump($x->method(call_user_func_array('nested', []))); - -echo "Alive\n"; -?> ---EXPECTF-- -Called #1 -NULL -Called #2 -NULL -Called #3 -NULL -Called #4 -NULL -Called #5 -NULL -Called #6 -NULL -Alive diff --git a/Zend/tests/methods-on-non-objects-nested-calls-ns.phpt b/Zend/tests/methods-on-non-objects-nested-calls-ns.phpt deleted file mode 100755 index b16f579fa9..0000000000 --- a/Zend/tests/methods-on-non-objects-nested-calls-ns.phpt +++ /dev/null @@ -1,26 +0,0 @@ ---TEST-- -Catch method calls on non-objects with nested calls to namespaced functions with core counterparts ---FILE-- -<?php namespace test; -function strlen($str) { - throw new LogicException('Should not be called'); -} -set_error_handler(function($code, $message) { - static $i= 0; - echo 'Called #'.(++$i)."\n"; -}); - -$x= null; -var_dump($x->method(strlen('Test'))); -var_dump($x->method(strlen('Test'), strlen('Test'))); -var_dump($x->method([strlen('Test')])); -echo "Alive\n"; -?> ---EXPECTF-- -Called #1 -NULL -Called #2 -NULL -Called #3 -NULL -Alive diff --git a/Zend/tests/methods-on-non-objects-nested-calls-static.phpt b/Zend/tests/methods-on-non-objects-nested-calls-static.phpt deleted file mode 100755 index 64972ee871..0000000000 --- a/Zend/tests/methods-on-non-objects-nested-calls-static.phpt +++ /dev/null @@ -1,33 +0,0 @@ ---TEST-- -Catch method calls on non-objects with nested calls to static methods ---FILE-- -<?php -class Nesting { - static function nested() { - throw new LogicException('Should not be called'); - } -} -set_error_handler(function($code, $message) { - static $i= 0; - echo 'Called #'.(++$i)."\n"; -}); - -$x= null; -$class= 'Nesting'; -$method= 'nested'; -var_dump($x->method(Nesting::nested())); -var_dump($x->method($class::nested())); -var_dump($x->method($class::{$method}())); -var_dump($x->method([Nesting::nested()])); -echo "Alive\n"; -?> ---EXPECTF-- -Called #1 -NULL -Called #2 -NULL -Called #3 -NULL -Called #4 -NULL -Alive diff --git a/Zend/tests/methods-on-non-objects-nested-calls.phpt b/Zend/tests/methods-on-non-objects-nested-calls.phpt deleted file mode 100644 index b25aeafd9c..0000000000 --- a/Zend/tests/methods-on-non-objects-nested-calls.phpt +++ /dev/null @@ -1,47 +0,0 @@ ---TEST-- -Catch method calls on non-objects with nested function and method calls ---FILE-- -<?php -function nested() { - throw new LogicException('Should not be called'); -} -set_error_handler(function($code, $message) { - static $i= 0; - echo 'Called #'.(++$i)."\n"; -}); - -$x= null; -var_dump($x->method(nested())); -var_dump($x->method(nested(), nested())); -var_dump($x->method(nested(nested()))); -var_dump($x->method($x->nested())); -var_dump($x->method($x->nested(), $x->nested())); -var_dump($x->method($x->nested(nested()))); -var_dump($x->method($x->nested($x->deep()))); -var_dump($x->method($x->nested(nested($x->deep())))); -var_dump($x->method(nested(nested($x->nested())))); -var_dump($x->method([nested()])); -echo "Alive\n"; -?> ---EXPECTF-- -Called #1 -NULL -Called #2 -NULL -Called #3 -NULL -Called #4 -NULL -Called #5 -NULL -Called #6 -NULL -Called #7 -NULL -Called #8 -NULL -Called #9 -NULL -Called #10 -NULL -Alive diff --git a/Zend/tests/methods-on-non-objects-return-unused.phpt b/Zend/tests/methods-on-non-objects-return-unused.phpt deleted file mode 100755 index ab2951f94f..0000000000 --- a/Zend/tests/methods-on-non-objects-return-unused.phpt +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -Catch method calls on non-objects without using return value ---INI-- -report_memleaks=1 ---FILE-- -<?php -set_error_handler(function($code, $message) { - echo "Caught\n"; -}); - -$x= null; -$x->method(); -echo "Alive\n"; -?> ---EXPECTF-- -Caught -Alive diff --git a/Zend/tests/methods-on-non-objects-throw.phpt b/Zend/tests/methods-on-non-objects-throw.phpt deleted file mode 100644 index 874f57cb24..0000000000 --- a/Zend/tests/methods-on-non-objects-throw.phpt +++ /dev/null @@ -1,29 +0,0 @@ ---TEST-- -Convert errors to exceptions from method calls on non-objects raise recoverable errors ---FILE-- -<?php -set_error_handler(function($code, $message) { - echo "Raising...\n"; - if (0 === strncmp('Call', $message, 4)) { - throw new BadMethodCallException($message); - } else if (0 === strncmp('Argument', $message, 8)) { - throw new InvalidArgumentException($message); - } else { - trigger_error($message, E_USER_ERROR); - } -}, E_RECOVERABLE_ERROR); - -$x= null; -echo "Calling...\n"; -try { - $x->method(); -} catch (BadMethodCallException $e) { - echo "Caught expected ", $e->getMessage(), "!\n"; -} -echo "Alive\n"; -?> ---EXPECTF-- -Calling... -Raising... -Caught expected Call to a member function method() on null! -Alive diff --git a/Zend/tests/methods-on-non-objects-usort.phpt b/Zend/tests/methods-on-non-objects-usort.phpt index fb1869c1c8..54779cd1ea 100644 --- a/Zend/tests/methods-on-non-objects-usort.phpt +++ b/Zend/tests/methods-on-non-objects-usort.phpt @@ -9,7 +9,12 @@ set_error_handler(function($code, $message) { $comparator= null; $list= [1, 4, 2, 3, -1]; usort($list, function($a, $b) use ($comparator) { - return $comparator->compare($a, $b); + try { + return $comparator->compare($a, $b); + } catch (EngineException $e) { + var_dump($e->getCode(), $e->getMessage()); + return 0; + } }); var_dump($list); echo "Alive\n"; diff --git a/Zend/tests/variadic/typehint_suppressed_error.phpt b/Zend/tests/variadic/typehint_suppressed_error.phpt index 5048e1c1bb..f03ec43d0a 100644 --- a/Zend/tests/variadic/typehint_suppressed_error.phpt +++ b/Zend/tests/variadic/typehint_suppressed_error.phpt @@ -7,27 +7,12 @@ function test(array... $args) { var_dump($args); } -set_error_handler(function($errno, $errstr) { - var_dump($errstr); - return true; -}); - -test([0], [1], 2); +try { + test([0], [1], 2); +} catch(EngineException $e) { + var_dump($e->getMessage()); +} ?> --EXPECTF-- string(%d) "Argument 3 passed to test() must be of the type array, integer given, called in %s on line %d and defined" -array(3) { - [0]=> - array(1) { - [0]=> - int(0) - } - [1]=> - array(1) { - [0]=> - int(1) - } - [2]=> - int(2) -} |