-
Notifications
You must be signed in to change notification settings - Fork 162
Closed
Labels
bugSomething isn't workingSomething isn't workingfalse negativeRule causes false negative findingsRule causes false negative findingsneed to discussRule requires discussionRule requires discussion
Description
Preconditions
- Magento.Exceptions.ThrowCatch rule implemented (#29: [New Rule] Exceptions must not be handled in the same function #43; tested on Magento Coding Standard 2.0.0 and 1.0.1)
Steps to reproduce
- Run phpcs with --standard=Magento2 against file containing multiple catch blocks (it fails as it should):
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento;
/**
* Doer
*/
class Doer
{
/**
* Do Something
*/
public function doSomething()
{
try {
$result = 2;
} catch (\DummyException $e) {
throw $e;
} catch (\NewException $e) {
throw $e;
}
return $result;
}
}
Run phpcs with --standard=Magento2 against file containing one catch block (it passes when it should not):
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento;
/**
* Doer
*/
class Doer
{
/**
* Do Something
*/
public function doSomething()
{
try {
$result = 2;
} catch (\DummyException $e) {
throw $e;
}
return $result;
}
}
Expected result
- Both files should fail Magento.Exceptions.ThrowCatch rule
Actual result
- Only file with two catch blocks fails Magento.Exceptions.ThrowCatch rule
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingfalse negativeRule causes false negative findingsRule causes false negative findingsneed to discussRule requires discussionRule requires discussion