Skip to content

Infinite loop/timeout DowngradePhp73JsonConstRector / DowngradeNullCoalescingOperatorRector #7843

@defunctl

Description

@defunctl

Bug Report

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

Minimal PHP Code Causing Issue

See https://getrector.com/demo/d8a840ee-144a-42a2-a14a-bdae1557a8ad

<?php

final class DemoFile
{
    public function run(?int $flags = null)
    {
        $flags ??= JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT | JSON_PRESERVE_ZERO_FRACTION | JSON_THROW_ON_ERROR;
        
        json_encode([], $flags);
    }
}

Responsible rules

  • DowngradeNullCoalescingOperatorRector
  • DowngradePhp73JsonConstRector

Expected Behavior

It should not timeout and complete with:

$flags = $flags ?? JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT | JSON_PRESERVE_ZERO_FRACTION;

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