Page MenuHomePhorge

April 5, 2022
Updated 962 Days AgoPublic

This document has been moved to /w/planning_meetings/2022-05-05/. You can edit it to put new content here, or use history to revert to an earlier version.

Referenced Files
F146502: image.png
Apr 9 2022, 19:43
Tokens
"Mountain of Wealth" token, awarded by 20after4.
Last Author
Matthew
Last Edited
May 3 2022, 18:55

Event Timeline

Matthew added subscribers: dcog, 20after4.

Some initial findings on Rector...

Installation:

mkdir rector-test && cd rector-test
git clone https://github.com/phacility/arcanist.git
git clone https://github.com/phacility/phabricator.git
composer require rector/rector --dev

Create rector.php in same directory. Example:

<?php

declare(strict_types=1);

use Rector\Core\Configuration\Option;
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
use Rector\Renaming\Rector\Name\RenameClassRector;
use Rector\Renaming\Rector\String_\RenameStringRector;
//use Rector\Set\ValueObject\LevelSetList;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
	$parameters = $containerConfigurator->parameters();
	$parameters->set(Option::PATHS, [
		__DIR__ . '/arcanist',
		__DIR__ . '/phabricator',
	]);

	// Define what rule sets will be applied
	//$containerConfigurator->import(LevelSetList::UP_TO_PHP_81);

	// Configure services / rectors
	$services = $containerConfigurator->services();

	$services->set(RenameStringRector::class)
		->configure([
			'Phabricator' => 'Phorge',
		]);

	$services->set(RenameClassRector::class)
		->configure([
			'PhabricatorHandleQuery' => 'PlatformHandleQuery',
			'PhabricatorAuthSSHKeyQuery' => 'PlatformAuthSSHKeyQuery',
			'PhabricatorPolicyInterface' => 'PlatformPolicyInterface'
		]);

	$services->set(RenameFunctionRector::class)
		->configure([
			'phabricator_date' => 'platform_date',
			'phabricator_time' => 'platform_time',
			'phabricator_read_config_file' => 'platform_read_config_file',
			'phabricator_startup' => 'platform_startup',
		]);
};

Do a dry run:

vendor/bin/rector process --dry-run

Wait a while, watching as your CPU weeps and moans in agony (make sure to save other files first in case it comes to a halt for a few minutes). If it can handle it eventually, you'll see a large amount of output like this:

image.png (957×538 px, 70 KB)

Also got a lot of these errors:

[ERROR] Could not process "phabricator/src/view/page/PhabricatorStandardPageView.php" file, due to: "PHPStan\BetterReflection\Reflection\ReflectionClass "AphrontResponseProducerInterface" could not be found in the located source". On line: 26

I think this is because it's not seeing the connection between the arcanist and phabricator directories. Fairly certain I saw somewhere that there's a way to have it autoload or look in other directories, so there's still more digging to do on setting up the rector.php file.. hopefully the way those two directories interact is supported in Rector