Skip to content

Commit 1891dca

Browse files
marinhekmanmmoreram
authored andcommitted
added backwards compatibility with deprecation notices
1 parent 3d25dbc commit 1891dca

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

src/ConnectionPool.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ public static function create(
5858
AbstractPlatform $platform,
5959
?ConnectionOptions $options = null
6060
): Connection {
61-
$numberOfConnections = ConnectionPoolOptions::DEFAULT_NUMBER_OF_CONNECTIONS;
61+
$numberOfConnections = $credentials->getConnections() ??
62+
ConnectionPoolOptions::DEFAULT_NUMBER_OF_CONNECTIONS;
6263
if ($options instanceof ConnectionPoolOptions) {
6364
$numberOfConnections = $options->getNumberOfConnections();
6465
}

src/Credentials.php

+47
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@ class Credentials
2626
private string $password;
2727
private string $dbName;
2828

29+
/**
30+
* @deprecated
31+
* @var array options
32+
*/
33+
private array $options;
34+
35+
/**
36+
* @deprecated
37+
* @var int|null $connections
38+
*/
39+
private ?int $connections = null;
40+
2941
/**
3042
* Credentials constructor.
3143
*
@@ -47,6 +59,23 @@ public function __construct(
4759
$this->user = $user;
4860
$this->password = $password;
4961
$this->dbName = $dbName;
62+
63+
if (func_num_args() > 5) {
64+
trigger_error(
65+
'6th argument is deprecated, for options please use ' . ConnectionOptions::class .
66+
' or and extend of this class instead, when creating a connection',
67+
E_USER_DEPRECATED
68+
);
69+
$this->options = (array)func_get_arg(5);
70+
}
71+
if (func_num_args() > 6) {
72+
trigger_error(
73+
'7th argument is deprecated, please use ' . ConnectionPoolOptions::class .
74+
' to set the number of connections, when creating a ' . ConnectionPool::class,
75+
E_USER_DEPRECATED
76+
);
77+
$this->connections = (int)func_get_arg(6);
78+
}
5079
}
5180

5281
/**
@@ -89,6 +118,24 @@ public function getDbName(): string
89118
return $this->dbName;
90119
}
91120

121+
/**
122+
* @deprecated
123+
* @return array
124+
*/
125+
public function getOptions(): array
126+
{
127+
return $this->options;
128+
}
129+
130+
/**
131+
* @deprecated
132+
* @return int|null
133+
*/
134+
public function getConnections(): ?int
135+
{
136+
return $this->connections;
137+
}
138+
92139
/**
93140
* To string.
94141
*/

0 commit comments

Comments
 (0)