Skip to content

Commit

Permalink
add return type to step-3
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Sep 24, 2019
1 parent b8de750 commit 4fbca58
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/set/doctrine/doctrine-id-to-uuid-step-3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ services:

# add Uuid type declarations
Rector\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedParamTypeRector: ~
Rector\TypeDeclaration\Rector\ClassMethod\AddArrayReturnDocTypeRector: ~
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public function provideDataForTest(): iterable
yield [__DIR__ . '/Fixture/yield_strings.php.inc'];
yield [__DIR__ . '/Fixture/add_without_return_type_declaration.php.inc'];
yield [__DIR__ . '/Fixture/fix_incorrect_array.php.inc'];
yield [__DIR__ . '/Fixture/return_uuid.php.inc'];

// skip
yield [__DIR__ . '/Fixture/skip_shorten_class_name.php.inc'];
yield [__DIR__ . '/Fixture/skip_constructor.php.inc'];
yield [__DIR__ . '/Fixture/skip_inner_function_return.php.inc'];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

namespace Rector\TypeDeclaration\Tests\Rector\ClassMethod\AddArrayReturnDocTypeRector\Fixture;

use Rector\TypeDeclaration\Tests\Rector\ClassMethod\AddArrayReturnDocTypeRector\Source\EntityReturningUuid;

final class FullyQualifiedName
{
/**
* @var EntityReturningUuid[]
*/
private $amenityBuildings = [];

/**
* @return int[]
*/
public function getBuildingIds(): array
{
$buildingIds = [];
foreach ($this->amenityBuildings as $amenityBuilding) {
$buildingIds[] = $amenityBuilding->getId();
}

return $buildingIds;
}
}

?>
-----
<?php

namespace Rector\TypeDeclaration\Tests\Rector\ClassMethod\AddArrayReturnDocTypeRector\Fixture;

use Rector\TypeDeclaration\Tests\Rector\ClassMethod\AddArrayReturnDocTypeRector\Source\EntityReturningUuid;

final class FullyQualifiedName
{
/**
* @var EntityReturningUuid[]
*/
private $amenityBuildings = [];

/**
* @return \Ramsey\Uuid\UuidInterface[]
*/
public function getBuildingIds(): array
{
$buildingIds = [];
foreach ($this->amenityBuildings as $amenityBuilding) {
$buildingIds[] = $amenityBuilding->getId();
}

return $buildingIds;
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php declare(strict_types=1);

namespace Rector\TypeDeclaration\Tests\Rector\ClassMethod\AddArrayReturnDocTypeRector\Source;

use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;

final class EntityReturningUuid
{
public function getId(): UuidInterface
{
return Uuid::uuid4();
}
}

0 comments on commit 4fbca58

Please sign in to comment.