Annotation of embedaddon/php/ext/standard/tests/array/sizeof_object1.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Test sizeof() function : object functionality - object with Countable interface
        !             3: --SKIPIF--
        !             4: <?php 
        !             5: // Skip the test case if Standard PHP Library(spl) is not installed
        !             6:   if( !extension_loaded('spl'))
        !             7:   {
        !             8:      die('skip spl is not installed');
        !             9:   }
        !            10: ?>
        !            11: --FILE--
        !            12: <?php
        !            13: /* Prototype  : int sizeof($mixed var[, int $mode])
        !            14:  * Description: Counts an elements in an array. If Standard PHP library is installed, 
        !            15:  * it will return the properties of an object.
        !            16:  * Source code: ext/standard/basic_functions.c
        !            17:  * Alias to functions: count()
        !            18:  */
        !            19: 
        !            20: echo "*** Testing sizeof() : object functionality ***\n";
        !            21: 
        !            22: echo "-- Testing sizeof() with an object which implements Countable interface --\n";
        !            23: class sizeof_class implements Countable 
        !            24: {
        !            25:   public $member1;
        !            26:   private $member2;
        !            27:   protected $member3;
        !            28:  
        !            29:   public function count()
        !            30:   {
        !            31:     return 3; // return the count of member variables in the object
        !            32:   }
        !            33: }
        !            34: 
        !            35: $obj = new sizeof_class();
        !            36: 
        !            37: echo "-- Testing sizeof() in default mode --\n";
        !            38: var_dump( sizeof($obj) );
        !            39: echo "-- Testing sizeof() in COUNT_NORMAL mode --\n";
        !            40: var_dump( sizeof($obj, COUNT_NORMAL) );
        !            41: echo "-- Testing sizeof() in COUNT_RECURSIVE mode --\n";
        !            42: var_dump( sizeof($obj, COUNT_RECURSIVE) );
        !            43: 
        !            44: echo "Done";
        !            45: ?>
        !            46: --EXPECTF--
        !            47: *** Testing sizeof() : object functionality ***
        !            48: -- Testing sizeof() with an object which implements Countable interface --
        !            49: -- Testing sizeof() in default mode --
        !            50: int(3)
        !            51: -- Testing sizeof() in COUNT_NORMAL mode --
        !            52: int(3)
        !            53: -- Testing sizeof() in COUNT_RECURSIVE mode --
        !            54: int(3)
        !            55: Done

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>