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
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@
"composer/pcre": "^3.3.0",
"composer/semver": "^3.4",
"composer/xdebug-handler": "^3.0.5",
"doctrine/inflector": "^2.0.10",
"illuminate/container": "^11.45",
"doctrine/inflector": "^2.1",
"illuminate/container": "^11.46",
"nette/utils": "^4.0",
"nikic/php-parser": "^5.6.1",
"ocramius/package-versions": "^2.10",
"ondram/ci-detector": "^4.2",
"phpstan/phpdoc-parser": "^2.2",
"phpstan/phpdoc-parser": "^2.3",
"phpstan/phpstan": "^2.1.26",
"react/event-loop": "^1.5",
"react/promise": "^3.2",
"react/promise": "^3.3",
"react/socket": "^1.16",
"rector/extension-installer": "^0.11.2",
"rector/rector-doctrine": "dev-main",
Expand All @@ -44,7 +44,7 @@
},
"require-dev": {
"php-parallel-lint/php-parallel-lint": "^1.4",
"phpecs/phpecs": "^2.1",
"phpecs/phpecs": "^2.2",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan-deprecation-rules": "^2.0",
"phpstan/phpstan-phpunit": "^2.0",
Expand All @@ -56,8 +56,8 @@
"rector/type-perfect": "^2.1",
"shipmonk/composer-dependency-analyser": "^1.8",
"symplify/phpstan-extensions": "^12.0",
"symplify/phpstan-rules": "^14.6.11",
"symplify/vendor-patches": "^11.4",
"symplify/phpstan-rules": "^14.8",
"symplify/vendor-patches": "^11.5",
"tomasvotruba/class-leak": "^2.0",
"tracy/tracy": "^2.10"
},
Expand Down
5 changes: 5 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -345,3 +345,8 @@ parameters:
-
identifier: symplify.noReference
message: '#Use explicit return value over magic &reference#'

# false positive
-
identifier: offsetAccess.invalidOffset
path: src/CustomRules/SimpleNodeDumper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

namespace Rector\Tests\CodeQuality\Rector\ClassConstFetch\VariableConstFetchToClassConstFetchRector\Fixture;

use Rector\Tests\CodeQuality\Rector\ClassConstFetch\VariableConstFetchToClassConstFetchRector\Source\ChildClassNotWithConstant;

final class AllowOverride
{
public function run(ChildClassNotWithConstant $classWithConstants)
{
return $classWithConstants::ORIGINAL_VALUE;
}
}

?>
-----
<?php

declare(strict_types=1);

namespace Rector\Tests\CodeQuality\Rector\ClassConstFetch\VariableConstFetchToClassConstFetchRector\Fixture;

use Rector\Tests\CodeQuality\Rector\ClassConstFetch\VariableConstFetchToClassConstFetchRector\Source\ChildClassNotWithConstant;

final class AllowOverride
{
public function run(ChildClassNotWithConstant $classWithConstants)
{
return \Rector\Tests\CodeQuality\Rector\ClassConstFetch\VariableConstFetchToClassConstFetchRector\Source\ChildClassNotWithConstant::ORIGINAL_VALUE;
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

namespace Rector\Tests\CodeQuality\Rector\ClassConstFetch\VariableConstFetchToClassConstFetchRector\Fixture;

use Rector\Tests\CodeQuality\Rector\ClassConstFetch\VariableConstFetchToClassConstFetchRector\Source\ChildClassNotWithConstant;

final class ParentHopFetch
{
public function run(ChildClassNotWithConstant $classWithConstants)
{
return $classWithConstants::NAME;
}
}

?>
-----
<?php

declare(strict_types=1);

namespace Rector\Tests\CodeQuality\Rector\ClassConstFetch\VariableConstFetchToClassConstFetchRector\Fixture;

use Rector\Tests\CodeQuality\Rector\ClassConstFetch\VariableConstFetchToClassConstFetchRector\Source\ChildClassNotWithConstant;

final class ParentHopFetch
{
public function run(ChildClassNotWithConstant $classWithConstants)
{
return \Rector\Tests\CodeQuality\Rector\ClassConstFetch\VariableConstFetchToClassConstFetchRector\Source\ChildClassNotWithConstant::NAME;
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace Rector\Tests\CodeQuality\Rector\ClassConstFetch\VariableConstFetchToClassConstFetchRector\Fixture;

use Rector\Tests\CodeQuality\Rector\ClassConstFetch\VariableConstFetchToClassConstFetchRector\Source\ChildClassNotWithConstant;

final class SkipDocType
{
/**
* @param ChildClassNotWithConstant $classWithConstants
*/
public function run($classWithConstants)
{
return $classWithConstants::ORIGINAL_VALUE;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);

namespace Rector\Tests\CodeQuality\Rector\ClassConstFetch\VariableConstFetchToClassConstFetchRector\Fixture;

use Rector\Tests\CodeQuality\Rector\ClassConstFetch\VariableConstFetchToClassConstFetchRector\Source\ClassWithConstants;

final class SkipDynamicName
{
public function run(ClassWithConstants $classWithConstants, $dynamic)
{
return $classWithConstants::$dynamic;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);

namespace Rector\Tests\CodeQuality\Rector\ClassConstFetch\VariableConstFetchToClassConstFetchRector\Fixture;

use Rector\Tests\CodeQuality\Rector\ClassConstFetch\VariableConstFetchToClassConstFetchRector\Source\ClassWithConstants;

final class SkipKnownClass
{
public function run()
{
return ClassWithConstants::NAME;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

namespace Rector\Tests\CodeQuality\Rector\ClassConstFetch\VariableConstFetchToClassConstFetchRector\Fixture;

final class SkipUnknownClass
{
public function run($classWithConstants)
{
return $classWithConstants::ORIGINAL_VALUE;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

namespace Rector\Tests\CodeQuality\Rector\ClassConstFetch\VariableConstFetchToClassConstFetchRector\Fixture;

use Rector\Tests\CodeQuality\Rector\ClassConstFetch\VariableConstFetchToClassConstFetchRector\Source\ClassWithConstants;

final class SomeClass
{
public function run(ClassWithConstants $classWithConstants)
{
return $classWithConstants::NAME;
}
}

?>
-----
<?php

declare(strict_types=1);

namespace Rector\Tests\CodeQuality\Rector\ClassConstFetch\VariableConstFetchToClassConstFetchRector\Fixture;

use Rector\Tests\CodeQuality\Rector\ClassConstFetch\VariableConstFetchToClassConstFetchRector\Source\ClassWithConstants;

final class SomeClass
{
public function run(ClassWithConstants $classWithConstants)
{
return \Rector\Tests\CodeQuality\Rector\ClassConstFetch\VariableConstFetchToClassConstFetchRector\Source\ClassWithConstants::NAME;
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

namespace Rector\Tests\CodeQuality\Rector\ClassConstFetch\VariableConstFetchToClassConstFetchRector\Source;

final class ChildClassNotWithConstant extends ClassWithConstants
{
public const ORIGINAL_VALUE = 456;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

namespace Rector\Tests\CodeQuality\Rector\ClassConstFetch\VariableConstFetchToClassConstFetchRector\Source;

class ClassWithConstants
{
public const NAME = 'SomeName';

public const ORIGINAL_VALUE = 123;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

namespace Rector\Tests\CodeQuality\Rector\ClassConstFetch\VariableConstFetchToClassConstFetchRector;

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

final class VariableConstFetchToClassConstFetchRectorTest 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';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\ClassConstFetch\VariableConstFetchToClassConstFetchRector;
use Rector\Config\RectorConfig;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->rule(VariableConstFetchToClassConstFetchRector::class);
};

This file was deleted.

Loading