sizeof_object2.phpt [plain text]
--TEST--
Test sizeof() function : object functionality - objects without Countable interface
--FILE--
<?php
echo "*** Testing sizeof() : object functionality ***\n";
echo "--- Testing sizeof() with objects which doesn't implement Countable interface ---\n";
class test
{
}
class test1
{
public $member1;
var $var1;
private $member2;
protected $member3;
}
class test2
{
public function display()
{
echo " Class Name : test2\n";
}
}
class child_test2 extends test2
{
public $child_member1;
private $child_member2;
}
abstract class abstract_class
{
public $member1;
private $member2;
abstract protected function display();
}
class concrete_class extends abstract_class
{
protected function display()
{
echo " class name is : concrete_class \n ";
}
}
$objects = array (
new test(),
new test1(),
new test2(),
new child_test2(),
new concrete_class()
);
$counter = 1;
for($i = 0; $i < count($objects); $i++)
{
echo "-- Iteration $counter --\n";
$var = $objects[$i];
echo "Default Mode: ";
var_dump( sizeof($var) );
echo "\n";
echo "COUNT_NORMAL Mode: ";
var_dump( sizeof($var, COUNT_NORMAL) );
echo "\n";
echo "COUNT_RECURSIVE Mode: ";
var_dump( sizeof($var, COUNT_RECURSIVE) );
echo "\n";
$counter++;
}
echo "Done";
?>
--EXPECTF--
*** Testing sizeof() : object functionality ***
--- Testing sizeof() with objects which doesn't implement Countable interface ---
-- Iteration 1 --
Default Mode: int(1)
COUNT_NORMAL Mode: int(1)
COUNT_RECURSIVE Mode: int(1)
-- Iteration 2 --
Default Mode: int(1)
COUNT_NORMAL Mode: int(1)
COUNT_RECURSIVE Mode: int(1)
-- Iteration 3 --
Default Mode: int(1)
COUNT_NORMAL Mode: int(1)
COUNT_RECURSIVE Mode: int(1)
-- Iteration 4 --
Default Mode: int(1)
COUNT_NORMAL Mode: int(1)
COUNT_RECURSIVE Mode: int(1)
-- Iteration 5 --
Default Mode: int(1)
COUNT_NORMAL Mode: int(1)
COUNT_RECURSIVE Mode: int(1)
Done