-
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix prefixing classes used in try/catch blocks (#167)
- Loading branch information
Showing
2 changed files
with
158 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the humbug/php-scoper package. | ||
* | ||
* Copyright (c) 2017 Théo FIDRY <theo.fidry@gmail.com>, | ||
* Pádraic Brady <padraic.brady@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
return [ | ||
'meta' => [ | ||
'title' => 'Miscellaneous', | ||
// Default values. If not specified will be the one used | ||
'prefix' => 'Humbug', | ||
'whitelist' => [], | ||
], | ||
|
||
'Catch an internal class' => <<<'PHP' | ||
<?php | ||
try { | ||
echo "foo"; | ||
} catch (Throwable $t) { | ||
} | ||
---- | ||
<?php | ||
namespace Humbug; | ||
try { | ||
echo "foo"; | ||
} catch (\Throwable $t) { | ||
} | ||
|
||
PHP | ||
, | ||
|
||
'Catch an internal class in a namespace' => <<<'PHP' | ||
<?php | ||
namespace Acme; | ||
try { | ||
echo "foo"; | ||
} catch (\Throwable $t) { | ||
} | ||
---- | ||
<?php | ||
namespace Humbug\Acme; | ||
try { | ||
echo "foo"; | ||
} catch (\Throwable $t) { | ||
} | ||
|
||
PHP | ||
, | ||
|
||
'Catch an custom exception class' => <<<'PHP' | ||
<?php | ||
try { | ||
echo "foo"; | ||
} catch (FooException $t) { | ||
} | ||
---- | ||
<?php | ||
namespace Humbug; | ||
try { | ||
echo "foo"; | ||
} catch (\Humbug\FooException $t) { | ||
} | ||
|
||
PHP | ||
, | ||
|
||
'Catch an custom exception class in a namespace' => <<<'PHP' | ||
<?php | ||
namespace Acme; | ||
try { | ||
echo "foo"; | ||
} catch (FooException $t) { | ||
} | ||
---- | ||
<?php | ||
namespace Humbug\Acme; | ||
try { | ||
echo "foo"; | ||
} catch (\Humbug\Acme\FooException $t) { | ||
} | ||
|
||
PHP | ||
, | ||
|
||
'Catch an custom exception class in a namespace imported with a use statement' => <<<'PHP' | ||
<?php | ||
namespace Acme; | ||
use X\FooException; | ||
try { | ||
echo "foo"; | ||
} catch (FooException $t) { | ||
} | ||
---- | ||
<?php | ||
namespace Humbug\Acme; | ||
use Humbug\X\FooException; | ||
try { | ||
echo "foo"; | ||
} catch (\Humbug\X\FooException $t) { | ||
} | ||
|
||
PHP | ||
, | ||
|
||
'Multiple catch statement' => <<<'PHP' | ||
<?php | ||
namespace Acme; | ||
use X\FooException; | ||
try { | ||
echo "foo"; | ||
} catch (FooException | \Throwable $t) { | ||
} | ||
---- | ||
<?php | ||
namespace Humbug\Acme; | ||
use Humbug\X\FooException; | ||
try { | ||
echo "foo"; | ||
} catch (\Humbug\X\FooException|\Throwable $t) { | ||
} | ||
|
||
PHP | ||
, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters