Annotation of embedaddon/php/Zend/tests/traits/property008.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Handling of private fields with traits needs to have same semantics as with normal inheritance.
        !             3: --FILE--
        !             4: <?php
        !             5: error_reporting(E_ALL | E_STRICT);
        !             6: 
        !             7: class BaseWithPropA {
        !             8:   private $hello = 0;
        !             9: }
        !            10: 
        !            11: // This is how privates are handled in normal inheritance
        !            12: class SubclassClassicInheritance extends BaseWithPropA {
        !            13:   private $hello = 0;
        !            14: }
        !            15: 
        !            16: // And here, we need to make sure, that the traits behave the same
        !            17: 
        !            18: trait AHelloProperty {
        !            19:   private $hello = 0;
        !            20: }
        !            21: 
        !            22: class BaseWithTPropB {
        !            23:     use AHelloProperty;
        !            24: }
        !            25: 
        !            26: class SubclassA extends BaseWithPropA {
        !            27:     use AHelloProperty;
        !            28: }
        !            29: 
        !            30: class SubclassB extends BaseWithTPropB {
        !            31:     use AHelloProperty;
        !            32: }
        !            33: 
        !            34: $classic = new SubclassClassicInheritance;
        !            35: var_dump($classic);
        !            36: 
        !            37: $a = new SubclassA;
        !            38: var_dump($a);
        !            39: 
        !            40: $b = new SubclassB;
        !            41: var_dump($b);
        !            42: 
        !            43: ?>
        !            44: --EXPECTF--    
        !            45: object(SubclassClassicInheritance)#1 (2) {
        !            46:   ["hello":"SubclassClassicInheritance":private]=>
        !            47:   int(0)
        !            48:   ["hello":"BaseWithPropA":private]=>
        !            49:   int(0)
        !            50: }
        !            51: object(SubclassA)#2 (2) {
        !            52:   ["hello":"SubclassA":private]=>
        !            53:   int(0)
        !            54:   ["hello":"BaseWithPropA":private]=>
        !            55:   int(0)
        !            56: }
        !            57: object(SubclassB)#3 (2) {
        !            58:   ["hello":"SubclassB":private]=>
        !            59:   int(0)
        !            60:   ["hello":"BaseWithTPropB":private]=>
        !            61:   int(0)
        !            62: }

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