foundry icon indicating copy to clipboard operation
foundry copied to clipboard

doc: Story State

Open seb-jean opened this issue 6 months ago • 3 comments

Hello, I have Foundry version 2.6.0. I'm using the code below, but my IDE (PhpStorm) doesn't recognize CategoryStory::php(). A small suggestion for improvement: here it's a createOne; we'd also need a createMany() to make the example in the PHPDoc.

// src/Story/CategoryStory.php
namespace App\Story;

use App\Factory\CategoryFactory;
use Zenstruck\Foundry\Persistence\Proxy;
use Zenstruck\Foundry\Story;

/**
 * @method static Category&Proxy<Category> php()
 */
final class CategoryStory extends Story
{
    public function build(): void
    {
        $this->addState('php', CategoryFactory::createOne(['name' => 'php']));
    }
}

seb-jean avatar Jun 14 '25 20:06 seb-jean

Hi @seb-jean

I don't understand what you suggest 🤔

This is exactly what is documented:

Image

nikophil avatar Jun 15 '25 10:06 nikophil

Yes, that's exactly what is documented but my IDE doesn't recognize it.

seb-jean avatar Jun 15 '25 10:06 seb-jean

hum ok I get it now, PHPStorm does not understands intersections in @method annotations

see https://youtrack.jetbrains.com/issue/WI-62217/Support-intersection-types-for-method

a user even mentions Foundry 😅

I think a workaround would be to use Proxy<Object>|Object, this is not 100% accurate, but it would unlock autocompletion...

A small suggestion for improvement: here it's a createOne; we'd also need a createMany() to make the example in the PHPDoc.

yeah, why not, feel free to propose any enhancement here. Maybe we can also explain that PHPStorm does not understand intersection and using union is an acceptable workaound...

nikophil avatar Jun 15 '25 11:06 nikophil

I'm closing this, anyway, the future of Foundry is free from Proxy object

nikophil avatar Oct 25 '25 08:10 nikophil