Skip to content

Commit 8917498

Browse files
committed
Forbid cloning and serialization
1 parent de27f1c commit 8917498

9 files changed

+45
-0
lines changed

src/CommandResult.php

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Amp\Sql\Common;
44

5+
use Amp\ForbidCloning;
6+
use Amp\ForbidSerialization;
57
use Amp\Future;
68
use Amp\Sql\Result;
79

@@ -13,6 +15,9 @@
1315
*/
1416
abstract class CommandResult implements Result, \IteratorAggregate
1517
{
18+
use ForbidCloning;
19+
use ForbidSerialization;
20+
1621
/**
1722
* @param Future<TResult|null> $nextResult
1823
*/

src/ConnectionPool.php

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
namespace Amp\Sql\Common;
44

55
use Amp\DeferredFuture;
6+
use Amp\ForbidCloning;
7+
use Amp\ForbidSerialization;
68
use Amp\Future;
79
use Amp\Sql\Connection;
810
use Amp\Sql\Link;
@@ -29,6 +31,9 @@
2931
*/
3032
abstract class ConnectionPool implements Pool
3133
{
34+
use ForbidCloning;
35+
use ForbidSerialization;
36+
3237
public const DEFAULT_MAX_CONNECTIONS = 100;
3338
public const DEFAULT_IDLE_TIMEOUT = 60;
3439

src/ConnectionTransaction.php

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
namespace Amp\Sql\Common;
44

55
use Amp\DeferredFuture;
6+
use Amp\ForbidCloning;
7+
use Amp\ForbidSerialization;
68
use Amp\Sql\Result;
79
use Amp\Sql\SqlException;
810
use Amp\Sql\Statement;
@@ -21,6 +23,9 @@
2123
*/
2224
abstract class ConnectionTransaction implements Transaction
2325
{
26+
use ForbidCloning;
27+
use ForbidSerialization;
28+
2429
/** @var \Closure():void */
2530
private readonly \Closure $release;
2631

src/NestedTransaction.php

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
namespace Amp\Sql\Common;
44

55
use Amp\DeferredFuture;
6+
use Amp\ForbidCloning;
7+
use Amp\ForbidSerialization;
68
use Amp\Sql\Result;
79
use Amp\Sql\SqlException;
810
use Amp\Sql\Statement;
@@ -21,6 +23,9 @@
2123
*/
2224
abstract class NestedTransaction implements Transaction
2325
{
26+
use ForbidCloning;
27+
use ForbidSerialization;
28+
2429
/** @var \Closure():void */
2530
private readonly \Closure $release;
2631

src/PooledResult.php

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Amp\Sql\Common;
44

5+
use Amp\ForbidCloning;
6+
use Amp\ForbidSerialization;
57
use Amp\Future;
68
use Amp\Sql\Result;
79
use Revolt\EventLoop;
@@ -15,6 +17,9 @@
1517
*/
1618
abstract class PooledResult implements Result, \IteratorAggregate
1719
{
20+
use ForbidCloning;
21+
use ForbidSerialization;
22+
1823
/** @var Future<TResult|null>|null */
1924
private ?Future $next = null;
2025

src/PooledStatement.php

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Amp\Sql\Common;
44

5+
use Amp\ForbidCloning;
6+
use Amp\ForbidSerialization;
57
use Amp\Sql\Result;
68
use Amp\Sql\SqlException;
79
use Amp\Sql\Statement;
@@ -15,6 +17,9 @@
1517
*/
1618
abstract class PooledStatement implements Statement
1719
{
20+
use ForbidCloning;
21+
use ForbidSerialization;
22+
1823
/** @var null|\Closure():void */
1924
private ?\Closure $release;
2025

src/PooledTransaction.php

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Amp\Sql\Common;
44

5+
use Amp\ForbidCloning;
6+
use Amp\ForbidSerialization;
57
use Amp\Sql\Result;
68
use Amp\Sql\Statement;
79
use Amp\Sql\Transaction;
@@ -17,6 +19,9 @@
1719
*/
1820
abstract class PooledTransaction implements Transaction
1921
{
22+
use ForbidCloning;
23+
use ForbidSerialization;
24+
2025
/** @var \Closure():void */
2126
private readonly \Closure $release;
2227

src/RetrySqlConnector.php

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
use Amp\Cancellation;
66
use Amp\CompositeException;
7+
use Amp\ForbidCloning;
8+
use Amp\ForbidSerialization;
79
use Amp\Sql\Connection;
810
use Amp\Sql\ConnectionException;
911
use Amp\Sql\SqlConfig;
@@ -16,6 +18,9 @@
1618
*/
1719
final class RetrySqlConnector implements SqlConnector
1820
{
21+
use ForbidCloning;
22+
use ForbidSerialization;
23+
1924
/**
2025
* @param SqlConnector<TConfig, TConnection> $connector
2126
*/

src/StatementPool.php

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
namespace Amp\Sql\Common;
44

55
use Amp\DeferredFuture;
6+
use Amp\ForbidCloning;
7+
use Amp\ForbidSerialization;
68
use Amp\Sql\Pool;
79
use Amp\Sql\Result;
810
use Amp\Sql\SqlConfig;
@@ -20,6 +22,9 @@
2022
*/
2123
abstract class StatementPool implements Statement
2224
{
25+
use ForbidCloning;
26+
use ForbidSerialization;
27+
2328
private readonly Pool $pool;
2429

2530
/** @var \SplQueue<TStatement> */

0 commit comments

Comments
 (0)