Inexact Code Example with Comparing Objects

Open Beginner friendly
#2,253 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
72/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Stale
Tech stack
php
Domain
documentation

Research direction

Open the object-comparison manual page linked in the issue and review the compareObjects example and its explanatory text. Update the example and wording to match the issue's requested clarification, then verify that the page accurately describes comparing object instances.

Written by the indexing model from the issue text.

Description

Category: Engine QA

From manual page: https://php.net/language.oop5.object-comparison

The code example on the mentioned page seems problematic.

function compareObjects(&$o1, &$o2) {...}

I am not sure what the original intention was to pass the variables by reference, but this is unnecessary, as the variables would point to the same object instances anyway, no matter if the variables themselves are references or not. The creation of references could lead to some confusion (it did for me), as to why this is done like this.

It might also be a consideration to avoid speaking of the two variables as references, as they are no aliases, just point to the same object instance:

echo "\nTwo references to the same instance\n";
Dominant language
XML
Stars
596
Forks
890
Avg merge
1d 15h
Merged PRs (30d)
55

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from php/doc-en

All issues in php/doc-en

Similar issues

More Documentation issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.