Skip to content

Commit

Permalink
Remove deprecated TemplateResolverInterface, RectorServiceConfigurator (
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Feb 6, 2023
1 parent 43dd2ef commit 4ef31e9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 77 deletions.
42 changes: 21 additions & 21 deletions src/Configuration/Option.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final class Option
public const AUTOLOAD_FILE = 'autoload-file';

/**
* @deprecated Use @see \Rector\Config\RectorConfig::bootstrapFiles() instead
* @internal Use @see \Rector\Config\RectorConfig::bootstrapFiles() instead
* @var string
*/
public const BOOTSTRAP_FILES = 'bootstrap_files';
Expand All @@ -46,37 +46,37 @@ final class Option
public const NO_PROGRESS_BAR = 'no-progress-bar';

/**
* @deprecated Use @see \Rector\Config\RectorConfig::phpVersion() instead
* @internal Use @see \Rector\Config\RectorConfig::phpVersion() instead
* @var string
*/
public const PHP_VERSION_FEATURES = 'php_version_features';

/**
* @deprecated Use @see \Rector\Config\RectorConfig::importNames() instead
* @internal Use @see \Rector\Config\RectorConfig::importNames() instead
* @var string
*/
public const AUTO_IMPORT_NAMES = 'auto_import_names';

/**
* @deprecated Use @see \Rector\Config\RectorConfig::importNames() instead
* @internal Use @see \Rector\Config\RectorConfig::importNames() instead
* @var string
*/
public const AUTO_IMPORT_DOC_BLOCK_NAMES = 'auto_import_doc_block_names';

/**
* @deprecated Use @see \Rector\Config\RectorConfig::importShortClasses() instead
* @internal Use @see \Rector\Config\RectorConfig::importShortClasses() instead
* @var string
*/
public const IMPORT_SHORT_CLASSES = 'import_short_classes';

/**
* @deprecated Use @see \Rector\Config\RectorConfig::symfonyContainerXml() instead
* @internal Use @see \Rector\Config\RectorConfig::symfonyContainerXml() instead
* @var string
*/
public const SYMFONY_CONTAINER_XML_PATH_PARAMETER = 'symfony_container_xml_path';

/**
* @deprecated Use @see \Rector\Config\RectorConfig::symfonyContainerPhp()
* @internal Use @see \Rector\Config\RectorConfig::symfonyContainerPhp()
* @var string
*/
public const SYMFONY_CONTAINER_PHP_PATH_PARAMETER = 'symfony_container_php_path';
Expand All @@ -87,50 +87,50 @@ final class Option
public const CLEAR_CACHE = 'clear-cache';

/**
* @deprecated Use @see \Rector\Config\RectorConfig::parallel() instead
* @internal Use @see \Rector\Config\RectorConfig::parallel() instead
* @var string
*/
public const PARALLEL = 'parallel';

/**
* @deprecated Use @see \Rector\Config\RectorConfig::paths() instead
* @internal Use @see \Rector\Config\RectorConfig::paths() instead
* @var string
*/
public const PATHS = 'paths';

/**
* @deprecated Use @see \Rector\Config\RectorConfig::autoloadPaths() instead
* @internal Use @see \Rector\Config\RectorConfig::autoloadPaths() instead
* @var string
*/
public const AUTOLOAD_PATHS = 'autoload_paths';

/**
* @deprecated Use @see \Rector\Config\RectorConfig::skip() instead
* @internal Use @see \Rector\Config\RectorConfig::skip() instead
* @var string
*/
public const SKIP = 'skip';

/**
* @deprecated Use RectorConfig::fileExtensions() instead
* @internal Use RectorConfig::fileExtensions() instead
* @var string
*/
public const FILE_EXTENSIONS = 'file_extensions';

/**
* @deprecated Use RectorConfig::nestedChainMethodCallLimit() instead
* @internal Use RectorConfig::nestedChainMethodCallLimit() instead
* @var string
*/
public const NESTED_CHAIN_METHOD_CALL_LIMIT = 'nested_chain_method_call_limit';

/**
* @deprecated Use RectorConfig::cacheDirectory() instead
* @internal Use RectorConfig::cacheDirectory() instead
* @var string
*/
public const CACHE_DIR = 'cache_dir';

/**
* Cache backend. Most of the time we cache in files, but in ephemeral environment (e.g. CI), a faster `MemoryCacheStorage` can be usefull.
* @deprecated Use RectorConfig::cacheClass() instead
* @internal Use RectorConfig::cacheClass() instead
*
* @var class-string<CacheStorageInterface>
* @internal
Expand All @@ -153,7 +153,7 @@ final class Option
public const CONFIG = 'config';

/**
* @deprecated Use @see \Rector\Config\RectorConfig::phpstanConfig() instead
* @internal Use @see \Rector\Config\RectorConfig::phpstanConfig() instead
* @var string
*/
public const PHPSTAN_FOR_RECTOR_PATH = 'phpstan_for_rector_path';
Expand All @@ -179,19 +179,19 @@ final class Option
public const PARALLEL_PORT = 'port';

/**
* @deprecated Use @see \Rector\Config\RectorConfig::parallel() instead with pass int $jobSize parameter
* @internal Use @see \Rector\Config\RectorConfig::parallel() instead with pass int $jobSize parameter
* @var string
*/
public const PARALLEL_JOB_SIZE = 'parallel-job-size';

/**
* @deprecated Use @see \Rector\Config\RectorConfig::parallel() instead with pass int $maxNumberOfProcess parameter
* @internal Use @see \Rector\Config\RectorConfig::parallel() instead with pass int $maxNumberOfProcess parameter
* @var string
*/
public const PARALLEL_MAX_NUMBER_OF_PROCESSES = 'parallel-max-number-of-processes';

/**
* @deprecated Use @see \Rector\Config\RectorConfig::parallel() instead with pass int $seconds parameter
* @internal Use @see \Rector\Config\RectorConfig::parallel() instead with pass int $seconds parameter
* @var string
*/
public const PARALLEL_TIMEOUT_IN_SECONDS = 'parallel-timeout-in-seconds';
Expand All @@ -202,13 +202,13 @@ final class Option
public const MEMORY_LIMIT = 'memory-limit';

/**
* @deprecated Use @see \Rector\Config\RectorConfig::indent() method
* @internal Use @see \Rector\Config\RectorConfig::indent() method
* @var string
*/
public const INDENT_CHAR = 'indent-char';

/**
* @deprecated Use @see \Rector\Config\RectorConfig::indent() method
* @internal Use @see \Rector\Config\RectorConfig::indent() method
* @var string
*/
public const INDENT_SIZE = 'indent-size';
Expand Down
15 changes: 0 additions & 15 deletions src/Contract/Template/TemplateResolverInterface.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,52 +4,12 @@

namespace Rector\Core\DependencyInjection\Loader\Configurator;

use Rector\Core\Configuration\ValueObjectInliner;
use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
use Symfony\Component\DependencyInjection\Loader\Configurator\ServiceConfigurator;

/**
* @api
* Same as Symfony service configurator, with extra "configure()" method for easier DX
* Same as Symfony service configurator
*/
final class RectorServiceConfigurator extends ServiceConfigurator
{
/**
* @deprecated Use @see \Rector\Config\RectorConfig instead
* @param mixed[] $configuration
*/
public function configure(array $configuration): self
{
$this->ensureClassIsConfigurable($this->id);

// decorate with value object inliner so Symfony understands, see https://getrector.org/blog/2020/09/07/how-to-inline-value-object-in-symfony-php-config
array_walk_recursive($configuration, static function (&$value) {
if (is_object($value)) {
$value = ValueObjectInliner::inline($value);
}

return $value;
});

$this->call('configure', [$configuration]);

return $this;
}

private function ensureClassIsConfigurable(?string $class): void
{
if ($class === null) {
throw new InvalidConfigurationException('The class is missing');
}

if (! is_a($class, ConfigurableRectorInterface::class, true)) {
$errorMessage = sprintf(
'The service "%s" is not configurable. Make it implement "%s" or remove "configure()" call.',
$class,
ConfigurableRectorInterface::class,
);
throw new InvalidConfigurationException($errorMessage);
}
}
}

0 comments on commit 4ef31e9

Please sign in to comment.