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
1 change: 1 addition & 0 deletions src/Configuration/PhpLevelSetResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ final class PhpLevelSetResolver
PhpVersion::PHP_82 => SetList::PHP_82,
PhpVersion::PHP_83 => SetList::PHP_83,
PhpVersion::PHP_84 => SetList::PHP_84,
PhpVersion::PHP_85 => SetList::PHP_85,
];

/**
Expand Down
6 changes: 5 additions & 1 deletion src/Configuration/RectorConfigBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,9 @@ public function withPhpSets(
bool $php55 = false,
bool $php54 = false,
bool $php53 = false,
bool $php84 = false, // place on later as BC break when used in php 7.x without named arg
// place on later as BC break when used in php 7.x without named arg
bool $php84 = false,
bool $php85 = false,
): self {
if ($this->isWithPhpSetsUsed === true) {
throw new InvalidConfigurationException(sprintf(
Expand Down Expand Up @@ -637,6 +639,8 @@ public function withPhpSets(
$targetPhpVersion = PhpVersion::PHP_83;
} elseif ($php84) {
$targetPhpVersion = PhpVersion::PHP_84;
} elseif ($php85) {
$targetPhpVersion = PhpVersion::PHP_85;
} else {
throw new InvalidConfigurationException('Invalid PHP version set');
}
Expand Down
27 changes: 27 additions & 0 deletions tests/Issues/WithPhpSets/Fixture/fixture.php.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Rector\Tests\Issues\WithPhpSets\Fixture;

final class Fixture
{
public function run()
{
socket_set_timeout();
}
}

?>
-----
<?php

namespace Rector\Tests\Issues\WithPhpSets\Fixture;

final class Fixture
{
public function run()
{
stream_set_timeout();
}
}

?>
28 changes: 28 additions & 0 deletions tests/Issues/WithPhpSets/WithPhpSetsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

namespace Rector\Tests\Issues\WithPhpSets;

use Iterator;
use PHPUnit\Framework\Attributes\DataProvider;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;

final class WithPhpSetsTest extends AbstractRectorTestCase
{
#[DataProvider('provideData')]
public function test(string $filePath): void
{
$this->doTestFile($filePath);
}

public static function provideData(): Iterator
{
return self::yieldFilesFromDirectory(__DIR__ . '/Fixture');
}

public function provideConfigFilePath(): string
{
return __DIR__ . '/config/configured_rule.php';
}
}
10 changes: 10 additions & 0 deletions tests/Issues/WithPhpSets/config/configured_rule.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\ValueObject\PhpVersion;

return RectorConfig::configure()
->withPhpSets(php85: true)
->withPhpVersion(PhpVersion::PHP_85);
Loading