Repository navigation
Conversation
…the end of file and improve test with more entries to test plural one
|
@sovetski FYI: You can run Behat test locally easily using commands like: This will run behat test of given file and 263 is the line number of your new Scenario. This will be helpful for quick test in local environment. With using |
Thank you, it helped a lot, now the test pass successfully |
| * | ||
| * @param mixed $value The variable you want to export. | ||
| * @param int $level The current indentation level. | ||
| * @param int $indentation The number of spaces for indentation. Default is 4. |
There was a problem hiding this comment.
I like using tabs for my own projects, but here as it is something which will be used on other developers IDE, I prefer to use spaces, because tabs configuration depends on the configuration of user. A space will be every time a space, but tab not. Some resources not related to this subject but still on the same issue:
https://medium.com/@peey/what-is-the-inconsistent-use-of-tabs-and-spaces-in-indentation-error-and-why-is-it-caused-f3bbb8b2568b
https://stackoverflow.com/questions/5685406/inconsistent-use-of-tabs-and-spaces-in-indentation
There was a problem hiding this comment.
I prefer to use spaces, because tabs configuration depends on the configuration of user
That's actually an advantage of tabs :-) But I don't wanna start yet another tabs vs spaces discussion here.
I am mainly suggesting using tabs because that's the WordPress coding standard and IMHO we should be consistent with that.
There was a problem hiding this comment.
Great, in this case I will try to change it to tabs to respect the standards, thanks!
| private static function pretty_export( $values, $indentation = 2 ) { | ||
| $result = '[' . PHP_EOL; | ||
| $indent = str_repeat( ' ', $indentation ); | ||
|
|
||
| foreach ( $values as $key => $value ) { | ||
| $result .= $indent . str_repeat( ' ', $indentation ) . "'$key' => "; | ||
|
|
||
| if ( is_array( $value ) ) { | ||
| $result .= self::pretty_export( $value, $indentation + $indentation ); | ||
| } elseif ( strpos( $value, "\0" ) !== false ) { | ||
| $parts = explode( "\0", $value ); | ||
| $result .= "'" . implode( "' . \"\\0\" . '", array_map( 'addslashes', $parts ) ) . "'"; | ||
| } else { | ||
| $result .= "'$value'"; | ||
| } | ||
|
|
||
| $result .= ',' . PHP_EOL; | ||
| } | ||
|
|
||
| $result .= $indent . ']'; | ||
| return $result; | ||
| } |
There was a problem hiding this comment.
The whole function is a bit hard to grasp. What's with the\0 checks here for example, why do we need that? 🤔
There was a problem hiding this comment.
Without that, instead of getting
'You have %d new message' => 'Du hast %d neue Nachricht' . "\0" . 'Du hast %d neue Nachrichten',
we will get
'You have %d new message' => 'Du hast %d neue NachrichtDu hast %d neue Nachrichten',
There was a problem hiding this comment.
My question is why is it doing this here and why is this not needed for the existing, non-pretty var_export() method?
|
I don't understand. The command When I add |
It sounds like it doesn't match exactly. When I manually run the |
|
Closing in favor of #458. Thanks again for contribution! |


It should resolve this issue: #395