Skip to content

Comparison operation does not works for 0.12.51 #3993

@limingxinleo

Description

@limingxinleo
<?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>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions