Skip to content

Convert float value to string with ScalarArgumentToExpectedParamTypeRector rule. #9358

@laurentmuller

Description

@laurentmuller

Bug Report

Subject Details
Rector version 2.1.6

Minimal PHP Code Causing Issue

class Column
{
    public function __construct(private ?string $text = null, private float $width = 0.0)
    {
    }

    public function instance(?string $text = null, float $width = 0.0)
        return new self($text, $width);
    }
}

use PHPUnit\Framework\TestCase;

class ColumnTest extends TestCase
{
    public function testWidth(): void
    {
        $column = Column::instance(width: 10.5)
        // ...
    }
}

When running rector:

- Column::instance(width: 10.0));
+ Column::instance(width: '10'));

Expected Behaviour

No change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions