xref: /PHP-7.1/tests/lang/bug21961.phpt (revision db76b708)
1--TEST--
2Bug #21961 (get_parent_class() segfault)
3--SKIPIF--
4<?php if (version_compare(zend_version(),'2.0.0-dev','<')) die('skip prepared for ZE2'); ?>
5--FILE--
6<?php
7
8class man
9{
10	public $name, $bars;
11	function __construct()
12	{
13		$this->name = 'Mr. X';
14		$this->bars = array();
15	}
16
17	function getdrunk($where)
18	{
19		$this->bars[] = new bar($where);
20	}
21
22	function getName()
23	{
24		return $this->name;
25	}
26}
27
28class bar extends man
29{
30	public $name;
31
32	function __construct($w)
33	{
34		$this->name = $w;
35	}
36
37	function getName()
38	{
39		return $this->name;
40	}
41
42	function whosdrunk()
43	{
44		$who = get_parent_class($this);
45		if($who == NULL)
46		{
47			return 'nobody';
48		}
49		return eval("return ".$who.'::getName();');
50	}
51}
52
53$x = new man;
54$x->getdrunk('The old Tavern');
55var_dump($x->bars[0]->whosdrunk());
56?>
57--EXPECT--
58string(14) "The old Tavern"
59