Skip to content

Commit 10ea91d

Browse files
Merge branch '8.5' into 9.5
2 parents 49ed71e + 8d8eeb4 commit 10ea91d

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/Framework/TestSuite.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
namespace PHPUnit\Framework;
1111

1212
use const PHP_EOL;
13-
use function array_diff;
1413
use function array_keys;
1514
use function array_map;
1615
use function array_merge;
@@ -128,9 +127,9 @@ class TestSuite implements IteratorAggregate, Reorderable, SelfDescribing, Test
128127
private $iteratorFilter;
129128

130129
/**
131-
* @var string[]
130+
* @var int
132131
*/
133-
private $declaredClasses;
132+
private $declaredClassesPointer;
134133

135134
/**
136135
* @psalm-var array<int,string>
@@ -167,7 +166,7 @@ public function __construct($theClass = '', string $name = '')
167166
);
168167
}
169168

170-
$this->declaredClasses = get_declared_classes();
169+
$this->declaredClassesPointer = count(get_declared_classes());
171170

172171
if (!$theClass instanceof ReflectionClass) {
173172
if (class_exists($theClass, true)) {
@@ -400,7 +399,7 @@ public function addTestFile(string $filename): void
400399
// The given file may contain further stub classes in addition to the
401400
// test class itself. Figure out the actual test class.
402401
$filename = FileLoader::checkAndLoad($filename);
403-
$newClasses = array_diff(get_declared_classes(), $this->declaredClasses);
402+
$newClasses = array_slice(get_declared_classes(), $this->declaredClassesPointer);
404403

405404
// The diff is empty in case a parent class (with test methods) is added
406405
// AFTER a child class that inherited from it. To account for that case,
@@ -410,8 +409,8 @@ public function addTestFile(string $filename): void
410409
// On the assumption that test classes are defined first in files,
411410
// process discovered classes in approximate LIFO order, so as to
412411
// 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());
415414
}
416415

417416
// The test class's name must match the filename, either in full, or as

0 commit comments

Comments
 (0)