Increase test coverage toward 90% (no file below 80%) - #659
Merged
Conversation
…assFieldAccess Part of raising code coverage across src/. More files in progress. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V96x2qKNqcQbqxjf5anAPH
…r, StaticInitializationJoinpoint Part of raising code coverage across src/. More files in progress. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V96x2qKNqcQbqxjf5anAPH
Part of raising code coverage across src/. More files in progress. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V96x2qKNqcQbqxjf5anAPH
Part of raising code coverage across src/. More files in progress (tests/Console/Command/BaseAspectCommandTest.php intentionally left uncommitted: still being written, currently has a risky test). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V96x2qKNqcQbqxjf5anAPH
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #659 +/- ##
=============================================
+ Coverage 85.40% 96.00% +10.60%
- Complexity 1636 1637 +1
=============================================
Files 99 99
Lines 4509 4510 +1
=============================================
+ Hits 3851 4330 +479
+ Misses 658 180 -478 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Real fixes: correct return type on AbstractMethodInvocationTest's anonymous getThis() (never null), fix a namespace collision between Go\Aop\Framework\Interceptor and Go\Aop\Intercept\Interceptor in InterceptorInjectorTest, pass real class-string constants (instead of made-up strings) to TraitIntroductionInfo in its test, and give InterceptorInjector's non-empty-list<Interceptor> parameter real interceptor instances instead of empty arrays. Elsewhere, follow this codebase's existing @PHPStan-Ignore convention (see StaticTraitAliasMethodInvocationTest, TheTest, ContainerTest) for runtime double-checks of literal/narrowed return types and deliberately mismatched test inputs. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V96x2qKNqcQbqxjf5anAPH
Add tests/Aop/Support/PointcutBuilderTest.php and tests/Aop/Support/LazyPointcutAdvisorTest.php. Fix PHPStan level-10 findings picked up in review: type the untyped matches() callback in AdviceMatcherTest (real bug risk - untyped closure params silently accept anything), narrow ReflectionProperty's mixed getValue() result with a runtime is_array() check instead of a blanket array return type, and align doParsePointcut()'s reflection parameter with the same per-call @template T pattern already used by AbstractAspectLoaderExtension::parsePointcut() so covariant ReflectionClass<ConcreteAspect> arguments type-check. Elsewhere, follow the existing @PHPStan-Ignore convention for runtime double-checks of narrowed return types and reflection-only private methods. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V96x2qKNqcQbqxjf5anAPH
Add tests/Lang/Attribute/DeclareParentsTest.php. Use real class-string constants (a fixture trait/interface) instead of made-up strings for DeclareParents' class-string-typed constructor params, matching the pattern already used in IntroductionAspectExtensionTest. Give doGetAdvice() an explicit Advice return type and type the untyped introduction/plainProperty test-fixture properties. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V96x2qKNqcQbqxjf5anAPH
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V96x2qKNqcQbqxjf5anAPH
Reflection-based helpers that read/invoke protected AspectKernel internals returned raw mixed, which cascaded into ~40 PHPStan errors (offset access, casts, foreach, array unpacking all done on mixed). Replace with narrow-and-validate helpers (invokeProtectedArray, invokeProtectedString, getKernelOptions/setKernelOptions) that build a properly-keyed array via a checked loop, plus PHPUnit's assertIsString()/assertIsArray() type-specifying extensions to narrow individual option values before using them. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V96x2qKNqcQbqxjf5anAPH
…ings Add tests/Console/Command/BaseAspectCommandTest.php, tests/Proxy/FunctionProxyGeneratorTest.php, tests/Proxy/Part/AbstractInterceptedPropertyGeneratorTest.php, and tests/Stubs/Generator/PropertyTypeStubs.php; extend the existing DebugAdvisorCommand/DebugAspectCommand in-process tests and the FileGenerator/InterceptedConstructorGenerator/InterceptedMethodGenerator generator tests. Real fix: BaseAspectCommandTest's command factory returned the BaseAspectCommand base type while assigning extra public properties on an anonymous subclass, so PHPStan couldn't see them - replaced with a named BaseAspectCommandTestCommandStub subclass. Elsewhere, narrow a ReflectionClass::getConstructor() nullable result with assertNotNull() before use, and follow the existing @PHPStan-Ignore convention for runtime double-checks of already-narrowed return types. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V96x2qKNqcQbqxjf5anAPH
…ix findings Extend tests/Instrument/Transformer/WeavingTransformerTest.php and ConstructorExecutionTransformerTest.php with trait weaving, abstract class handling, attribute-comma removal, promoted-property attributes, inherited-member dispatch, function-proxy caching, and no-cache-dir paths; add matching stub fixtures under Stubs/ and _files/. Extend PointcutParserTest with the non-Pointcut-result guard on parse(). Fix PHPStan findings: give the anonymous TokenStream's getIterator() an explicit generic @return type, and mark the deliberate direct __get()/__call() magic-method exercises in ConstructorExecutionTransformerTest with the project's existing @PHPStan-Ignore convention. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V96x2qKNqcQbqxjf5anAPH
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V96x2qKNqcQbqxjf5anAPH
file_put_contents() with LOCK_EX fails on any non-"file://" stream wrapper (PHP core rejects the flag there), which saveProxyToCache() already accounts for a few lines below via an $isStreamPath guard. processFunctions() wrote the function-proxy cache file unconditionally with LOCK_EX, so generating a fresh function proxy into a stream-backed cache dir (e.g. the virtual file system used throughout this test suite) would fail. Apply the same guard, and add a test that exercises the actual generation path (previously only the "already fresh, reuse existing file" path was covered). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V96x2qKNqcQbqxjf5anAPH
Both have had no effect since PHP 8.1 (reflection access no longer respects visibility) and PHP 8.5 now emits a deprecation notice for calling them, which failOnDeprecation in phpunit.xml.dist turns into a CI failure on the PHP 8.5/8.6 test matrix. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V96x2qKNqcQbqxjf5anAPH
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CacheWarmer.phpat 82.93%).Aop/Framework,Aop/Pointcut,Aop/Support,Core,Console/Command,Proxy,Proxy/Generator,Proxy/Part,Instrument/Transformer, andLang/Attribute, following the repo's existing conventions (virtual filesystem for FS tests,@phpstan-ignorefor provable-by-design runtime double-checks, etc.).WeavingTransformer::processFunctions()wrote the function-proxy cache file withLOCK_EXunconditionally, which PHP rejects on any non-file://stream-wrapper path.saveProxyToCache()a few lines below already guards against this; applied the same guard, with a new test exercising the actual generation path.Test plan
XDEBUG_MODE=coverage php8.4 vendor/bin/phpunit --coverage-textshows overall line coverage ≥90% (95.76%)src/has line coverage below 80%phpunit.xml.distenforcesfailOnRisky,failOnWarning,failOnNotice,failOnDeprecation)phpstan analyze --memory-limit=512M(level 10) is clean acrosssrc/andtests/php-cs-fixer check --diff(PER-CS) is clean🤖 Generated with Claude Code
https://claude.ai/code/session_01V96x2qKNqcQbqxjf5anAPH