Skip to content

Commit 80a029f

Browse files
committed
Tidy
1 parent a5a7445 commit 80a029f

12 files changed

+37
-265
lines changed

src/AutoloadsBuilder.php

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/ClassMapBuilder.php

Lines changed: 0 additions & 130 deletions
This file was deleted.

src/MemoizeAttributeCollector.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ public function __construct(
4747
*
4848
* @throws ReflectionException
4949
*/
50-
public function collectAttributes(array $classMap): Collector
50+
public function collectAttributes(array $classMap): TransientCollection
5151
{
5252
$filterClasses = [];
5353
$classAttributeCollector = $this->classAttributeCollector;
54-
$collector = new Collector();
54+
$collector = new TransientCollection();
5555

5656
foreach ($classMap as $class => $filepath) {
5757
$filterClasses[$class] = true;
@@ -66,7 +66,12 @@ public function collectAttributes(array $classMap): Collector
6666
$mtime = filemtime($filepath);
6767

6868
if ($timestamp < $mtime) {
69-
$this->io->debug("Refresh attributes of class '$class' in '$filepath' ($timestamp < $mtime)");
69+
if ($timestamp) {
70+
$diff = $mtime - $timestamp;
71+
$this->io->debug("Refresh attributes of class '$class' in '$filepath' ($diff sec ago)");
72+
} else {
73+
$this->io->debug("Collect attributes of class '$class' in '$filepath'");
74+
}
7075

7176
[
7277
$classAttributes,

src/MemoizeClassMapFilter.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,13 @@ public function filter(array $classMap, Closure $filter): array
5353
assert(is_int($mtime));
5454

5555
if ($timestamp < $mtime) {
56-
$this->io->debug("Refresh filtered for '$pathname' ($timestamp < $mtime)");
56+
if ($timestamp) {
57+
$diff = $mtime - $timestamp;
58+
$this->io->debug("Refresh filtered files in '$pathname' ($diff sec ago)");
59+
} else {
60+
$this->io->debug("Filter files in '$pathname'");
61+
}
62+
5763
$keep = $filter($class, $pathname);
5864
$this->state[$pathname] = [ time(), $keep ];
5965
}

src/MemoizeClassMapGenerator.php

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function getMap(): array
6363

6464
$maps = [];
6565

66-
foreach ($this->state as [ , $map ]) {
66+
foreach ($this->state as [, $map]) {
6767
$maps[] = $map;
6868
}
6969

@@ -77,33 +77,25 @@ public function getMap(): array
7777
* The path to search in.
7878
* @param non-empty-string|null $excluded
7979
* Regex that matches file paths to be excluded from the classmap
80-
* @param 'classmap'|'psr-0'|'psr-4' $autoloadType
81-
* Optional autoload standard to use mapping rules with the namespace instead of purely doing a classmap
82-
* @param string|null $namespace
83-
* Optional namespace prefix to filter by, only for psr-0/psr-4 autoloading
8480
*
8581
* @throws RuntimeException When the path is neither an existing file nor directory
8682
*/
87-
public function scanPaths(
88-
string $path,
89-
string $excluded = null,
90-
string $autoloadType = 'classmap',
91-
?string $namespace = null
92-
): void {
83+
public function scanPaths(string $path, string $excluded = null): void
84+
{
9385
$this->paths[$path] = true;
9486
[ $timestamp ] = $this->state[$path] ?? [ 0 ];
9587

96-
if ($this->should_update($timestamp, $path)) {
88+
if ($this->shouldUpdate($timestamp, $path)) {
9789
$inner = new ClassMapGenerator();
9890
$inner->avoidDuplicateScans();
99-
$inner->scanPaths($path, $excluded, $autoloadType, $namespace);
91+
$inner->scanPaths($path, $excluded);
10092
$map = $inner->getClassMap()->getMap();
10193

10294
$this->state[$path] = [ time(), $map ];
10395
}
10496
}
10597

106-
private function should_update(int $timestamp, string $path): bool
98+
private function shouldUpdate(int $timestamp, string $path): bool
10799
{
108100
if (!$timestamp) {
109101
return true;
@@ -127,7 +119,7 @@ private function should_update(int $timestamp, string $path): bool
127119

128120
foreach (new DirectoryIterator($path) as $di) {
129121
if ($di->isDir() && !$di->isDot()) {
130-
if ($this->should_update($timestamp, $di->getPathname())) {
122+
if ($this->shouldUpdate($timestamp, $di->getPathname())) {
131123
return true;
132124
}
133125
}

src/Plugin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ private static function buildFileFilter(): Filter
149149
]);
150150
}
151151

152-
private static function render(Collector $collector): string
152+
private static function render(TransientCollection $collector): string
153153
{
154-
return CollectionRenderer::render($collector);
154+
return TransientCollectionRenderer::render($collector);
155155
}
156156
}

src/Collector.php renamed to src/TransientCollection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
namespace olvlvl\ComposerAttributeCollector;
1111

1212
/**
13-
* Collects classes and methods with attributes.
13+
* A collection of attributes used during the collection process.
1414
*
1515
* @internal
1616
*/
17-
final class Collector
17+
final class TransientCollection
1818
{
1919
/**
2020
* @var array<class-string, iterable<TransientTargetClass>>

src/CollectionRenderer.php renamed to src/TransientCollectionRenderer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
*
1010
* @internal
1111
*/
12-
final class CollectionRenderer
12+
final class TransientCollectionRenderer
1313
{
14-
public static function render(Collector $collector): string
14+
public static function render(TransientCollection $collector): string
1515
{
1616
$targetClassesCode = self::targetsToCode($collector->classes);
1717
$targetMethodsCode = self::targetsToCode($collector->methods);

tests/ClassMapBuilderTest.php

Lines changed: 0 additions & 68 deletions
This file was deleted.

0 commit comments

Comments
 (0)