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 NullToStrictStringFuncCallArgRector #8447

Closed
Axelkt17 opened this issue Jan 31, 2024 · 1 comment · Fixed by rectorphp/rector-src#5532
Closed

Incorrect behavior of NullToStrictStringFuncCallArgRector #8447

Axelkt17 opened this issue Jan 31, 2024 · 1 comment · Fixed by rectorphp/rector-src#5532
Labels

Comments

@Axelkt17
Copy link

Axelkt17 commented Jan 31, 2024

Bug Report

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

Minimal PHP Code Causing Issue

See https://getrector.com/demo/02a7fdb5-a431-4806-b363-3d1d96495bf5

<?php

final class DemoFile
{

    public $importedId;
    
    public function setImportedId($importedId) {
        if (strlen($this->importedId) > 0) {
            $this->importedId = $importedId;
        }
    }
}

Responsible rules

  • NullToStrictStringFuncCallArgRector

Expected Behavior

The example above works as expected. Why doesn't rector add the typecast when there is a docblock like

   /**
     * @var string|null
     */
    public $importedId;

?
See: https://getrector.com/demo/83bcd62a-a5a2-4650-a1c3-7eeb0127cc2b
The param could be null, so a typecast would be correct in this case.
Is there a possibility in rector to disable the parsing of phpdoc, so rector wolud behave as if the phpdoc param was not there?
Thanks!

@Axelkt17
Copy link
Author

Wow, great service :-) !

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

Successfully merging a pull request may close this issue.

1 participant