1--TEST-- 2Test DateTime class registration 3--FILE-- 4<?php 5 6echo "*** Verify DateTime class ***\n"; 7 8echo "Verify DateTime class registered OK\n"; 9$class = new ReflectionClass('DateTime'); 10var_dump($class); 11 12echo "..and get names of all its methods\n"; 13$methods = $class->getMethods(); 14var_dump($methods); 15 16echo "..and get names of all its class constants\n"; 17$constants = $class->getConstants(); 18var_dump($constants); 19 20echo "..and get __set_state arguments\n"; 21$method = new ReflectionMethod('DateTime', '__set_state'); 22var_dump($method->getParameters()); 23var_dump($method->getParameters()[0]->isOptional()); 24 25?> 26===DONE=== 27--EXPECTF-- 28*** Verify DateTime class *** 29Verify DateTime class registered OK 30object(ReflectionClass)#%d (1) { 31 ["name"]=> 32 string(8) "DateTime" 33} 34..and get names of all its methods 35array(19) { 36 [0]=> 37 object(ReflectionMethod)#%d (2) { 38 ["name"]=> 39 string(11) "__construct" 40 ["class"]=> 41 string(8) "DateTime" 42 } 43 [1]=> 44 object(ReflectionMethod)#%d (2) { 45 ["name"]=> 46 string(8) "__wakeup" 47 ["class"]=> 48 string(8) "DateTime" 49 } 50 [2]=> 51 object(ReflectionMethod)#%d (2) { 52 ["name"]=> 53 string(11) "__set_state" 54 ["class"]=> 55 string(8) "DateTime" 56 } 57 [3]=> 58 object(ReflectionMethod)#%d (2) { 59 ["name"]=> 60 string(19) "createFromImmutable" 61 ["class"]=> 62 string(8) "DateTime" 63 } 64 [4]=> 65 object(ReflectionMethod)#%d (2) { 66 ["name"]=> 67 string(16) "createFromFormat" 68 ["class"]=> 69 string(8) "DateTime" 70 } 71 [5]=> 72 object(ReflectionMethod)#%d (2) { 73 ["name"]=> 74 string(13) "getLastErrors" 75 ["class"]=> 76 string(8) "DateTime" 77 } 78 [6]=> 79 object(ReflectionMethod)#%d (2) { 80 ["name"]=> 81 string(6) "format" 82 ["class"]=> 83 string(8) "DateTime" 84 } 85 [7]=> 86 object(ReflectionMethod)#%d (2) { 87 ["name"]=> 88 string(6) "modify" 89 ["class"]=> 90 string(8) "DateTime" 91 } 92 [8]=> 93 object(ReflectionMethod)#%d (2) { 94 ["name"]=> 95 string(3) "add" 96 ["class"]=> 97 string(8) "DateTime" 98 } 99 [9]=> 100 object(ReflectionMethod)#%d (2) { 101 ["name"]=> 102 string(3) "sub" 103 ["class"]=> 104 string(8) "DateTime" 105 } 106 [10]=> 107 object(ReflectionMethod)#%d (2) { 108 ["name"]=> 109 string(11) "getTimezone" 110 ["class"]=> 111 string(8) "DateTime" 112 } 113 [11]=> 114 object(ReflectionMethod)#%d (2) { 115 ["name"]=> 116 string(11) "setTimezone" 117 ["class"]=> 118 string(8) "DateTime" 119 } 120 [12]=> 121 object(ReflectionMethod)#%d (2) { 122 ["name"]=> 123 string(9) "getOffset" 124 ["class"]=> 125 string(8) "DateTime" 126 } 127 [13]=> 128 object(ReflectionMethod)#%d (2) { 129 ["name"]=> 130 string(7) "setTime" 131 ["class"]=> 132 string(8) "DateTime" 133 } 134 [14]=> 135 object(ReflectionMethod)#%d (2) { 136 ["name"]=> 137 string(7) "setDate" 138 ["class"]=> 139 string(8) "DateTime" 140 } 141 [15]=> 142 object(ReflectionMethod)#%d (2) { 143 ["name"]=> 144 string(10) "setISODate" 145 ["class"]=> 146 string(8) "DateTime" 147 } 148 [16]=> 149 object(ReflectionMethod)#%d (2) { 150 ["name"]=> 151 string(12) "setTimestamp" 152 ["class"]=> 153 string(8) "DateTime" 154 } 155 [17]=> 156 object(ReflectionMethod)#%d (2) { 157 ["name"]=> 158 string(12) "getTimestamp" 159 ["class"]=> 160 string(8) "DateTime" 161 } 162 [18]=> 163 object(ReflectionMethod)#%d (2) { 164 ["name"]=> 165 string(4) "diff" 166 ["class"]=> 167 string(8) "DateTime" 168 } 169} 170..and get names of all its class constants 171array(13) { 172 ["ATOM"]=> 173 string(13) "Y-m-d\TH:i:sP" 174 ["COOKIE"]=> 175 string(16) "l, d-M-Y H:i:s T" 176 ["ISO8601"]=> 177 string(13) "Y-m-d\TH:i:sO" 178 ["RFC822"]=> 179 string(16) "D, d M y H:i:s O" 180 ["RFC850"]=> 181 string(16) "l, d-M-y H:i:s T" 182 ["RFC1036"]=> 183 string(16) "D, d M y H:i:s O" 184 ["RFC1123"]=> 185 string(16) "D, d M Y H:i:s O" 186 ["RFC7231"]=> 187 string(21) "D, d M Y H:i:s \G\M\T" 188 ["RFC2822"]=> 189 string(16) "D, d M Y H:i:s O" 190 ["RFC3339"]=> 191 string(13) "Y-m-d\TH:i:sP" 192 ["RFC3339_EXTENDED"]=> 193 string(15) "Y-m-d\TH:i:s.vP" 194 ["RSS"]=> 195 string(16) "D, d M Y H:i:s O" 196 ["W3C"]=> 197 string(13) "Y-m-d\TH:i:sP" 198} 199..and get __set_state arguments 200array(1) { 201 [0]=> 202 object(ReflectionParameter)#%d (1) { 203 ["name"]=> 204 string(5) "array" 205 } 206} 207bool(false) 208===DONE=== 209