-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Squiz.WhiteSpace.ScopeClosingBrace fails to fix closing brace within indented PHP tags #1405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
If it hit 50 loops, it is never going to finish. The most likely issue is that two of the fixers are conflicting, but I can only figure that out if you're able to get me some code you can reproduce the issue on, and let me know what coding standard you are using. Is that possible? |
attached is my ruleset.xml let me know what else do you need 🤝 |
I'd need a sample file you are using to reproduce the problem please. |
here is the file, thanks. my phpcs version: |
Perfect, thanks. I'll take a look into it. |
The smallest piece of code I can reproduce with is: <?php
if ($foo === $bar)
$foo = true;
else
$foo = false;
if ($foo) {
?>
<?php } ?> |
is this the problem ? |
Smaller bit of code: <?php
if ($foo) {
?>
<?php } ?> |
…sing brace within indented PHP tags
The problem was with the Squiz.WhiteSpace.ScopeClosingBrace sniff thinking that the The fix has been committed and will be in the next release. Thanks for providing those test files. |
thanks, i'll be waiting the next release |
I checked your sample file with your ruleset before committing. When I do, I get this output from PHPCS:
Running PHPCBF over it produces no errors any more:
And running a diff report with PHPCS shows: 115:PHP_CodeSniffer gsherwood$ php scripts/phpcs ~/Desktop/sample.php --standard=~/Desktop/ruleset.xml --report=diff
--- /Users/gsherwood/Desktop/sample.php
+++ PHP_CodeSniffer
@@ -20,7 +20,8 @@
//$_SESSION['test'] = 123;
// <editor-fold defaultstate="collapsed" desc="Functions">
-function createCombo($sql, $setvalue = "", $disabled = "", $id = "", $valuekey = "", $value = "", $uniq = "", $tabindex = "", $class = "", $empty = 0) {
+function createCombo($sql, $setvalue = "", $disabled = "", $id = "", $valuekey = "", $value = "", $uniq = "", $tabindex = "", $class = "", $empty = 0)
+{
global $myDatabase;
ini_set('default_charset', 'utf-8');
$result2 = $myDatabase->query("SET NAMES 'UTF8'", MYSQLI_STORE_RESULT);
@@ -36,10 +37,11 @@
}
while ($combo_row = $result->fetch_object()) {
- if (strtoupper($combo_row->$valuekey) == strtoupper($setvalue))
+ if (strtoupper($combo_row->$valuekey) == strtoupper($setvalue)) {
$prop = "selected";
- else
- $prop = "";
+ } else {
+$prop = "";
+ }
echo "<OPTION value=\"" . $combo_row->$valuekey . "\" " . $prop . ">" . $combo_row->$value . "</OPTION>";
}
@@ -54,10 +56,11 @@
// </editor-fold>
-if ($_SESSION['userCategory'] != 1)
+if ($_SESSION['userCategory'] != 1) {
$using_cop = true;
-else
- $using_cop = false;
+} else {
+$using_cop = false;
+}
$qry = "SELECT concat(case when title = 1 then 'Mr.' when title = 2 then 'Ms.' when title = 3 then 'Mrs.' when title = 4 then 'PT.' when title = 5 then 'CV.' else '' end ,' ' , `client_name` ) as client_name " .
"FROM client where client_id = " . $_SESSION['openPolicyID_client'];
@@ -220,7 +223,7 @@
$("#prs__ff_onSUBMIT_FILTER").trigger("click");
}
});
-<?
+<?php
if ($_SESSION['openPolicyID_client_messageboard'] > 0) {
?>
$.fancybox({
@@ -246,7 +249,7 @@
$("body").css("overflow", "auto");
}
});
- <?
+ <?php
$_SESSION['openPolicyID_client_messageboard'] --;
}
?>
@@ -317,18 +320,20 @@
<div class="container">
<div class="row">
<div class="span4 logo">
- <?
+ <?php
if (file_exists("./_images/" . ($_SESSION['applicationType'] == "1" ? 'client/' : 'client_training/') . $_SESSION['openPolicyID_client'] . ".png")) {
?>
<img alt="logo" title="" width="123px" src="./_images/<?php echo ($_SESSION['applicationType'] == "1" ? 'client/' : 'client_training/') . $_SESSION['openPolicyID_client']; ?>.png">
- <?
+ <?php
} else {
?>
<img alt="logo" title="" width="123px" src="./_images/<?php echo ($_SESSION['applicationType'] == "1" ? 'client/' : 'client_training/') . $_SESSION['openPolicyID_client']; ?>.jpg">
<?php } ?>
<br/><?php echo $clientName; ?>
</div>
- <div class="span4"><?php if ($_SESSION['applicationType'] == 2) echo '<div style="font-size:25px; text-align:center;margin-top:40px;">TRAINING VERSION</div>'; ?></div>
+ <div class="span4"><?php if ($_SESSION['applicationType'] == 2) {
+echo '<div style="font-size:25px; text-align:center;margin-top:40px;">TRAINING VERSION</div>';
+ } ?></div>
<div class="span4 logo">
<!-- HEADER: LOGO -->
<a class="logo">
@@ -348,8 +353,9 @@
<ul class="nav nav-pills">
<li class="single">
<a href="<?php
- if (isset($_SESSION['originWebsite']))
+ if (isset($_SESSION['originWebsite'])) {
echo $_SESSION['originWebsite'] . '/';
+ }
?>corporate.php?from=client">
HOME
<i>s</i>
@@ -407,7 +413,7 @@
<li><a href="procedures.php">Terms & Conditions</a></li>
</ul>
</li>
- <?
+ <?php
}
if ($right_ViewManagementReports) {
?>
@@ -417,7 +423,7 @@
<i>dashboards</i>
</a>
</li>
- <?
+ <?php
}
if ($right_ViewGuidelines) {
?>
@@ -427,7 +433,7 @@
<i>list of hospitals</i>
</a>
</li>
- <?
+ <?php
}
?>
</ul>
@@ -558,7 +564,7 @@
<div class="row show-grid">
<!-- FOOTER: COPYRIGHT TEXT -->
<div class="span12">
- <p><?
+ <p><?php
if ($_SESSION['userID'] == 3) {
echo "<br/>";
echo "HTTP_HOST:" . $_SERVER["HTTP_HOST"] . "<br/>"; So it looks fine to me. Maybe you are missing other fixes that have since been released. You could always clone the report directly and run PHPCS from there to test:
|
Your output shows you must be using a different ruleset than the one you posted here. The one you are using has, for example, the Are you sure you gave me the right ruleset? Note that I've tried fixing your file using the entire Squiz standard and I can't, so there is probably a second issue somewhere in this file. So I'll try and find and fix that, but it would be good to know wat standard you are using so I can make sure your specific case is fixed this time. |
sorry, i was reupdating my codesniffer version to so here is my ruleset.xml on my /home atm it look different from before, now i'm confuse which ruleset should i've change. |
Morning, Today i've edit the file under and write the changes as declared by you in bug #1405, now the problem is solved. i've checked it with this command Because i cannot choose which one is the default ruleset, so i set the standard like above. Can you please point out which one is the default ruleset? or i can add my ruleset to the default so globally my phpcs will work like this one. the list is in above post. Gracias. |
…when they are preceded by inline comments (ref #1405)
I found the other issue with the Squiz standard unable to fix your file, but it was completely unrelated to the original issue here. It has been fixed though. |
@rezashamdani You've obviously got PHPCS installed via composer and via PEAR. The fact you've had to change the PEAR one tells me that your When you run the You might want to look at the following wiki sections: |
Good Monday Morning,
I just using the phpcs & squzlabs fot the past 2 days, so far it help me a lot with my ugly writen codes.
I have problem with large files with the last log shown below;
*** Reached maximum number of loops with 2 violations left unfixed ***
*** END FILE FIXING ***
If there any change for me to add more than 50 loops maximum ?
Big Thanks.
The text was updated successfully, but these errors were encountered: