-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for PHP 8.4 #228
Comments
It seems reasonable and appropriate to me. cc/ @pmjones @harikt @frederikbosch |
Boooom.. @srjlewis Thank you for bringing this up and also nice pointers. We can make this next major version, but I am not sure what should we call this. I don't like the name Some of the methods came to my mind are |
PR #229 |
@harikt I do agree with the naming, I used autoConnect as an example, and can easily be changed, apart from this issue I have not run into any other issues with PHP 8.4 |
With driver specific subclasses in PHP, I think we should re-evaluate more than just the new If so, would it then not be better to drop < 8.4 for a new version 6.0? And just use override the <?php
class ExtendedPdo
{
public const CONNECT_IMMEDIATELY = 'immediate';
protected array $args = [];
protected bool $driverSpecific = false;
public function __construct(
string $dsn,
?string $username = null,
?string $password = null,
array $options = [],
array $queries = [],
?ProfilerInterface $profiler = null
) {
// if no error mode is specified, use exceptions
if (! isset($options[PDO::ATTR_ERRMODE])) {
$options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
}
// retain the arguments for later
$this->args = [
$dsn,
$username,
$password,
$options,
$queries
];
if ($options[self::CONNECT_IMMEDIATELY]) {
$this->establishConnection();
}
// keep the rest of the constructor
}
#[\Override]
public static function connect(string $dsn, string $username = null, string $password = null, array $options = null) {
{
$pdo = new self($dsn, $username, $password, $options);
$pdo->driverSpecific = true;
return $pdo;
}
// call this method from query, perform, execute etc
private function establishConnection(): void
{
if ($this->pdo) {
return;
}
if ($this->driverSpecific) {
$this->pdo = PDO::connect($dsn, $username, $password, $options);$password, $options);
} else {
$this->pdo = new PDO($dsn, $username,
}
}
} |
@frederikbosch we could approch the issue has you mention, but I see a few issues in your approach.
but by all means keep the ideas flowing |
|
It will help with a smooth migration/update path We can release v6.0 and users can implement it before the release of PHP 8.4 This would also allow users to run PHP 8.x in production and do testing with PHP 8.4 before its release. This is what I am doing at the moment, yes I know users can use some composer magic but that makes it more complicated for the users. I also think it is a good idea to keep compatability with all supported version of PHP and not make users switch between versions of the libaray. |
I disagree with that.
Moreover, that is why there is semantic versioning: it's a contract how to deal with backward compatibility. When, you change the major version, you are going to break things. Now, with PHP 8.4 compatibility will be broken anyhow since the new connect method will force us to break things. You can better re-evaluate, and put the library in a mode that is going to proof itself again in the future. Hence, I suggest we slow down, and evaluate whether we need the driver specific parsers included in this library now PHP provides them in the core of PDO. And then see what is the best syntactic solution for immediate or manual connections. |
Hi
I am doing some eairly testing with PHP 8.4
I have found a conflict within the library
It is a result of a accepted PHP RFC https://wiki.php.net/rfc/pdo_driver_specific_subclasses which introduces a static connect method PDO::connect() as shown in the above method.
Here is lavavel's fix within there library https://github.com/laravel/framework/pull/52538/files
It looks like
ExtendedPdoInterface::connect()
would need renaming to somthing along the lines ofExtendedPdoInterface::autoConnect()
and throughout the rest of the library.I would then think
ExtendedPdo:autoConnect()
would looke somthing like.This would need to be a new majer version due to the big BC break
ExtendedPdoInterface::connect()
being public.I can create a MR for this if needed.
The text was updated successfully, but these errors were encountered: