doc: Story State
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']));
}
}
Hi @seb-jean
I don't understand what you suggest 🤔
This is exactly what is documented:
Yes, that's exactly what is documented but my IDE doesn't recognize it.
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...
I'm closing this, anyway, the future of Foundry is free from Proxy object