<commit_before><?php

/* This file is part of the Staq project, which is under MIT license */


namespace Staq\Core\Router\Stack;

class Controller implements \Stack\IController {



	/*************************************************************************
	 ATTRIBUTES
	 *************************************************************************/
	protected $routes = [ ];



	/*************************************************************************
	  GETTER
	 *************************************************************************/
	public function get_routes( ) {
		return $this->routes;
	}



	/*************************************************************************
	  CONSTRUCTOR             
	 *************************************************************************/
	public function __construct( ) {
		$this->initialize_routes( );
	}



	/*************************************************************************
	  ACTION METHODS           
	 *************************************************************************/
	public function action( ) { }



	/*************************************************************************
	  PROTECTED METHODS             
	 *************************************************************************/
	protected function initialize_routes( ) {
		foreach( array_keys( get_object_vars( $this ) ) as $attribute_name ) {
			if ( \UString::is_start_with( $attribute_name, 'route_action' ) ) {
				$action = \UString::substr_after( $attribute_name, 'route_' );
				$this->routes[ ] = $this->get_route_from_attribute( $action, $this->$attribute_name );
			}
		}
	}
	protected function get_route_from_attribute( $action, $params ) {
		$callable = [ $this, $action ];
		if ( is_callable( $callable ) ) {
			$match_uri = NULL;
			$match_exceptions = [ ];
			$aliases_uri = [ ];
			if ( is_array( $params ) ) {
				$match_uri        = isset( $params[ 'match_uri'        ] ) ? $params[ 'match_uri'        ] : $match_uri;
				$match_exceptions = isset( $params[ 'match_exceptions' ] ) ? $params[ 'match_exceptions' ] : $match_exceptions;
				$aliases_uri      = isset( $params[ 'aliases_uri'      ] ) ? $params[ 'aliases_uri'      ] : $aliases_uri;
			} else if ( is_string( $params ) ) {
				$match_uri = $params;
			}
			return new \Stack\Route( $callable, $match_uri, $match_exceptions, $aliases_uri );
		}
	}
}
<commit_msg>BugFix: No parameters should be mandatory on controller action methods<commit_after><?php

/* This file is part of the Staq project, which is under MIT license */


namespace Staq\Core\Router\Stack;

class Controller implements \Stack\IController {



	/*************************************************************************
	 ATTRIBUTES
	 *************************************************************************/
	protected $routes = [ ];



	/*************************************************************************
	  GETTER
	 *************************************************************************/
	public function get_routes( ) {
		return $this->routes;
	}



	/*************************************************************************
	  CONSTRUCTOR             
	 *************************************************************************/
	public function __construct( ) {
		$this->initialize_routes( );
	}



	/*************************************************************************
	  PROTECTED METHODS             
	 *************************************************************************/
	protected function initialize_routes( ) {
		foreach( array_keys( get_object_vars( $this ) ) as $attribute_name ) {
			if ( \UString::is_start_with( $attribute_name, 'route_action' ) ) {
				$action = \UString::substr_after( $attribute_name, 'route_' );
				$this->routes[ ] = $this->get_route_from_attribute( $action, $this->$attribute_name );
			}
		}
	}
	protected function get_route_from_attribute( $action, $params ) {
		$callable = [ $this, $action ];
		if ( is_callable( $callable ) ) {
			$match_uri = NULL;
			$match_exceptions = [ ];
			$aliases_uri = [ ];
			if ( is_array( $params ) ) {
				$match_uri        = isset( $params[ 'match_uri'        ] ) ? $params[ 'match_uri'        ] : $match_uri;
				$match_exceptions = isset( $params[ 'match_exceptions' ] ) ? $params[ 'match_exceptions' ] : $match_exceptions;
				$aliases_uri      = isset( $params[ 'aliases_uri'      ] ) ? $params[ 'aliases_uri'      ] : $aliases_uri;
			} else if ( is_string( $params ) ) {
				$match_uri = $params;
			}
			return new \Stack\Route( $callable, $match_uri, $match_exceptions, $aliases_uri );
		}
	}
}

{'fraction_non_alphanumeric': 0.38625954198473283, 'fraction_numerical': 0.0, 'mean_word_length': 4.492215568862275, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '1356720', 'n_tokens_mistral': 1372, 'n_tokens_neox': 1176, 'n_words': 232}