-
Notifications
You must be signed in to change notification settings - Fork 671
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
Array cast pass taints #6810
Array cast pass taints #6810
Conversation
The issue with invalid data returned from the data provider should have been caught by Psalm, but somehow it wasn't. Even though one of the elements is missing |
If I remember correctly, it's this one:
|
Psalm uses at most 101 elements to infer array shape: https://psalm.dev/r/5f192e37bf This doesn't look right. While it's understandable that we cannot allow unbounded shapes, we probably should still be able to use all elements to infer array value/key type (as we actually process all elements). |
I found these snippets: https://psalm.dev/r/5f192e37bf<?php
$_a = [
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 10
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 20
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 30
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 40
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 50
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 60
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 70
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 80
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 90
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 100
"aaaa",
];
/** @psalm-trace $_a */;
https://psalm.dev/r/62d9666fdc<?php
$_a = [
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 10
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 20
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 30
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 40
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 50
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 60
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 70
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 80
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 90
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 100
1, // 101
"aaaa",
];
/** @psalm-trace $_a */;
https://psalm.dev/r/6462ff9bcc<?php
$_a = [
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 10
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 20
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 30
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 40
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 50
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 60
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 70
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 80
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 90
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 100
1, 1, // 102
"aaaa",
];
/** @psalm-trace $_a */;
|
c89a00a
to
24137bd
Compare
This makes array casts taint sensitive and fix #5550