Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

PSR12.ControlStructures.BooleanOperatorPlacement false positive when operator is the only content on line #3075

Copy link
Copy link
@morozov

Description

@morozov
Issue body actions

Describe the bug
A fixable rule violation is cannot be auto-fixed.

Code sample

<?php

function test($value)
{
    if (
        ($value == 1 ||
            $value == 2)
        &&
        ($value == 3 ||
            $value == 4)
    ) {
        return 5;
    }

    return 6;
}

Custom ruleset
None.

To reproduce
Steps to reproduce the behavior:

  1. Run phpcs -s --standard=PSR12 test.php
FILE: /home/morozov/Projects/phpcs-playground/test.php
------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------
 5 | ERROR | [x] Boolean operators between conditions must be at the beginning or end of the
   |       |     line, but not both
   |       |     (PSR12.ControlStructures.BooleanOperatorPlacement.FoundMixed)
------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------

Time: 44ms; Memory: 6MB
  1. Run phpcbf --standard=PSR12 test.php
PHPCBF RESULT SUMMARY
----------------------------------------------------------------------
FILE                                                  FIXED  REMAINING
----------------------------------------------------------------------
/home/morozov/Projects/phpcs-playground/test.php      FAILED TO FIX
----------------------------------------------------------------------
A TOTAL OF 0 ERRORS WERE FIXED IN 1 FILE
----------------------------------------------------------------------
PHPCBF FAILED TO FIX 1 FILE
----------------------------------------------------------------------

Time: 46ms; Memory: 6MB

Expected behavior
The violation is fixed.

Versions (please complete the following information):

  • OS: Linux
  • PHP: 7.4.9
  • PHPCS: 3.5.6
  • Standard: Squiz

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.