-
Notifications
You must be signed in to change notification settings - Fork 657
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
literal-string
becomes non-empty-string
after 1000 chars
#8075
Comments
I found these snippets: https://psalm.dev/r/05f9492c43<?php
/**
* @param literal-string $i
*/
function takesLiteralString($i) : string {
return $i;
}
takesLiteralString("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
|
There is an undocumented config attribute called Lines 1085 to 1088 in 4e59398
Lines 247 to 252 in 4e59398
You may want to tweak it. |
That does it, wonderful. Thank you! (ps: thanks for pointing out where that is in the codebase, that helps familiarize to it so that I can eventually contribute back!) |
I assume that's from before |
As usual when we have to juggle between types, we're confronted to this choice. You can design a psalm.dev example that will fail for any choice you'll take. Maybe a refactoring of TString could allow this and keep flags for literalness, non-emptyness, lowercaseness, non-falsyness etc... but it's a monstrous task |
I'd much rather just get around to finishing my type system rewrite so that we can do |
I came up with this as well (@orklah this is why I've reached out to you on slack recently). I can think that the doctrine plugin for example could take advantage of it (if its plans are to support DQL analysis), etc. But also my plugin (boesing/psalm-plugin-stringf#102) is kinda affected by the By raising the So yes, that might be a solution but I definitely would love to see a way how plugins can still interact with the non-shortened version of the string in some way. |
Max literal-string length default is 999 chars. See vimeo/psalm#8075 for the undocumented config option to raise the limit. In my codebase the longest literal string is now 1978 chars so 2600 should be a safe new limit. Also 2600 Hz because why not.
Max literal-string length default is 999 chars. See vimeo/psalm#8075 for the undocumented config option to raise the limit. In my codebase the longest literal string is now 1978 chars so 2600 should be a safe new limit. Also 2600 Hz because why not.
tl;dr: looks like after 1000 chars and over, a
literal-string
suddenly starts being considered anon-empty-string
.Fails with a 1000-char literal
https://psalm.dev/r/05f9492c43
Same exact thing, but with 1 fewer char passes
https://psalm.dev/r/1059fb0c2f
Found this adding
literal-string
to methods taking SQL strings. Some long/complex queries were triggering warnings of ArgumentTypeCoercion despite being literals. The only apparent trigger was when the query's length.Psalm 4.23.0@f1fe6ff483bf325c803df9f510d09a03fd796f88
The text was updated successfully, but these errors were encountered: