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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Compat Tests for global install
name: Compat Tests for global install for PHPStan

on:
pull_request: null
Expand All @@ -13,19 +13,13 @@ jobs:
matrix:
actions:
-
name: 'Rector dev + PHPUnit 12 global install'
run: |
composer remove --dev phpunit/phpunit -W
composer global require --dev "phpunit/phpunit:12.*" -W
composer require --dev "rector/rector:dev-main" -W
name: 'Rector stable + PHPUnit 12 global for PHPStan'
run: composer require --dev "rector/rector:^2.2" -W
php: 8.3

-
name: 'Rector stable + PHPUnit 12 global install'
run: |
composer remove --dev phpunit/phpunit -W
composer global require --dev "phpunit/phpunit:12.*" -W
composer require --dev "rector/rector:^2.2" -W
name: 'Rector dev + PHPUnit 12 global for PHPStan'
run: composer require --dev "rector/rector:dev-main" -W
php: 8.3

name: ${{ matrix.actions.name }}
Expand All @@ -42,10 +36,12 @@ jobs:
coverage: none

- uses: "ramsey/composer-install@v2"
- run: ${{ matrix.actions.run }}

- run: phpunit tests/PHPStan
- run: composer remove --dev phpunit/phpunit -W
- run: composer global require --dev "phpunit/phpunit:12.*" -W

- run: ${{ matrix.actions.run }}

- run: phpunit tests/Rector
- run: /home/runner/.composer/vendor/bin/phpunit tests/PHPStan

- run: phpunit
- run: /home/runner/.composer/vendor/bin/phpunit
47 changes: 47 additions & 0 deletions .github/workflows/compat_tests_global_rector.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Compat Tests for global install for Rector

on:
pull_request: null
push:
branches:
- main

jobs:
compat_tests:
strategy:
fail-fast: false
matrix:
actions:
-
name: 'Rector stable + PHPUnit 12 global for Rector'
run: composer require --dev "rector/rector:^2.2" -W
php: 8.3

-
name: 'Rector dev + PHPUnit 12 global for Rector'
run: composer require --dev "rector/rector:dev-main" -W
php: 8.3

name: ${{ matrix.actions.name }}

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

-
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.actions.php }}
coverage: none

- uses: "ramsey/composer-install@v2"

- run: composer remove --dev phpunit/phpunit -W
- run: composer global require --dev "phpunit/phpunit:12.*" -W

- run: ${{ matrix.actions.run }}

- run: /home/runner/.composer/vendor/bin/phpunit tests/Rector

- run: /home/runner/.composer/vendor/bin/phpunit
36 changes: 36 additions & 0 deletions src/Rector/MakeNewlineAfterIfRector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

namespace Rector\RectorCompatTests\Rector;

use PhpParser\Node;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\If_;
use PhpParser\Node\Stmt\Nop;
use Rector\Contract\PhpParser\Node\StmtsAwareInterface;
use Rector\Rector\AbstractRector;

final class MakeNewlineAfterIfRector extends AbstractRector
{
/**
* @return array<class-string<Class_>>
*/
public function getNodeTypes(): array
{
return [StmtsAwareInterface::class];
}

/**
* @param StmtsAwareInterface $node
* @return array<Node>|null
*/
public function refactor(Node $node): ?array
{
if (! $node instanceof If_) {
return null;
}

return [$node, new Nop()];
}
}
34 changes: 34 additions & 0 deletions tests/Rector/MakeNewlineAfterIf/Fixture/some_if.php.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace Rector\RectorCompatTests\Tests\Rector\MakeClassFinalRector\Fixture;

class SomeIf
{
public function run()
{
if (true) {
echo 'test';
}
echo 'done';
}
}

?>
-----
<?php

namespace Rector\RectorCompatTests\Tests\Rector\MakeClassFinalRector\Fixture;

class SomeIf
{
public function run()
{
if (true) {
echo 'test';
}

echo 'done';
}
}

?>
18 changes: 18 additions & 0 deletions tests/Rector/MakeNewlineAfterIf/MakeNewlineAfterIfTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Rector\RectorCompatTests\Tests\Rector\MakeNewlineAfterIf;

use Rector\Testing\PHPUnit\AbstractRectorTestCase;

final class MakeNewlineAfterIfTest extends AbstractRectorTestCase
{
public function test(): void
{
$this->doTestFile(__DIR__ . '/Fixture/some_if.php.inc');
}

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

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\RectorCompatTests\Rector\MakeNewlineAfterIfRector;

return RectorConfig::configure()
->withRules([MakeNewlineAfterIfRector::class]);
Loading