Skip to content

issue #9807 refactored syntax for better understanding #10687

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

Open
wants to merge 3 commits into
base: 5.x
Choose a base branch
from
Open
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 @@ -44,7 +44,9 @@ public static function analyze(
|| $root_expr instanceof PhpParser\Node\Expr\NullsafeMethodCall
|| $root_expr instanceof PhpParser\Node\Expr\Ternary
) {
$left_var_id = '$<tmp coalesce var>' . (int) $left_expr->getAttribute('startFilePos');
$left_var_id = '$<psalm_coalesce_temp_var>'
. (int) $left_expr->getAttribute('startFilePos')
. ': array<array-key, mixed>';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure why array<array-key, mixed> is hardcoded here. And it doesn't seem it adds anything useful to the message as TypeContradiction would still list the inferred type anyway.

Copy link
Author

Choose a reason for hiding this comment

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

The hardcoded type hint array<array-key, mixed> in the variable assignment was initially introduced to provide explicit information about the expected type of the temporary variable. However, after careful consideration and feedback, it appears that this information is already effectively conveyed by TypeContradiction.

To improve code readability and adhere to the feedback received, should I make the necessary changes?

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes, please remove it, I think it add confusion instead of reducing it


$cloned = clone $context;
$cloned->inside_isset = true;
Expand Down