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

Incorrect behavior of ParamTypeByMethodCallTypeRector #8872

Open
staabm opened this issue Oct 25, 2024 · 0 comments · May be fixed by rectorphp/rector-src#6401
Open

Incorrect behavior of ParamTypeByMethodCallTypeRector #8872

staabm opened this issue Oct 25, 2024 · 0 comments · May be fixed by rectorphp/rector-src#6401
Labels

Comments

@staabm
Copy link
Contributor

staabm commented Oct 25, 2024

Bug Report

Subject Details
Rector version last dev-main
Installed as composer dependency

Minimal PHP Code Causing Issue

See https://getrector.com/demo/08d68709-877e-4905-a393-ba6faea77000

<?php

namespace shop\basket\viewmodel;

use Webmozart\Assert\Assert;

/**
 * @immutable
 */
final class TestObj
{
    public string $code;

    public function __construct(string $code)
    {
        $this->code = $code;
    }

    public static function tryFromUntrusted($code): ?self
    {
        $ok = \is_string($code) && self::isCodeOk($code);
        if (! $ok) {
            return null;
        }

        return new self($code);
    }

    private static function isCodeOk(string $code): bool
    {
        return true;
    }
}

Responsible rules

  • ParamTypeByMethodCallTypeRector

Expected Behavior

rector should not infer string param type, because the code is meant to work for anything (on a php version which does not support a mixed param type)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant