-
Notifications
You must be signed in to change notification settings - Fork 667
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
Enums: new function enum_exists
#6431
Comments
psalm.dev/r/9b5935609d |
I found these snippets: https://psalm.dev/r/9b5935609d<?php
enum Status: int
{
case FOO;
case BAR = 42;
}
enum_exists(Status::FOO); //returns true
enum_exists(Status::BAZ); //returns false
|
enum_exists
I should be able to do this one as well if you want @weirdan? |
Sure. Although this one will need some more work, as it's similar to $ rg "'class_exists'" src
src/Psalm/Internal/Codebase/Functions.php
452: 'class_exists', // impure by virtue of triggering autoloader
src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php
1772: && strtolower($stmt->name->parts[0]) === 'class_exists'
src/Psalm/Internal/Analyzer/Statements/Expression/Call/NamedFunctionCallHandler.php
81: if ($function_id === 'class_exists') {
src/Psalm/Internal/PhpVisitor/Reflector/ExpressionResolver.php
327: if ($function->name->parts === ['class_exists']
src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentsAnalyzer.php
169: if ($method_id === 'class_exists' |
If you're stuck, just ping us, we'll help :) |
Interesting, I'll give it a crack tonight and let you know if I get stuck. |
I had a first attempt last night but got a little lost. I'll try again tonigh and tell you where I'm getting lost if I don't make any progress. |
Hey, sorry I've gone quiet. I haven't had enough time to get into this. Please let anyone else pick this up if they want to do it. Whenever I do have time I'll pick something else up. |
I took a stab at this one and was able create some additional test cases in I started to fill in the gaps you pointed out.
Also from the documentation I noticed the You can see my fork at https://github.com/DannyvdSluijs/psalm/tree/6431-new-function--enum_exists if you're interested and it would help. The test are still failing. |
Your call. You could probably go the way of
Please try without adding anything here. I'm not actually sure why we have specific handling here, we'll see if we can make the tests pass without it Seems like a good start :) |
psalm.dev/r/9b5935609d
Guide to editing callmaps: Editing callmaps.
The text was updated successfully, but these errors were encountered: