Skip to content

Commit 10c3875

Browse files
committed
Updated Rector to commit da48be85d84c065d1f018c9074694980d2351e77
rectorphp/rector-src@da48be8 [NetteUtils] Bind nette/utils rules to installed package version (#8275)
1 parent 0bf34f1 commit 10c3875

7 files changed

Lines changed: 27 additions & 11 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
use Rector\Config\RectorConfig;
77
use Rector\NetteUtils\Rector\StaticCall\UtilsJsonStaticCallNamedArgRector;
8+
// applies to any installed nette/utils version, the rules inside are bound
9+
// to the exact version they are available from
810
return static function (RectorConfig $rectorConfig): void {
911
$rectorConfig->rules([UtilsJsonStaticCallNamedArgRector::class]);
1012
};

rules/NetteUtils/Rector/StaticCall/UtilsJsonStaticCallNamedArgRector.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,23 @@
99
use PhpParser\Node\Identifier;
1010
use Rector\Rector\AbstractRector;
1111
use Rector\TypeDeclarationDocblocks\Enum\NetteClassName;
12+
use Rector\VersionBonding\Contract\ComposerPackageConstraintInterface;
13+
use Rector\VersionBonding\ValueObject\ComposerPackageConstraint;
1214
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
1315
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
1416
/**
1517
* @see \Rector\Tests\NetteUtils\Rector\StaticCall\UtilsJsonStaticCallNamedArgRector\UtilsJsonStaticCallNamedArgRectorTest
1618
*/
17-
final class UtilsJsonStaticCallNamedArgRector extends AbstractRector
19+
final class UtilsJsonStaticCallNamedArgRector extends AbstractRector implements ComposerPackageConstraintInterface
1820
{
21+
/**
22+
* The bool $pretty and bool $forceArrays params were added in nette/utils 4.0,
23+
* before that both methods took int $flags
24+
*/
25+
public function provideComposerPackageConstraint(): ComposerPackageConstraint
26+
{
27+
return new ComposerPackageConstraint('nette/utils', '>=4.0');
28+
}
1929
public function getRuleDefinition(): RuleDefinition
2030
{
2131
return new RuleDefinition('Change `' . Json::class . '::encode()` and `decode()` to named args', [new CodeSample(<<<'CODE_SAMPLE'

src/Application/VersionResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ final class VersionResolver
1919
* @api
2020
* @var string
2121
*/
22-
public const PACKAGE_VERSION = '0e8debcce2038e1f01c29a1525e9e5306ef3c2c6';
22+
public const PACKAGE_VERSION = 'da48be85d84c065d1f018c9074694980d2351e77';
2323
/**
2424
* @api
2525
* @var string
2626
*/
27-
public const RELEASE_DATE = '2026-08-03 14:40:17';
27+
public const RELEASE_DATE = '2026-08-03 16:55:51';
2828
/**
2929
* @var int
3030
*/

src/Configuration/RectorConfigBuilder.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ public function withPreparedSets(bool $deadCode = \false, bool $codeQuality = \f
473473
}
474474
public function withComposerBased(bool $twig = \false, bool $doctrine = \false, bool $phpunit = \false, bool $symfony = \false, bool $netteUtils = \false, bool $laravel = \false, bool $drupal = \false): self
475475
{
476-
$setMap = [SetGroup::TWIG => $twig, SetGroup::DOCTRINE => $doctrine, SetGroup::NETTE_UTILS => $netteUtils, SetGroup::LARAVEL => $laravel, SetGroup::DRUPAL => $drupal];
476+
$setMap = [SetGroup::TWIG => $twig, SetGroup::DOCTRINE => $doctrine, SetGroup::LARAVEL => $laravel, SetGroup::DRUPAL => $drupal];
477477
foreach ($setMap as $setPath => $isEnabled) {
478478
if ($isEnabled) {
479479
$this->setGroups[] = $setPath;
@@ -487,6 +487,10 @@ public function withComposerBased(bool $twig = \false, bool $doctrine = \false,
487487
// single set, as every rule inside is bound to the installed Symfony package version on its own
488488
$this->sets[] = SymfonySetList::COMPOSER_BASED;
489489
}
490+
if ($netteUtils) {
491+
// single set, as every rule inside is bound to the installed nette/utils version on its own
492+
$this->sets[] = SetList::NETTE_UTILS_COMPOSER_BASED;
493+
}
490494
return $this;
491495
}
492496
/**

src/Set/Enum/SetGroup.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@ final class SetGroup
3636
* @var string
3737
*/
3838
public const SYMFONY = 'symfony';
39-
/**
40-
* Version-based set provider
41-
* @var string
42-
*/
43-
public const NETTE_UTILS = 'nette-utils';
4439
/**
4540
* Version-based set provider
4641
* @var string

src/Set/SetProvider/CoreSetProvider.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use Rector\Set\Contract\SetInterface;
77
use Rector\Set\Contract\SetProviderInterface;
88
use Rector\Set\Enum\SetGroup;
9-
use Rector\Set\ValueObject\ComposerTriggeredSet;
109
use Rector\Set\ValueObject\Set;
1110
final class CoreSetProvider implements SetProviderInterface
1211
{
@@ -15,6 +14,6 @@ final class CoreSetProvider implements SetProviderInterface
1514
*/
1615
public function provide(): array
1716
{
18-
return [new Set(SetGroup::CORE, 'Code Quality', __DIR__ . '/../../../config/set/code-quality.php'), new Set(SetGroup::CORE, 'Coding Style', __DIR__ . '/../../../config/set/coding-style.php'), new Set(SetGroup::CORE, 'Dead Code', __DIR__ . '/../../../config/set/dead-code.php'), new Set(SetGroup::CORE, 'DateTime to Carbon', __DIR__ . '/../../../config/set/datetime-to-carbon.php'), new Set(SetGroup::CORE, 'Instanceof', __DIR__ . '/../../../config/set/instanceof.php'), new Set(SetGroup::CORE, 'Early return', __DIR__ . '/../../../config/set/early-return.php'), new Set(SetGroup::CORE, 'Gmagick to Imagick', __DIR__ . '/../../../config/set/gmagick-to-imagick.php'), new Set(SetGroup::CORE, 'Naming', __DIR__ . '/../../../config/set/naming.php'), new Set(SetGroup::CORE, 'Privatization', __DIR__ . '/../../../config/set/privatization.php'), new Set(SetGroup::CORE, 'Type Declarations', __DIR__ . '/../../../config/set/type-declaration.php'), new ComposerTriggeredSet(SetGroup::NETTE_UTILS, 'nette/utils', '4.0', __DIR__ . '/../../../config/set/nette-utils/nette-utils4.php')];
17+
return [new Set(SetGroup::CORE, 'Code Quality', __DIR__ . '/../../../config/set/code-quality.php'), new Set(SetGroup::CORE, 'Coding Style', __DIR__ . '/../../../config/set/coding-style.php'), new Set(SetGroup::CORE, 'Dead Code', __DIR__ . '/../../../config/set/dead-code.php'), new Set(SetGroup::CORE, 'DateTime to Carbon', __DIR__ . '/../../../config/set/datetime-to-carbon.php'), new Set(SetGroup::CORE, 'Instanceof', __DIR__ . '/../../../config/set/instanceof.php'), new Set(SetGroup::CORE, 'Early return', __DIR__ . '/../../../config/set/early-return.php'), new Set(SetGroup::CORE, 'Gmagick to Imagick', __DIR__ . '/../../../config/set/gmagick-to-imagick.php'), new Set(SetGroup::CORE, 'Naming', __DIR__ . '/../../../config/set/naming.php'), new Set(SetGroup::CORE, 'Privatization', __DIR__ . '/../../../config/set/privatization.php'), new Set(SetGroup::CORE, 'Type Declarations', __DIR__ . '/../../../config/set/type-declaration.php')];
1918
}
2019
}

src/Set/ValueObject/SetList.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ final class SetList
3939
* @var string
4040
*/
4141
public const NAMED_ARGS = __DIR__ . '/../../../config/set/named-args.php';
42+
/**
43+
* Applies to any installed nette/utils version, the rules inside are bound
44+
* to the exact version they are available from
45+
* @var string
46+
*/
47+
public const NETTE_UTILS_COMPOSER_BASED = __DIR__ . '/../../../config/set/nette-utils/composer-based.php';
4248
/**
4349
* Opinionated rules that match rector coding standard
4450
* @var string

0 commit comments

Comments
 (0)