1
0
mirror of https://github.com/php/php-src.git synced 2026-04-12 10:33:11 +02:00
Files
archived-php-src/tests/lang/passByReference_006.phpt
Josh Soref 462da6e09c Fix spelling and grammar mistakes
This PR corrects misspellings identified by the check-spelling action.

The misspellings have been reported at jsoref@b6ba3e2#commitcomment-48946465

The action reports that the changes in this PR would make it happy: jsoref@602417c

Closes GH-6822.
2021-04-13 12:09:37 +02:00

105 lines
1.9 KiB
PHP

--TEST--
Pass uninitialized objects and arrays by reference to test implicit initialisation.
--FILE--
<?php
function refs(&$ref1, &$ref2) {
$ref1 = "Ref1 changed";
$ref2 = "Ref2 changed";
}
class C {
function __construct(&$ref1, &$ref2) {
$ref1 = "Ref1 changed";
$ref2 = "Ref2 changed";
}
function refs(&$ref1, &$ref2) {
$ref1 = "Ref1 changed";
$ref2 = "Ref2 changed";
}
static function static_refs(&$ref1, &$ref2) {
$ref1 = "Ref1 changed";
$ref2 = "Ref2 changed";
}
}
echo "\n ---- Pass uninitialized array & object by ref: function call ---\n";
unset($u1, $u2);
refs($u1[0], $u2[0][1]);
var_dump($u1, $u2);
echo "\n ---- Pass uninitialized arrays & objects by ref: static method call ---\n";
unset($u1, $u2);
C::static_refs($u1[0], $u2[0][1]);
var_dump($u1, $u2);
echo "\n\n---- Pass uninitialized arrays & objects by ref: constructor ---\n";
unset($u1, $u2);
$c = new C($u1[0], $u2[0][1]);
var_dump($u1, $u2);
echo "\n ---- Pass uninitialized arrays & objects by ref: instance method call ---\n";
unset($u1, $u2);
$c->refs($u1[0], $u2[0][1]);
var_dump($u1, $u2);
?>
--EXPECT--
---- Pass uninitialized array & object by ref: function call ---
array(1) {
[0]=>
string(12) "Ref1 changed"
}
array(1) {
[0]=>
array(1) {
[1]=>
string(12) "Ref2 changed"
}
}
---- Pass uninitialized arrays & objects by ref: static method call ---
array(1) {
[0]=>
string(12) "Ref1 changed"
}
array(1) {
[0]=>
array(1) {
[1]=>
string(12) "Ref2 changed"
}
}
---- Pass uninitialized arrays & objects by ref: constructor ---
array(1) {
[0]=>
string(12) "Ref1 changed"
}
array(1) {
[0]=>
array(1) {
[1]=>
string(12) "Ref2 changed"
}
}
---- Pass uninitialized arrays & objects by ref: instance method call ---
array(1) {
[0]=>
string(12) "Ref1 changed"
}
array(1) {
[0]=>
array(1) {
[1]=>
string(12) "Ref2 changed"
}
}