remove dead code and fix linting errors

master
Josha von Gizycki 3 weeks ago
parent c439307d81
commit a58db4b5d7

@ -85,7 +85,7 @@ readonly class EntityAnalyzer
$idFields = array_filter($fields, static fn(EntityField $f) => $f->isIdField); $idFields = array_filter($fields, static fn(EntityField $f) => $f->isIdField);
$nrIdFields = count($idFields); $nrIdFields = count($idFields);
if ($nrIdFields !== 1) { if ($nrIdFields === 0 || $nrIdFields > 1) {
throw new InvalidEntity( throw new InvalidEntity(
"Invalid number of id fields on entity $this->entity found: $nrIdFields, expected: 1" "Invalid number of id fields on entity $this->entity found: $nrIdFields, expected: 1"
); );
@ -109,6 +109,7 @@ readonly class EntityAnalyzer
$name = $param->getName(); $name = $param->getName();
} }
/** @var ReflectionClass<E> $refClass */
$refClass = $param->getDeclaringClass(); $refClass = $param->getDeclaringClass();
$readAccess = $this->readAccess($refClass, $param); $readAccess = $this->readAccess($refClass, $param);

@ -36,38 +36,4 @@ readonly class DataToEntityMapper
/** @var E */ /** @var E */
return new $this->entityResult->classFqcn(...$params); return new $this->entityResult->classFqcn(...$params);
} }
/**
* @param E $entity
* @param EntityField<object> $field
* @param object $value
*/
private function getsetWrite(object $entity, EntityField $field, mixed $value): void
{
$setter = FieldAccess::setterName($field->name);
$entity->$setter($value);
}
/**
* @param E $entity
* @param EntityField<object> $field
* @param object $value
*/
private function publicWrite(object $entity, EntityField $field, mixed $value): void
{
$entity->{$field->name} = $value;
}
/**
* @param E $entity
* @param EntityField<object> $field
* @param object $value
* @return E
*/
private function witherWrite(object $entity, EntityField $field, mixed $value): object
{
$wither = FieldAccess::witherName($field->name);
/** @var E */
return $entity->$wither($value);
}
} }

Loading…
Cancel
Save