phpwordpressphpcsphpcodesniffer

How to fix, assignments must be the first block of code on a line?


I'm developing WordPress plugin and stuck with code sniffer warnings. How do I fix the below warning message?

[Squiz.PHP.DisallowMultipleAssignments.Found] Assignments must be the first block of code on a line

The above error/ warning is highlighting for the below code.

$testimonial_gravatar_image = $out = $before = $after = '';

How do I define those empty variables? If I skip or remove then the error displays undefined variable etc.

$testimonial_gravatar_image is inside the while loop and $out for generating output.


Solution

  • $testimonial_gravatar_image = '';
    $out = '';
    $before = '';
    $after = '';