Annotation of embedaddon/php/ext/reflection/tests/ReflectionParameter_002.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: ReflectionParameter class - isPassedByReferenceMethod()
        !             3: --CREDITS--
        !             4: Robin Fernandes <robinf@php.net>
        !             5: Steve Seear <stevseea@php.net>
        !             6: --FILE--
        !             7: <?php
        !             8: class ReflectTestClass {
        !             9:     public static function staticMethod(&$paramOne, $anotherParam) {
        !            10:         return ++$theIncrement;
        !            11:     }
        !            12:     
        !            13:     public function instanceMethod($firstParam, &$secondParam) {
        !            14:       $firstParam = "Hello\n";
        !            15:     }
        !            16: }
        !            17: 
        !            18: // Create an instance of the Reflection_Method class
        !            19: $method = new ReflectionMethod('ReflectTestClass', 'staticMethod');
        !            20: // Get the parameters
        !            21: $parameters = $method->getParameters();
        !            22: echo "Parameters from staticMethod:\n\n";
        !            23: foreach($parameters as $parameter) {
        !            24:        var_dump($parameter);
        !            25:     if($parameter->isPassedByReference()) {
        !            26:        echo "This param is passed by reference\n";
        !            27:     } else {
        !            28:        echo "This param is not passed by reference\n";
        !            29:     }
        !            30:     echo "\n";
        !            31: }
        !            32: 
        !            33: // Create an instance of the Reflection_Method class
        !            34: $method = new ReflectionMethod('ReflectTestClass', 'instanceMethod');
        !            35: // Get the parameters
        !            36: $parameters = $method->getParameters();
        !            37: echo "Parameters from instanceMethod:\n\n";
        !            38: foreach($parameters as $parameter) {
        !            39:        var_dump($parameter);
        !            40:     if($parameter->isPassedByReference()) {
        !            41:        echo "This param is passed by reference\n";
        !            42:     } else {
        !            43:        echo "This param is not passed by reference\n";
        !            44:     }
        !            45:     echo "\n";
        !            46: }
        !            47: 
        !            48: echo "done\n";
        !            49: 
        !            50: ?>
        !            51: --EXPECTF--
        !            52: Parameters from staticMethod:
        !            53: 
        !            54: object(ReflectionParameter)#%i (1) {
        !            55:   ["name"]=>
        !            56:   string(8) "paramOne"
        !            57: }
        !            58: This param is passed by reference
        !            59: 
        !            60: object(ReflectionParameter)#%i (1) {
        !            61:   ["name"]=>
        !            62:   string(12) "anotherParam"
        !            63: }
        !            64: This param is not passed by reference
        !            65: 
        !            66: Parameters from instanceMethod:
        !            67: 
        !            68: object(ReflectionParameter)#%i (1) {
        !            69:   ["name"]=>
        !            70:   string(10) "firstParam"
        !            71: }
        !            72: This param is not passed by reference
        !            73: 
        !            74: object(ReflectionParameter)#%i (1) {
        !            75:   ["name"]=>
        !            76:   string(11) "secondParam"
        !            77: }
        !            78: This param is passed by reference
        !            79: 
        !            80: done

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