Skip to content

Appending an array item to another one doesn't work as expected #1019

@simonschaufi

Description

@simonschaufi

I'm creating a rector rule and do the following:

  1. create a native php array
  2. parse it with the php parser
  3. append the new array item to another php array which is there as parsed array

Expected:

<?php\n
\n
return [\n
    'tools_toolsmaintenance' => [\n
        'parent' => 'tools',\n
        'access' => 'systemMaintainer',\n
        'path' => '/module/tools/toolsmaintenance',\n
        'iconIdentifier' => 'module-install-maintenance',\n
        'labels' => 'LLL:EXT:install/Resources/Private/Language/ModuleInstallMaintenance.xlf',\n
        'routes' => [\n
            '_default' => [\n
                'target' => 'TYPO3\\CMS\\Install\\Controller\\BackendModuleController::maintenanceAction',\n
            ],\n
        ],\n
    ],\n
    'tools_toolssettings' => [\n
        'parent' => 'tools',\n
        'access' => 'systemMaintainer',\n
        'path' => '/module/tools/settings',\n
        'iconIdentifier' => 'module-install-settings',\n
        'labels' => 'LLL:EXT:install/Resources/Private/Language/ModuleInstallSettings.xlf',\n
        'routes' => [\n
            '_default' => [\n
                'target' => 'TYPO3\\CMS\\Install\\Controller\\BackendModuleController::settingsAction',\n
            ],\n
        ],\n
    ],\n
];\n

Actual:

<?php\n
\n
return [\n
    'tools_toolsmaintenance' => [\n
        'parent' => 'tools',\n
        'access' => 'systemMaintainer',\n
        'path' => '/module/tools/toolsmaintenance',\n
        'iconIdentifier' => 'module-install-maintenance',\n
        'labels' => 'LLL:EXT:install/Resources/Private/Language/ModuleInstallMaintenance.xlf',\n
        'routes' => [\n
            '_default' => [\n
                'target' => 'TYPO3\\CMS\\Install\\Controller\\BackendModuleController::maintenanceAction',\n
            ],\n
        ],\n
    ], 'tools_toolsmaintenance' => [\n
        'parent' => 'tools',\n
        'access' => 'systemMaintainer',\n
        'path' => '/module/tools/toolsmaintenance',\n
        'iconIdentifier' => 'module-install-maintenance',\n
        'labels' => 'LLL:EXT:install/Resources/Private/Language/ModuleInstallMaintenance.xlf',\n
        'routes' => [\n
            '_default' => [\n
                'target' => 'TYPO3\\CMS\\Install\\Controller\\BackendModuleController::maintenanceAction',\n
            ],\n
        ],\n
    ],\n
];\n

The strange thing is that the merged array looks good in xdebug:

image

but the output is a duplicate of the original array item and I don't understand why this is happening.

My PR of the rule is here sabbelasichon/typo3-rector#4243 and the important section is here: https://github.com/sabbelasichon/typo3-rector/pull/4243/files#diff-6659bbad2dc4a8d574769de61529b6e6d9387889d39813bbe2f246c873ba3bfeR231

and here: https://github.com/sabbelasichon/typo3-rector/pull/4243/files#diff-6659bbad2dc4a8d574769de61529b6e6d9387889d39813bbe2f246c873ba3bfeR425-R447

Can you please help me as I'm totally stuck? I don't understand what is happening in the PrettyPrinterAbstract class as it is quite complex

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions