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

[11.x] Use Str::wrap() instead of nesting Str::start() inside Str::finish() #53987

Open
wants to merge 1 commit into
base: 11.x
Choose a base branch
from

Conversation

shaedrich
Copy link
Contributor

Btw, is there a reason, why the null coalescing assignment operator is used instead of just the null coalescing operator?

/**
* Wrap the string with the given strings.
*
* @param string $value
* @param string $before
* @param string|null $after
* @return string
*/
public static function wrap($value, $before, $after = null)
{
return $before.$value.($after ??= $before);
}

@shaedrich shaedrich changed the title Use Str::wrap() instead of nesting Str::start() inside Str::finish() [12.x] Use Str::wrap() instead of nesting Str::start() inside Str::finish() Dec 19, 2024
@shaedrich shaedrich changed the title [12.x] Use Str::wrap() instead of nesting Str::start() inside Str::finish() [11.x] Use Str::wrap() instead of nesting Str::start() inside Str::finish() Dec 19, 2024
@sydgren
Copy link

sydgren commented Dec 20, 2024

Btw, is there a reason, why the null coalescing assignment operator is used instead of just the null coalescing operator?

/**
* Wrap the string with the given strings.
*
* @param string $value
* @param string $before
* @param string|null $after
* @return string
*/
public static function wrap($value, $before, $after = null)
{
return $before.$value.($after ??= $before);
}

It does indeed seem unnecessary to reassign the $after variable.

I guess it's some leftovers from a previous change. Perhaps $after ??= $before has been on its own line above the return statement?

@shaedrich
Copy link
Contributor Author

shaedrich commented Dec 20, 2024

Would make sense, but—I checked it real quick—nope, it's always been this way (since 8ea50bc) 🤔

@stevebauman Is there a reason behind that, that we are missing or can the equal sign be removed?

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.

2 participants