I'm writing some PHP code in which one object (a "Container") keeps a pointer to another object (the "Contents"). The problem is that the contents needs to access methods or properties of the container.

Here's a simplified example of what I want to do:

```
class Container {
    function __construct($type, $contents) {
        $this->type = $type;
        $this->contents = $contents;
    }

    function display() {
        return $this->contents->display();
    }
}

class Contents {
    function __construct($stuff) {
        $this->stuff = $stuff;
    }

    function display() {
        return 'I am ' . $this->stuff . ' in '; // how to access Container here?
    }
}

$item = new Container('a can', new Contents('Prince Albert'));
echo $item->display() . "\n";
// Displays: I am Prince Albert in 
// Wanted: I am Prince Albert in a can

```

What's the **right** way to do this?

I've tried a couple of methods that work, but they feel wrong. For example:

* Re-defined `Contents::display()` to take a parameter, which doesn't seem elegant:

```
function display($container) {
    return 'I am ' . $this->stuff . ' in ' . $container->type;
}

```
* In `Contents::display()`, I called `debug_backtrace(true)` to find out what called it, then access the object from the backtrace info. That feels kludgy/dangerous.

Is there a common solution for this kind of problem?