mattiabasone commented on code in PR #3624:
URL: https://github.com/apache/avro/pull/3624#discussion_r2689636451


##########
lang/php/lib/Schema/AvroRecordSchema.php:
##########
@@ -62,62 +62,30 @@ public function __construct(
      * @throws AvroSchemaParseException
      */
     public static function parseFields(
-        array $field_data,
+        array $fieldsDefinitions,
         ?string $default_namespace,
-        ?AvroNamedSchemata $schemata = null
+        AvroNamedSchemata $schemata
     ): array {
         $fields = [];
-        $field_names = [];
-        $alias_names = [];
-        foreach ($field_data as $field) {
-            $name = $field[AvroField::FIELD_NAME_ATTR] ?? null;
-            $type = $field[AvroSchema::TYPE_ATTR] ?? null;
-            $order = $field[AvroField::ORDER_ATTR] ?? null;
-            $aliases = $field[AvroSchema::ALIASES_ATTR] ?? null;
-
-            $default = null;
-            $has_default = false;
-            if (array_key_exists(AvroField::DEFAULT_ATTR, $field)) {
-                $default = $field[AvroField::DEFAULT_ATTR];
-                $has_default = true;
-            }
+        $fieldNames = [];
+        $aliasNames = [];
+        foreach ($fieldsDefinitions as $fieldsDefinition) {
+            $name = $fieldsDefinition[AvroField::FIELD_NAME_ATTR] ?? null;
 
-            if (in_array($name, $field_names)) {
+            if (in_array($name, $fieldNames)) {
                 throw new AvroSchemaParseException(
                     sprintf("Field name %s is already in use", $name)
                 );
             }
 
-            $is_schema_from_schemata = false;
-            $field_schema = null;
-            if (
-                is_string($type)
-                && $field_schema = $schemata->schemaByName(
-                    new AvroName($type, null, $default_namespace)
-                )
-            ) {
-                $is_schema_from_schemata = true;
-            } elseif (is_string($type) && self::isPrimitiveType($type)) {
-                $field_schema = self::subparse($field, $default_namespace, 
$schemata);
-            } else {
-                $field_schema = self::subparse($type, $default_namespace, 
$schemata);
-            }
+            $new_field = AvroField::fromFieldDefinition($fieldsDefinition, 
$default_namespace, $schemata);

Review Comment:
   My bad, nice catch



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to