Skip to content

Commit 09604db

Browse files
committed
feat: implement universal cache type detection for PSR-16 implementations
- Add universal Redis/Memcached connection detection via reflection - Support direct cache instance checking (Redis, Memcached, Predis) - Add recursive property search methods (findRedisInProperties, findMemcachedInProperties) - Enhance detectCacheType() with multi-level strategy: * Level 1: Check already discovered connections (fastest) * Level 2: Direct type checking (instanceof) * Level 3: Universal reflection for any PSR-16 implementation * Level 4: Class name pattern matching (fallback) - Update getRedisConnection() and getMemcachedConnection() for universal support - Works with Symfony Cache, direct wrappers, and any custom PSR-16 implementations - Add phpstan.neon ignore pattern for ReflectionClass generic type warnings This allows cache type detection to work universally with any PSR-16 cache implementation, not just Symfony Cache, by recursively searching for Redis/Memcached connections in object properties.
1 parent 77cd891 commit 09604db

File tree

2 files changed

+289
-62
lines changed

2 files changed

+289
-62
lines changed

phpstan.neon

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,9 @@ parameters:
2121
# Additional strict checks for detecting redundant code
2222
checkMissingCallableSignature: true
2323
checkUninitializedProperties: true
24-
checkDynamicProperties: true
24+
checkDynamicProperties: true
25+
26+
# Ignore ReflectionClass generic type warnings for recursive property search methods
27+
# These methods work correctly at runtime but PHPStan cannot infer the generic type statically
28+
ignoreErrors:
29+
- '#has parameter \$reflection with generic class ReflectionClass but does not specify its types: T#'

0 commit comments

Comments
 (0)