Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

exSnake's avatar

PHPStorm autocomplete for custom faker provider class

I'm trying to create my custom Faker Provider,

<?php

namespace Faker\Provider;

class FakerSlot extends Base
{
    public static function aams_id()
    {
        return static::regexify('[J-O]N0[1-9]{7}[A-Z]{1}');
    }
}

i put the php file in the database\providers directory, i would like to enable autocompletion with PHPStorm when i add the provider to the Faker\Generator

$factory->define(App\Slot::class, function (Faker\Generator $faker)
{
    $faker->addProvider(new FakerSlot($faker));

    $faker->slot //autocompletion should pop-up now
}

How i can do that? Why the Faker\Generator class have it's own autocompletion and mine is only recognized if i declare a new class like that

$fakerSlot = new Faker\Provider\FakerSlot;
$fakerSlot->slot //now the autocompletion pop-up

? I'm using the barryvdh ide-helper.

0 likes
0 replies

Please or to participate in this conversation.