summaryrefslogtreecommitdiff
path: root/tests/test_tools/simpletest/reflection_php4.php
blob: 4af685ec6dcb7897d774165dcd93731f2bbda733 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
    /**
     *	base include file for SimpleTest
     *	@package	SimpleTest
     *	@subpackage	UnitTester
     *	@version	$Id: reflection_php4.php 1398 2006-09-08 19:31:03Z xue $
     */

    /**
     *    Version specific reflection API.
	 *	  @package SimpleTest
	 *	  @subpackage UnitTester
     */
    class SimpleReflection {
        protected $_interface;

        /**
         *    Stashes the class/interface.
         *    @param string $interface    Class or interface
         *                                to inspect.
         */
        function SimpleReflection($interface) {
            $this->_interface = $interface;
        }

        /**
         *    Checks that a class has been declared.
         *    @return boolean        True if defined.
         *    @access public
         */
        function classExists() {
            return class_exists($this->_interface);
        }

        /**
         *    Needed to kill the autoload feature in PHP5
         *    for classes created dynamically.
         *    @return boolean        True if defined.
         *    @access public
         */
        function classExistsSansAutoload() {
            return class_exists($this->_interface);
        }

        /**
         *    Checks that a class or interface has been
         *    declared.
         *    @return boolean        True if defined.
         *    @access public
         */
        function classOrInterfaceExists() {
            return class_exists($this->_interface);
        }

        /**
         *    Needed to kill the autoload feature in PHP5
         *    for classes created dynamically.
         *    @return boolean        True if defined.
         *    @access public
         */
        function classOrInterfaceExistsSansAutoload() {
            return class_exists($this->_interface);
        }

        /**
         *    Gets the list of methods on a class or
         *    interface.
         *    @returns array          List of method names.
         *    @access public
         */
        function getMethods() {
            return get_class_methods($this->_interface);
        }

        /**
         *    Gets the list of interfaces from a class. If the
         *	  class name is actually an interface then just that
         *	  interface is returned.
         *    @returns array          List of interfaces.
         *    @access public
         */
        function getInterfaces() {
            return array();
        }

        /**
         *    Finds the parent class name.
         *    @returns string      Parent class name.
         *    @access public
         */
        function getParent() {
            return strtolower(get_parent_class($this->_interface));
        }

        /**
         *    Determines if the class is abstract, which for PHP 4
         *    will never be the case.
         *    @returns boolean      True if abstract.
         *    @access public
         */
        function isAbstract() {
            return false;
        }

        /**
         *	  Gets the source code matching the declaration
         *	  of a method.
         * 	  @param string $method		  Method name.
         *    @access public
         */
        function getSignature($method) {
        	return "function $method()";
        }
    }
?>