Skip to content

Variable argument affectation in function argument crash rector with ChangeReadOnlyVariableWithDefaultValueToConstantRector rule #7805

@jbcr

Description

@jbcr

Bug Report

Subject Details
Rector version Rector 0.15.17

Rector crash on apply the rule ChangeReadOnlyVariableWithDefaultValueToConstantRector.

Minimal PHP Code Causing Issue

        $c = base64_decode(str_replace(['--', '_'], ['+', '/'], $key));

        $ivlen = openssl_cipher_iv_length($cipher = "AES-128-CFB");
        $iv = substr($c, 0, $ivlen);
        $hmac = substr($c, $ivlen, $sha2len = 32);
        $ciphertext_raw = substr($c, $ivlen + $sha2len); //<- When I comment since this line, the rule doesn't crash
        $original_plaintext = openssl_decrypt($ciphertext_raw, $cipher, $this->privateKey, options: 0,  iv: $iv);
        $calcmac = hash_hmac('sha256', $ciphertext_raw, $this->privateKey, binary: true);

Expected Behaviour

Change the code to transform the $sha2len = 32 and $cipher = "AES-128-CFB" variable affectation to constants.

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