Skip to content
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Apply Rector changes (CI)
  • Loading branch information
shuangjie authored and github-actions[bot] committed Apr 17, 2025
commit 40f70ae1264c4976bbb994486d6f353eb004cf69
2 changes: 1 addition & 1 deletion src/Renderer/HtmlRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -510,14 +510,14 @@
try {
$reflectionClass = new ReflectionClass($throwable);
if (class_exists('Yiisoft\FriendlyException\Attribute\FriendlyException')) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use full class name notation without quotes

Suggested change
if (class_exists('Yiisoft\FriendlyException\Attribute\FriendlyException')) {
if (class_exists(\Yiisoft\FriendlyException\Attribute\FriendlyException::class)) {

$attributes = $reflectionClass->getAttributes('Yiisoft\FriendlyException\Attribute\FriendlyException');

Check failure on line 513 in src/Renderer/HtmlRenderer.php

View workflow job for this annotation

GitHub Actions / psalm / PHP 8.3-ubuntu-latest

ArgumentTypeCoercion

src/Renderer/HtmlRenderer.php:513:67: ArgumentTypeCoercion: Argument 1 of ReflectionClass::getAttributes expects class-string|null, but parent type 'Yiisoft\\FriendlyException\\Attribute\\FriendlyException' provided (see https://psalm.dev/193)

Check warning on line 513 in src/Renderer/HtmlRenderer.php

View check run for this annotation

Codecov / codecov/patch

src/Renderer/HtmlRenderer.php#L513

Added line #L513 was not covered by tests
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same


if (!empty($attributes)) {
$friendlyExceptionAttribute = $attributes[0]->newInstance();

Check warning on line 516 in src/Renderer/HtmlRenderer.php

View check run for this annotation

Codecov / codecov/patch

src/Renderer/HtmlRenderer.php#L515-L516

Added lines #L515 - L516 were not covered by tests
$name = $friendlyExceptionAttribute->name . ' (' . $name . ')';

Check failure on line 517 in src/Renderer/HtmlRenderer.php

View workflow job for this annotation

GitHub Actions / psalm / PHP 8.3-ubuntu-latest

MixedOperand

src/Renderer/HtmlRenderer.php:517:33: MixedOperand: Left operand cannot be mixed (see https://psalm.dev/059)
}
}
} catch (\Throwable $e) {
} catch (\Throwable) {

Check warning on line 520 in src/Renderer/HtmlRenderer.php

View check run for this annotation

Codecov / codecov/patch

src/Renderer/HtmlRenderer.php#L520

Added line #L520 was not covered by tests
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do you expect an exception? I'd remove try/catch

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, the try/catch block isn't necessary here. When checking for the FriendlyException attribute, it would be better to let any exceptions propagate normally, making potential issues easier to discover. I'll remove the try/catch block. Thank you for the suggestion!

// Ignore exception and keep default name
}
}
Expand Down
Loading