Skip to content

Commit e9bd270

Browse files
committed
bug fix in readTrait
Pri zadnem dalsim zanorenim cyklus neskoncil, ale poziral dal. Signed-off-by: Jan Pecha <[email protected]>
1 parent 17612b7 commit e9bd270

File tree

2 files changed

+74
-1
lines changed

2 files changed

+74
-1
lines changed

src/PhpDepend.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ private function readTrait()
440440
{
441441
$level--;
442442

443-
if($level === 0)
443+
if($level < 1)
444444
{
445445
return $traits;
446446
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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

Comments
 (0)