moserware/PHPSkills — Issue #3: Unnecessary use of references
Author: deadbeef84
Created: 2011-11-02 21:06:44+00:00
State: open

Wow, this is awesome! I was really happy to find an implementation of the TrueSkill algorithm in PHP. I realize that this was your first project with PHP, and I find the code to be of very good quality/structure in general, however it seems you have misunderstood how references together with objects work in PHP (which is easy to do because the manual doesnt say much about it).

It is true that PHP by default passes function arguments by value, however passing objects work pretty much like in Java - meaning it will by default pass a reference (to the object) by value.

Be aware that arrays counts as primitives so they are by default not passed as a reference.

Passing objects by reference (like you're doing mostly) will give you the ability to change the object that the passed variable points to.

I would really like to help, but I'm not sure I've got the time at the moment.