Replaces static::* constant access with self::* for private constants and in final classes.
class Foo
{
private const BAR = 'bar';
public const BAZ = 'baz';
public function run()
{
- $bar = static::BAR;
+ $bar = self::BAR;
$baz = static::BAZ;
}
}
Configure your rector.php
:
<?php
use Rector\CodeQuality\Rector\ClassConstFetch\ConvertStaticPrivateConstantToSelfRector;
use Rector\Config\RectorConfig;
return RectorConfig::configure()
->withRules([
ConvertStaticPrivateConstantToSelfRector::class,
]);