Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHPStan - Add Rule to ensure get_subscribed_events use one of the three possible syntax #7123

Open
Miraeld opened this issue Nov 21, 2024 · 1 comment · May be fixed by #7124 or #7138
Open

PHPStan - Add Rule to ensure get_subscribed_events use one of the three possible syntax #7123

Miraeld opened this issue Nov 21, 2024 · 1 comment · May be fixed by #7124 or #7138
Assignees
Labels
noQA type: enhancement Improvements that slightly enhance existing functionality and are fast to implement

Comments

@Miraeld
Copy link
Contributor

Miraeld commented Nov 21, 2024

We need to add a new custom rules to make sure that get_subscribed_events function is following one of the three possible syntax.

As a reminder, here is the docblock provided:

	/**
	 * Returns an array of events that this subscriber wants to listen to.
	 *
	 * The array key is the event name. The value can be:
	 *
	 *  * The method name
	 *  * An array with the method name and priority
	 *  * An array with the method name, priority and number of accepted arguments
	 *
	 * For instance:
	 *
	 *  * array('hook_name' => 'method_name')
	 *  * array('hook_name' => array('method_name', $priority))
	 *  * array('hook_name' => array('method_name', $priority, $accepted_args))
	 *  * array('hook_name' => array(array('method_name_1', $priority_1, $accepted_args_1)), array('method_name_2', $priority_2, $accepted_args_2)))
	 *
	 * @return array
	 */
@Miraeld Miraeld added the type: enhancement Improvements that slightly enhance existing functionality and are fast to implement label Nov 21, 2024
@Miraeld Miraeld self-assigned this Nov 21, 2024
@Miraeld Miraeld linked a pull request Nov 21, 2024 that will close this issue
9 tasks
@CrochetFeve0251
Copy link
Contributor

CrochetFeve0251 commented Nov 21, 2024

@Miraeld I would cut this issue into two parts:

  • checking as you did that the method are effectively on the class.
  • asserting the return syntax is valid.

@Miraeld Miraeld added the noQA label Nov 25, 2024
@CrochetFeve0251 CrochetFeve0251 linked a pull request Nov 25, 2024 that will close this issue
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
noQA type: enhancement Improvements that slightly enhance existing functionality and are fast to implement
Projects
None yet
2 participants