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

Bug #20345 String concat is not required here; use a single string instead
Submitted: 2014-07-10 21:04 UTC
From: petervanderdoes Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version Unknown)
PHP Version: 5.4.30 OS: Linux
Roadmaps: (Not assigned)    
Subscription  


 [2014-07-10 21:04 UTC] petervanderdoes (Peter van der Does)
Description: ------------ Codesniffer reports: String concat is not required here; use a single string instead Which only is true if I would switch all quotation marks from single to double and vide versa. This comes through Scrutinizer-CI, I don't really know the exact PHP version or Package version. Test script: --------------- '<a class="adm-scored" data-scored="Yes" data-id="' . $competition->ID . '">' . 'No' . '</a>'; Expected result: ---------------- No message Actual result: -------------- String concat is not required here; use a single string instead

Comments

 [2014-07-11 07:39 UTC] squiz (Greg Sherwood)
-Status: Open +Status: Feedback -Assigned To: +Assigned To: squiz
When I run PHPCS over that code, I get 2 of those unnecessary concat errors. But the errors are being reported for the last two concat operators you have there, which join 3 single-quoted strings. Scrutinizer-CI obviously isn't using the column position that the error provides to show you where PHPCS is complaining, which makes this confusing given there are 4 concats happening on the same line number. I imagine it is just listen the message for you like the default screen-based output of PHPCS does. Anyway, the change being asked for is this: '<a class="adm-scored" data-scored="Yes" data-id="'.$competition- >ID.'">No</a>'; If I run PHPCS over that code, I don't get any concat errors. Does that work for you too?
 [2014-07-11 09:14 UTC] petervanderdoes (Peter van der Does)
yep that was it, thanks for the quick response.
 [2014-07-11 09:14 UTC] petervanderdoes (Peter van der Does)
-Status: Feedback +Status: Closed