1
0
mirror of https://github.com/php/php-src.git synced 2026-03-26 17:22:15 +01:00
Files
archived-php-src/Zend/tests/nullsafe_operator/002.phpt
Ilija Tovilo 9bf119832d Implement nullsafe ?-> operator
RFC: https://wiki.php.net/rfc/nullsafe_operator

Closes GH-5619.

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2020-07-24 10:05:03 +02:00

43 lines
756 B
PHP

--TEST--
Test nullsafe strict type check
--FILE--
<?php
try {
false?->bar();
} catch (Throwable $e) {
var_dump($e->getMessage());
}
try {
[]?->bar();
} catch (Throwable $e) {
var_dump($e->getMessage());
}
try {
(0)?->bar();
} catch (Throwable $e) {
var_dump($e->getMessage());
}
try {
(0.0)?->bar();
} catch (Throwable $e) {
var_dump($e->getMessage());
}
try {
''?->bar();
} catch (Throwable $e) {
var_dump($e->getMessage());
}
?>
--EXPECT--
string(39) "Call to a member function bar() on bool"
string(40) "Call to a member function bar() on array"
string(38) "Call to a member function bar() on int"
string(40) "Call to a member function bar() on float"
string(41) "Call to a member function bar() on string"