1--TEST--
2PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', true, true)
3--SKIPIF--
4<?php
5if (!version_compare(PHP_VERSION, '7.1', '>=')) print 'skip: PHP >= 7.1 required';
6?>
7--FILE--
8<?php
9interface Foo
10{
11    public function bar(string $baz): ?string;
12}
13
14require __DIR__ . '/../../../vendor/autoload.php';
15
16$generator = new PHPUnit_Framework_MockObject_Generator;
17
18$mock = $generator->generate(
19    'Foo',
20    array(),
21    'MockFoo',
22    true,
23    true
24);
25
26print $mock['code'];
27?>
28--EXPECTF--
29class MockFoo implements PHPUnit_Framework_MockObject_MockObject, Foo
30{
31    private $__phpunit_invocationMocker;
32    private $__phpunit_originalObject;
33    private $__phpunit_configurable = ['bar'];
34
35    public function __clone()
36    {
37        $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
38    }
39
40    public function bar(string $baz): ?string
41    {
42        $arguments = array($baz);
43        $count     = func_num_args();
44
45        if ($count > 1) {
46            $_arguments = func_get_args();
47
48            for ($i = 1; $i < $count; $i++) {
49                $arguments[] = $_arguments[$i];
50            }
51        }
52
53        $result = $this->__phpunit_getInvocationMocker()->invoke(
54            new PHPUnit_Framework_MockObject_Invocation_Object(
55                'Foo', 'bar', $arguments, '?string', $this, true
56            )
57        );
58
59        return $result;
60    }
61
62    public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
63    {
64        return $this->__phpunit_getInvocationMocker()->expects($matcher);
65    }
66
67    public function method()
68    {
69        $any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
70        $expects = $this->expects($any);
71        return call_user_func_array(array($expects, 'method'), func_get_args());
72    }
73
74    public function __phpunit_setOriginalObject($originalObject)
75    {
76        $this->__phpunit_originalObject = $originalObject;
77    }
78
79    public function __phpunit_getInvocationMocker()
80    {
81        if ($this->__phpunit_invocationMocker === null) {
82            $this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
83        }
84
85        return $this->__phpunit_invocationMocker;
86    }
87
88    public function __phpunit_hasMatchers()
89    {
90        return $this->__phpunit_getInvocationMocker()->hasMatchers();
91    }
92
93    public function __phpunit_verify($unsetInvocationMocker = true)
94    {
95        $this->__phpunit_getInvocationMocker()->verify();
96
97        if ($unsetInvocationMocker) {
98            $this->__phpunit_invocationMocker = null;
99        }
100    }
101}
102