Skip to content

Commit

Permalink
Update src/Maker/Factory/MakeFactoryData.php
Browse files Browse the repository at this point in the history
Co-authored-by: Nicolas PHILIPPE <[email protected]>
  • Loading branch information
KDederichs and nikophil committed Jan 29, 2025
1 parent ab074c9 commit 5c082a0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Maker/Factory/MakeFactoryData.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,20 +158,20 @@ public function addDefaultProperty(string $propertyName, string $defaultValue):
public function getDefaultProperties(): array
{
$defaultProperties = $this->defaultProperties;
$clazz = $this->object->getName();
$class = $this->object->getName();

/**
* If forceProperties is not set we filter out properties that can not be set because they're either readonly or have no setter.
* Useful for properties that auto generate when the entity is created and can not be changed like a createdAt property for example.
*
* We do this here because we need to get the class of the Entity which only seems to be accessible here.
*/
$defaultProperties = array_filter($defaultProperties, function (string $propertyName) use ($clazz): bool {
$defaultProperties = array_filter($defaultProperties, function (string $propertyName) use ($class): bool {
if (true === $this->forceProperties) {
return true;
}

return self::propertyInfo()->isWritable($clazz, $propertyName) || self::propertyInfo()->isInitializable($clazz, $propertyName);
return self::propertyInfo()->isWritable($class, $propertyName) || self::propertyInfo()->isInitializable($class, $propertyName);
}, ARRAY_FILTER_USE_KEY);

\ksort($defaultProperties);
Expand Down

0 comments on commit 5c082a0

Please sign in to comment.