Skip to content

Commit 72c537a

Browse files
authored
[Php80] Keep numeric string as is on StringAnnotationToAttributeMapper (#6608)
1 parent 5e0f1ce commit 72c537a

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

src/PhpAttribute/AnnotationToAttributeMapper/StringAnnotationToAttributeMapper.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use PhpParser\Node\Expr;
88
use PhpParser\Node\Expr\ConstFetch;
99
use PhpParser\Node\Name;
10-
use PhpParser\Node\Scalar\Int_;
1110
use PhpParser\Node\Scalar\String_;
1211
use Rector\NodeTypeResolver\Node\AttributeKey;
1312
use Rector\PhpAttribute\Contract\AnnotationToAttributeMapperInterface;
@@ -39,11 +38,6 @@ public function map($value): Expr
3938
return new ConstFetch(new Name('null'));
4039
}
4140

42-
// number as string to number
43-
if (is_numeric($value) && strlen((string) (int) $value) === strlen($value)) {
44-
return Int_::fromString($value);
45-
}
46-
4741
if (str_contains($value, "'") && ! str_contains($value, "\n")) {
4842
$kind = String_::KIND_DOUBLE_QUOTED;
4943
} else {

tests/PhpAttribute/AnnotationToAttributeMapper/AnnotationToAttributeMapperTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ public static function provideData(): Iterator
4444
{
4545
yield [false, ConstFetch::class];
4646
yield ['false', ConstFetch::class];
47-
yield ['100', Int_::class];
47+
yield ['100', String_::class];
48+
yield [200, Int_::class];
4849
yield ['hey', String_::class];
4950
yield [['hey'], Array_::class];
5051
}

0 commit comments

Comments
 (0)