10
10
namespace PHPUnit \Framework ;
11
11
12
12
use const PHP_EOL ;
13
- use function array_diff ;
14
13
use function array_keys ;
15
14
use function array_map ;
16
15
use function array_merge ;
@@ -128,9 +127,9 @@ class TestSuite implements IteratorAggregate, Reorderable, SelfDescribing, Test
128
127
private $ iteratorFilter ;
129
128
130
129
/**
131
- * @var string[]
130
+ * @var int
132
131
*/
133
- private $ declaredClasses ;
132
+ private $ declaredClassesPointer ;
134
133
135
134
/**
136
135
* @psalm-var array<int,string>
@@ -167,7 +166,7 @@ public function __construct($theClass = '', string $name = '')
167
166
);
168
167
}
169
168
170
- $ this ->declaredClasses = get_declared_classes ();
169
+ $ this ->declaredClassesPointer = count ( get_declared_classes () );
171
170
172
171
if (!$ theClass instanceof ReflectionClass) {
173
172
if (class_exists ($ theClass , true )) {
@@ -400,7 +399,7 @@ public function addTestFile(string $filename): void
400
399
// The given file may contain further stub classes in addition to the
401
400
// test class itself. Figure out the actual test class.
402
401
$ filename = FileLoader::checkAndLoad ($ filename );
403
- $ newClasses = array_diff (get_declared_classes (), $ this ->declaredClasses );
402
+ $ newClasses = array_slice (get_declared_classes (), $ this ->declaredClassesPointer );
404
403
405
404
// The diff is empty in case a parent class (with test methods) is added
406
405
// AFTER a child class that inherited from it. To account for that case,
@@ -410,8 +409,8 @@ public function addTestFile(string $filename): void
410
409
// On the assumption that test classes are defined first in files,
411
410
// process discovered classes in approximate LIFO order, so as to
412
411
// avoid unnecessary reflection.
413
- $ this ->foundClasses = array_merge ($ newClasses , $ this ->foundClasses );
414
- $ this ->declaredClasses = get_declared_classes ();
412
+ $ this ->foundClasses = array_merge ($ newClasses , $ this ->foundClasses );
413
+ $ this ->declaredClassesPointer = count ( get_declared_classes () );
415
414
}
416
415
417
416
// The test class's name must match the filename, either in full, or as
0 commit comments