FalseType #7027
-
|
It seems there is currently no support for the Would be great if a |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
|
The /**
*@var null|false|\stdClass
*/
private $unionValue;will be converted to: private \stdClass|false|null $unionValue = null; class Test4
{
- /**
- *@var null|false|\stdClass
- */
- private $unionValue;
+ private \stdClass|false|null $unionValue = null;with <?php
declare(strict_types=1);
use Rector\Core\Configuration\Option;
use Rector\Core\ValueObject\PhpVersionFeature;
use Rector\Php74\Rector\Property\TypedPropertyRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(TypedPropertyRector::class);
$parameters = $containerConfigurator->parameters();
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersionFeature::UNION_TYPES);
};It seems it still in composer config minimum-stability dev
composer config prefer-stable true
composer update rector/rector:dev-mainis that works for you? |
Beta Was this translation helpful? Give feedback.
-
|
@brandonkelly you can use return static function(ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(AddReturnTypeDeclarationRector::class)
->configure([
new AddReturnTypeDeclaration('my\\class', 'myMethod', new UnionType([
new \PHPStan\Type\IntegerType(),
new \PHPStan\Type\Constant\ConstantBooleanType(false)(),
]))
]);
}; |
Beta Was this translation helpful? Give feedback.
@brandonkelly you can use
PHPStan\Type\Constant\ConstantBooleanType(false)for that: