[doc-en] master: Removed unnecessary pass-by-reference(&) from example code (#5952)
| From: | Scott Keck-Warren via GitHub | Date: | Sun, 18 Oct 2026 08:26:31 +0000 |
| Subject: | [doc-en] master: Removed unnecessary pass-by-reference(&) from example code (#5952) | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-23845@lists.php.net to get a copy of this message | ||
Author: Scott Keck-Warren (warren5236)
Committer: GitHub (web-flow)
Pusher: jordikroon
Date: 2026-10-18T10:26:28+02:00
Commit: https://github.com/php/doc-en/commit/a2a11180e43d242a92dd299eab74b1ea68bb7de6
Raw diff: https://github.com/php/doc-en/commit/a2a11180e43d242a92dd299eab74b1ea68bb7de6.diff
Removed unnecessary pass-by-reference(&) from example code (#5952)
"language/oop5/object-comparison.xml" contained the following example code:
```php
function compareObjects(&$o1, &$o2)
{
echo 'o1 == o2 : ' . bool2str($o1 == $o2) . "\n";
echo 'o1 != o2 : ' . bool2str($o1 != $o2) . "\n";
echo 'o1 === o2 : ' . bool2str($o1 === $o2) . "\n";
echo 'o1 !== o2 : ' . bool2str($o1 !== $o2) . "\n";
}
```
Because it's comparing two object which are already passed by reference the
&
is unnecessary and potentially confusing.
Changed to:
```php
function compareObjects($o1, $o2)
```
Closes #5950
Changed paths:
M language/oop5/object-comparison.xml
Diff:
diff --git a/language/oop5/object-comparison.xml b/language/oop5/object-comparison.xml
index d3cff6988ab6..2c71d6d6366b 100644
--- a/language/oop5/object-comparison.xml
+++ b/language/oop5/object-comparison.xml
@@ -29,7 +29,7 @@ function bool2str($bool)
}
}
-function compareObjects(&$o1, &$o2)
+function compareObjects($o1, $o2)
{
echo 'o1 == o2 : ' . bool2str($o1 == $o2) . "\n";
echo 'o1 != o2 : ' . bool2str($o1 != $o2) . "\n";