/
ClassType.from.phpt
80 lines (60 loc) 路 1.23 KB
/
ClassType.from.phpt
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
<?php
/**
* Test: Nette\PhpGenerator generator.
*/
declare(strict_types=1);
namespace Abc;
use Nette\PhpGenerator\ClassType;
use Nette\PhpGenerator\Factory;
use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
/**
* Interface
* @author John Doe
*/
interface Interface1
{
function func1();
}
interface Interface2
{
}
abstract class Class1 implements Interface1
{
/** @return Class1 */
function func1()
{}
abstract protected function func2();
}
class Class2 extends Class1 implements Interface2
{
/**
* Public
* @var int
*/
public $public;
/** @var int */
protected $protected = 10;
private $private = [];
static public $static;
/**
* Func3
* @return Class1
*/
private function &func3(array $a = [], Class2 $b = NULL, \Abc\Unknown $c, \Xyz\Unknown $d, callable $e, $f = Unknown::ABC, $g)
{}
final function func2()
{}
}
class Class3
{
public $prop1;
}
$res[] = ClassType::from(Interface1::class);
$res[] = ClassType::from(Interface2::class);
$res[] = ClassType::from(Class1::class);
$res[] = ClassType::from(new Class2);
$obj = new Class3;
$obj->prop2 = 1;
$res[] = (new Factory)->fromClassReflection(new \ReflectionObject($obj));
Assert::matchFile(__DIR__ . '/ClassType.from.expect', implode("\n", $res));