Skip to content

Commit 17612b7

Browse files
committed
PhpDepend: bug fix in readStaticClass()
Nenacetlo to nazev tridy, protoze prvni token v cyklu byl '::' a ne nazev a s tim skript nepocital, takze hned skoncil. Signed-off-by: Jan Pecha <[email protected]>
1 parent a016957 commit 17612b7

File tree

2 files changed

+51
-2
lines changed

2 files changed

+51
-2
lines changed

src/PhpDepend.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,15 @@ private function readStaticClass()
376376
while($token = $this->prev())
377377
{
378378
$i++;
379-
if(is_array($token) && ($token[0] === T_STRING || $token[0] === self::$T_NS_SEPARATOR))
379+
if(is_array($token))
380380
{
381-
if(!($token[1] === 'self' || $token[1] === 'parent' || $token[1] === 'static'))
381+
if($token[0] === T_DOUBLE_COLON)
382+
{
383+
continue;
384+
}
385+
386+
if(($token[0] === T_STRING || $token[0] === self::$T_NS_SEPARATOR)
387+
&& !($token[1] === 'self' || $token[1] === 'parent' || $token[1] === 'static'))
382388
{
383389
$name = $token[1] . $name;
384390
continue;
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
use Tester\Assert;
3+
require __DIR__ . '/bootstrap.php';
4+
require __DIR__ . '/../../src/PhpDepend.php';
5+
6+
$phpdepend = new Cz\PhpDepend;
7+
8+
9+
10+
$phpdepend->parse('<?php
11+
class MyClass
12+
{
13+
public function __construct()
14+
{
15+
$ret = self::fooBar();
16+
$set = static::fooBar();
17+
$get = parent::fooBar();
18+
}
19+
}
20+
');
21+
22+
Assert::same(array('MyClass'), $phpdepend->getClasses());
23+
Assert::same(array(), $phpdepend->getDependencies());
24+
25+
26+
27+
$phpdepend->parse('<?php
28+
use Foo\Bar;
29+
30+
class MyClass
31+
{
32+
public function __construct()
33+
{
34+
$ret = Bar::fooBar();
35+
$set = Foo::fooBar();
36+
$get = Bar\FooBar::fooBar();
37+
}
38+
}
39+
');
40+
41+
Assert::same(array('MyClass'), $phpdepend->getClasses());
42+
Assert::same(array('Foo\Bar', 'Foo', 'Foo\Bar\FooBar'), $phpdepend->getDependencies());
43+

0 commit comments

Comments
 (0)