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
phpmd ignore SuppressWarnings(PHPMD.CountInLoopExpression) inside class #676
Milestone
Comments
Hi @fernandoval, please dump the code so we can reproduce it. Did you check the PHPDoc comment has the valid syntax with 2 stars: |
Sample of code where comment works: /**
* @SuppressWarnings(PHPMD.CountInLoopExpression)
*/
class ArrayUtils
{
public function dottedUnset(array &$array, string $key)
{
$keys = explode('.', $key);
while (count($keys) > 1) {
$key = array_shift($keys);
if (!isset($array[$key]) || !is_array($array[$key])) {
return;
}
$array = &$array[$key];
}
unset($array[array_shift($keys)]);
}
} Sample where comment does not works: class ArrayUtils
{
/**
* Removes the element from an array using dot notation.
*
* @SuppressWarnings(PHPMD.CountInLoopExpression)
*
* @param array $array
* @param string $key
*
* @return void
*/
public function dottedUnset(array &$array, string $key)
{
$keys = explode('.', $key);
while (count($keys) > 1) {
$key = array_shift($keys);
if (!isset($array[$key]) || !is_array($array[$key])) {
return;
}
$array = &$array[$key];
}
unset($array[array_shift($keys)]);
}
} |
Bug reproduced. Fix #677 proposed. |
kylekatarnls
added a commit
to kylekatarnls/phpmd
that referenced
this issue
Oct 8, 2019
tvbeek
added a commit
that referenced
this issue
Oct 8, 2019
…-in-loop-method-suppress Fix #676 Handle @SuppressWarnings on each method for CountInLoop
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Current Behavior
Receiving "Avoid using count() function in while loops" warning message.
Expected Behavior
No error messages.
Steps To Reproduce:
If comment @SuppressWarnings(PHPMD.CountInLoopExpression) is in class comment block no warning message is printed.
But if the suppression instruction is in function comment block the warning message is printed.
The text was updated successfully, but these errors were encountered: