Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 3.7.2

Request #20220 Squiz_Sniffs_WhiteSpace_ObjectOperatorSpacingSniff sniff isn't multi-line safe
Submitted: 2014-03-17 22:49 UTC
From: aik099 Assigned:
Status: Open Package: PHP_CodeSniffer (version 1.5.2)
PHP Version: 5.4.20 OS: Slackware Linux
Roadmaps: (Not assigned)    
Subscription  


 [2014-03-17 22:49 UTC] aik099 (Alexander Obuhovich)
Description: ------------ The "Squiz_Sniffs_WhiteSpace_ObjectOperatorSpacingSniff" sniff check for "$variable ->method" and for ""$variable-> method" violations (space before/after object operator). This is valid, but when I'm chaining calls using multiline formatting: $this->eventDispatcher ->shouldReceive('dispatch') ->with($event_name, m::any()) ->once(); Then sniff reports it as an error. I think, that in such case when "->" is on the different line then the actual variable or previously chained method, then this shouldn't be considered as violation.

Comments

 [2014-03-24 07:25 UTC] squiz (Greg Sherwood)
-Type: Bug +Type: Feature/Change Request
This sniff is part of the Squiz standard and it doesn't want that newline character there. So it is an expected violation in this case and not a bug. If the sniff was to allow this syntax, I'd also want it to do things like enforce an indentation on the next line and force all object operators to be on a new line if one of them is. I'll leave this as a feature request for something like that.