{"id":22589001,"url":"https://github.com/matbour/slevomat-negative-operator","last_synced_at":"2025-03-28T17:44:50.640Z","repository":{"id":119558765,"uuid":"250865995","full_name":"matbour/slevomat-negative-operator","owner":"matbour","description":"Minimal example of the false positive raised by SlevomatCodingStandard.Operators.NegationOperatorSpacing.","archived":false,"fork":false,"pushed_at":"2020-03-28T19:32:53.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-02T18:33:02.510Z","etag":null,"topics":["bug-report","slevomat-coding-standard"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/matbour.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-03-28T18:28:15.000Z","updated_at":"2020-03-28T19:52:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"ca7b2731-9c1d-4364-946e-cad945dbad72","html_url":"https://github.com/matbour/slevomat-negative-operator","commit_stats":null,"previous_names":["matbour/slevomat-negative-operator"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matbour%2Fslevomat-negative-operator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matbour%2Fslevomat-negative-operator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matbour%2Fslevomat-negative-operator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matbour%2Fslevomat-negative-operator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matbour","download_url":"https://codeload.github.com/matbour/slevomat-negative-operator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246073723,"owners_count":20719537,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bug-report","slevomat-coding-standard"],"created_at":"2024-12-08T08:11:49.245Z","updated_at":"2025-03-28T17:44:50.605Z","avatar_url":"https://github.com/matbour.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NegationOperatorSpacing false positive\n\nIssue: https://github.com/slevomat/coding-standard/issues/951\n\n`SlevomatCodingStandard.Operators.NegationOperatorSpacing` returns a false positive when\nassigning a negative number like `$a = -1` with property `spacesCount` set to zero.\n\nConfiguration (see [phpcs.xml](phpcs.xml):\n\n```xml\n\u003crule ref=\"SlevomatCodingStandard.Operators.NegationOperatorSpacing\"\u003e\n    \u003cproperties\u003e\n        \u003cproperty name=\"spacesCount\" value=\"0\"/\u003e\n    \u003c/properties\u003e\n\u003c/rule\u003e\n```\n\nThe output of `$ ./vendor/bin/phpcs` is the following:\n\n```\nFILE: ./slevomat-negative-operator/test.php\n----------------------------------------------------------------------\nFOUND 1 ERROR AFFECTING 1 LINE\n----------------------------------------------------------------------\n 2 | ERROR | [x] Expected exactly 0 space after \"-\", 0 found.\n----------------------------------------------------------------------\nPHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY\n----------------------------------------------------------------------\n\nTime: 18ms; Memory: 4MB\n```\n\nWhich seems very strange.\n\nMoreover, the output of `$ ./vendor/bin/phpcbf` is the following:\n\n```\nPHP 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\nStack trace:\n#0 ./slevomat-negative-operator/vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Operators/NegationOperatorSpacingSniff.php(70): PHP_CodeSniffer\\Runner-\u003ehandleErrors()\n#1 ./slevomat-negative-operator/vendor/squizlabs/php_codesniffer/src/Files/File.php(496): SlevomatCodingStandard\\Sniffs\\Operators\\NegationOperatorSpacingSniff-\u003eprocess()\n#2 ./slevomat-negative-operator/vendor/squizlabs/php_codesniffer/src/Files/LocalFile.php(91): PHP_CodeSniffer\\Files\\File-\u003eprocess()\n#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\n```\n\nThus, it may be directly related to PHP_CodeSniffer itself.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatbour%2Fslevomat-negative-operator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatbour%2Fslevomat-negative-operator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatbour%2Fslevomat-negative-operator/lists"}