php/WP_CLI/SynopsisParser.php
private static function classify_token( $token ) {
		$param = array();

		list( $param['optional'], $token )  = self::is_optional( $token );
		list( $param['repeating'], $token ) = self::is_repeating( $token );

		$p_name  = '([a-z-_0-9]+)';
		$p_value = '([a-zA-Z-_|,0-9]+)';

		if ( '--<field>=<value>' === $token ) {
			$param['type'] = 'generic';
		} elseif ( preg_match( "/^<($p_value)>$/", $token, $matches ) ) {
			$param['type'] = 'positional';
			$param['name'] = $matches[1];
		} elseif ( preg_match( "/^--(?:\\[no-\\])?$p_name/", $token, $matches ) ) {
			$param['name'] = $matches[1];

			$value = substr( $token, strlen( $matches[0] ) );

			// substr returns false <= PHP 5.6, and '' PHP 7+
			if ( false === $value || '' === $value ) {
				$param['type'] = 'flag';
			} else {
				$param['type'] = 'assoc';

				list( $param['value']['optional'], $value ) = self::is_optional( $value );

				if ( preg_match( "/^=<$p_value>$/", $value, $matches ) ) {
					$param['value']['name'] = $matches[1];
				} else {
					$param = array(
						'type' => 'unknown',
					);
				}
			}
		} else {
			$param['type'] = 'unknown';
		}

		return $param;
	}
private static function classify_token( $token ) {
		$param = array();

		list( $param['optional'], $token )  = self::is_optional( $token );
		list( $param['repeating'], $token ) = self::is_repeating( $token );

		$p_name  = '([a-z-_0-9]+)';
		$p_value = '([a-zA-Z-_|,0-9]+)';

		if ( '--<field>=<value>' === $token ) {
			$param['type'] = 'generic';
		} elseif ( preg_match( "/^<($p_value)>$/", $token, $matches ) ) {
			$param['type'] = 'positional';
			$param['name'] = $matches[1];
		} elseif ( preg_match( "/^--(?:\\[no-\\])?$p_name/", $token, $matches ) ) {
			$param['name'] = $matches[1];

			$value = substr( $token, strlen( $matches[0] ) );

			// substr returns false <= PHP 5.6, and '' PHP 7+
			if ( false === $value || '' === $value ) {
				$param['type'] = 'flag';
			} else {
				$param['type'] = 'assoc';

				list( $param['value']['optional'], $value ) = self::is_optional( $value );

				if ( preg_match( "/^=<$p_value>$/", $value, $matches ) ) {
					$param['value']['name'] = $matches[1];
				} else {
					$param = array(
						'type' => 'unknown',
					);
				}
			}
		} else {
			$param['type'] = 'unknown';
		}

		return $param;
	}
private static function classify_token ( $ token ) { $ param = array ( ) ; list ( $ param [ 'optional' ] , $ token ) = self :: is_optional ( $ token ) ; list ( $ param [ 'repeating' ] , $ token ) = self :: is_repeating ( $ token ) ; $ p_name = '([a-z-_0-9]+)' ; $ p_value = '([a-zA-Z-_|,0-9]+)' ; if ( '--<field>=<value>' === $ token ) { $ param [ 'type' ] = 'generic' ; } elseif ( preg_match ( "/^<($p_value)>$/" , $ token , $ matches ) ) { $ param [ 'type' ] = 'positional' ; $ param [ 'name' ] = $ matches [ 1 ] ; } elseif ( preg_match ( "/^--(?:\\[no-\\])?$p_name/" , $ token , $ matches ) ) { $ param [ 'name' ] = $ matches [ 1 ] ; $ value = substr ( $ token , strlen ( $ matches [ 0 ] ) ) ; // substr returns false <= PHP 5.6, and '' PHP 7+ if ( false === $ value || '' === $ value ) { $ param [ 'type' ] = 'flag' ; } else { $ param [ 'type' ] = 'assoc' ; list ( $ param [ 'value' ] [ 'optional' ] , $ value ) = self :: is_optional ( $ value ) ; if ( preg_match ( "/^=<$p_value>$/" , $ value , $ matches ) ) { $ param [ 'value' ] [ 'name' ] = $ matches [ 1 ] ; } else { $ param = array ( 'type' => 'unknown' , ) ; } } } else { $ param [ 'type' ] = 'unknown' ; } return $ param ; }
Classify argument attributes based on its syntax.

@param string $token
@return array $param
Classify argument attributes based on its syntax .