Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"phpstan/phpstan-webmozart-assert": "^2.0",
"phpunit/phpunit": "^13.2",
"rector/jack": "^1.0",
"rector/rector-src": "dev-composer-triggered-set-version-constraint as dev-main",
"rector/rector-src": "dev-main",
"rector/swiss-knife": "^2.4",
"symplify/easy-coding-standard": "^13.2",
"symplify/phpstan-extensions": "^12.0",
Expand Down
20 changes: 19 additions & 1 deletion config/sets/composer-based.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,17 @@
use Rector\PHPUnit\AnnotationsToAttributes\Rector\ClassMethod\DataProviderAnnotationToAttributeRector;
use Rector\PHPUnit\AnnotationsToAttributes\Rector\ClassMethod\DependsAnnotationWithValueToAttributeRector;
use Rector\PHPUnit\AnnotationsToAttributes\Rector\ClassMethod\TestWithAnnotationToAttributeRector;
use Rector\PHPUnit\CodeQuality\Rector\Class_\AddIntersectionVarToMockObjectPropertyRector;
use Rector\PHPUnit\CodeQuality\Rector\Class_\AddStubIntersectionVarToStubPropertyRector;
use Rector\PHPUnit\CodeQuality\Rector\ClassMethod\BareCreateMockAssignToDirectUseRector;
use Rector\PHPUnit\PHPUnit110\Rector\CallLike\AssertContainsOnlyMethodCallRector;
use Rector\PHPUnit\PHPUnit110\Rector\ClassMethod\MockObjectArgCreateStubToCreateMockRector;
use Rector\PHPUnit\PHPUnit120\Rector\CallLike\CreateStubInCoalesceArgRector;
use Rector\PHPUnit\PHPUnit120\Rector\CallLike\CreateStubOverCreateMockArgRector;
use Rector\PHPUnit\PHPUnit120\Rector\Class_\AssertIsTypeMethodCallRector;
use Rector\PHPUnit\PHPUnit120\Rector\Class_\PropertyCreateMockToCreateStubRector;
use Rector\PHPUnit\PHPUnit120\Rector\ClassMethod\ExpressionCreateMockToCreateStubRector;
use Rector\PHPUnit\PHPUnit120\Rector\Property\MockObjectVarToStubRector;
use Rector\PHPUnit\ValueObject\AnnotationWithValueToAttribute;

/**
Expand All @@ -35,7 +43,17 @@
RequiresAnnotationWithValueToAttributeRector::class,
DependsAnnotationWithValueToAttributeRector::class,

// stubs are required over mocks since PHPUnit 11.0
// stubs over mocks, where no expectations are set, since PHPUnit 11.0
CreateStubOverCreateMockArgRector::class,
CreateStubInCoalesceArgRector::class,
ExpressionCreateMockToCreateStubRector::class,
PropertyCreateMockToCreateStubRector::class,
MockObjectVarToStubRector::class,
AddIntersectionVarToMockObjectPropertyRector::class,
AddStubIntersectionVarToStubPropertyRector::class,
BareCreateMockAssignToDirectUseRector::class,

// mocks back over stubs, where a mock object is required
MockObjectArgCreateStubToCreateMockRector::class,

// deprecated in PHPUnit 11.5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@
use Rector\PHPUnit\CodeQuality\NodeFinder\VariableFinder;
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
use Rector\Rector\AbstractRector;
use Rector\VersionBonding\Contract\ComposerPackageConstraintInterface;
use Rector\VersionBonding\ValueObject\ComposerPackageConstraint;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;

/**
* @see \Rector\PHPUnit\Tests\CodeQuality\Rector\ClassMethod\BareCreateMockAssignToDirectUseRector\BareCreateMockAssignToDirectUseRectorTest
*/
final class BareCreateMockAssignToDirectUseRector extends AbstractRector
final class BareCreateMockAssignToDirectUseRector extends AbstractRector implements ComposerPackageConstraintInterface
{
public function __construct(
private readonly TestsNodeAnalyzer $testsNodeAnalyzer,
Expand All @@ -40,6 +42,11 @@ public function __construct(
) {
}

public function provideComposerPackageConstraint(): ComposerPackageConstraint
{
return new ComposerPackageConstraint('phpunit/phpunit', '>=11.0');
}

public function getRuleDefinition(): RuleDefinition
{
return new RuleDefinition(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
use Rector\Rector\AbstractRector;
use Rector\ValueObject\MethodName;
use Rector\VersionBonding\Contract\ComposerPackageConstraintInterface;
use Rector\VersionBonding\ValueObject\ComposerPackageConstraint;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;

/**
* @see \Rector\PHPUnit\Tests\CodeQuality\Rector\Class_\AddIntersectionVarToMockObjectPropertyRector\AddIntersectionVarToMockObjectPropertyRectorTest
*/
final class AddIntersectionVarToMockObjectPropertyRector extends AbstractRector
final class AddIntersectionVarToMockObjectPropertyRector extends AbstractRector implements ComposerPackageConstraintInterface
{
public function __construct(
private readonly TestsNodeAnalyzer $testsNodeAnalyzer,
Expand Down Expand Up @@ -107,6 +109,11 @@ public function refactor(Node $node): ?Class_
return $node;
}

public function provideComposerPackageConstraint(): ComposerPackageConstraint
{
return new ComposerPackageConstraint('phpunit/phpunit', '>=11.0');
}

public function getRuleDefinition(): RuleDefinition
{
return new RuleDefinition(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
use Rector\Rector\AbstractRector;
use Rector\ValueObject\MethodName;
use Rector\VersionBonding\Contract\ComposerPackageConstraintInterface;
use Rector\VersionBonding\ValueObject\ComposerPackageConstraint;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;

/**
* @see \Rector\PHPUnit\Tests\CodeQuality\Rector\Class_\AddStubIntersectionVarToStubPropertyRector\AddStubIntersectionVarToStubPropertyRectorTest
*/
final class AddStubIntersectionVarToStubPropertyRector extends AbstractRector
final class AddStubIntersectionVarToStubPropertyRector extends AbstractRector implements ComposerPackageConstraintInterface
{
public function __construct(
private readonly TestsNodeAnalyzer $testsNodeAnalyzer,
Expand Down Expand Up @@ -94,6 +96,11 @@ public function refactor(Node $node): ?Class_
return $node;
}

public function provideComposerPackageConstraint(): ComposerPackageConstraint
{
return new ComposerPackageConstraint('phpunit/phpunit', '>=11.0');
}

public function getRuleDefinition(): RuleDefinition
{
return new RuleDefinition(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
use PhpParser\Node\Identifier;
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
use Rector\Rector\AbstractRector;
use Rector\VersionBonding\Contract\ComposerPackageConstraintInterface;
use Rector\VersionBonding\ValueObject\ComposerPackageConstraint;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;

Expand All @@ -21,13 +23,18 @@
*
* @see \Rector\PHPUnit\Tests\PHPUnit120\Rector\CallLike\CreateStubInCoalesceArgRector\CreateStubInCoalesceArgRectorTest
*/
final class CreateStubInCoalesceArgRector extends AbstractRector
final class CreateStubInCoalesceArgRector extends AbstractRector implements ComposerPackageConstraintInterface
{
public function __construct(
private readonly TestsNodeAnalyzer $testsNodeAnalyzer,
) {
}

public function provideComposerPackageConstraint(): ComposerPackageConstraint
{
return new ComposerPackageConstraint('phpunit/phpunit', '>=11.0');
}

public function getRuleDefinition(): RuleDefinition
{
return new RuleDefinition(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
use Rector\Rector\AbstractRector;
use Rector\Reflection\ReflectionResolver;
use Rector\VersionBonding\Contract\ComposerPackageConstraintInterface;
use Rector\VersionBonding\ValueObject\ComposerPackageConstraint;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;

Expand All @@ -37,7 +39,7 @@
*
* @see \Rector\PHPUnit\Tests\PHPUnit120\Rector\CallLike\CreateStubOverCreateMockArgRector\CreateStubOverCreateMockArgRectorTest
*/
final class CreateStubOverCreateMockArgRector extends AbstractRector
final class CreateStubOverCreateMockArgRector extends AbstractRector implements ComposerPackageConstraintInterface
{
public function __construct(
private readonly TestsNodeAnalyzer $testsNodeAnalyzer,
Expand All @@ -46,6 +48,11 @@ public function __construct(
) {
}

public function provideComposerPackageConstraint(): ComposerPackageConstraint
{
return new ComposerPackageConstraint('phpunit/phpunit', '>=11.0');
}

public function getRuleDefinition(): RuleDefinition
{
return new RuleDefinition(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
use Rector\PHPUnit\CodeQuality\NodeAnalyser\MockObjectExprDetector;
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
use Rector\Rector\AbstractRector;
use Rector\VersionBonding\Contract\ComposerPackageConstraintInterface;
use Rector\VersionBonding\ValueObject\ComposerPackageConstraint;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;

/**
* @see \Rector\PHPUnit\Tests\PHPUnit120\Rector\ClassMethod\ExpressionCreateMockToCreateStubRector\ExpressionCreateMockToCreateStubRectorTest
*/
final class ExpressionCreateMockToCreateStubRector extends AbstractRector
final class ExpressionCreateMockToCreateStubRector extends AbstractRector implements ComposerPackageConstraintInterface
{
public function __construct(
private readonly AssignedMocksCollector $assignedMocksCollector,
Expand All @@ -31,6 +33,11 @@ public function __construct(
) {
}

public function provideComposerPackageConstraint(): ComposerPackageConstraint
{
return new ComposerPackageConstraint('phpunit/phpunit', '>=11.0');
}

public function getRuleDefinition(): RuleDefinition
{
return new RuleDefinition(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
use Rector\Rector\AbstractRector;
use Rector\ValueObject\MethodName;
use Rector\VersionBonding\Contract\ComposerPackageConstraintInterface;
use Rector\VersionBonding\ValueObject\ComposerPackageConstraint;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;

Expand All @@ -25,7 +27,7 @@
*
* @see https://github.com/sebastianbergmann/phpunit/commit/24c208d6a340c3071f28a9b5cce02b9377adfd43
*/
final class PropertyCreateMockToCreateStubRector extends AbstractRector
final class PropertyCreateMockToCreateStubRector extends AbstractRector implements ComposerPackageConstraintInterface
{
public function __construct(
private readonly TestsNodeAnalyzer $testsNodeAnalyzer,
Expand Down Expand Up @@ -82,6 +84,11 @@ public function refactor(Node $node): ?Class_
return $node;
}

public function provideComposerPackageConstraint(): ComposerPackageConstraint
{
return new ComposerPackageConstraint('phpunit/phpunit', '>=11.0');
}

public function getRuleDefinition(): RuleDefinition
{
return new RuleDefinition(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@
use Rector\PHPUnit\Enum\PHPUnitClassName;
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
use Rector\Rector\AbstractRector;
use Rector\VersionBonding\Contract\ComposerPackageConstraintInterface;
use Rector\VersionBonding\ValueObject\ComposerPackageConstraint;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;

/**
* @see \Rector\PHPUnit\Tests\PHPUnit120\Rector\Property\MockObjectVarToStubRector\MockObjectVarToStubRectorTest
*/
final class MockObjectVarToStubRector extends AbstractRector
final class MockObjectVarToStubRector extends AbstractRector implements ComposerPackageConstraintInterface
{
public function __construct(
private readonly PhpDocInfoFactory $phpDocInfoFactory,
Expand Down Expand Up @@ -73,6 +75,11 @@ public function refactor(Node $node): ?Property
return $node;
}

public function provideComposerPackageConstraint(): ComposerPackageConstraint
{
return new ComposerPackageConstraint('phpunit/phpunit', '>=11.0');
}

public function getRuleDefinition(): RuleDefinition
{
return new RuleDefinition(
Expand Down
Loading