<commit_before><?php

namespace WP_CLI\Dispatcher;

abstract class Subcommand {

	function __construct( $method ) {
		$this->method = $method;
	}

	abstract function show_usage();
	abstract function invoke( $args, $assoc_args );

	protected function check_args( $args, $assoc_args ) {
		$accepted_params = $this->parse_synopsis( $this->get_synopsis() );

		$this->check_positional( $args, $accepted_params );

		$this->check_assoc( $assoc_args, $accepted_params );

		$this->check_unknown_assoc( $assoc_args, $accepted_params );
	}

	private function check_positional( $args, $accepted_params ) {
		$count = 0;

		foreach ( $accepted_params['positional'] as $param ) {
			if ( !$param['optional'] )
				$count++;
		}

		if ( count( $args ) < $count ) {
			$this->show_usage();<commit_msg>don't check args if synopsis isn't set<commit_after><?php

namespace WP_CLI\Dispatcher;

abstract class Subcommand {

	function __construct( $method ) {
		$this->method = $method;
	}

	abstract function show_usage();
	abstract function invoke( $args, $assoc_args );

	protected function check_args( $args, $assoc_args ) {
		$synopsis = $this->get_synopsis();
		if ( !$synopsis )
			return;

		$accepted_params = $this->parse_synopsis( $synopsis );

		$this->check_positional( $args, $accepted_params );

		$this->check_assoc( $assoc_args, $accepted_params );

		$this->check_unknown_assoc( $assoc_args, $accepted_params );
	}

	private function check_positional( $args, $accepted_params ) {
		$count = 0;

		foreach ( $accepted_params['positional'] as $param ) {
			if ( !$param['optional'] )
				$count++;
		}

		if ( count( $args ) < $count ) {
			$this->show_usage();
{'fraction_non_alphanumeric': 0.1513872135102533, 'fraction_numerical': 0.0012062726176115801, 'mean_word_length': 4.623728813559322, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, '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': '5887591', 'n_tokens_mistral': 631, 'n_tokens_neox': 571, 'n_words': 120}