-
-
Notifications
You must be signed in to change notification settings - Fork 333
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TypeDeclaration] Skip key has bracket {}[] on ArrayShapeFromConstant…
…ArrayReturnRector (#1968) * [TypeDeclaration] Skip key has bracket {}[] on ArrayShapeFromConstantArrayReturnRector * more test * final touch: using \W regex * add unicode support * update url regex * final touch: regex name * final touch: skip empty string key * really final touch: re-use variable
- Loading branch information
1 parent
e913b61
commit 6f61a09
Showing
5 changed files
with
75 additions
and
6 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
...tor/ClassMethod/ArrayShapeFromConstantArrayReturnRector/Fixture/skip_bracket_keys.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ArrayShapeFromConstantArrayReturnRector\Fixture; | ||
|
||
final class SkipBracketKeys | ||
{ | ||
public function run(string $name) | ||
{ | ||
return ['{someKey}' => $name, '[someKey]' => $name]; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...ClassMethod/ArrayShapeFromConstantArrayReturnRector/Fixture/skip_empty_string_key.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ArrayShapeFromConstantArrayReturnRector\Fixture; | ||
|
||
final class SkipEmptyStringKey | ||
{ | ||
public function run(string $name) | ||
{ | ||
return ['' => $name]; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...r/ClassMethod/ArrayShapeFromConstantArrayReturnRector/Fixture/skip_key_has_at.php.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ArrayShapeFromConstantArrayReturnRector\Fixture; | ||
|
||
final class SkipKeyHasAt | ||
{ | ||
public function run(string $name) | ||
{ | ||
return ['some@key' => $name]; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...on/Rector/ClassMethod/ArrayShapeFromConstantArrayReturnRector/Fixture/unicode_key.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ArrayShapeFromConstantArrayReturnRector\Fixture; | ||
|
||
final class UnicodeKey | ||
{ | ||
public function run(string $name) | ||
{ | ||
return ['äÄ' => $name]; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ArrayShapeFromConstantArrayReturnRector\Fixture; | ||
|
||
final class UnicodeKey | ||
{ | ||
/** | ||
* @return array{äÄ: string} | ||
*/ | ||
public function run(string $name) | ||
{ | ||
return ['äÄ' => $name]; | ||
} | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters