Re: Proposal: short_var_export($value, bool $return=false, int $flags=0)

From: Date: Wed, 20 Jan 2021 15:43:44 +0000
Subject: Re: Proposal: short_var_export($value, bool $return=false, int $flags=0)
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-112937@lists.php.net to get a copy of this message
On 19-01-2021 16:12, tyson andre wrote: > It seems inconsistent and prone to bugs when refactoring (e.g. converting to string and not > using the result) > to have two functions named var_export where one prints by default and the other doesn't, > but otherwise . > Changing to a different name entirely would solve that, such as var_repr(), > var_representation(), serialize_[value_]as_php_snippet(), etc. > I am considering to try and introduce a __repr() magic method that is similar to the __repr__() method from Python. Having a var_repr() method which does not use the __repr() method would be confusing. So I would like to suggest not to use that name. As the intent of the resulting string is to obtain PHP code that will construct the variable, another option might be: var_constructor(). Regards, Dik Takken

« previous php.internals (#112937) next »