1--TEST--
2is_a and is_subclass_of behaviour (with and without autoload)
3--SKIPIF--
4<?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 needed'); ?>
5--FILE--
6<?php
7
8interface if_a {
9	function f_a();
10}
11
12interface if_b extends if_a {
13	function f_b();
14}
15
16class base {
17	function _is_a($sub) {
18
19		echo "\n>>> With Defined class\n";
20		echo str_pad('is_a( OBJECT:'.get_class($this).', '.$sub.') = ', 60) . (is_a($this, $sub) ? 'yes' : 'no')."\n";
21		echo str_pad('is_a( STRING:'.get_class($this).', '.$sub.') = ', 60). (is_a(get_class($this), $sub) ? 'yes' : 'no')."\n";
22		echo str_pad('is_a( STRING:'.get_class($this).', '.$sub.', true) = ', 60). (is_a(get_class($this), $sub, true) ? 'yes' : 'no')."\n";
23		echo str_pad('is_subclass_of( OBJECT:'.get_class($this).', '.$sub.') = ', 60).  (is_subclass_of($this, $sub) ? 'yes' : 'no')."\n";
24		echo str_pad('is_subclass_of( STRING:'.get_class($this).', '.$sub.') = ', 60). (is_subclass_of(get_class($this), $sub) ? 'yes' : 'no')."\n";
25		echo str_pad('is_subclass_of( STRING:'.get_class($this).', '.$sub.',false) = ', 60). (is_subclass_of(get_class($this), $sub , false) ? 'yes' : 'no')."\n";
26
27		// with autoload options..
28		echo ">>> With Undefined\n";
29		echo  str_pad('is_a( STRING:undefB, '.$sub.',true) = ', 60). (is_a('undefB', $sub, true) ? 'yes' : 'no')."\n";
30		echo  str_pad('is_a( STRING:undefB, '.$sub.') = ', 60). (is_a('undefB', $sub) ? 'yes' : 'no')."\n";
31		echo  str_pad('is_subclass_of( STRING:undefB, '.$sub.',false) = ', 60). (is_subclass_of('undefB', $sub, false) ? 'yes' : 'no')."\n";
32		echo  str_pad('is_subclass_of( STRING:undefB, '.$sub.') = ', 60). (is_subclass_of('undefB', $sub) ? 'yes' : 'no')."\n";
33	}
34	function test() {
35		echo $this->_is_a('base');
36		echo $this->_is_a('derived_a');
37		echo $this->_is_a('if_a');
38		echo $this->_is_a('undefA');
39		echo "\n";
40	}
41}
42
43class derived_a extends base implements if_a {
44	function f_a() {}
45}
46
47class derived_b extends base implements if_a, if_b {
48	function f_a() {}
49	function f_b() {}
50}
51
52class derived_c extends derived_a implements if_b {
53	function f_b() {}
54}
55
56class derived_d extends derived_c {
57}
58
59$t = new base();
60$t->test();
61
62$t = new derived_a();
63$t->test();
64
65eval('
66  function __autoload($name)
67  {
68      echo ">>>> In __autoload: ";
69      var_dump($name);
70  }
71');
72
73echo "NOW WITH AUTOLOAD\n\n";
74
75$t = new base();
76$t->test();
77
78$t = new derived_a();
79$t->test();
80
81$t = new derived_b();
82$t->test();
83
84
85
86
87
88?>
89--EXPECTF--
90>>> With Defined class
91is_a( OBJECT:base, base) =                                  yes
92is_a( STRING:base, base) =                                  no
93is_a( STRING:base, base, true) =                            yes
94is_subclass_of( OBJECT:base, base) =                        no
95is_subclass_of( STRING:base, base) =                        no
96is_subclass_of( STRING:base, base,false) =                  no
97>>> With Undefined
98is_a( STRING:undefB, base,true) =                           no
99is_a( STRING:undefB, base) =                                no
100is_subclass_of( STRING:undefB, base,false) =                no
101is_subclass_of( STRING:undefB, base) =                      no
102
103>>> With Defined class
104is_a( OBJECT:base, derived_a) =                             no
105is_a( STRING:base, derived_a) =                             no
106is_a( STRING:base, derived_a, true) =                       no
107is_subclass_of( OBJECT:base, derived_a) =                   no
108is_subclass_of( STRING:base, derived_a) =                   no
109is_subclass_of( STRING:base, derived_a,false) =             no
110>>> With Undefined
111is_a( STRING:undefB, derived_a,true) =                      no
112is_a( STRING:undefB, derived_a) =                           no
113is_subclass_of( STRING:undefB, derived_a,false) =           no
114is_subclass_of( STRING:undefB, derived_a) =                 no
115
116>>> With Defined class
117is_a( OBJECT:base, if_a) =                                  no
118is_a( STRING:base, if_a) =                                  no
119is_a( STRING:base, if_a, true) =                            no
120is_subclass_of( OBJECT:base, if_a) =                        no
121is_subclass_of( STRING:base, if_a) =                        no
122is_subclass_of( STRING:base, if_a,false) =                  no
123>>> With Undefined
124is_a( STRING:undefB, if_a,true) =                           no
125is_a( STRING:undefB, if_a) =                                no
126is_subclass_of( STRING:undefB, if_a,false) =                no
127is_subclass_of( STRING:undefB, if_a) =                      no
128
129>>> With Defined class
130is_a( OBJECT:base, undefA) =                                no
131is_a( STRING:base, undefA) =                                no
132is_a( STRING:base, undefA, true) =                          no
133is_subclass_of( OBJECT:base, undefA) =                      no
134is_subclass_of( STRING:base, undefA) =                      no
135is_subclass_of( STRING:base, undefA,false) =                no
136>>> With Undefined
137is_a( STRING:undefB, undefA,true) =                         no
138is_a( STRING:undefB, undefA) =                              no
139is_subclass_of( STRING:undefB, undefA,false) =              no
140is_subclass_of( STRING:undefB, undefA) =                    no
141
142
143>>> With Defined class
144is_a( OBJECT:derived_a, base) =                             yes
145is_a( STRING:derived_a, base) =                             no
146is_a( STRING:derived_a, base, true) =                       yes
147is_subclass_of( OBJECT:derived_a, base) =                   yes
148is_subclass_of( STRING:derived_a, base) =                   yes
149is_subclass_of( STRING:derived_a, base,false) =             no
150>>> With Undefined
151is_a( STRING:undefB, base,true) =                           no
152is_a( STRING:undefB, base) =                                no
153is_subclass_of( STRING:undefB, base,false) =                no
154is_subclass_of( STRING:undefB, base) =                      no
155
156>>> With Defined class
157is_a( OBJECT:derived_a, derived_a) =                        yes
158is_a( STRING:derived_a, derived_a) =                        no
159is_a( STRING:derived_a, derived_a, true) =                  yes
160is_subclass_of( OBJECT:derived_a, derived_a) =              no
161is_subclass_of( STRING:derived_a, derived_a) =              no
162is_subclass_of( STRING:derived_a, derived_a,false) =        no
163>>> With Undefined
164is_a( STRING:undefB, derived_a,true) =                      no
165is_a( STRING:undefB, derived_a) =                           no
166is_subclass_of( STRING:undefB, derived_a,false) =           no
167is_subclass_of( STRING:undefB, derived_a) =                 no
168
169>>> With Defined class
170is_a( OBJECT:derived_a, if_a) =                             yes
171is_a( STRING:derived_a, if_a) =                             no
172is_a( STRING:derived_a, if_a, true) =                       yes
173is_subclass_of( OBJECT:derived_a, if_a) =                   yes
174is_subclass_of( STRING:derived_a, if_a) =                   yes
175is_subclass_of( STRING:derived_a, if_a,false) =             no
176>>> With Undefined
177is_a( STRING:undefB, if_a,true) =                           no
178is_a( STRING:undefB, if_a) =                                no
179is_subclass_of( STRING:undefB, if_a,false) =                no
180is_subclass_of( STRING:undefB, if_a) =                      no
181
182>>> With Defined class
183is_a( OBJECT:derived_a, undefA) =                           no
184is_a( STRING:derived_a, undefA) =                           no
185is_a( STRING:derived_a, undefA, true) =                     no
186is_subclass_of( OBJECT:derived_a, undefA) =                 no
187is_subclass_of( STRING:derived_a, undefA) =                 no
188is_subclass_of( STRING:derived_a, undefA,false) =           no
189>>> With Undefined
190is_a( STRING:undefB, undefA,true) =                         no
191is_a( STRING:undefB, undefA) =                              no
192is_subclass_of( STRING:undefB, undefA,false) =              no
193is_subclass_of( STRING:undefB, undefA) =                    no
194
195NOW WITH AUTOLOAD
196
197
198>>> With Defined class
199is_a( OBJECT:base, base) =                                  yes
200is_a( STRING:base, base) =                                  no
201is_a( STRING:base, base, true) =                            yes
202is_subclass_of( OBJECT:base, base) =                        no
203is_subclass_of( STRING:base, base) =                        no
204is_subclass_of( STRING:base, base,false) =                  no
205>>> With Undefined
206>>>> In __autoload: string(6) "undefB"
207is_a( STRING:undefB, base,true) =                           no
208is_a( STRING:undefB, base) =                                no
209is_subclass_of( STRING:undefB, base,false) =                no
210>>>> In __autoload: string(6) "undefB"
211is_subclass_of( STRING:undefB, base) =                      no
212
213>>> With Defined class
214is_a( OBJECT:base, derived_a) =                             no
215is_a( STRING:base, derived_a) =                             no
216is_a( STRING:base, derived_a, true) =                       no
217is_subclass_of( OBJECT:base, derived_a) =                   no
218is_subclass_of( STRING:base, derived_a) =                   no
219is_subclass_of( STRING:base, derived_a,false) =             no
220>>> With Undefined
221>>>> In __autoload: string(6) "undefB"
222is_a( STRING:undefB, derived_a,true) =                      no
223is_a( STRING:undefB, derived_a) =                           no
224is_subclass_of( STRING:undefB, derived_a,false) =           no
225>>>> In __autoload: string(6) "undefB"
226is_subclass_of( STRING:undefB, derived_a) =                 no
227
228>>> With Defined class
229is_a( OBJECT:base, if_a) =                                  no
230is_a( STRING:base, if_a) =                                  no
231is_a( STRING:base, if_a, true) =                            no
232is_subclass_of( OBJECT:base, if_a) =                        no
233is_subclass_of( STRING:base, if_a) =                        no
234is_subclass_of( STRING:base, if_a,false) =                  no
235>>> With Undefined
236>>>> In __autoload: string(6) "undefB"
237is_a( STRING:undefB, if_a,true) =                           no
238is_a( STRING:undefB, if_a) =                                no
239is_subclass_of( STRING:undefB, if_a,false) =                no
240>>>> In __autoload: string(6) "undefB"
241is_subclass_of( STRING:undefB, if_a) =                      no
242
243>>> With Defined class
244is_a( OBJECT:base, undefA) =                                no
245is_a( STRING:base, undefA) =                                no
246is_a( STRING:base, undefA, true) =                          no
247is_subclass_of( OBJECT:base, undefA) =                      no
248is_subclass_of( STRING:base, undefA) =                      no
249is_subclass_of( STRING:base, undefA,false) =                no
250>>> With Undefined
251>>>> In __autoload: string(6) "undefB"
252is_a( STRING:undefB, undefA,true) =                         no
253is_a( STRING:undefB, undefA) =                              no
254is_subclass_of( STRING:undefB, undefA,false) =              no
255>>>> In __autoload: string(6) "undefB"
256is_subclass_of( STRING:undefB, undefA) =                    no
257
258
259>>> With Defined class
260is_a( OBJECT:derived_a, base) =                             yes
261is_a( STRING:derived_a, base) =                             no
262is_a( STRING:derived_a, base, true) =                       yes
263is_subclass_of( OBJECT:derived_a, base) =                   yes
264is_subclass_of( STRING:derived_a, base) =                   yes
265is_subclass_of( STRING:derived_a, base,false) =             no
266>>> With Undefined
267>>>> In __autoload: string(6) "undefB"
268is_a( STRING:undefB, base,true) =                           no
269is_a( STRING:undefB, base) =                                no
270is_subclass_of( STRING:undefB, base,false) =                no
271>>>> In __autoload: string(6) "undefB"
272is_subclass_of( STRING:undefB, base) =                      no
273
274>>> With Defined class
275is_a( OBJECT:derived_a, derived_a) =                        yes
276is_a( STRING:derived_a, derived_a) =                        no
277is_a( STRING:derived_a, derived_a, true) =                  yes
278is_subclass_of( OBJECT:derived_a, derived_a) =              no
279is_subclass_of( STRING:derived_a, derived_a) =              no
280is_subclass_of( STRING:derived_a, derived_a,false) =        no
281>>> With Undefined
282>>>> In __autoload: string(6) "undefB"
283is_a( STRING:undefB, derived_a,true) =                      no
284is_a( STRING:undefB, derived_a) =                           no
285is_subclass_of( STRING:undefB, derived_a,false) =           no
286>>>> In __autoload: string(6) "undefB"
287is_subclass_of( STRING:undefB, derived_a) =                 no
288
289>>> With Defined class
290is_a( OBJECT:derived_a, if_a) =                             yes
291is_a( STRING:derived_a, if_a) =                             no
292is_a( STRING:derived_a, if_a, true) =                       yes
293is_subclass_of( OBJECT:derived_a, if_a) =                   yes
294is_subclass_of( STRING:derived_a, if_a) =                   yes
295is_subclass_of( STRING:derived_a, if_a,false) =             no
296>>> With Undefined
297>>>> In __autoload: string(6) "undefB"
298is_a( STRING:undefB, if_a,true) =                           no
299is_a( STRING:undefB, if_a) =                                no
300is_subclass_of( STRING:undefB, if_a,false) =                no
301>>>> In __autoload: string(6) "undefB"
302is_subclass_of( STRING:undefB, if_a) =                      no
303
304>>> With Defined class
305is_a( OBJECT:derived_a, undefA) =                           no
306is_a( STRING:derived_a, undefA) =                           no
307is_a( STRING:derived_a, undefA, true) =                     no
308is_subclass_of( OBJECT:derived_a, undefA) =                 no
309is_subclass_of( STRING:derived_a, undefA) =                 no
310is_subclass_of( STRING:derived_a, undefA,false) =           no
311>>> With Undefined
312>>>> In __autoload: string(6) "undefB"
313is_a( STRING:undefB, undefA,true) =                         no
314is_a( STRING:undefB, undefA) =                              no
315is_subclass_of( STRING:undefB, undefA,false) =              no
316>>>> In __autoload: string(6) "undefB"
317is_subclass_of( STRING:undefB, undefA) =                    no
318
319
320>>> With Defined class
321is_a( OBJECT:derived_b, base) =                             yes
322is_a( STRING:derived_b, base) =                             no
323is_a( STRING:derived_b, base, true) =                       yes
324is_subclass_of( OBJECT:derived_b, base) =                   yes
325is_subclass_of( STRING:derived_b, base) =                   yes
326is_subclass_of( STRING:derived_b, base,false) =             no
327>>> With Undefined
328>>>> In __autoload: string(6) "undefB"
329is_a( STRING:undefB, base,true) =                           no
330is_a( STRING:undefB, base) =                                no
331is_subclass_of( STRING:undefB, base,false) =                no
332>>>> In __autoload: string(6) "undefB"
333is_subclass_of( STRING:undefB, base) =                      no
334
335>>> With Defined class
336is_a( OBJECT:derived_b, derived_a) =                        no
337is_a( STRING:derived_b, derived_a) =                        no
338is_a( STRING:derived_b, derived_a, true) =                  no
339is_subclass_of( OBJECT:derived_b, derived_a) =              no
340is_subclass_of( STRING:derived_b, derived_a) =              no
341is_subclass_of( STRING:derived_b, derived_a,false) =        no
342>>> With Undefined
343>>>> In __autoload: string(6) "undefB"
344is_a( STRING:undefB, derived_a,true) =                      no
345is_a( STRING:undefB, derived_a) =                           no
346is_subclass_of( STRING:undefB, derived_a,false) =           no
347>>>> In __autoload: string(6) "undefB"
348is_subclass_of( STRING:undefB, derived_a) =                 no
349
350>>> With Defined class
351is_a( OBJECT:derived_b, if_a) =                             yes
352is_a( STRING:derived_b, if_a) =                             no
353is_a( STRING:derived_b, if_a, true) =                       yes
354is_subclass_of( OBJECT:derived_b, if_a) =                   yes
355is_subclass_of( STRING:derived_b, if_a) =                   yes
356is_subclass_of( STRING:derived_b, if_a,false) =             no
357>>> With Undefined
358>>>> In __autoload: string(6) "undefB"
359is_a( STRING:undefB, if_a,true) =                           no
360is_a( STRING:undefB, if_a) =                                no
361is_subclass_of( STRING:undefB, if_a,false) =                no
362>>>> In __autoload: string(6) "undefB"
363is_subclass_of( STRING:undefB, if_a) =                      no
364
365>>> With Defined class
366is_a( OBJECT:derived_b, undefA) =                           no
367is_a( STRING:derived_b, undefA) =                           no
368is_a( STRING:derived_b, undefA, true) =                     no
369is_subclass_of( OBJECT:derived_b, undefA) =                 no
370is_subclass_of( STRING:derived_b, undefA) =                 no
371is_subclass_of( STRING:derived_b, undefA,false) =           no
372>>> With Undefined
373>>>> In __autoload: string(6) "undefB"
374is_a( STRING:undefB, undefA,true) =                         no
375is_a( STRING:undefB, undefA) =                              no
376is_subclass_of( STRING:undefB, undefA,false) =              no
377>>>> In __autoload: string(6) "undefB"
378is_subclass_of( STRING:undefB, undefA) =                    no
379