This is very bad, reassigning the same variable to contain different object type!

The variable could be named instead something like $referenceAsString