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

Bug #20045 Errors about indentation for closures with multi-line 'use' in functions
Submitted: 2013-08-21 15:09 UTC
From: gnutix Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.4.6)
PHP Version: Irrelevant OS: Debian Wheezy
Roadmaps: (Not assigned)    

 [2013-08-21 15:09 UTC] gnutix (Dorian Villet)
Description: ------------ When having closures with a long "use" statement (too long to be on one line), we need to use multi- line arguments. Then, the closing use characters ) and the function's opening bracket { are also on a line of their own. The issue is the indentation for this last line composed of ") {": if the closure is in a simple file, at the first level of indentation, no issue. But if the closure is inside a function, a class method, or anything else you might think of, PHPCS expects 4 more spaces than it should at the beginning of the line. You'll find examples in the gist below. The standard used is PSR2. Test script: --------------- Expected result: ---------------- user@server:~$ phpcs test.php --standard=PSR2 Time: 33 ms, Memory: 5.50Mb Actual result: -------------- user@server:~$ phpcs test.php --standard=PSR2 FILE: /home/user/test.php ------------------------------------------------------------------------ -------- FOUND 1 ERROR(S) AFFECTING 1 LINE(S) ------------------------------------------------------------------------ -------- 13 | ERROR | Multi-line function declaration not indented correctly; | | expected 8 spaces but found 4 ------------------------------------------------------------------------ -------- Time: 33 ms, Memory: 5.50Mb


 [2013-08-23 06:29 UTC] squiz (Greg Sherwood)
-Status: Open +Status: Closed -Assigned To: +Assigned To: squiz
Fix committed to github repo: dbc807e98e1d2b