Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BetterPhpDocParser] Use str_starts_with() and str_ends_with() over str_contains() on DoctrineAnnotationDecorator #6671

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,9 @@ private function isClosedContent(string $composedContent): bool
if ($composedTokenIterator->isCurrentTokenType(
Lexer::TOKEN_OPEN_CURLY_BRACKET,
Lexer::TOKEN_OPEN_PARENTHESES
) || \str_contains($composedTokenIterator->currentTokenValue(), '(')) {
) || \str_starts_with($composedTokenIterator->currentTokenValue(), '{')
|| \str_starts_with($composedTokenIterator->currentTokenValue(), '(')
) {
++$openBracketCount;
}

Expand All @@ -449,8 +451,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_ends_with($composedTokenIterator->currentTokenValue(), '}')
|| \str_ends_with($composedTokenIterator->currentTokenValue(), ')')) {
++$closeBracketCount;
}

Expand Down
27 changes: 27 additions & 0 deletions tests/Issues/InlineTags/Fixture/with_description.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} some description
* @covers \Tests\BarController
*/
class WithDescription extends TestCase
{
}

?>
-----
<?php

use PHPUnit\Framework\TestCase;

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

?>
Loading