rector: PHPStan\Type\IntegerRangeType::fromInterval(): Argument #1 ($min) must be of type ?int

Bug Report

Subject Details
Rector version 0.12.16 (528d6dd6986c529246832f686e482c3f7bc46a40)
PHP version 8.0

I’m getting an error that shows PHPStan backtrace but doesn’t point me to where the issue is in my code, so im not sure how to fix it.

[parsing] app/redacted-file.php

In IntegerRangeType.php line 25:

  PHPStan\Type\IntegerRangeType::fromInterval(): Argument #1 ($min) must be of type ?int, float given, called in phar:///Users/phil/src/cloudbeds/myfrontdesk-docker-local/microservice-compset-rates/ven
  dor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php on line 3590

Minimal PHP Code Causing Issue

Trial and error showed me that commenting out this code would let rector pass instead of tripping on that error.

 <?php

function convert($amount = null)
{
    // absolute value of amount
    $amount = abs($amount);
    // convert amount to cents for more accuracy
    if ($amount >= 1000000000 && $amount < 1000000000000) {
        $amount = $amount * 1000000000000;
    }
    return $amount;
}

Expected Behaviour

Rector could perhaps look at the backtrace to help identify what is wrong with the the code and where?

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (9 by maintainers)

Most upvoted comments

Solved with using rector global installation.

@philsturgeon yes, you can send me an email to samsonasik@gmail.com for your availability for remote debugging 😉

Thank you for looking into this. I’m having the same trouble recreating in a standalone repo.

I’ve got the rector.php, phpstan.neon, composer.json and recreatebug.php file all moved over and it’s running just fine.

▶ ./vendor/bin/rector process Rectatebug.php -vvv --clear-cache
[parsing] Rectatebug.php
[refactoring] Rectatebug.php
    [applying] Rector\Php80\Rector\FunctionLike\UnionTypesRector
    [applying] Rector\Php80\Rector\FuncCall\ClassOnObjectRector
    [applying] Rector\Php80\Rector\FuncCall\TokenGetAllToObjectRector
    [applying] Rector\Renaming\Rector\FuncCall\RenameFunctionRector
    [applying] Rector\Arguments\Rector\FuncCall\FunctionArgumentDefaultValueReplacerRector
    [applying] Rector\Php80\Rector\FuncCall\Php8ResourceReturnToObjectRector
[post rectors] Rectatebug.php
    [post rector] Rector\PostRector\Rector\NodeToReplacePostRector
    [post rector] Rector\PostRector\Rector\NodeAddingPostRector
    [post rector] Rector\PostRector\Rector\PropertyAddingPostRector
    [post rector] Ssch\TYPO3Rector\Rector\PostRector\FullQualifiedNamePostRector
    [post rector] Rector\PostRector\Rector\NodeRemovingPostRector
    [post rector] Rector\PostRector\Rector\ClassRenamingPostRector
    [post rector] Rector\PostRector\Rector\NameImportingPostRector
    [post rector] Rector\PostRector\Rector\UseAddingPostRector
[print] Rectatebug.php


 [OK] Rector is done!

What else can I try? Do you ever do freelance, maybe have an hourly rate for remote debugging?