-
Notifications
You must be signed in to change notification settings - Fork 650
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
InvalidConstantAssignmentValue with no docblock type #9376
Labels
Comments
I found these snippets: https://psalm.dev/r/8f0c1f98d6<?php
class A {
public const T = 'TEXT';
}
class B
{
public const ARRAY = [
'a' => A::T,
'b' => 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
];
}
echo strlen(B::ARRAY['b']) . "\n";
|
weirdan
added a commit
to weirdan/psalm
that referenced
this issue
Feb 23, 2023
Fixes vimeo#9376 Ensures: * that we never have a literal string exceeding the length limit * that we call string interpreter for all literal strings
weirdan
added a commit
to weirdan/psalm
that referenced
this issue
Feb 23, 2023
Fixes vimeo#9376 Ensures: * that we never have a literal string exceeding the length limit * that we call string interpreter for all literal strings
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When a constant contains a long string, it's possible to receive an
InvalidConstantAssignmentValue
even though there's no docblock-defined type for the constant:https://psalm.dev/r/8f0c1f98d6
I believe there are a few things happening here:
literal-string
becomesnon-empty-string
after 1000 chars #8075), so the assigned type of the constant isnon-empty-string
rather thanliteral-string
.literal-string
. Maybe it's constructing its type through a different code path that doesn't respect the max string length?ClassConstAnalyzer
is type-checking the constant, which kinda seems like a waste of effort since a constant without a docblock type can never result in a type error. (I think?)The text was updated successfully, but these errors were encountered: