Skip to content

Commit

Permalink
minor #132 Upgrade rector to 1.0 (alexander-schranz)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.4 branch.

Discussion
----------

seperate to the symfony upgrade we can ugprade rector.

Commits
-------
  Upgrade rector
  Upgrade rector to 1.0
  • Loading branch information
TheMilek authored Jul 15, 2024
2 parents 7971415 + f5dc6ec commit 33f428e
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 27 deletions.
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"symfony/twig-bundle": "^5.4 || ^6.0",
"twig/twig": "^2.0 || ^3.0",
"vimeo/psalm": "5.20.0",
"rector/rector": "^0.11.57"
"rector/rector": "^1.0"
},
"config": {
"allow-plugins": {
Expand Down Expand Up @@ -79,9 +79,11 @@
"analyse": [
"@composer validate --strict",
"vendor/bin/ecs check spec src tests || true",
"vendor/bin/psalm"
"vendor/bin/psalm",
"vendor/bin/rector process --dry-run"
],
"fix": [
"vendor/bin/rector process",
"vendor/bin/ecs check spec src tests --fix"
],
"test": [
Expand Down
25 changes: 14 additions & 11 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@

declare(strict_types=1);

use Rector\Core\Configuration\Option;
use Rector\Php74\Rector\Property\TypedPropertyRector;
use Rector\Set\ValueObject\SetList;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Rector\Config\RectorConfig;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictSetUpRector;

return static function (ContainerConfigurator $containerConfigurator): void
{
$parameters = $containerConfigurator->parameters();
$parameters->set(Option::AUTO_IMPORT_NAMES, true);
$parameters->set(Option::IMPORT_SHORT_CLASSES, false);
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths(['src', 'tests']);

$services = $containerConfigurator->services();
$services->set(TypedPropertyRector::class);
$rectorConfig->importNames();
$rectorConfig->importShortClasses(false);

$rectorConfig->rules([
TypedPropertyFromStrictConstructorRector::class,
TypedPropertyFromStrictSetUpRector::class,
TypedPropertyFromAssignsRector::class,
]);
};
6 changes: 2 additions & 4 deletions src/Asset/Package/PathPackage.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@
*/
class PathPackage extends BasePathPackage
{
/** @var ThemeContextInterface */
protected $themeContext;
protected ThemeContextInterface $themeContext;

/** @var PathResolverInterface */
protected $pathResolver;
protected PathResolverInterface $pathResolver;

public function __construct(
string $basePath,
Expand Down
6 changes: 2 additions & 4 deletions src/Model/Theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@

class Theme implements ThemeInterface
{
/** @var string */
protected $name;
protected string $name;

/** @var string */
protected $path;
protected string $path;

/** @var string|null */
protected $title;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
final class TranslatorLoaderProvider implements TranslatorLoaderProviderInterface
{
/** @var LoaderInterface[] */
private $loaders;
private array $loaders;

/**
* @param LoaderInterface[] $loaders
Expand Down
2 changes: 1 addition & 1 deletion src/Translation/ThemeAwareTranslator.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
final class ThemeAwareTranslator implements TranslatorInterface, TranslatorBagInterface, WarmableInterface, LocaleAwareInterface
{
/** @var TranslatorInterface&LocaleAwareInterface&TranslatorBagInterface */
private $translator;
private TranslatorInterface $translator;

private ThemeContextInterface $themeContext;

Expand Down
12 changes: 8 additions & 4 deletions tests/Application/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@

namespace Sylius\Bundle\ThemeBundle\Tests\Application;

use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Bundle\TwigBundle\TwigBundle;
use Sylius\Bundle\ThemeBundle\Tests\Application\TestBundle\TestBundle;
use Sylius\Bundle\ThemeBundle\SyliusThemeBundle;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\HttpKernel\Kernel as HttpKernel;

Expand All @@ -21,10 +25,10 @@ final class Kernel extends HttpKernel
public function registerBundles(): iterable
{
return [
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new \Symfony\Bundle\TwigBundle\TwigBundle(),
new \Sylius\Bundle\ThemeBundle\Tests\Application\TestBundle\TestBundle(),
new \Sylius\Bundle\ThemeBundle\SyliusThemeBundle(),
new FrameworkBundle(),
new TwigBundle(),
new TestBundle(),
new SyliusThemeBundle(),
];
}

Expand Down

0 comments on commit 33f428e

Please sign in to comment.