php-src/Zend/tests/function_arguments/sensitive_parameter_value.phpt
Tyson Andre c4ecd82f93
Make inspecting SplFixedArray instances more memory efficient/consistent, change print_r null props handling (#9757)
* Make handling of SplFixedArray properties more consistent

Create a brand new reference counted array every time in SplFixedArray
to be freed by the callers (or return null).
Switch from overriding `get_properties` to overriding `get_properties_for` handler

* Print objects with null hash table like others in print_r

Noticed when working on subsequent commits for SplFixedArray.
Make whether zend_get_properties_for returns null or an empty array
invisible to the end user - it would be always be a non-null array for
user-defined classes.
Always print newlines with `\n\s*(\n\s*)` after objects

Noticed when working on SplFixedArray changes, e.g. in
ext/spl/tests/SplFixedArray__construct_param_null.phpt
2022-10-24 08:33:25 -04:00

47 lines
847 B
PHP

--TEST--
A SensitiveParameterValue keeps the inner value secret.
--FILE--
<?php
$v = new SensitiveParameterValue('secret');
echo "# var_dump() / debug_zval_dump() / print_r()", PHP_EOL;
var_dump($v);
debug_zval_dump($v);
print_r($v);
echo PHP_EOL;
echo "# var_export()", PHP_EOL;
echo var_export($v, true), PHP_EOL;
echo PHP_EOL;
echo "# (array) / json_encode()", PHP_EOL;
var_dump((array)$v);
var_dump(json_encode($v));
echo PHP_EOL;
echo "# ->getValue()", PHP_EOL;
var_dump($v->getValue());
?>
--EXPECTF--
# var_dump() / debug_zval_dump() / print_r()
object(SensitiveParameterValue)#%d (0) {
}
object(SensitiveParameterValue)#%d (%d) refcount(%d){
}
SensitiveParameterValue Object
(
)
# var_export()
\SensitiveParameterValue::__set_state(array(
))
# (array) / json_encode()
array(0) {
}
string(2) "{}"
# ->getValue()
string(6) "secret"