Skip to content

Incorrect behavior of ManualJsonStringToJsonEncodeArrayRector #6637

@zingimmick

Description

@zingimmick

Bug Report

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

Rule ManualJsonStringToJsonEncodeArrayRector always convert manual JSON string to \Nette\Utils\Json::encode array even if the class 'Nette\Utils\Json' not found.

Minimal PHP Code Causing Issue

See https://getrector.org/demo/1ebfe3fd-7e9c-614c-9bb2-274ba6035927

<?php

final class DemoFile
{
    public function run()
    {
        $someJsonAsString = '{"role_name":"admin","numberz":{"id":"10"}}';
    }
}

Responsible rules

  • ManualJsonStringToJsonEncodeArrayRector

Expected Behavior

Any of the following options:

  • Convert manual JSON string to json_encode array and let JsonDecodeEncodeToNetteUtilsJsonDecodeEncodeRector in rector-nette handle the rest.
  • Convert manual JSON string to json_encode array if the class 'Nette\Utils\Json' not found.

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