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
312 changes: 312 additions & 0 deletions config/sets/composer-based.php

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,12 @@ public function provideConfigFilePath(): string
{
return __DIR__ . '/config/configured_rule.php';
}

/**
* The rule is bound to a PHPUnit version older than the one installed here
*/
protected function provideComposerJsonFilePath(): string
{
return __DIR__ . '/config/composer.json';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"require": {
"phpunit/phpunit": "^9.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,12 @@ public function provideConfigFilePath(): string
{
return __DIR__ . '/config/configured_rule.php';
}

/**
* The rule is bound to a PHPUnit version older than the one installed here
*/
protected function provideComposerJsonFilePath(): string
{
return __DIR__ . '/config/composer.json';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"require": {
"phpunit/phpunit": "^9.0"
}
}
12 changes: 11 additions & 1 deletion rules/PHPUnit100/Rector/Class_/AddProphecyTraitRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,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 @@ -24,8 +26,16 @@
*
* @see \Rector\PHPUnit\Tests\PHPUnit100\Rector\Class_\AddProphecyTraitRector\AddProphecyTraitRectorTest
*/
final class AddProphecyTraitRector extends AbstractRector
final class AddProphecyTraitRector extends AbstractRector implements ComposerPackageConstraintInterface
{
/**
* inherited from the PHPUnit 10.0 set
*/
public function provideComposerPackageConstraint(): ComposerPackageConstraint
{
return new ComposerPackageConstraint('phpunit/phpunit', '>=10.0');
}

public function __construct(
private readonly TestsNodeAnalyzer $testsNodeAnalyzer,
private readonly ReflectionResolver $reflectionResolver,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,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,8 +27,16 @@
*
* @see \Rector\PHPUnit\Tests\PHPUnit100\Rector\Class_\ParentTestClassConstructorRector\ParentTestClassConstructorRectorTest
*/
final class ParentTestClassConstructorRector extends AbstractRector
final class ParentTestClassConstructorRector extends AbstractRector implements ComposerPackageConstraintInterface
{
/**
* inherited from the PHPUnit 10.0 set
*/
public function provideComposerPackageConstraint(): ComposerPackageConstraint
{
return new ComposerPackageConstraint('phpunit/phpunit', '>=10.0');
}

public function __construct(
private readonly TestsNodeAnalyzer $testsNodeAnalyzer,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,24 @@
use Rector\PHPUnit\NodeFinder\DataProviderClassMethodFinder;
use Rector\Privatization\NodeManipulator\VisibilityManipulator;
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\PHPUnit100\Rector\Class_\PublicDataProviderClassMethodRector\PublicDataProviderClassMethodRectorTest
*/
final class PublicDataProviderClassMethodRector extends AbstractRector
final class PublicDataProviderClassMethodRector extends AbstractRector implements ComposerPackageConstraintInterface
{
/**
* inherited from the PHPUnit 10.0 set
*/
public function provideComposerPackageConstraint(): ComposerPackageConstraint
{
return new ComposerPackageConstraint('phpunit/phpunit', '>=10.0');
}

public function __construct(
private readonly TestsNodeAnalyzer $testsNodeAnalyzer,
private readonly DataProviderClassMethodFinder $dataProviderClassMethodFinder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,24 @@
use Rector\PHPUnit\NodeFinder\DataProviderClassMethodFinder;
use Rector\Privatization\NodeManipulator\VisibilityManipulator;
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\PHPUnit100\Rector\Class_\StaticDataProviderClassMethodRector\StaticDataProviderClassMethodRectorTest
*/
final class StaticDataProviderClassMethodRector extends AbstractRector
final class StaticDataProviderClassMethodRector extends AbstractRector implements ComposerPackageConstraintInterface
{
/**
* inherited from the PHPUnit 10.0 set
*/
public function provideComposerPackageConstraint(): ComposerPackageConstraint
{
return new ComposerPackageConstraint('phpunit/phpunit', '>=10.0');
}

public function __construct(
private readonly TestsNodeAnalyzer $testsNodeAnalyzer,
private readonly DataProviderClassMethodFinder $dataProviderClassMethodFinder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
use Rector\PHPUnit\NodeAnalyzer\IdentifierManipulator;
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,8 +23,16 @@
*
* @see \Rector\PHPUnit\Tests\PHPUnit100\Rector\MethodCall\PropertyExistsWithoutAssertRector\PropertyExistsWithoutAssertRectorTest
*/
final class PropertyExistsWithoutAssertRector extends AbstractRector
final class PropertyExistsWithoutAssertRector extends AbstractRector implements ComposerPackageConstraintInterface
{
/**
* inherited from the PHPUnit 10.0 set
*/
public function provideComposerPackageConstraint(): ComposerPackageConstraint
{
return new ComposerPackageConstraint('phpunit/phpunit', '>=10.0');
}

/**
* @var array<string, string>
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
use Rector\PhpParser\Node\Value\ValueResolver;
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 @@ -22,8 +24,16 @@
*
* @see \Rector\PHPUnit\Tests\PHPUnit100\Rector\MethodCall\RemoveSetMethodsMethodCallRector\RemoveSetMethodsMethodCallRectorTest
*/
final class RemoveSetMethodsMethodCallRector extends AbstractRector
final class RemoveSetMethodsMethodCallRector extends AbstractRector implements ComposerPackageConstraintInterface
{
/**
* inherited from the PHPUnit 10.0 set
*/
public function provideComposerPackageConstraint(): ComposerPackageConstraint
{
return new ComposerPackageConstraint('phpunit/phpunit', '>=10.0');
}

public function __construct(
private readonly TestsNodeAnalyzer $testsNodeAnalyzer,
private readonly ValueResolver $valueResolver,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,24 @@
use Rector\PHPUnit\PHPUnit100\NodeDecorator\WillReturnIfNodeDecorator;
use Rector\PHPUnit\PHPUnit100\NodeFactory\WillReturnCallbackFactory;
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\PHPUnit100\Rector\StmtsAwareInterface\WithConsecutiveRector\WithConsecutiveRectorTest
*/
final class WithConsecutiveRector extends AbstractRector
final class WithConsecutiveRector extends AbstractRector implements ComposerPackageConstraintInterface
{
/**
* inherited from the PHPUnit 10.0 set
*/
public function provideComposerPackageConstraint(): ComposerPackageConstraint
{
return new ComposerPackageConstraint('phpunit/phpunit', '>=10.0');
}

public function __construct(
private readonly TestsNodeAnalyzer $testsNodeAnalyzer,
private readonly WillReturnCallbackFactory $willReturnCallbackFactory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
use PhpParser\Node\Stmt\Return_;
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 @@ -24,8 +26,16 @@
* @see https://github.com/sebastianbergmann/phpunit/pull/5225
* @see \Rector\PHPUnit\Tests\PHPUnit100\Rector\Class_\StaticDataProviderClassMethodRector\StaticDataProviderClassMethodRectorTest
*/
final class NamedArgumentForDataProviderRector extends AbstractRector
final class NamedArgumentForDataProviderRector extends AbstractRector implements ComposerPackageConstraintInterface
{
/**
* inherited from the PHPUnit 11.0 set
*/
public function provideComposerPackageConstraint(): ComposerPackageConstraint
{
return new ComposerPackageConstraint('phpunit/phpunit', '>=11.0');
}

public function __construct(
private readonly TestsNodeAnalyzer $testsNodeAnalyzer,
) {
Expand Down
12 changes: 11 additions & 1 deletion rules/PHPUnit50/Rector/StaticCall/GetMockRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,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 @@ -21,8 +23,16 @@
*
* @see \Rector\PHPUnit\Tests\PHPUnit50\Rector\StaticCall\GetMockRector\GetMockRectorTest
*/
final class GetMockRector extends AbstractRector
final class GetMockRector extends AbstractRector implements ComposerPackageConstraintInterface
{
/**
* createMock() was added in PHPUnit 5.4
*/
public function provideComposerPackageConstraint(): ComposerPackageConstraint
{
return new ComposerPackageConstraint('phpunit/phpunit', '>=5.4');
}

public function __construct(
private readonly TestsNodeAnalyzer $testsNodeAnalyzer,
private readonly ReflectionResolver $reflectionResolver,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
use Rector\PHPUnit\NodeAnalyzer\MockedVariableAnalyzer;
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 @@ -24,8 +26,16 @@
*
* @see \Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\AddDoesNotPerformAssertionToNonAssertingTestRectorTest
*/
final class AddDoesNotPerformAssertionToNonAssertingTestRector extends AbstractRector
final class AddDoesNotPerformAssertionToNonAssertingTestRector extends AbstractRector implements ComposerPackageConstraintInterface
{
/**
* inherited from the PHPUnit 6.0 set
*/
public function provideComposerPackageConstraint(): ComposerPackageConstraint
{
return new ComposerPackageConstraint('phpunit/phpunit', '>=6.0');
}

public function __construct(
private readonly TestsNodeAnalyzer $testsNodeAnalyzer,
private readonly AssertCallAnalyzer $assertCallAnalyzer,
Expand Down
12 changes: 11 additions & 1 deletion rules/PHPUnit60/Rector/ClassMethod/ExceptionAnnotationRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
use Rector\PHPUnit\NodeFactory\ExpectExceptionMethodCallFactory;
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 @@ -22,8 +24,16 @@
*
* @see \Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\ExceptionAnnotationRector\ExceptionAnnotationRectorTest
*/
final class ExceptionAnnotationRector extends AbstractRector
final class ExceptionAnnotationRector extends AbstractRector implements ComposerPackageConstraintInterface
{
/**
* expectException() was added in PHPUnit 5.2
*/
public function provideComposerPackageConstraint(): ComposerPackageConstraint
{
return new ComposerPackageConstraint('phpunit/phpunit', '>=5.2');
}

/**
* In reversed order, which they should be called in code.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,24 @@
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
use Rector\PHPUnit\NodeFactory\AssertCallFactory;
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\PHPUnit60\Rector\MethodCall\DelegateExceptionArgumentsRector\DelegateExceptionArgumentsRectorTest
*/
final class DelegateExceptionArgumentsRector extends AbstractRector
final class DelegateExceptionArgumentsRector extends AbstractRector implements ComposerPackageConstraintInterface
{
/**
* expectExceptionMessage() and expectExceptionCode() were added in PHPUnit 5.2
*/
public function provideComposerPackageConstraint(): ComposerPackageConstraint
{
return new ComposerPackageConstraint('phpunit/phpunit', '>=5.2');
}

/**
* @var array<string, string>
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
use PhpParser\Node\Expr\Variable;
use PHPStan\Type\ObjectType;
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 @@ -17,8 +19,16 @@
*
* @see \Rector\PHPUnit\Tests\PHPUnit60\Rector\MethodCall\GetMockBuilderGetMockToCreateMockRector\GetMockBuilderGetMockToCreateMockRectorTest
*/
final class GetMockBuilderGetMockToCreateMockRector extends AbstractRector
final class GetMockBuilderGetMockToCreateMockRector extends AbstractRector implements ComposerPackageConstraintInterface
{
/**
* createMock() was added in PHPUnit 5.4
*/
public function provideComposerPackageConstraint(): ComposerPackageConstraint
{
return new ComposerPackageConstraint('phpunit/phpunit', '>=5.4');
}

/**
* @var string[]
*/
Expand Down
Loading
Loading