mirror of
https://github.com/php/php-src.git
synced 2026-04-18 05:21:02 +02:00
This helps to avoid unnecessary IS_REFERENCE checks. This changes some notices "Only variables should be passed by reference" to exception "Cannot pass parameter %d by reference". Also, for consistency, compile-time fatal error "Only variables can be passed by reference" was converted to exception "Cannot pass parameter %d by reference"
34 lines
638 B
PHP
34 lines
638 B
PHP
--TEST--
|
|
Bug #72038 (Function calls with values to a by-ref parameter don't always throw a notice)
|
|
--FILE--
|
|
<?php
|
|
|
|
try {
|
|
test($foo = new stdClass);
|
|
var_dump($foo);
|
|
} catch (Throwable $e) {
|
|
echo "Exception: " . $e->getMessage() . "\n";
|
|
}
|
|
try {
|
|
test($bar = 2);
|
|
var_dump($bar);
|
|
} catch (Throwable $e) {
|
|
echo "Exception: " . $e->getMessage() . "\n";
|
|
}
|
|
try {
|
|
test($baz = &$bar);
|
|
var_dump($baz);
|
|
} catch (Throwable $e) {
|
|
echo "Exception: " . $e->getMessage() . "\n";
|
|
}
|
|
|
|
function test(&$param) {
|
|
$param = 1;
|
|
}
|
|
|
|
?>
|
|
--EXPECT--
|
|
Exception: Cannot pass parameter 1 by reference
|
|
Exception: Cannot pass parameter 1 by reference
|
|
int(1)
|