title: spl_autoload_register loads class twice
body: <p>I keep trying to know what the problem is with this very simple class loader script. 
  The class loader looks like this:</p>
  
  <pre><code>#src/vendors/Autoloading/lib/ClassLoader.php
  
  namespace App\Vendors\Autoloading;
  
  class ClassLoader
  {
      private $path; 
  
      function __construct($path)
      {
          $this-&gt;path         = $path; 
      }
  
      public function load($class)
      {
        if(file_exists(  $class = str_replace(array('\\', '_'), DIRECTORY_SEPARATOR, $this-&gt;path) . '.php')){
              require $class;
              return true;
          }
      }
  
      public function register()
      {
          return spl_autoload_register([$this, 'load']);
      }
  }
  </code></pre>
  
  <p>The initial class loader had more methods and some functions to validate the file names ... 
  but, in the process of debugging I had to narrow it to that. </p>
  
  <p>So, that class loader is being required inside an <code>autoload.php</code> file, as you can see below.</p>
  
  <pre><code>#src/vendors/autoload.php
  
  namespace App\Vendors;
  
  require 'Autoloading/lib/ClassLoader.php';
  $autoload = new Autoloading\ClassLoader('path/Foo/FooClass');
  $autoload-&gt;register(); 
  </code></pre>
  
  <p>The <code>FooClass.php</code> is located in <code>src/Foo/FooClass.php</code> </p>
  
  <pre><code>namespace App\Foo;
  class FooClass{}
  </code></pre>
  
  <p>and there is actually no problem with the autoloading part, the class gets loaded just fine, but it is done <strong>twice</strong> which shows me the below error. I am calling it from an <code>index.php</code> file</p>
  
  <pre><code>&lt;?php 
  
  use \App\Foo\FooClass;
  FooClass::somefunction(); 
  </code></pre>
  
  <p>Just using that generates this error. </p>
  
  <blockquote>
    <p>Fatal error: Cannot redeclare class path\foo\FooClass in /path/to/index.php on line 4</p>
  </blockquote>