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

Bug in detect return type for get_object_vars. #11215

Open
mj4444ru opened this issue Jan 29, 2025 · 2 comments
Open

Bug in detect return type for get_object_vars. #11215

mj4444ru opened this issue Jan 29, 2025 · 2 comments

Comments

@mj4444ru
Copy link

$x = new stdClass();
$x->{1} = 1;

var_dump(get_object_vars($x));

Return

array(1) {
  [1]=>
  int(1)
}

https://psalm.dev/r/ae7bc9df71

I'm waiting array<array-key, mixed>.

Copy link

I found these snippets:

https://psalm.dev/r/ae7bc9df71
<?php

$x = new stdClass();
$x->{1} = 1;

$t = get_object_vars($x);
/** @psalm-trace $t */
Psalm output (using commit a17fdd7):

INFO: Trace - 7:23 - $t: array<string, mixed>

@orklah
Copy link
Collaborator

orklah commented Jan 29, 2025

Yeah, this is technically correct but if feels more like an oversight on php implementation than a real feature imho. The ratio between the bugs that would be hidden by loosening this type vs the number of false positive solved feels bad...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants