In general there are no problems.
There may be if the passed type has passing semantics by reference. Obviously in this case the change will affect the variable that was used as an argument, if a variable was used instead of a literal, that there would be no problems because obviously it could not be used elsewhere, but in this case there was more passing reference and not by reference.
A string type passes a reference and does not copy the data as it does a number, for example, but the pass is not by reference, so any change in it does not reflect the variable used on the call.
Then nothing changes. In fact your example seems very interesting to reassign a value to the same parameter variable because the background is the same given.
I will not go into the merit of the parameter name to be bad because it is an example, but in a condition style question this can be important. If you are using meaningful names, assigning them to another variable can make a difference in readability, have names that indicate what that text is. If the parameter was called $texto
, it could call the new variable of $texto_formatado
to make it clear that there the content had the change. Give meaning to content.
Reinforcement that in simple cases so this type of readability is overkill and does not make sense, but can make in code more complex. While some will say more complex codes is already a bad practice.
I know it's just an example but since we're on the subject, in this case the variable is not even needed, this function would only need to have the return
line with the expression. That's why I said it depends on the context whether you need to readable or not. In general I think you do not have to be willing to document all operations by creating intermediate variables, I only do this when it's really confusing, but it's taste.
Of course, if you need to use the original value of the parameter other times, you can not discard it. And it would be silly to avoid discarding this value in another variable and reassigning a new value in this parameter.