Skip to content

Proposal: allow inline anon functions in hooks' callbacks #54

Open
@slaFFik

Description

@slaFFik

Expected Behavior

Silence those 3 warnings listed below when used within add_action() and add_filter() context.

Current Behavior

When you have a code like this:

add_action( 'admin_init', static function() {

	( new Admin() )->init();
} );

you receive these warnings for the 1st line:

  • PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket
  • PEAR.Functions.FunctionCallSignature.MultipleArguments

and this one for the last line:

  • PEAR.Functions.FunctionCallSignature.CloseBracketLine

Otherwise, this thing needs to be done which looks kinda ugly and excessive:

add_action( 
	'admin_init', 
	static function() {

		( new Admin() )->init();
	}
);

Screenshots

image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions