rector-src icon indicating copy to clipboard operation
rector-src copied to clipboard

Add failing test fixture for NullToStrictStringFuncCallArgRector

Open stephanvierkant opened this issue 3 years ago • 2 comments

Failing Test for NullToStrictStringFuncCallArgRector

Based on https://getrector.org/demo/9a90408b-44b7-48f9-a5fa-458a526e8749

Code should be untouched: trim can't get a null value. If method is used without trait, it works fine.

stephanvierkant avatar Oct 24 '22 12:10 stephanvierkant

That's expected, property is defined in class, while trait access it, it will be marked as mixed, as trait here is depends on class.

Once the trait is consumed by class that not has the property, it will be undefined https://3v4l.org/Yt7Bq .

Even property defined in trait, accessing property from property fetch under trait seems not possible, at least for now.

samsonasik avatar Oct 24 '22 12:10 samsonasik

Thanks for your reply. I experienced this problem after PHPStan notifying me that there is a useless type cast. So there should be a way to detect that $title is a ?string

stephanvierkant avatar Oct 24 '22 16:10 stephanvierkant

These 2 files should be separated. One in Fixture and another in Source.

TomasVotruba avatar Nov 18 '22 21:11 TomasVotruba