|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * @phpversion > 5.4 |
| 4 | + */ |
| 5 | + |
| 6 | +use Tester\Assert; |
| 7 | +require __DIR__ . '/bootstrap.php'; |
| 8 | +require __DIR__ . '/../../src/PhpDepend.php'; |
| 9 | + |
| 10 | +$phpdepend = new Cz\PhpDepend; |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | +// Basic |
| 15 | +$phpdepend->parse('<?php |
| 16 | + trait ezcReflectionReturnInfo { |
| 17 | + } |
| 18 | +
|
| 19 | + class ezcReflectionMethod extends ReflectionMethod { |
| 20 | + use ezcReflectionReturnInfo; |
| 21 | + /* ... */ |
| 22 | + } |
| 23 | +
|
| 24 | + class ezcReflectionFunction extends ReflectionFunction { |
| 25 | + use ezcReflectionReturnInfo; |
| 26 | + /* ... */ |
| 27 | + } |
| 28 | +'); |
| 29 | + |
| 30 | +Assert::same(array( |
| 31 | + 'ezcReflectionReturnInfo', 'ezcReflectionMethod', 'ezcReflectionFunction' |
| 32 | +), $phpdepend->getClasses()); |
| 33 | +Assert::same(array( |
| 34 | + 'ReflectionMethod', 'ezcReflectionReturnInfo', 'ReflectionFunction' |
| 35 | +), $phpdepend->getDependencies()); |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | +// Multiple |
| 40 | +$phpdepend->parse('<?php |
| 41 | + trait Hello { |
| 42 | + } |
| 43 | +
|
| 44 | + trait World { |
| 45 | + } |
| 46 | +
|
| 47 | + class MyHelloWorld { |
| 48 | + use Hello, World; |
| 49 | + } |
| 50 | +'); |
| 51 | + |
| 52 | +Assert::same(array('Hello', 'World', 'MyHelloWorld'), $phpdepend->getClasses()); |
| 53 | +Assert::same(array('Hello', 'World'), $phpdepend->getDependencies()); |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | +// Block { } |
| 58 | +$phpdepend->parse('<?php |
| 59 | + trait HelloWorld { |
| 60 | + } |
| 61 | +
|
| 62 | + class MyClass1 { |
| 63 | + use HelloWorld { sayHello as protected; } |
| 64 | + } |
| 65 | +
|
| 66 | + class MyClass2 { |
| 67 | + use HelloWorld { sayHello as private myPrivateHello; } |
| 68 | + } |
| 69 | +'); |
| 70 | + |
| 71 | +Assert::same(array('HelloWorld', 'MyClass1', 'MyClass2'), $phpdepend->getClasses()); |
| 72 | +Assert::same(array('HelloWorld'), $phpdepend->getDependencies()); |
| 73 | + |
0 commit comments