Add polyfill for PDO driver specific sub class constants #547
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.
As of PHP 8.4, specific subclasses of
PDOexist for all drivers, which may contain driver-specific constants and methods if applicable. See also https://wiki.php.net/rfc/pdo_driver_specific_subclasses.As of PHP 8.5, the driver specific constants and methods available on the base
PDOclass will be deprecated, to be removed in PHP 9.0. See also https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_driver_specific_pdo_constants_and_methods.This PR adds a polyfill to expose the constants on the driver-specific child classes for PHP versions prior to PHP 8.4. This allows one to already refer to the 'new' constant, to prevent deprecation errors on PHP 8.5, while retaining backwards compatibility. This can be particularly useful for code requiring support for multiple versions; see e.g. laravel/framework#57141.
Note that no methods have been added in this PR, nor are the classes actually extending the base
PDOclass yet, with the following reasoning:connectstatic factory method, for which I currently see no way to polyfill; promoting direct construction of subclasses as migration path seems counterproductive to me and the Laravel approach seems to be the neatest way to ensure all new functionality is used on recent PHP versionsThis is however opionated and it therefore may still be considered to aim for a more complete polyfill. Note this can also be part of a follow-up effort, rather than as extended goal of this PR.
Edit: second note is that in case clas instatiation is indeed not intended, it might be worthwhile to add a manual constructor throwing some kind of well-chosen exception with well-worded message to better signify this towards consumers of this polyfill.