rector/config/set/doctrine-dbal-30.php
Tomas Votruba dc2047f70a
[TypeDeclaration] Switch from stringy types to PHPStan types (#4510)
* nette-30 config cleanup

* [TypeDeclaratoin] Move AddReturnTypeDeclarationRector from generic

* add Type support to AddReturnTypeDeclaration

* make AddParamTypeDeclarationRector use PHPStan type objects over strings

* [SymfonyPhpConfig] Add support for nested types

* drop StringTypeToPhpParserNodeMapper

* [ci-review] Rector Rectify

Co-authored-by: rector-bot <tomas@getrector.org>
2020-10-30 11:58:35 +00:00

36 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
use PHPStan\Type\VoidType;
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
use Rector\Renaming\ValueObject\MethodCallRename;
use function Rector\SymfonyPhpConfig\inline_value_objects;
use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector;
use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
# https://github.com/doctrine/dbal/blob/master/UPGRADE.md#bc-break-changes-in-handling-string-and-binary-columns
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(RenameMethodRector::class)
->call('configure', [[
RenameMethodRector::METHOD_CALL_RENAMES => inline_value_objects([
new MethodCallRename(
'DBAL\Platforms\AbstractPlatform',
'getVarcharTypeDeclarationSQL',
'getStringTypeDeclarationSQL'
),
new MethodCallRename('Doctrine\DBAL\Driver\DriverException', 'getErrorCode', 'getCode'),
]),
]]);
$services->set(AddReturnTypeDeclarationRector::class)
->call('configure', [[
AddReturnTypeDeclarationRector::METHOD_RETURN_TYPES => inline_value_objects([
new AddReturnTypeDeclaration('Doctrine\DBAL\Connection', 'ping', new VoidType()),
]),
]]);
};