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

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)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 39 - 25 = ?

 
 [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: --------------- https://gist.github.com/gnutix/6291918 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

Comments

 [2013-08-23 06:29 UTC] squiz (Greg Sherwood)
-Status: Open +Status: Closed -Assigned To: +Assigned To: squiz
Fix committed to github repo: https://github.com/squizlabs/PHP_CodeSniffer/commit/12a1ec7ab9f362b85a3e5d5717 dbc807e98e1d2b