Skip to content

Temporary expression proceeded by curly brace is detected as function call #1669

@sergeyklay

Description

@sergeyklay

How to reproduce:

  1. Install
$ curl -sSL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar -o $(which phpcs) \ && chmod +x $(which phpcs) \ && phpcs --version > PHP_CodeSniffer version 3.1.0 (stable) by Squiz (http://www.squiz.net) 
  1. test.php
<?php namespace Test; class Foo { public function bar($a, $b) { if (!$a || !$b) { return; } (new stdClass())->a = $a; } }
  1. Run test
$ phpcs --standard=PSR2 $(pwd)/test.php FILE: $(pwd)/test.php --------------------------------------------------------------------------------------------------------- FOUND 3 ERRORS AFFECTING 2 LINES --------------------------------------------------------------------------------------------------------- 11 | ERROR | [x] Space before opening parenthesis of function call prohibited 11 | ERROR | [x] Opening parenthesis of a multi-line function call must be the last content on the line 13 | ERROR | [x] Closing parenthesis of a multi-line function call must be on a line by itself --------------------------------------------------------------------------------------------------------- PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY ---------------------------------------------------------------------------------------------------------

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