title: PHP 'sibling' classes? How does it work?
body: <p>I know this is done all the time, but for some reason, it's not making one bit of sense to me. [Insert @#$%! here] I don't know what the proper OOP procedure is for this (assumingly) obvious solution. I've briefly read up on Abstract and Interface type classes, with no avail to any examples that do what I'm asking.</p>
  
  <p>So here's the setup...</p>
  
  <p>In this example, I have two classes, one that I am going to call from my script, and another two that I could either call from my script or from within the first class that I called. The psuedo-code:</p>
  
  <pre><code>&lt;?php
  
      // Some code here
  
      $timer = new timer();
      $doSomethingCool = new doSomethingCool();
  
      $doSomethingCool-&gt;doIt();
      print $timer-&gt;length();
  
  
  
      class timer {
          private $startTime;
          private $stopTime;
          private $length;
  
          public function start() {
              // Start running the timer
          }
          public function end() {
              // End the timer
          }
          public function length() {
              // Return the length of the timer
              return $this-&gt;length;
          }
      }
  
      class doSomethingCool {
          public function doIt() {
  
              $timer-&gt;start();
  
              // Some code here
  
              $timer-&gt;end();
  
          }
      }
  
  ?&gt;
  </code></pre>
  
  <p>I have been able to get this to "run" (see below), but this work-around is messy, and I am 100% sure this isn't proper object oriented modeling:</p>
  
  <pre><code>&lt;?php
      // Start by declaring all classes and pass all classes to themselves...
  
      $doSomethingCool = new doSomethingCool();
      $timer = new timer();
      $class = array(
          'doSomethingCool'=&gt;$doSomethingCool,
          'timer'=&gt;$timer
      );
  
      $doSomethingCool-&gt;class = $class;
      $timer-&gt;class = $class;
  
  
      // Some code here
      $class['doSomethingCool']-&gt;doIt();
      print $timer-&gt;length();
  
  
  
      class timer {
          // In each class we now declare a public variable
          // 'class' that we had passed all class instances to...
          public $class;
  
          private $startTime;
          private $stopTime;
          private $length;
  
          public function start() {
              // Start running the timer
          }
          public function end() {
              // End the timer
          }
          public function length() {
              // Return the length of the timer
              return $this-&gt;length;
          }
      }
  
      class doSomethingCool {
          public $class;
  
          public function doIt() {
  
              $this-&gt;class['timer']-&gt;start();
  
              // Some code here
  
              $this-&gt;class['timer']-&gt;end();
  
          }
      }
  
  ?&gt;
  </code></pre>
  
  <p>Due to E_STRICT, I do not want to use <code>$timer::start();</code>.</p>
  
  <p>So what's the solution, ladies and gentlemen? Thanks!</p>