File tree 3 files changed +32
-4
lines changed
library/Zend/Code/Scanner
3 files changed +32
-4
lines changed Original file line number Diff line number Diff line change @@ -584,10 +584,6 @@ protected function getUsesNoScan($namespace)
584
584
}
585
585
}
586
586
587
- if (!$ namespaces ) {
588
- return array ();
589
- }
590
-
591
587
if ($ namespace === null ) {
592
588
$ namespace = array_shift ($ namespaces );
593
589
} elseif (!is_string ($ namespace )) {
Original file line number Diff line number Diff line change @@ -24,6 +24,18 @@ public function testScannerReturnsNamespaces()
24
24
$ this ->assertContains ('ZendTest\Code\TestAsset ' , $ namespaces );
25
25
}
26
26
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
+
27
39
public function testScannerReturnsClassNames ()
28
40
{
29
41
$ tokenScanner = new TokenArrayScanner (token_get_all (file_get_contents ((__DIR__ . '/../TestAsset/FooClass.php ' ))));
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments