Skip to content

Commit

Permalink
feat: skip readonly properties on entities when generating factories
Browse files Browse the repository at this point in the history
  • Loading branch information
KDederichs committed Jan 29, 2025
1 parent 26233a4 commit 7961d20
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/Maker/Factory/MakeFactoryData.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
use Symfony\Bundle\MakerBundle\Str;
use Symfony\Bundle\MakerBundle\Util\ClassNameDetails;
use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor;
use Symfony\Component\PropertyInfo\PropertyAccessExtractorInterface;
use Symfony\Component\PropertyInfo\PropertyInitializableExtractorInterface;
use Zenstruck\Foundry\ObjectFactory;
use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory;
use Zenstruck\Foundry\Persistence\Proxy;
Expand All @@ -32,10 +30,7 @@ final class MakeFactoryData
public const STATIC_ANALYSIS_TOOL_PHPSTAN = 'phpstan';
public const STATIC_ANALYSIS_TOOL_PSALM = 'psalm';

/**
* @var null|PropertyAccessExtractorInterface&PropertyInitializableExtractorInterface
*/
private static mixed $propertyInfo = null;
private static ReflectionExtractor|null $propertyInfo = null;

/** @var list<string> */
private array $uses;
Expand All @@ -53,6 +48,7 @@ public function __construct(
private string $staticAnalysisTool,
private bool $persisted,
bool $withPhpDoc,
/** @var string[]|true $forceProperties */
array|bool $forceProperties
) {
$this->uses = [
Expand Down Expand Up @@ -216,7 +212,7 @@ public function addEnumDefaultProperty(string $propertyName, string $enumClass):
);
}

private static function propertyInfo(): PropertyAccessExtractorInterface&PropertyInitializableExtractorInterface
private static function propertyInfo(): ReflectionExtractor
{
return self::$propertyInfo ??= new ReflectionExtractor();
}
Expand Down

0 comments on commit 7961d20

Please sign in to comment.