Skip to content

Empty FUNCTION statement detected should be allowed for around plugins #95

Closed
@markshust

Description

@markshust

Description

A WARNING is thrown for sniff "Empty FUNCTION statement detected"

This warning should not be through if the empty function is an around plugin. A common use-case for around plugins is to prevent execution of the original calling method. For example:

    public function aroundPrepareFavicon(Renderer $subject, callable $proceed)
    {
        // Do not call $proceed() to remove favicon code
    }

Expected behavior

I would expect this sniff to still run and throw a WARNING in all circumstances other than an around plugin. The sniff should not throw a WARNING for an around plugin.

A consideration may be to mandate the use of a comment for an around plugin with an empty function statement. This would ensure that the empty around plugin not calling the callable $proceed is desired. See above for an example comment which explains why this around plugin is empty.

Benefits

Empty around plugins are not only valid but this is a common use-case. The sniff should not detect this as an error. A comment within an empty around plugin would also most likely be desired and document to the user why this around function is empty.

Metadata

Metadata

Labels

Progress: good first issueIssues is easy to get started withacceptedNew rule is acceptedenhancementImprovements to existing rulesfalse positiveRule causes false positive findings

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions