reflectClass()->getAttribute(Table::class); foreach ($reflector->reflectProperties() as $property) { $entityField = $property->getAttribute(EntityField::class); $field = $property->getAttribute(Field::class); if ($field) { $arrayOf = $property->getAttribute(ArrayOf::class); $types = $property->getTypes(); if ($property->value ?? false) { $default = $property->value instanceof \BackedEnum ? $property->value->value : $property->value; } else { $default = $field->object->attributes['default'] ?? null; } $fields[] = [ 'name' => $property->name, 'description' => $entityField->object->description ?? "", 'fieldName' => $field->object->name ?: $property->name, 'tag' => $field->tag, 'type' => $field->object->type ?? implode(' | ', array_map(fn($e) => $e->type, $types)), 'allowNulls' => $property->allowsNull(), 'length' => $field->object->length ?? null, 'readonly' => $field->object->readonly, 'default' => $default, 'arrayOf' => $arrayOf ?? null, ]; } } $searchFields = []; $searchRequestReflector = new ObjectReflection($entityName::searchRequest()::class); $searchRequestParameter = $searchRequestReflector->reflectClass()->getAttribute(SearchRequestParameter::class); foreach($searchRequestReflector->reflectProperties() as $property) { $field = $property->getAttribute(SearchParameter::class); if ($field) { $possibleValues = null; $types = $property->getTypes(); foreach($types as $type) { if (! $type->builtIn && enum_exists($type->type)) { $possibleValues = implode(', ', array_map(fn($e) => $e->value, $type->type::cases())); } } $searchFields[] = [ 'name' => $property->name, 'description' => $field->object->description, 'parameter' => $field->object->parameter ? implode(', ', $field->object->getParameters()) : $property->name, 'tag' => $field->tag, 'type' => implode(' | ', array_map(fn($e) => $e->type, $types)), 'allowNulls' => $property->allowsNull(), 'possibleValues' => $possibleValues, 'default' => $this->displayValue($property->value ?? "") ]; } } $list[$entity] = [ 'className' => $reflector->reflectClass()->getClassName(), 'description' => $table->object->description ?? null, 'fields' => $fields, 'searchRequestDescription' => $searchRequestParameter->object->description ?? "", 'searchRequestFields' => $searchFields, ]; } return $list; } }