Skip to content

Add failing test fixture for NullToStrictStringFuncCallArgRector#3012

Closed
stephanvierkant wants to merge 1 commit intorectorphp:mainfrom
stephanvierkant:patch-1
Closed

Add failing test fixture for NullToStrictStringFuncCallArgRector#3012
stephanvierkant wants to merge 1 commit intorectorphp:mainfrom
stephanvierkant:patch-1

Conversation

@stephanvierkant
Copy link
Contributor

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.

@samsonasik
Copy link
Member

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.

@stephanvierkant
Copy link
Contributor Author

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

@TomasVotruba
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants