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
27 changes: 22 additions & 5 deletions .github/workflows/code_analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,41 @@ jobs:
fail-fast: false
matrix:
actions:
-
name: 'Active Classes'
run: vendor/bin/class-leak check config src rules
-
name: "Validate docs"
run: vendor/bin/rule-doc-generator validate src rules

-
name: 'Active Classes'
run: vendor/bin/class-leak check config src rules --ansi --skip-suffix "Rector" --skip-type "\Rector\Set\Contract\SetProviderInterface"

-
name: "Finalize Classes"
run: vendor/bin/swiss-knife finalize config src tests rules rules-tests --ansi

-
name: 'Composer Validate'
run: composer validate

-
name: 'PHPStan'
run: vendor/bin/phpstan

-
name: 'Tests'
run: vendor/bin/phpunit

name: ${{ matrix.actions.name }}
runs-on: ubuntu-latest
timeout-minutes: 10
timeout-minutes: 3

steps:
- uses: actions/checkout@v4

-
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
php-version: 8.3
coverage: none

- uses: "ramsey/composer-install@v2"
Expand Down
19 changes: 0 additions & 19 deletions .github/workflows/code_analysis_reusable.yaml

This file was deleted.

39 changes: 39 additions & 0 deletions .github/workflows/rector.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# github action that checks code with Rector
name: Rector

on:
pull_request: null

env:
# see https://github.com/composer/composer/issues/9368#issuecomment-718112361
COMPOSER_ROOT_VERSION: "dev-main"

jobs:
rector:
runs-on: ubuntu-latest
if: github.event.pull_request.head.repo.full_name == 'rectorphp/rector-downgrade-php'
steps:
-
if: github.event.pull_request.head.repo.full_name == github.repository
uses: actions/checkout@v4
with:
# Must be used to trigger workflow after push
token: ${{ secrets.ACCESS_TOKEN }}

-
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
coverage: none

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

- run: vendor/bin/rector --ansi

-
# commit only to core contributors who have repository access
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: '[rector] Rector fixes'
commit_author: 'GitHub Action <[email protected]>'
commit_user_email: '[email protected]'
36 changes: 0 additions & 36 deletions .github/workflows/tests.yaml

This file was deleted.

15 changes: 9 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,25 @@
"license": "MIT",
"description": "Rector downgrade PHP rules",
"require": {
"php": ">=8.2"
"php": ">=8.3"
},
"require-dev": {
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan": "^2.1.32",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan": "^2.1.33",
"phpstan/phpstan-webmozart-assert": "^2.0",
"phpunit/phpunit": "^11.5",
"rector/jack": "^0.5.1",
"rector/rector-src": "dev-main",
"rector/swiss-knife": "^2.3",
"rector/type-perfect": "^2.1",
"symplify/easy-coding-standard": "^12.3",
"symplify/easy-coding-standard": "^13.0",
"symplify/phpstan-extensions": "^12.0",
"symplify/phpstan-rules": "^14.9",
"symplify/rule-doc-generator": "^12.2",
"symplify/vendor-patches": "^11.5",
"tomasvotruba/class-leak": "^1.0",
"tracy/tracy": "^2.10"
"tomasvotruba/class-leak": "^2.1",
"tomasvotruba/unused-public": "^2.2",
"tracy/tracy": "^2.11"
},
"autoload": {
"psr-4": {
Expand Down
3 changes: 2 additions & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@

return RectorConfig::configure()
->withImportNames(removeUnusedImports: true)
->withPhpSets(php82: true)
->withPhpSets()
->withComposerBased(phpunit: true)
->withPreparedSets(
deadCode: true,
codeQuality: true,
codingStyle: true,
typeDeclarations: true,
typeDeclarationDocblocks: true,
privatization: true,
naming: true,
earlyReturn: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Rector\Tests\DowngradePhp72\Rector\ClassMethod\DowngradeParameterTypeWideningRector\Source;

class ParentNullableString
final class ParentNullableString
{
public function load(string $value = null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Rector\Tests\DowngradePhp72\Rector\FunctionLike\DowngradeObjectTypeDeclarationRector\Source;


class AnotherClass
final class AnotherClass
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

namespace Rector\Tests\DowngradePhp74\Rector\ArrowFunction\ArrowFunctionToAnonymousFunctionRector\Source;

class Foo {
final class Foo {
public $bar = 1;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Rector\Tests\DowngradePhp74\Rector\Property\DowngradeTypedPropertyRector\Source;

class AnotherClass
final class AnotherClass
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Rector\Tests\DowngradePhp80\Rector\ClassMethod\DowngradeStaticTypeDeclarationRector\Source;


class AnotherClass
final class AnotherClass
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Rector\Tests\DowngradePhp80\Rector\FunctionLike\DowngradeMixedTypeDeclarationRector\Source;


class AnotherClass
final class AnotherClass
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

namespace Rector\Tests\DowngradePhp80\Rector\FunctionLike\DowngradeUnionTypeDeclarationRector\Source;

class Foo1 implements FooInterface
final class Foo1 implements FooInterface
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

namespace Rector\Tests\DowngradePhp80\Rector\FunctionLike\DowngradeUnionTypeDeclarationRector\Source;

class Foo2 implements FooInterface
final class Foo2 implements FooInterface
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Rector\Tests\DowngradePhp80\Rector\MethodCall\DowngradeNamedArgumentRector\Source;

class Foo
final class Foo
{
public function __construct(
public ?array $a = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Rector\Tests\DowngradePhp80\Rector\MethodCall\DowngradeReflectionClassGetConstantsFilterRector\Source;

class Foo
final class Foo
{
public const A1 = 'A1 Value';
protected const A2 = 'A2 Value';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Rector\Tests\DowngradePhp80\Rector\MethodCall\DowngradeReflectionPropertyGetDefaultValueRector\Source;

class SomeClassHasGetDefaultValue
final class SomeClassHasGetDefaultValue
{
public function getDefaultValue()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Rector\Tests\DowngradePhp81\Rector\FunctionLike\DowngradeNeverTypeDeclarationRector\Source;

class SomeParentVoid
final class SomeParentVoid
{
public function run(): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Rector\Tests\DowngradePhp82\Rector\FunctionLike\DowngradeStandaloneNullTrueFalseReturnTypeRector\Source;

class ParentClass
final class ParentClass
{
public function getSomeString(): ?string
{
Expand Down
2 changes: 1 addition & 1 deletion rules/DowngradePhp72/NodeAnalyzer/RegexFuncAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/**
* @var string[]
*/
private const REGEX_FUNCTION_NAMES = ['preg_match', 'preg_match_all'];
private const array REGEX_FUNCTION_NAMES = ['preg_match', 'preg_match_all'];

public function __construct(
private NodeNameResolver $nodeNameResolver,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@
*/
final class DowngradePhp72JsonConstRector extends AbstractRector
{
/**
* @var string
*/
private const PHP72_JSON_CONSTANT_IS_KNOWN = 'php72_json_constant_is_known';
private const string PHP72_JSON_CONSTANT_IS_KNOWN = 'php72_json_constant_is_known';

public function __construct(
private readonly JsonConstCleaner $jsonConstCleaner,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ final class DowngradePregUnmatchedAsNullConstantRector extends AbstractRector
{
/**
* @see https://www.php.net/manual/en/function.preg-match.php
* @var string
*/
private const UNMATCHED_NULL_FLAG = 'PREG_UNMATCHED_AS_NULL';
private const string UNMATCHED_NULL_FLAG = 'PREG_UNMATCHED_AS_NULL';

public function __construct(
private readonly BitwiseFlagCleaner $bitwiseFlagCleaner,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,12 @@
*/
final class DowngradePhp73JsonConstRector extends AbstractRector
{
/**
* @var string
*/
private const PHP73_JSON_CONSTANT_IS_KNOWN = 'php73_json_constant_is_known';
private const string PHP73_JSON_CONSTANT_IS_KNOWN = 'php73_json_constant_is_known';

/**
* @var array<string>
*/
private const JSON_FUNCTIONS = ['json_decode', 'json_encode'];
private const array JSON_FUNCTIONS = ['json_decode', 'json_encode'];

public function __construct(
private readonly JsonConstCleaner $jsonConstCleaner,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ final class SetCookieOptionsArrayToArgumentsRector extends AbstractRector
* Conversion table from argument index to options name
* @var array<string, int>
*/
private const ARGUMENT_ORDER = [
private const array ARGUMENT_ORDER = [
'expires' => 2,
'path' => 3,
'domain' => 4,
Expand All @@ -37,7 +37,7 @@ final class SetCookieOptionsArrayToArgumentsRector extends AbstractRector
* Conversion table from argument index to options name
* @var array<int, int|string|bool>
*/
private const ARGUMENT_DEFAULT_VALUES = [
private const array ARGUMENT_DEFAULT_VALUES = [
2 => 0,
3 => '',
4 => '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,9 @@
*/
final class DowngradeListReferenceAssignmentRector extends AbstractRector
{
/**
* @var int
*/
private const ALL = 0;
private const int ALL = 0;

/**
* @var int
*/
private const ANY = 1;
private const int ANY = 1;

public function getRuleDefinition(): RuleDefinition
{
Expand Down
Loading