Issue Task Closed

#61788Use fully class name resolution in PHP 5.5

Xavier Perseguers 09/22/14, 07:33 updated 10/02/18, 11:50

Description

Since PHP 5.5 is a requirement, calls to GeneralUtility::makeInstance should use the ::class construct instead of a string.

rewrite.php

<?php
$fileName = $argv[1];
$contents = file_get_contents($fileName);

$contents = preg_replace_callback(
    "/::makeInstance\\('([^']+)'/",
    function ($matches) {
        return '::makeInstance(\\' . str_replace('\\\\', '\\', $matches[1]) . '::class';
    },
    $contents
);

file_put_contents($fileName, $contents);

Command

$ for f in $(grep -sr "::makeInstance(" * | cut -d: -f1 | egrep ".php$" | grep -v "rewrite.php" | sort -u); do php rewrite.php $f; done

Reviews 2