src/EntityDescriptor/FieldDescriptor.php
public static function parseType($fieldName, $desc) {
		if( is_array($desc) ) {
			$typeDesc = $desc['type'];
		} else {
			$typeDesc = $desc;
			$desc = array();
		}
		$parse					= EntityDescriptor::parseType($fieldName, $typeDesc);
		
		/* Field : String name, TypeDescriptor type, Array args, default, writable, nullable */
		$field					= new static($fieldName, $parse->type);
		$TYPE					= $field->getType();
		$field->args			= $TYPE->parseArgs($parse->args);
		$field->default			= $parse->default;
		
		// Type's default
		$field->writable		= $TYPE->isWritable();
		$field->nullable		= $TYPE->isNullable();
		
		// Default if no type's default
		if( !isset($field->writable) ) {
			$field->writable = true;
		}
		if( !isset($field->nullable) ) {
			$field->nullable = false;
		}
		
		// Field flags
		if( isset($desc['writable']) ) {
			$field->writable = !empty($desc['writable']);
		} else if( $field->writable ) {
			$field->writable = !in_array('readonly', $parse->flags);
		} else {
			$field->writable = in_array('writable', $parse->flags);
		}
		if( isset($desc['nullable']) ) {
			$field->nullable = !empty($desc['nullable']);
		} else if( $field->nullable ) {
			$field->nullable = !in_array('notnull', $parse->flags);
		} else {
			$field->nullable = in_array('nullable', $parse->flags);
		}
		return $field;
	}
public static function parseType($fieldName, $desc) {
		if( is_array($desc) ) {
			$typeDesc = $desc['type'];
		} else {
			$typeDesc = $desc;
			$desc = array();
		}
		$parse					= EntityDescriptor::parseType($fieldName, $typeDesc);
		
		/* Field : String name, TypeDescriptor type, Array args, default, writable, nullable */
		$field					= new static($fieldName, $parse->type);
		$TYPE					= $field->getType();
		$field->args			= $TYPE->parseArgs($parse->args);
		$field->default			= $parse->default;
		
		// Type's default
		$field->writable		= $TYPE->isWritable();
		$field->nullable		= $TYPE->isNullable();
		
		// Default if no type's default
		if( !isset($field->writable) ) {
			$field->writable = true;
		}
		if( !isset($field->nullable) ) {
			$field->nullable = false;
		}
		
		// Field flags
		if( isset($desc['writable']) ) {
			$field->writable = !empty($desc['writable']);
		} else if( $field->writable ) {
			$field->writable = !in_array('readonly', $parse->flags);
		} else {
			$field->writable = in_array('writable', $parse->flags);
		}
		if( isset($desc['nullable']) ) {
			$field->nullable = !empty($desc['nullable']);
		} else if( $field->nullable ) {
			$field->nullable = !in_array('notnull', $parse->flags);
		} else {
			$field->nullable = in_array('nullable', $parse->flags);
		}
		return $field;
	}
public static function parseType ( $ fieldName , $ desc ) { if ( is_array ( $ desc ) ) { $ typeDesc = $ desc [ 'type' ] ; } else { $ typeDesc = $ desc ; $ desc = array ( ) ; } $ parse = EntityDescriptor :: parseType ( $ fieldName , $ typeDesc ) ; /* Field : String name, TypeDescriptor type, Array args, default, writable, nullable */ $ field = new static ( $ fieldName , $ parse -> type ) ; $ TYPE = $ field -> getType ( ) ; $ field -> args = $ TYPE -> parseArgs ( $ parse -> args ) ; $ field -> default = $ parse -> default ; // Type's default $ field -> writable = $ TYPE -> isWritable ( ) ; $ field -> nullable = $ TYPE -> isNullable ( ) ; // Default if no type's default if ( ! isset ( $ field -> writable ) ) { $ field -> writable = true ; } if ( ! isset ( $ field -> nullable ) ) { $ field -> nullable = false ; } // Field flags if ( isset ( $ desc [ 'writable' ] ) ) { $ field -> writable = ! empty ( $ desc [ 'writable' ] ) ; } else if ( $ field -> writable ) { $ field -> writable = ! in_array ( 'readonly' , $ parse -> flags ) ; } else { $ field -> writable = in_array ( 'writable' , $ parse -> flags ) ; } if ( isset ( $ desc [ 'nullable' ] ) ) { $ field -> nullable = ! empty ( $ desc [ 'nullable' ] ) ; } else if ( $ field -> nullable ) { $ field -> nullable = ! in_array ( 'notnull' , $ parse -> flags ) ; } else { $ field -> nullable = in_array ( 'nullable' , $ parse -> flags ) ; } return $ field ; }
Parse field type configuration from file string

@param string $fieldName
@param string|string[] $desc
@return	FieldDescriptor The parsed field descriptor
Parse field type configuration from file string