src/EntityDescriptor/EntityDescriptor.php
public static function parseType($fieldName, $desc) {
		$result = array('type'=>null, 'args'=>array(), 'default'=>null, 'flags'=>array());
		$matches = null;
		if( !preg_match('#([^\(\[=]+)(?:\(([^\)]*)\))?(?:\[([^\]]*)\])?(?:=([^\[]*))?#', $desc, $matches) ) {
			throw new Exception('failToParseType');
		}
		$result['type']			= trim($matches[1]);
		$result['args']			= !empty($matches[2]) ? preg_split('#\s*,\s*#', $matches[2]) : array();
		$result['flags']		= !empty($matches[3]) ? preg_split('#\s#', $matches[3], -1, PREG_SPLIT_NO_EMPTY) : array();
		if( isset($matches[4]) ) {
			$result['default']	= $matches[4];
			if( $result['default']==='true' ) {
				$result['default'] = true;
			} else
			if( $result['default']==='false' ) {
				$result['default'] = false;
			} else {
				$len = strlen($result['default']);
				if( $len && $result['default'][$len-1]==')' ) {
					$result['default'] = static::parseType($fieldName, $result['default']);
				}
			}
		}
		return (object) $result;
	}
public static function parseType($fieldName, $desc) {
		$result = array('type'=>null, 'args'=>array(), 'default'=>null, 'flags'=>array());
		$matches = null;
		if( !preg_match('#([^\(\[=]+)(?:\(([^\)]*)\))?(?:\[([^\]]*)\])?(?:=([^\[]*))?#', $desc, $matches) ) {
			throw new Exception('failToParseType');
		}
		$result['type']			= trim($matches[1]);
		$result['args']			= !empty($matches[2]) ? preg_split('#\s*,\s*#', $matches[2]) : array();
		$result['flags']		= !empty($matches[3]) ? preg_split('#\s#', $matches[3], -1, PREG_SPLIT_NO_EMPTY) : array();
		if( isset($matches[4]) ) {
			$result['default']	= $matches[4];
			if( $result['default']==='true' ) {
				$result['default'] = true;
			} else
			if( $result['default']==='false' ) {
				$result['default'] = false;
			} else {
				$len = strlen($result['default']);
				if( $len && $result['default'][$len-1]==')' ) {
					$result['default'] = static::parseType($fieldName, $result['default']);
				}
			}
		}
		return (object) $result;
	}
public static function parseType ( $ fieldName , $ desc ) { $ result = array ( 'type' => null , 'args' => array ( ) , 'default' => null , 'flags' => array ( ) ) ; $ matches = null ; if ( ! preg_match ( '#([^\(\[=]+)(?:\(([^\)]*)\))?(?:\[([^\]]*)\])?(?:=([^\[]*))?#' , $ desc , $ matches ) ) { throw new Exception ( 'failToParseType' ) ; } $ result [ 'type' ] = trim ( $ matches [ 1 ] ) ; $ result [ 'args' ] = ! empty ( $ matches [ 2 ] ) ? preg_split ( '#\s*,\s*#' , $ matches [ 2 ] ) : array ( ) ; $ result [ 'flags' ] = ! empty ( $ matches [ 3 ] ) ? preg_split ( '#\s#' , $ matches [ 3 ] , - 1 , PREG_SPLIT_NO_EMPTY ) : array ( ) ; if ( isset ( $ matches [ 4 ] ) ) { $ result [ 'default' ] = $ matches [ 4 ] ; if ( $ result [ 'default' ] === 'true' ) { $ result [ 'default' ] = true ; } else if ( $ result [ 'default' ] === 'false' ) { $ result [ 'default' ] = false ; } else { $ len = strlen ( $ result [ 'default' ] ) ; if ( $ len && $ result [ 'default' ] [ $ len - 1 ] == ')' ) { $ result [ 'default' ] = static :: parseType ( $ fieldName , $ result [ 'default' ] ) ; } } } return ( object ) $ result ; }
parse type from configuration string

@param string $fieldName
@param string $desc
@throws Exception
@return StdClass
parse type from configuration string