mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-15 13:25:30 +01:00
add slash to repeated literal to class constant
This commit is contained in:
parent
f229a7a3f5
commit
83ef24bd9d
@ -182,7 +182,7 @@ PHP
|
||||
}
|
||||
|
||||
// is replaceable value?
|
||||
$matches = Strings::match($value, '#(?<' . self::VALUE . '>[\w\-_]+)#');
|
||||
$matches = Strings::match($value, '#(?<' . self::VALUE . '>[\w\-\/\\_]+)#');
|
||||
if (! isset($matches[self::VALUE])) {
|
||||
return true;
|
||||
}
|
||||
@ -199,7 +199,7 @@ PHP
|
||||
private function createConstName(string $value): string
|
||||
{
|
||||
$value = StaticRectorStrings::camelCaseToUnderscore($value);
|
||||
$value = Strings::replace($value, '#-#', '_');
|
||||
$value = Strings::replace($value, '#[-\\\/]#', '_');
|
||||
|
||||
return strtoupper($value);
|
||||
}
|
||||
|
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\SOLID\Tests\Rector\Class_\RepeatedLiteralToClassConstantRector\Fixture;
|
||||
|
||||
class WithSlash
|
||||
{
|
||||
public function run($key, $items)
|
||||
{
|
||||
if ($key === 'phpstan/phpstan') {
|
||||
return $items['phpstan/phpstan'];
|
||||
}
|
||||
|
||||
return $items['phpstan/phpstan'];
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\SOLID\Tests\Rector\Class_\RepeatedLiteralToClassConstantRector\Fixture;
|
||||
|
||||
class WithSlash
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private const PHPSTAN_PHPSTAN = 'phpstan/phpstan';
|
||||
public function run($key, $items)
|
||||
{
|
||||
if ($key === self::PHPSTAN_PHPSTAN) {
|
||||
return $items[self::PHPSTAN_PHPSTAN];
|
||||
}
|
||||
|
||||
return $items[self::PHPSTAN_PHPSTAN];
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user