Git Product home page Git Product logo

slevomat-negative-operator's Introduction

NegationOperatorSpacing false positive

Issue: slevomat/coding-standard#951

SlevomatCodingStandard.Operators.NegationOperatorSpacing returns a false positive when assigning a negative number like $a = -1 with property spacesCount set to zero.

Configuration (see phpcs.xml:

<rule ref="SlevomatCodingStandard.Operators.NegationOperatorSpacing">
    <properties>
        <property name="spacesCount" value="0"/>
    </properties>
</rule>

The output of $ ./vendor/bin/phpcs is the following:

FILE: ./slevomat-negative-operator/test.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 2 | ERROR | [x] Expected exactly 0 space after "-", 0 found.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

Time: 18ms; Memory: 4MB

Which seems very strange.

Moreover, the output of $ ./vendor/bin/phpcbf is the following:

PHP Fatal error:  Uncaught PHP_CodeSniffer\Exceptions\RuntimeException: Undefined offset: 6 in ./slevomat-negative-operator/vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Operators/NegationOperatorSpacingSniff.php on line 70 in ./slevomat-negative-operator/vendor/squizlabs/php_codesniffer/src/Runner.php:606
Stack trace:
#0 ./slevomat-negative-operator/vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Operators/NegationOperatorSpacingSniff.php(70): PHP_CodeSniffer\Runner->handleErrors()
#1 ./slevomat-negative-operator/vendor/squizlabs/php_codesniffer/src/Files/File.php(496): SlevomatCodingStandard\Sniffs\Operators\NegationOperatorSpacingSniff->process()
#2 ./slevomat-negative-operator/vendor/squizlabs/php_codesniffer/src/Files/LocalFile.php(91): PHP_CodeSniffer\Files\File->process()
#3 ./slevomat-negative-operator/vendor/squizlabs/php_codesniffer/src/Fixer.php(174): PHP_CodeSni in ./slevomat-negative-operator/vendor/squizlabs/php_codesniffer/src/Runner.php on line 606

Thus, it may be directly related to PHP_CodeSniffer itself.

slevomat-negative-operator's People

Contributors

mathieu-bour avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.