Skip to content

Conversation

@samsonasik
Copy link
Member

Continue on #3180

The following normal variable:

trait NormalVariableInTrait
{
    public function getTitle($title)
    {
        return trim($title);
    }
}

should be processed to :

-return trim($title);
+return trim((string) $title);

@TomasVotruba
Copy link
Member

Good one 👍 Go for the merge ✔️

@samsonasik samsonasik force-pushed the allow-normal-variable-trait branch from ee285d6 to 4d29206 Compare December 10, 2022 14:56
@samsonasik samsonasik force-pushed the allow-normal-variable-trait branch from aa16ca7 to 241204c Compare December 10, 2022 15:16
@samsonasik
Copy link
Member Author

samsonasik commented Dec 10, 2022

I rolled back property assigned in trait construct that was processed on #3173 to be skipped back, while __construct() method can be overridden by class that consume the trait, the use case seems very rare, so skip seems make sense:

241204c


private function shouldSkipTrait(Expr $expr, bool $isTrait): bool
{
if (! $expr instanceof MethodCall) {
Copy link
Member Author

@samsonasik samsonasik Dec 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MethodCall or possibly StaticCall detection as FuncCall argument may be in next iteration for improvement where the result is Typed and actually non-mixed type, eg: Nullable type.

@samsonasik
Copy link
Member Author

I am merging it ;)

@samsonasik samsonasik merged commit e479114 into main Dec 10, 2022
@samsonasik samsonasik deleted the allow-normal-variable-trait branch December 10, 2022 15:29
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.

4 participants