Skip to content

Commit 42f4e8c

Browse files
committed
Merge branch 'patch-2' of git://github.com/prolic/zf2 into hotfix/2759
2 parents 05f35fd + 990e7b0 commit 42f4e8c

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

library/Zend/Code/Scanner/TokenArrayScanner.php

-4
Original file line numberDiff line numberDiff line change
@@ -584,10 +584,6 @@ protected function getUsesNoScan($namespace)
584584
}
585585
}
586586

587-
if (!$namespaces) {
588-
return array();
589-
}
590-
591587
if ($namespace === null) {
592588
$namespace = array_shift($namespaces);
593589
} elseif (!is_string($namespace)) {

tests/ZendTest/Code/Scanner/TokenArrayScannerTest.php

+12
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,18 @@ public function testScannerReturnsNamespaces()
2424
$this->assertContains('ZendTest\Code\TestAsset', $namespaces);
2525
}
2626

27+
public function testScannerReturnsNamespacesInNotNamespacedClasses()
28+
{
29+
$tokenScanner = new TokenArrayScanner(token_get_all(file_get_contents((__DIR__ . '/../TestAsset/FooBarClass.php'))));
30+
$uses = $tokenScanner->getUses();
31+
$this->assertInternalType('array', $uses);
32+
$foundUses = array();
33+
foreach ($uses as $use) {
34+
$foundUses[] = $use['use'];
35+
}
36+
$this->assertContains('ArrayObject', $foundUses);
37+
}
38+
2739
public function testScannerReturnsClassNames()
2840
{
2941
$tokenScanner = new TokenArrayScanner(token_get_all(file_get_contents((__DIR__ . '/../TestAsset/FooClass.php'))));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
/**
3+
* Zend Framework (http://framework.zend.com/)
4+
*
5+
* @link http://github.com/zendframework/zf2 for the canonical source repository
6+
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
7+
* @license http://framework.zend.com/license/new-bsd New BSD License
8+
* @package Zend_Code
9+
*/
10+
11+
use ArrayObject;
12+
13+
/**
14+
* This is a test class, declaring no namespace at all.
15+
* It is used to test, if the token scanner can find use
16+
* statements in classes with no namespace defined.
17+
*/
18+
class ZendTest_Code_TestAsset_FooBar extends ArrayObject
19+
{
20+
}

0 commit comments

Comments
 (0)