diff options
| author | Nikita Popov <nikita.ppv@gmail.com> | 2019-06-05 14:38:01 +0200 |
|---|---|---|
| committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-06-05 14:53:50 +0200 |
| commit | 7686b0b88906e2522300b9e631ddde2051de839f (patch) | |
| tree | 31a3cfd1feaf6f7190bad8222a6f9da567acd723 /tests | |
| parent | 03a9c2df7baea96a4777346c8799f0a6fdd7c882 (diff) | |
| parent | a31f46421d7bf6f55dd9ac5876b8e2eacf7e0708 (diff) | |
| download | php-git-7686b0b88906e2522300b9e631ddde2051de839f.tar.gz | |
Merge branch 'PHP-7.4'
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/classes/tostring_001.phpt | 32 | ||||
| -rw-r--r-- | tests/classes/tostring_003.phpt | 5 | ||||
| -rw-r--r-- | tests/classes/tostring_004.phpt | 37 |
3 files changed, 46 insertions, 28 deletions
diff --git a/tests/classes/tostring_001.phpt b/tests/classes/tostring_001.phpt index 53144ca207..418aa1fc25 100644 --- a/tests/classes/tostring_001.phpt +++ b/tests/classes/tostring_001.phpt @@ -3,12 +3,6 @@ ZE2 __toString() --FILE-- <?php -function my_error_handler($errno, $errstr, $errfile, $errline) { - var_dump($errstr); -} - -set_error_handler('my_error_handler'); - class test1 { } @@ -33,7 +27,11 @@ class test3 echo "====test1====\n"; $o = new test1; print_r($o); -var_dump((string)$o); +try { + var_dump((string)$o); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} var_dump($o); echo "====test2====\n"; @@ -70,7 +68,11 @@ echo sprintf("%s", $o); echo "====test10====\n"; $o = new test3; var_dump($o); -echo $o; +try { + echo $o; +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} ?> ====DONE==== @@ -79,9 +81,8 @@ echo $o; test1 Object ( ) -string(54) "Object of class test1 could not be converted to string" -string(0) "" -object(test1)#%d (0) { +Object of class test1 could not be converted to string +object(test1)#1 (0) { } ====test2==== test2 Object @@ -89,7 +90,7 @@ test2 Object ) test2::__toString() Converted -object(test2)#%d (0) { +object(test2)#3 (0) { } ====test3==== test2::__toString() @@ -113,7 +114,8 @@ test2::__toString() Converted ====test7==== test2::__toString() -string(19) "Illegal offset type" + +Warning: Illegal offset type in %s on line %d ====test8==== test2::__toString() string(9) "Converted" @@ -123,8 +125,8 @@ string(9) "Converted" test2::__toString() Converted ====test10==== -object(test3)#%d (0) { +object(test3)#1 (0) { } test3::__toString() -string(53) "Method test3::__toString() must return a string value" +Method test3::__toString() must return a string value ====DONE==== diff --git a/tests/classes/tostring_003.phpt b/tests/classes/tostring_003.phpt index e3bc7f8f2c..4dad51f2cf 100644 --- a/tests/classes/tostring_003.phpt +++ b/tests/classes/tostring_003.phpt @@ -29,5 +29,6 @@ catch(Exception $e) ?> ====DONE==== ---EXPECTF-- -Fatal error: Method Test::__toString() must not throw an exception, caught Exception: Damn! in %stostring_003.php on line %d +--EXPECT-- +string(5) "Damn!" +====DONE==== diff --git a/tests/classes/tostring_004.phpt b/tests/classes/tostring_004.phpt index 6029938f32..997f2e2e7f 100644 --- a/tests/classes/tostring_004.phpt +++ b/tests/classes/tostring_004.phpt @@ -12,12 +12,19 @@ error_reporting(8191); echo "Object with no __toString():\n"; $obj = new stdClass; echo "Try 1:\n"; -printf($obj); +try { + printf($obj); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} printf("\n"); echo "\nTry 2:\n"; -printf($obj . "\n"); - +try { + printf($obj . "\n"); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} echo "\n\nObject with bad __toString():\n"; class badToString { @@ -25,30 +32,38 @@ class badToString { return 0; } } + $obj = new badToString; echo "Try 1:\n"; -printf($obj); +try { + printf($obj); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} printf("\n"); echo "\nTry 2:\n"; -printf($obj . "\n"); +try { + printf($obj . "\n"); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} ?> --EXPECT-- Object with no __toString(): Try 1: -Error: 4096 - Object of class stdClass could not be converted to string -Object +Object of class stdClass could not be converted to string -Try 2: -Error: 4096 - Object of class stdClass could not be converted to string +Try 2: +Object of class stdClass could not be converted to string Object with bad __toString(): Try 1: -Error: 4096 - Method badToString::__toString() must return a string value +Method badToString::__toString() must return a string value Try 2: -Error: 4096 - Method badToString::__toString() must return a string value +Method badToString::__toString() must return a string value |
