Add event monitoring, streaming uploads, adaptive cookies, and PHPStan analysis#26
Merged
parsilver merged 3 commits intoOct 30, 2025
Merged
Conversation
…n analysis This commit introduces three major features and significantly improves code quality: New Features: - Event system for HTTP lifecycle monitoring with 5 built-in events - Adaptive cookie collection system with automatic performance optimization - Streaming multipart file uploads for memory-efficient large file handling Code Quality: - PHPStan level 8 static analysis integration - Type safety improvements across entire codebase - Fixed 50+ type-related issues Documentation: - Comprehensive README updates with examples - Added event-monitoring.php and streaming-upload.php examples - Enhanced package description and keywords All changes are backward compatible.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #26 +/- ##
============================================
- Coverage 96.41% 95.18% -1.23%
- Complexity 426 709 +283
============================================
Files 33 48 +15
Lines 1255 1954 +699
============================================
+ Hits 1210 1860 +650
- Misses 45 94 +49 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Expands test suite with additional coverage for cookie management and HTTP client factory functionality.
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
This PR introduces three major features and significantly improves code quality through PHPStan static analysis.
New Features
1. 🎯 Event System for HTTP Lifecycle Monitoring
Monitor the complete HTTP request/response lifecycle with flexible event listeners.
Built-in Events:
RequestSendingEvent- Fired before sending a requestRequestSentEvent- Fired after request is sentResponseReceivedEvent- Fired when response is receivedRequestFailedEvent- Fired when request failsRetryAttemptEvent- Fired on each retry attemptUse Cases:
Example: See
examples/event-monitoring.php2. 🍪 Adaptive Cookie Collection System
Automatic performance optimization based on cookie workload.
Features:
SimpleCookieCollection- O(n) linear search for < 50 cookiesIndexedCookieCollection- O(1) hash lookup for ≥ 50 cookiesAdaptiveCookieCollection- Automatically switches between implementationsDesign Patterns:
3. 📤 Streaming Multipart File Uploads
Memory-efficient uploads for large files without loading entire content into memory.
Features:
StreamingMultipartBuilder- Explicit streaming with 8KB chunk readsMultipartBuilderFactory- Auto-selects builder based on file size (1MB threshold)Example: See
examples/streaming-upload.phpCode Quality Improvements
4. 🔍 PHPStan Static Analysis (Level 8)
Comprehensive static analysis integration with strictest rule level.
Improvements:
New Scripts:
composer analyse- Run PHPStan analysiscomposer analyse:baseline- Generate baseline for existing issuesDocumentation
Technical Details
Files Changed: 42 files
New Files:
Breaking Changes
None - All changes are backward compatible additions.
Existing code will continue to work without modifications. New features are opt-in.
Test Plan
Migration Guide
No migration needed. To use new features:
Event Monitoring:
Streaming Uploads:
Cookie Management:
Automatic - no code changes required for performance optimization.
Performance Impact