Fix PHPCS errors in WordPress

Visibility must be declared on method “__construct”

Add public before the class method

Detected usage of a non-sanitized input variable: $_POST[‘xyz’]

You need to sanitize it. E.g. esc_html( $_POST['xyz'] ) or sanitize_text_field( $_POST['xyz'] )

 Detected usage of a possibly undefined superglobal array index: $_POST[‘query’]. Use isset() or empty() to check

Wrap it inside empty() e.g. empty( $_POST['query'] )

Object property “$errorCode” is not in valid snake_case format, try “$error_code”

You need to write your variable in snake case e.g. $var_name instead of $varName

Leave a Reply