title: How does a Laravel factory gets the $factory variable defined?
body: <p>A new factory in laravel looks like this;</p>
  
  <pre><code>&lt;?php
  
  /* @var $factory \Illuminate\Database\Eloquent\Factory */
  
  use App\Model;
  use Faker\Generator as Faker;
  
  $factory-&gt;define(Model::class, function (Faker $faker) {
      return [
          //
      ];
  });
  </code></pre>
  
  <p>The variabele <code>$factory</code> does'nt get defined in this file. How and where does this variabele get defined? A <code>dd($factory)</code> results as expected in an <code>\Illuminate\Database\Eloquent\Factory</code> object</p>