Skip to content

Commit ab31be8

Browse files
authored
[DowngradePhp81] Support JsonSerializable in AddReturnTypeWillChangeAttributeRector (#380)
* Add JsonSerializable methods to type mapping * Add test for JsonSerializable
1 parent 391a44d commit ab31be8

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace Rector\Tests\DowngradePhp81\Rector\ClassMethod\AddReturnTypeWillChangeAttributeRector\Fixture;
4+
5+
class SomeJsonSerializable implements \JsonSerializable
6+
{
7+
public function jsonSerialize()
8+
{
9+
}
10+
}
11+
12+
?>
13+
-----
14+
<?php
15+
16+
namespace Rector\Tests\DowngradePhp81\Rector\ClassMethod\AddReturnTypeWillChangeAttributeRector\Fixture;
17+
18+
class SomeJsonSerializable implements \JsonSerializable
19+
{
20+
#[\ReturnTypeWillChange]
21+
public function jsonSerialize()
22+
{
23+
}
24+
}
25+
26+
?>

rules/DowngradePhp81/Rector/ClassMethod/AddReturnTypeWillChangeAttributeRector.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ final class AddReturnTypeWillChangeAttributeRector extends AbstractRector
3535
'Countable' => ['count'],
3636
'Iterator' => ['current', 'key', 'next', 'rewind', 'valid'],
3737
'IteratorAggregate' => ['getIterator'],
38+
'JsonSerializable' => ['jsonSerialize'],
3839
'Stringable' => ['__toString'],
3940
];
4041

0 commit comments

Comments
 (0)