Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect behavior of DowngradeTypedPropertyRector #6925

Closed
iNem0o opened this issue Jan 10, 2022 · 0 comments · Fixed by rectorphp/rector-src#1687
Closed

Incorrect behavior of DowngradeTypedPropertyRector #6925

iNem0o opened this issue Jan 10, 2022 · 0 comments · Fixed by rectorphp/rector-src#1687
Labels

Comments

@iNem0o
Copy link

iNem0o commented Jan 10, 2022

Hello

The DowngradeTypedPropertyRector rule doesn't preserve the default value if the property is nullable.

I didn't find the right way to fix this code to PR but i believe that maybe the default value should not be overridden here
https://github.com/rectorphp/rector-src/blob/main/rules/DowngradePhp74/Rector/Property/DowngradeTypedPropertyRector.php#L70
if there is a default value defined on the original property

Best

Bug Report

Subject Details
Rector version last dev-master
Installed as composer dependency

Minimal PHP Code Causing Issue

See https://getrector.org/demo/1ec72395-f107-68ec-9441-876a705acf57

<?php
declare(strict_types=1);

class DemoFile
{
	protected ?string $test = "test";
}

Responsible rules

  • DowngradeTypedPropertyRector

  • DowngradeAttributeToAnnotationRector

Expected Behavior

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant