mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
40 lines
1.0 KiB
PHP
40 lines
1.0 KiB
PHP
|
<?php
|
||
|
namespace Psalm\Tests;
|
||
|
|
||
|
class TryCatchTest extends TestCase
|
||
|
{
|
||
|
use Traits\FileCheckerValidCodeParseTestTrait;
|
||
|
|
||
|
/**
|
||
|
* @return array
|
||
|
*/
|
||
|
public function providerFileCheckerValidCodeParse()
|
||
|
{
|
||
|
return [
|
||
|
'PHP7-interfaceHasGetMessage' => [
|
||
|
'<?php
|
||
|
interface CustomThrowable {}
|
||
|
class CustomException extends Exception implements CustomThrowable {}
|
||
|
|
||
|
try {
|
||
|
throw new CustomException("Bad");
|
||
|
} catch (CustomThrowable $e) {
|
||
|
echo $e->getMessage();
|
||
|
}',
|
||
|
],
|
||
|
'tryCatchVar' => [
|
||
|
'<?php
|
||
|
try {
|
||
|
$worked = true;
|
||
|
}
|
||
|
catch (\Exception $e) {
|
||
|
$worked = false;
|
||
|
}',
|
||
|
'assertions' => [
|
||
|
'$worked' => 'bool',
|
||
|
],
|
||
|
],
|
||
|
];
|
||
|
}
|
||
|
}
|