mirror of
https://github.com/php/php-src.git
synced 2026-03-24 16:22:37 +01:00
* 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
36 lines
787 B
PHP
36 lines
787 B
PHP
--TEST--
|
|
SplFixedArray - values should be gced after var_export then being modified
|
|
--FILE--
|
|
<?php
|
|
class HasDestructor {
|
|
public function __destruct() {
|
|
echo "In destructor\n";
|
|
}
|
|
}
|
|
$array = SplFixedArray::fromArray([new HasDestructor()]);
|
|
var_dump($array);
|
|
echo "Replacing\n";
|
|
$array[0] = new stdClass();
|
|
// As of php 8.3, this will be freed before the var_dump call
|
|
echo "Dumping again\n";
|
|
var_dump($array);
|
|
// As of php 8.3, this only contain object properties (dynamic properties and declared subclass properties)
|
|
var_dump(get_mangled_object_vars($array));
|
|
?>
|
|
--EXPECT--
|
|
object(SplFixedArray)#2 (1) {
|
|
[0]=>
|
|
object(HasDestructor)#1 (0) {
|
|
}
|
|
}
|
|
Replacing
|
|
In destructor
|
|
Dumping again
|
|
object(SplFixedArray)#2 (1) {
|
|
[0]=>
|
|
object(stdClass)#3 (0) {
|
|
}
|
|
}
|
|
array(0) {
|
|
}
|