title: Arguement passed to constructor must be an instance of interface, instance of decorator given
body: <p>I am having an issue trying to debug my code, as far as I can see looking at the various bits of code, it all links up correctly, but there must be something obvious I am missing here.</p>
  
  <p>I am sorry about the amount of code I've pasted in to the question here, but unfortunately there are a lot of files in play for a single entity of the application, and I thought it better to provide more rather than less.</p>
  
  <p>First of all the error message:</p>
  
  <pre><code>Argument 1 passed to Raid\Composers\PreferenceDataComposer::__construct() must be an instance of Raid\Repo\User\PreferenceInterface, instance of Raid\Repo\Preference\CacheDecorator given, called in C:\wamp\www\raid\app\Raid\Composers\ComposerServiceProvider.php on line 34 and defined
  </code></pre>
  
  <p>So first of all, my view composer which is where this error is being generated:</p>
  
  <pre><code>&lt;?php namespace Raid\Composers;
  
  use Raid\Repo\User\PreferenceInterface;
  
  class PreferenceDataComposer {
  
      protected $preference;
  
      public function __construct(PreferenceInterface $preference)
      {
          $this-&gt;preference = $preference;
      }
  
      public function compose($view)
      {       
          $view-&gt;with('preferences', $this-&gt;preference-&gt;getActive());
      }
  
  }
  </code></pre>
  
  <p>and then the service provider for the composer:</p>
  
  <pre><code>&lt;?php namespace Raid\Composers;
  
  use Illuminate\Support\ServiceProvider;
  
  class ComposerServiceProvider extends ServiceProvider {
  
      public function register()
      {
          $this-&gt;app-&gt;bind('Raid\Composers\PreferenceDataComposer', function($app)
          {
              return new PreferenceDataComposer(
                  $this-&gt;app-&gt;make('Raid\Repo\Preference\PreferenceInterface')
              );
          });
      }
  
      public function boot()
      {
          $this-&gt;app-&gt;view-&gt;composer('account.preferences', 'Raid\Composers\PreferenceDataComposer');
      }
  
  }
  </code></pre>
  
  <p>Next up is the interface:</p>
  
  <pre><code>&lt;?php namespace Raid\Repo\Preference;
  
  interface PreferenceInterface {
  
      public function getActive();
  
  }
  </code></pre>
  
  <p>And the CacheDecorator:</p>
  
  <pre><code>&lt;?php namespace Raid\Repo\Preference;
  
  use Raid\Service\Cache\CacheInterface;
  
  class CacheDecorator extends AbstractPreferenceDecorator implements PreferenceInterface {
  
      protected $cache;
  
      public function __construct(PreferenceInterface $preference, CacheInterface $cache)
      {
          parent::__construct($preference);
          $this-&gt;cache = $cache;
      }
  
      public function getActive()
      {
          $key = md5('active');
  
          if ($this-&gt;cache-&gt;has($key)) {
              return $this-&gt;cache-&gt;get($key);
          }
  
          $preferences = $this-&gt;preference-&gt;getActive();
  
          $this-&gt;cache-&gt;put($key, $preferences);
  
          return $preferences;
      }
  }
  </code></pre>
  
  <p>and the abstract decorator:</p>
  
  <pre><code>&lt;?php namespace Raid\Repo\Preference;
  
  abstract class AbstractPreferenceDecorator implements PreferenceInterface {
  
      protected $preference;
  
      public function __construct(PreferenceInterface $preference)
      {
          $this-&gt;preference = $preference;
      }
  
  }
  </code></pre>
  
  <p>then we have the repository:</p>
  
  <pre><code>&lt;?php namespace Raid\Repo\Preference;
  
  use Raid\Repo\AbstractRepo;
  use Illuminate\Database\Eloquent\Model;
  use Raid\Service\Log\LogInterface;
  use Raid\Service\Email\EmailInterface;
  
  class EloquentPreference extends AbstractRepo implements PreferenceInterface {
  
      protected $preference;
      protected $preferenceType;
      protected $log;
      protected $email;
  
      public function __construct(Model $preference, Model $preferenceType, LogInterface $log, EmailInterface $email)
      {
          $this-&gt;preference = $preference;
          $this-&gt;preferenceType = $preferenceType;
          $this-&gt;log = $log;
          $this-&gt;email = $email;
      }
  
      public function getActive()
      {
          return $this-&gt;preference-&gt;whereActive()-&gt;get();
      }
  
  }
  </code></pre>
  
  <p>and then the eloquent Model itself:</p>
  
  <pre><code>&lt;?php
  
  class Preference extends Eloquent {
  
      protected $table = 'preferences';
      protected $guarded = array('id');
      protected $softDelete = true;
  
      public function scopeWhereActive($query)
      {
          return $query-&gt;where('active', '=', '1');
      }
  
  }
  </code></pre>
  
  <p>and then the service provider that binds the interface and the repo:</p>
  
  <pre><code>&lt;?php namespace Raid\Repo;
  
  use Preference;
  use PreferenceType;
  use Raid\Service\Cache\FileCache;
  use Raid\Repo\Preference\CacheDecorator as PreferenceCacheDecorator;
  use Raid\Repo\Preference\EloquentPreference;
  use Illuminate\Support\ServiceProvider;
  
  class RepoServiceProvider extends ServiceProvider {
  
      public function register()
      {
          $app = $this-&gt;app;
  
          $app-&gt;bind('Raid\Repo\Preference\PreferenceInterface', function($app)
          {
              $preference = new EloquentPreference(
                  new Preference, 
                  new PreferenceType,
                  $app-&gt;make('Raid\Service\Log\LogInterface'),
                  $app-&gt;make('Raid\Service\Email\EmailInterface')
              );
  
              return new PreferenceCacheDecorator(
                  $preference, 
                  new FileCache($app['cache'], 'preferences', 1440)
              );
          });
      }
  
  }
  </code></pre>
  
  <p>In the code above, you can see in the Composer, that I ask for an instance of the Interface, and in the composer's service provider, I resolve an instance of it out of the IoC. </p>
  
  <p>In the repo service provider I bind the interface by making a instance of the repo (passing in its dependencies), and then return the repo wrapped with a cache decorator. All of the repo, the decorator, the abstract decorator implement the interface, so I'm not sure how it is being resolved as not being an instance of the interface?</p>
  
  <p>Any help you are able to give with debugging would be me wonderful.</p>
  
  <p>If you need further code, please shout.</p>