title: PHP ReflectionClass - Fatal error: Class name must be a valid object or a string
body: <p>I cannot seem to get around this error when I'm trying to create an Object using Reflection and get this error every time.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>public static function getMapper($klass) {
      echo $klass;
      if(class_exists($klass)) {
          echo "YES!";
      } else {
          echo "NO!";
      }
  
      $mapperClass = new \ReflectionClass($klass);
      print_r($mapperClass);
      return new $mapperClass-&gt;newInstance();
  }
  </code></pre>
  
  <p>The first echo prints "\domain\Member". This is correct as it is what I passed in and it's the class I'm trying to create an Object of.</p>
  
  <p>Next, the echo prints "YES". The class exists!</p>
  
  <p>Next, I pass $klass into ReflectionClass and...</p>
  
  <p>The next print_r prints: </p>
  
  <pre><code>ReflectionClass Object ( [name] =&gt; domain\Member )
  </code></pre>
  
  <p>Notice the \ before domain is gone. Could be part of the problem?</p>
  
  <p>Then, when I call newInstance() I get the error. </p>
  
  <p>Fatal error: Class name must be a valid object or a string in C:\Users\Zack\PhpstormProjects\MyApp\base\Registry.php on line 53</p>
  
  <p>So I don't know what the problem is. The Member class exists in the domain namespace. Just in case maybe something in Member is wrong, here it is; not much yet:</p>
  
  <pre><code>&lt;?php
  
  namespace domain;
  
  use base\Registry;
  use domain\base\BaseMember;
  
  class Member extends BaseMember {
  
  /**
   * @param $displayName
   * @return Member
   */
  public static function findMemberByDisplayName($displayName) {
      return Registry::memberRepository()-&gt;findMemberByDisplayName($displayName);
  }
  </code></pre>