Adjusting PHPStan Linting and updated download()#663
Merged
Conversation
…lso specify file name
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR improves PHPStan integration and enhances the file download functionality in FlightPHP. The changes address IDE compatibility issues with PHPStan rules while maintaining static analysis capabilities.
- Refactored PHPStan annotations to use separate
@phpstan-*tags to avoid IDE conflicts while preserving type checking - Enhanced the
downloadFile()method to accept an optional$fileNameparameter for custom download filenames - Updated documentation formatting and copyright notices across multiple files
Reviewed Changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| flight/net/Response.php | Added optional $fileName parameter to downloadFile() method with proper documentation |
| flight/database/PdoWrapper.php | Updated return type annotations for better PHPStan compatibility |
| flight/core/Dispatcher.php | Added PHPStan template support and improved documentation formatting |
| flight/Flight.php | Separated PHPStan-specific annotations from IDE-friendly method tags |
| flight/Engine.php | Applied consistent documentation pattern with separate PHPStan annotations |
| $this->setRealHeader('Content-Description: File Transfer'); | ||
| $this->setRealHeader('Content-Type: ' . $mimeType); | ||
| $this->setRealHeader('Content-Disposition: attachment; filename="' . basename($filePath) . '"'); | ||
| $this->setRealHeader('Content-Disposition: attachment; filename="' . $fileName . '"'); |
There was a problem hiding this comment.
The filename is directly concatenated into the header without sanitization. This could allow header injection if the filename contains special characters like quotes or newlines. Consider sanitizing the filename or using proper header encoding.
Collaborator
Author
There was a problem hiding this comment.
How would you sanitize it?
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.
$fileNameto the download() method to allow you to specify the file name.