<commit_before><?php
namespace Kassko\DataMapperTest\ClassMetadataLoader\Fixture\Metadata;

use Kassko\DataMapper\Annotation as DM;

class Field
{
    /**
     * @DM\Field(
     *      name="FirstField",
     *      type="string",
     *      class="stdClass",
     *      readConverter="readConvertFirstField",
     *      writeConverter="writeConvertFirstField",
     *      fieldMappingExtensionClass="ExtensionClass"
     * )
     */
    protected $fieldOne;

    /**
     * @DM\Field(
     *      name="SecondField",
     *      type="integer",
     *      class="\DateTime",
     *      readDateConverter="readDateConvertSecondField",
     *      writeDateConverter="writeDateConvertSecondField",
     *      fieldMappingExtensionClass="ExtensionClass",
     *      defaultValue="12"
     * )
     */
    protected $fieldTwo;

    /**
     * @DM\Field(
     *      name="DateField",
     *      type="date"
     * )
     */
    protected $dateField;

    /**
     * @return array
     */
    public static function loadInnerPhpMetadata()
    {
        return [
            'fields' => [
                'fieldOne'  => [
                    'name'                       => 'FirstField',
                    'type'                       => 'string',
                    'class'                      => 'stdClass',
                    'readConverter'              => 'readConvertFirstField',
                    'writeConverter'             => 'writeConvertFirstField',
                    'readDateConverter'          => null,
                    'writeDateConverter'         => null,
                    'fieldMappingExtensionClass' => 'ExtensionClass',
                    //'defaultValue'               => null
                ],
                'fieldTwo'  => [
                    'name'                       => 'SecondField',
                    'type'                       => 'integer',
                    'class'                      => '\DateTime',
                    'readConverter'              => null,
                    'writeConverter'             => null,
                    'readDateConverter'          => 'readDateConvertSecondField',
                    'writeDateConverter'         => 'writeDateConvertSecondField',
                    'fieldMappingExtensionClass' => 'ExtensionClass',
                    'defaultValue'               => 12
                ],
                'dateField' => [
                    'name'                       => 'DateField',
                    'type'                       => 'date',
                    'class'                      => null,
                    //'readConverter'              => null, //(1)
                    //'writeConverter'             => null, //(1)
                    'readDateConverter'          => null,
                    'writeDateConverter'         => null,
                    'fieldMappingExtensionClass' => null,
                    'defaultValue'               => null
                ]
            ]
        ];
    }

    /**
     * @return string
     */
    public static function loadInnerYamlMetadata()
    {
        return <<<EOF
fields:
  fieldOne:
    name: FirstField
    type: string
    class: stdClass
    readConverter: readConvertFirstField
    writeConverter: writeConvertFirstField
    readDateConverter: null
    writeDateConverter: null
    fieldMappingExtensionClass: ExtensionClass
  fieldTwo:
    name: SecondField
    type: integer
    class: "\\\DateTime"
    readConverter: null
    writeConverter: null
    readDateConverter: readDateConvertSecondField
    writeDateConverter: writeDateConvertSecondField
    fieldMappingExtensionClass: ExtensionClass
    defaultValue: 12
  dateField:
    name: DateField
    type: date
    class: null
    # readConverter: null # (1)
    # writeConverter: null # (1)
    readDateConverter: ~ # Identical to null
    writeDateConverter: ~ 
    fieldMappingExtensionClass: null
EOF;
    }
}

/**
 * (1) The normalization process will add missing entries (readConverter, writeConverter) and set them to null.
 */<commit_msg>[unit tests] [loaders] Improve the test of normalization of default entries values<commit_after><?php
namespace Kassko\DataMapperTest\ClassMetadataLoader\Fixture\Metadata;

use Kassko\DataMapper\Annotation as DM;

class Field
{
    /**
     * @DM\Field(
     *      name="FirstField",
     *      type="string",
     *      class="stdClass",
     *      readConverter="readConvertFirstField",
     *      writeConverter="writeConvertFirstField",
     *      fieldMappingExtensionClass="ExtensionClass"
     * )
     */
    protected $fieldOne;

    /**
     * @DM\Field(
     *      name="SecondField",
     *      type="integer",
     *      class="\DateTime",
     *      readDateConverter="readDateConvertSecondField",
     *      writeDateConverter="writeDateConvertSecondField",
     *      fieldMappingExtensionClass="ExtensionClass",
     *      defaultValue="12"
     * )
     */
    protected $fieldTwo;

    /**
     * @DM\Field(
     *      name="DateField",
     *      type="date"
     * )
     */
    protected $dateField;

    /**
     * @return array
     */
    public static function loadInnerPhpMetadata()
    {
        return [
            'fields' => [
                'fieldOne'  => [
                    'name'                       => 'FirstField',
                    'type'                       => 'string',
                    'class'                      => 'stdClass',
                    'readConverter'              => 'readConvertFirstField',
                    'writeConverter'             => 'writeConvertFirstField',
                    'fieldMappingExtensionClass' => 'ExtensionClass',
                ],
                'fieldTwo'  => [
                    'name'                       => 'SecondField',
                    'type'                       => 'integer',
                    'class'                      => '\DateTime',
                    'readDateConverter'          => 'readDateConvertSecondField',
                    'writeDateConverter'         => 'writeDateConvertSecondField',
                    'fieldMappingExtensionClass' => 'ExtensionClass',
                    'defaultValue'               => 12
                ],
                'dateField' => [
                    'name'                       => 'DateField',
                    'type'                       => 'date',
                    'readDateConverter'          => null, //We can omit this key instead of specify it with the value null.
                ]
            ]
        ];
    }

    /**
     * @return string
     */
    public static function loadInnerYamlMetadata()
    {
        return <<<EOF
fields:
  fieldOne:
    name: FirstField
    type: string
    class: stdClass
    readConverter: readConvertFirstField
    writeConverter: writeConvertFirstField
    fieldMappingExtensionClass: ExtensionClass
  fieldTwo:
    name: SecondField
    type: integer
    class: "\\\DateTime"
    readDateConverter: readDateConvertSecondField
    writeDateConverter: writeDateConvertSecondField
    fieldMappingExtensionClass: ExtensionClass
    defaultValue: 12
  dateField:
    name: DateField
    type: date
    readDateConverter: null # We can omit this key instead of specify it with the value null.
    writeDateConverter: ~ # Identical to null. We can omit this key too.
EOF;
    }
}

/**
 * (1) Allows to test the normalization process. 
 * It will add the missing entries (readConverter, writeConverter) and set them to null.
 */
{'fraction_non_alphanumeric': 0.10038456438138178, 'fraction_numerical': 0.002386951332714494, 'mean_word_length': 1.4266409266409266, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 54, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3013939', 'n_tokens_mistral': 1880, 'n_tokens_neox': 1780, 'n_words': 369}