This repository was archived by the owner on Jan 30, 2020. It is now read-only.
File tree 3 files changed +64
-1
lines changed
3 files changed +64
-1
lines changed Original file line number Diff line number Diff line change 3
3
* Zend Framework (http://framework.zend.com/)
4
4
*
5
5
* @link http://github.com/zendframework/zf2 for the canonical source repository
6
- * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
6
+ * @copyright Copyright (c) 2005-2017 Zend Technologies USA Inc. (http://www.zend.com)
7
7
* @license http://framework.zend.com/license/new-bsd New BSD License
8
8
*/
9
9
10
10
namespace ZendTest \File ;
11
11
12
12
use Zend \File \ClassFileLocator ;
13
13
use Zend \File \Exception ;
14
+ use Zend \File \PhpClassFile ;
14
15
15
16
/**
16
17
* Test class for Zend\File\ClassFileLocator
@@ -147,4 +148,29 @@ public function testIterationShouldNotCountFQCNScalarResolutionConstantAsClass()
147
148
$ this ->assertCount (1 , $ file ->getClasses ());
148
149
}
149
150
}
151
+
152
+ /**
153
+ * @requires PHP 7.1
154
+ */
155
+ public function testIgnoresAnonymousClasses ()
156
+ {
157
+ $ classFileLocator = new ClassFileLocator (__DIR__ . '/TestAsset/Anonymous ' );
158
+
159
+ $ classFiles = \iterator_to_array ($ classFileLocator );
160
+
161
+ $ this ->assertCount (1 , $ classFiles );
162
+
163
+ $ classNames = \array_reduce ($ classFiles , function (array $ classNames , PhpClassFile $ classFile ) {
164
+ return \array_merge (
165
+ $ classNames ,
166
+ $ classFile ->getClasses ()
167
+ );
168
+ }, []);
169
+
170
+ $ expected = [
171
+ TestAsset \Anonymous \WithAnonymousClass::class,
172
+ ];
173
+
174
+ $ this ->assertEquals ($ expected , $ classNames );
175
+ }
150
176
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /**
4
+ * Zend Framework (http://framework.zend.com/)
5
+ *
6
+ * @link https://github.com/zendframework/zend-file for the canonical source repository
7
+ * @copyright Copyright (c) 2017 Zend Technologies USA Inc. (http://www.zend.com)
8
+ * @license https://github.com/zendframework/zend-file/blob/master/LICENSE.md New BSD License
9
+ */
10
+
11
+ namespace ZendTest \File \TestAsset \Anonymous ;
12
+
13
+ final class WithAnonymousClass
14
+ {
15
+ private $ anonymous ;
16
+
17
+ public function __construct ()
18
+ {
19
+ $ this ->anonymous = new class extends \stdClass {
20
+
21
+ };
22
+ }
23
+ }
24
+
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /**
4
+ * Zend Framework (http://framework.zend.com/)
5
+ *
6
+ * @link https://github.com/zendframework/zend-file for the canonical source repository
7
+ * @copyright Copyright (c) 2017 Zend Technologies USA Inc. (http://www.zend.com)
8
+ * @license https://github.com/zendframework/zend-file/blob/master/LICENSE.md New BSD License
9
+ */
10
+
11
+ $ anonymous = new class extends \stdClass {
12
+
13
+ };
You can’t perform that action at this time.
0 commit comments