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

TypeDoesNotContainType issues with is_numeric() and strings #26

Closed
erunion opened this issue Dec 16, 2016 · 1 comment · Fixed by #29
Closed

TypeDoesNotContainType issues with is_numeric() and strings #26

erunion opened this issue Dec 16, 2016 · 1 comment · Fixed by #29
Labels

Comments

@erunion
Copy link
Contributor

erunion commented Dec 16, 2016

I have the following code that's parsing annotations for error codes, by looking for (\SomeError\Class::CASE) or (1337). Psalm seems to be having issues with the is_numeric check I'm doing to verify if the found error code is a numeric, or a FQN class name.

if (preg_match(self::REGEX_ERROR_CODE, $doc, $matches)) {
    $error_code = substr($matches[1], 1, -1);
    if (is_numeric($error_code)) {
        $parsed['error_code'] = $error_code;
    } else {
        if (!defined($error_code)) {
            throw UncallableErrorCodeException::create($this->docblock, $this->controller, $this->method);
        }

        $parsed['error_code'] = constant($error_code);
    }

    $doc = trim(preg_replace(self::REGEX_ERROR_CODE, '', $doc));
}
$ ./vendor/bin/psalm 
ERROR: TypeDoesNotContainType - src/Parser/Annotations/ThrowsAnnotation.php:116 - Cannot resolve types for $error_code - string does not contain numeric
            if (is_numeric($error_code)) {

Ideas?

@erunion erunion added the bug label Dec 16, 2016
@muglug
Copy link
Collaborator

muglug commented Dec 16, 2016

Definitely a bug, will fix within 24 hours or so.

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

Successfully merging a pull request may close this issue.

2 participants