Skip to content

Commit dfde227

Browse files
committed
release: merge develop into main
Changes from develop: - test(scanner): completar cobertura de ComposerNamespaceResolver (33% → 66% methods, 70% → 93% lines) - test(filter): completar cobertura de AttributeFilter para 100% - test(cache): completar cobertura de FileCacheStrategy (71% → 85% methods, 93% → 96% lines) - fix: suprimir PHP Warnings com @ operator em file_get_contents e mkdir - docs: atualizar README com casos de uso reais e exemplos completos - docs: padronizar README com layout premium do kariricode-devkit Quality: cs-fixer ✓ | phpstan L9 ✓ | psalm ✓ | phpunit 222 tests ✓ Coverage: 95.44% lines
2 parents 4b791f3 + 3d3bfb0 commit dfde227

44 files changed

Lines changed: 1623 additions & 137 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 405 additions & 118 deletions
Large diffs are not rendered by default.

src/Cache/ChainCacheStrategy.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,16 @@
1212
*
1313
* Typical configuration: Memory (L1) → File (L2).
1414
* On L1 miss + L2 hit, result is promoted to L1.
15+
*
16+
* @package KaririCode\ClassDiscovery\Cache
17+
* @author Walmir Silva <walmir.silva@kariricode.org>
18+
* @license MIT
19+
* @since 3.0.0
1520
*/
16-
final class ChainCacheStrategy implements CacheStrategy
21+
final readonly class ChainCacheStrategy implements CacheStrategy
1722
{
1823
/** @var array<CacheStrategy> */
19-
private readonly array $tiers;
24+
private array $tiers;
2025

2126
public function __construct(CacheStrategy ...$tiers)
2227
{

src/Cache/FileCacheStrategy.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,18 @@
1313
*
1414
* OPcache-friendly when using var_export format. Production-grade
1515
* with atomic writes (write to temp, rename) to prevent corruption.
16+
*
17+
* @package KaririCode\ClassDiscovery\Cache
18+
* @author Walmir Silva <walmir.silva@kariricode.org>
19+
* @license MIT
20+
* @since 3.0.0
1621
*/
17-
final class FileCacheStrategy implements CacheStrategy
22+
final readonly class FileCacheStrategy implements CacheStrategy
1823
{
1924
public function __construct(
2025
private readonly string $cacheDirectory,
2126
) {
22-
if (! is_dir($this->cacheDirectory) && ! mkdir($this->cacheDirectory, 0o755, true)) {
27+
if (! is_dir($this->cacheDirectory) && ! @mkdir($this->cacheDirectory, 0o755, true)) {
2328
throw DiscoveryException::cacheCorruption('init', "Cannot create cache directory: {$this->cacheDirectory}");
2429
}
2530
}

src/Cache/MemoryCacheStrategy.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
*
1313
* No persistence — cache lives only during the request lifecycle.
1414
* Zero I/O overhead. Ideal for dev mode with hot-reload.
15+
*
16+
* @package KaririCode\ClassDiscovery\Cache
17+
* @author Walmir Silva <walmir.silva@kariricode.org>
18+
* @license MIT
19+
* @since 3.0.0
1520
*/
1621
final class MemoryCacheStrategy implements CacheStrategy
1722
{

src/Enum/AttributeTarget.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
*
1212
* Backed enum: int values map to PHP's native Attribute::TARGET_* bitmask.
1313
* ARFA 1.3 E-003: backed enums permitted when external representation required.
14+
*
15+
* @package KaririCode\ClassDiscovery\Enum
16+
* @author Walmir Silva <walmir.silva@kariricode.org>
17+
* @license MIT
18+
* @since 3.0.0
1419
*/
1520
enum AttributeTarget: int
1621
{

src/Enum/ScannerType.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
* Scanner strategy classification.
99
*
1010
* Pure enum: no external representation required.
11+
*
12+
* @package KaririCode\ClassDiscovery\Enum
13+
* @author Walmir Silva <walmir.silva@kariricode.org>
14+
* @license MIT
15+
* @since 3.0.0
1116
*/
1217
enum ScannerType
1318
{

src/Filter/CompositeFilter.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,18 @@
1212
*
1313
* Use static factories: CompositeFilter::any(...) for OR-logic,
1414
* CompositeFilter::all(...) for AND-logic.
15+
*
16+
* @package KaririCode\ClassDiscovery\Filter
17+
* @author Walmir Silva <walmir.silva@kariricode.org>
18+
* @license MIT
19+
* @since 3.0.0
1520
*/
16-
final class CompositeFilter implements ClassFilter
21+
final readonly class CompositeFilter implements ClassFilter
1722
{
1823
/** @var list<ClassFilter> */
19-
private readonly array $filters;
24+
private array $filters;
2025

21-
private readonly bool $requireAll;
26+
private bool $requireAll;
2227

2328
/**
2429
* @param list<ClassFilter> $filters

src/Filter/InterfaceFilter.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77
use KaririCode\ClassDiscovery\Contract\ClassFilter;
88
use KaririCode\ClassDiscovery\Result\ClassMetadata;
99

10+
/**
11+
* Filters classes by implemented interface.
12+
*
13+
* @package KaririCode\ClassDiscovery\Filter
14+
* @author Walmir Silva <walmir.silva@kariricode.org>
15+
* @license MIT
16+
* @since 3.0.0
17+
*/
1018
final readonly class InterfaceFilter implements ClassFilter
1119
{
1220
public function __construct(

src/Filter/NamespaceFilter.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77
use KaririCode\ClassDiscovery\Contract\ClassFilter;
88
use KaririCode\ClassDiscovery\Result\ClassMetadata;
99

10+
/**
11+
* Filters classes by namespace prefix.
12+
*
13+
* @package KaririCode\ClassDiscovery\Filter
14+
* @author Walmir Silva <walmir.silva@kariricode.org>
15+
* @license MIT
16+
* @since 3.0.0
17+
*/
1018
final readonly class NamespaceFilter implements ClassFilter
1119
{
1220
public function __construct(

src/Integration/CacheBridge.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@
1515
* PSR-16 compliant cache with the discovery system.
1616
*
1717
* Optional dependency: kariricode/cache
18+
*
19+
* @package KaririCode\ClassDiscovery\Integration
20+
* @author Walmir Silva <walmir.silva@kariricode.org>
21+
* @license MIT
22+
* @since 3.1.0
1823
*/
19-
final class CacheBridge implements CacheStrategy
24+
final readonly class CacheBridge implements CacheStrategy
2025
{
2126
/**
2227
* @param object $simpleCache PSR-16 CacheInterface instance

0 commit comments

Comments
 (0)