|
2 | 2 |
|
3 | 3 | declare(strict_types=1); |
4 | 4 |
|
| 5 | +use AmazonPHP\SellingPartner\Model\CatalogItem\Categories; |
| 6 | +use AmazonPHP\SellingPartner\Model\ListingsItems\ListingsItemPutRequest; |
| 7 | +use AmazonPHP\SellingPartner\Model\Messaging\GetSchemaResponse; |
| 8 | +use AmazonPHP\SellingPartner\Model\Uploads\UploadDestination; |
| 9 | +use PHPStan\Type\ArrayType; |
| 10 | +use PHPStan\Type\MixedType; |
| 11 | +use PHPStan\Type\NullType; |
| 12 | +use PHPStan\Type\UnionType; |
5 | 13 | use Rector\Core\Configuration\Option; |
6 | | -use Rector\Core\ValueObject\PhpVersion; |
7 | 14 | use Rector\Set\ValueObject\SetList; |
| 15 | +use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector; |
| 16 | +use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector; |
| 17 | +use Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration; |
| 18 | +use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration; |
8 | 19 | use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; |
| 20 | +use Symplify\SymfonyPhpConfig\ValueObjectInliner; |
9 | 21 |
|
10 | 22 | return static function (ContainerConfigurator $containerConfigurator): void { |
11 | 23 | // get parameters |
|
32 | 44 | $containerConfigurator->import(SetList::PHP_73); |
33 | 45 | $containerConfigurator->import(SetList::PHP_74); |
34 | 46 | $containerConfigurator->import(SetList::TYPE_DECLARATION); |
| 47 | + |
| 48 | + /** |
| 49 | + * Explanation here: https://github.com/amazon-php/sp-api-sdk/issues/101#issuecomment-1002159988 |
| 50 | + */ |
| 51 | + $services->set(AddParamTypeDeclarationRector::class) |
| 52 | + ->call('configure', [[ |
| 53 | + AddParamTypeDeclarationRector::PARAMETER_TYPEHINTS => ValueObjectInliner::inline([ |
| 54 | + new AddParamTypeDeclaration( |
| 55 | + Categories::class, |
| 56 | + 'setParent', |
| 57 | + 0, |
| 58 | + new UnionType([new NullType(), new ArrayType(new MixedType(), new MixedType())]) |
| 59 | + ), |
| 60 | + new AddParamTypeDeclaration( |
| 61 | + ListingsItemPutRequest::class, |
| 62 | + 'setAttributes', |
| 63 | + 0, |
| 64 | + new UnionType([new NullType(), new ArrayType(new MixedType(), new MixedType())]) |
| 65 | + ), |
| 66 | + new AddParamTypeDeclaration( |
| 67 | + GetSchemaResponse::class, |
| 68 | + 'setPayload', |
| 69 | + 0, |
| 70 | + new UnionType([new NullType(), new ArrayType(new MixedType(), new MixedType())]) |
| 71 | + ), |
| 72 | + new AddParamTypeDeclaration( |
| 73 | + UploadDestination::class, |
| 74 | + 'setHeaders', |
| 75 | + 0, |
| 76 | + new UnionType([new NullType(), new ArrayType(new MixedType(), new MixedType())]) |
| 77 | + ), |
| 78 | + ]) |
| 79 | + ]]); |
| 80 | + |
| 81 | + $services->set(AddReturnTypeDeclarationRector::class) |
| 82 | + ->call('configure', [[ |
| 83 | + AddReturnTypeDeclarationRector::METHOD_RETURN_TYPES => ValueObjectInliner::inline([ |
| 84 | + new AddReturnTypeDeclaration( |
| 85 | + Categories::class, |
| 86 | + 'getParent', |
| 87 | + new UnionType([new NullType(), new ArrayType(new MixedType(), new MixedType())]), |
| 88 | + ), |
| 89 | + new AddReturnTypeDeclaration( |
| 90 | + ListingsItemPutRequest::class, |
| 91 | + 'getAttributes', |
| 92 | + new UnionType([new NullType(), new ArrayType(new MixedType(), new MixedType())]), |
| 93 | + ), |
| 94 | + new AddReturnTypeDeclaration( |
| 95 | + GetSchemaResponse::class, |
| 96 | + 'getPayload', |
| 97 | + new UnionType([new NullType(), new ArrayType(new MixedType(), new MixedType())]), |
| 98 | + ), |
| 99 | + new AddReturnTypeDeclaration( |
| 100 | + GetSchemaResponse::class, |
| 101 | + 'getHeaders', |
| 102 | + new UnionType([new NullType(), new ArrayType(new MixedType(), new MixedType())]), |
| 103 | + ), |
| 104 | + ]) |
| 105 | + ]]); |
35 | 106 | }; |
0 commit comments