<?php

// Some supporting classes and functions

class Person {
	protected $name = "";

	public function __construct($name) {
		$this->name = $name;
	}

	public function getName() {
		return $this->name;
	}
}

function showPerson(Person $person) {
	echo($person->getName() . "\n");
}

class PersonViewer {
	public function viewPerson(Person $person) {
		showPerson($person);
	}
}

class Persons {
	public $johnDoe = new Person("John Doe");
}

class TestGetSet {
	protected $values = array();

	public function __set($key, $value) {
		$this->values[$key] = $value;
	}
	
	public function __get($key) {
		return $this->values[$key];
	}	
	
}

// Set up some objects
$test = new TestGetSet();
$test->johnDoe = new Person("John Doe");

$persons = new Persons();

// Now call the test functions to expose the bug
showPerson(new Person("John Doe")); 
showPerson($persons->johnDoe);      
showPerson($test->johnDoe);         

$personViewer = new PersonViewer();                
$personViewer->viewPerson(new Person("John Doe")); 
$personViewer->viewPerson($persons->johnDoe);
$personViewer->viewPerson($test->johnDoe); // This fails because null is passed to viewPerson(), however, $test->johnDoe is not null

?>