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

Comparison operation does not works for 0.12.51 #3993

Closed
limingxinleo opened this issue Oct 24, 2020 · 3 comments
Closed

Comparison operation does not works for 0.12.51 #3993

limingxinleo opened this issue Oct 24, 2020 · 3 comments

Comments

@limingxinleo
Copy link

<?php

abstract class AbstractConstants
{
    public static function __callStatic($name, $arguments)
    {
        if (! isset($arguments) || count($arguments) === 0) {
            throw new \Exception('The Code is required');
        }

        $code = $arguments[0];
        $name = strtolower(substr($name, 3));

        array_shift($arguments);

        $message = '';

        $count = count($arguments);
        if ($count > 0) {
            return sprintf($message, ...(array) $arguments[0]);
        }

        return $message;
    }
}
$ vendor/bin/phpstan analyse -l 5 index.php
 1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

 ------ --------------------------------------------------------------------
  Line   index.php
 ------ --------------------------------------------------------------------
  19     Comparison operation ">" between int<1, max> and 0 is always true.
  23     Unreachable statement - code above always terminates.
 ------ --------------------------------------------------------------------


 [ERROR] Found 2 errors

If the $arguments is [0], the operation ">" should between int <0, max>

@limingxinleo
Copy link
Author

@ondrejmirtes
Copy link
Member

Fixed: phpstan/phpstan-src@26d29ec

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants