-
-
Notifications
You must be signed in to change notification settings - Fork 338
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TypeDeclaration] Add fallback return direct array support on ReturnT…
…ypeFromStrictNewArrayRector (#4928) * [TypeDeclaration] Add fallback return array support on ReturnTypeFromStrictNewArrayRector * [ci-review] Rector Rectify * Fix phpstan * Fix phpstan * [ci-review] Rector Rectify --------- Co-authored-by: GitHub Action <actions@github.com>
- Loading branch information
1 parent
10eb09f
commit 2a697f7
Showing
3 changed files
with
77 additions
and
19 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
...ctor/ClassMethod/ReturnTypeFromStrictNewArrayRector/Fixture/fallback_return_array.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,58 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictNewArrayRector\Fixture; | ||
|
||
final class FallbackReturnArray | ||
{ | ||
public function groupOffers($offers) | ||
{ | ||
if (count($offers) == 0) { | ||
return []; | ||
} | ||
|
||
$groupOffers = []; | ||
|
||
$groupedOffers = []; | ||
foreach ($offers as $offer) { | ||
$groupedOffers[$offer->groupid.'--'.$offer->tarifid] = $offer; | ||
$groupedOffers[$offer->groupid.'--'.$offer->tarifid]->groupedOffers = $groupOffers; | ||
} | ||
|
||
return $groupedOffers; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictNewArrayRector\Fixture; | ||
|
||
final class FallbackReturnArray | ||
{ | ||
/** | ||
* @return mixed[] | ||
*/ | ||
public function groupOffers($offers): array | ||
{ | ||
if (count($offers) == 0) { | ||
return []; | ||
} | ||
|
||
$groupOffers = []; | ||
|
||
$groupedOffers = []; | ||
foreach ($offers as $offer) { | ||
$groupedOffers[$offer->groupid.'--'.$offer->tarifid] = $offer; | ||
$groupedOffers[$offer->groupid.'--'.$offer->tarifid]->groupedOffers = $groupOffers; | ||
} | ||
|
||
return $groupedOffers; | ||
} | ||
} | ||
|
||
?> |
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
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