mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-24 11:44:14 +01:00
Merge pull request #3199 from rectorphp/exception-annotation
[PHPUnit] Fix ExceptionAnnotationRector for null phpdoc
This commit is contained in:
commit
cc40d00c7d
@ -83,8 +83,11 @@ PHP
|
||||
return null;
|
||||
}
|
||||
|
||||
/** @var PhpDocInfo $phpDocInfo */
|
||||
/** @var PhpDocInfo|null $phpDocInfo */
|
||||
$phpDocInfo = $node->getAttribute(AttributeKey::PHP_DOC_INFO);
|
||||
if ($phpDocInfo === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach (self::ANNOTATION_TO_METHOD as $annotation => $method) {
|
||||
if (! $phpDocInfo->hasByName($annotation)) {
|
||||
|
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\Rector\ExceptionAnnotationRector\Fixture;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class SkipMethodWithNullPhpDoc extends TestCase
|
||||
{
|
||||
public function testLiteralMessage(): void
|
||||
{
|
||||
$this->expectException('Exception');
|
||||
throw new \Exception('A literal exception message');
|
||||
}
|
||||
|
||||
// test
|
||||
|
||||
public function testPartialMessageBegin(): void
|
||||
{
|
||||
throw new \Exception('A partial exception message');
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user