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
Expand Up @@ -153,7 +153,11 @@ public function refactorWithScope(Node $node, Scope $scope): ?Node
return null;
}

if (str_contains($uppercasedConstantName, '\\')) {
if (
str_contains($uppercasedConstantName, '\\')
|| str_contains($uppercasedConstantName, '(')
|| str_contains($uppercasedConstantName, "'")
) {
return null;
}

Expand Down
28 changes: 28 additions & 0 deletions tests/Issues/EmptyLongArraySyntax/EmptyLongArraySyntaxTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

namespace Rector\Core\Tests\Issues\EmptyLongArraySyntax;

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

final class EmptyLongArraySyntaxTest 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';
}
}
33 changes: 33 additions & 0 deletions tests/Issues/EmptyLongArraySyntax/Fixture/empty_long_array.php.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

declare(strict_types=1);

namespace Rector\Core\Tests\Issues\EmptyLongArraySyntax\Fixture;

use Rector\Core\Tests\Issues\EmptyLongArraySyntax\Source\ParentWithEmptyLongArray;

final class EmptyLongArray extends ParentWithEmptyLongArray
{
public function run()
{
}
}

?>
-----
<?php

declare(strict_types=1);

namespace Rector\Core\Tests\Issues\EmptyLongArraySyntax\Fixture;

use Rector\Core\Tests\Issues\EmptyLongArraySyntax\Source\ParentWithEmptyLongArray;

final class EmptyLongArray extends ParentWithEmptyLongArray
{
public function run($default = array())
{
}
}

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

declare(strict_types=1);

namespace Rector\Core\Tests\Issues\EmptyLongArraySyntax\Source;

class ParentWithEmptyLongArray
{
public function run($default = array())
{
}
}
14 changes: 14 additions & 0 deletions tests/Issues/EmptyLongArraySyntax/config/configured_rule.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Php73\Rector\ConstFetch\SensitiveConstantNameRector;
use Rector\Php80\Rector\ClassMethod\AddParamBasedOnParentClassMethodRector;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->rules([
SensitiveConstantNameRector::class,
AddParamBasedOnParentClassMethodRector::class,
]);
};