Skip to content

Commit

Permalink
[BetterPhpDocParser] Check for closing brace in text content (#8977) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols authored Jan 16, 2025
1 parent b99ece5 commit 6085713
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,8 @@ private function isClosedContent(string $composedContent): bool
Lexer::TOKEN_CLOSE_CURLY_BRACKET,
Lexer::TOKEN_CLOSE_PARENTHESES
// sometimes it gets mixed int ")
) || \str_contains($composedTokenIterator->currentTokenValue(), ')')) {
) || \str_contains($composedTokenIterator->currentTokenValue(), '}')
|| \str_contains($composedTokenIterator->currentTokenValue(), ')')) {
++$closeBracketCount;
}

Expand Down
27 changes: 27 additions & 0 deletions tests/Issues/InlineTags/Fixture/fixture.php.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

use PHPUnit\Framework\TestCase;

/**
* @copyright Example {@link https://example.com}
* @covers \Tests\BarController
*/
class BarController extends TestCase
{
}

?>
-----
<?php

use PHPUnit\Framework\TestCase;

/**
* @copyright Example {@link https://example.com}
*/
#[\PHPUnit\Framework\Attributes\CoversClass(\Tests\BarController::class)]
class BarController extends TestCase
{
}

?>
28 changes: 28 additions & 0 deletions tests/Issues/InlineTags/InlineTagsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

namespace Rector\Tests\Issues\InlineTagsTest;

use Iterator;
use PHPUnit\Framework\Attributes\DataProvider;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;

final class InlineTagsTest extends AbstractRectorTestCase
{
#[DataProvider('provideData')]
public function test(string $filePath): void
{
$this->doTestFile($filePath);
}

public static function provideData(): Iterator
{
return self::yieldFilesFromDirectory(__DIR__ . '/Fixture');
}

public function provideConfigFilePath(): string
{
return __DIR__ . '/config/configured_rule.php';
}
}
9 changes: 9 additions & 0 deletions tests/Issues/InlineTags/config/configured_rule.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\PHPUnit\AnnotationsToAttributes\Rector\Class_\CoversAnnotationWithValueToAttributeRector;

return RectorConfig::configure()
->withRules([CoversAnnotationWithValueToAttributeRector::class]);

0 comments on commit 6085713

Please sign in to comment.