Skip to content

Conversation

@sumaiazaman
Copy link
Contributor

This PR adds missing @throws annotations to the Database Connection class methods that throw exceptions but were missing proper documentation.

Changes Made

  • escape() method: Added @throws \RuntimeException annotation
  • escapeBinary() method: Added @throws \RuntimeException annotation

Why This Matters

These methods throw RuntimeException when the PDO connection is not available, but were missing the proper @throws annotations in their docblocks. This improvement:

  • Enhances IDE support and autocomplete functionality
  • Improves static analysis capabilities (PHPStan, Psalm, etc.)
  • Provides better documentation for developers using these methods
  • Maintains consistency with Laravel's documentation standards
  • Helps developers understand when these methods might fail and handle exceptions appropriately

Implementation Details

Both methods check for PDO availability and throw RuntimeException with descriptive messages when the connection is not available:

  • escape(): Throws when trying to escape values without a PDO connection
  • escapeBinary(): Throws when trying to escape binary data without a PDO connection

Testing

No functional changes were made - only documentation improvements. The existing test suite should continue to pass without modification.

- Add @throws RuntimeException to escape() method
- Add @throws RuntimeException to escapeBinary() method

These methods throw RuntimeException when the PDO connection is not available but were missing proper @throws annotations in their docblocks.
@taylorotwell taylorotwell merged commit 0d0b16d into laravel:12.x Oct 20, 2025
66 of 68 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants