Skip to content

Conversation

@TomasVotruba
Copy link
Member

@TomasVotruba TomasVotruba commented Sep 3, 2025

Sometimes, test pass invalid type of scalar value. But this type is already defined in the method parameter.

Let's alling tests with code in automated fashion 🥳

final class SomeClassWithSetter
{
    public function setPhoneNumber(string $phoneNumber)
    {
    }
}
use PHPUnit\Framework\TestCase;


final class SimpleMethodCall extends TestCase
{
    public function test()
    {
        $someClassWithSetter = new SomeClassWithSetter();
-       $someClassWithSetter->setPhoneNumber(123456);
+       $someClassWithSetter->setPhoneNumber('123456');
    }
}

@TomasVotruba TomasVotruba changed the title tv tests pass arg retype [code-quality] Add ScalarArgumentToExpectedParamTypeRector Sep 3, 2025
@TomasVotruba TomasVotruba force-pushed the tv-tests-pass-arg-retype branch from 012ad6b to 16e08d3 Compare September 3, 2025 17:22
@TomasVotruba TomasVotruba force-pushed the tv-tests-pass-arg-retype branch from df8e703 to bca109c Compare September 3, 2025 17:25
@TomasVotruba TomasVotruba enabled auto-merge (squash) September 3, 2025 17:29
@TomasVotruba TomasVotruba merged commit a910a8b into main Sep 3, 2025
6 checks passed
@TomasVotruba TomasVotruba deleted the tv-tests-pass-arg-retype branch September 3, 2025 17:30
}

$scope = ScopeFetcher::fetch($call);
$extendedMethodReflection = $classReflection->getMethod($methodName, $scope);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$extendedMethodReflection = $classReflection->getMethod($methodName, $scope);
$extendedMethodReflection = $classReflection->getNativeMethod($methodName);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants