title: Function returning reference to object property
body: <p>I've got an event object that looks like this:</p>
  
  <pre><code>class InputEvent
  {
      protected $input;
  
      public function __construct(&amp;$input)
      {
          $this-&gt;input = &amp;$input;
      }
  
      public function getInput()
      {
           return $this-&gt;input;
      }
  }
  </code></pre>
  
  <p>Now, since <code>$input</code> is a string, I have to pass it in by reference. However, when I create an event listener, input value doesn't get changed since <code>getInput</code> function returns <code>$input</code> value rather than reference to <code>$input</code> property.</p>
  
  <pre><code>class Listener
  {
      public function myEvent(InputEvent $event)
      {
           $input = $event-&gt;getInput();
  
           // doesn't change InputEvent::input property
           $input = "asd";
      }
  }
  </code></pre>
  
  <p>Is there a way for me to return reference to <code>$input</code> value, so that it gets changed inside event object?</p>
  
  <p>I can make two workarounds, but both are.....well, workarounds, not really pretty.</p>
  
  <ol>
  <li><p>Wrap <code>$input</code> into a class, for example creating a <code>String</code> class which would only hold value and getter, setter methods.</p></li>
  <li><p>Add <code>setInput</code> method to <code>InputEvent</code>, but still isn't as elegant as just assigning it to a value like in <code>Listener</code> example above.</p></li>
  </ol>