1010use Hhxsv5 \LaravelS \Swoole \Task \Event ;
1111use Hhxsv5 \LaravelS \Swoole \Task \Listener ;
1212use Hhxsv5 \LaravelS \Swoole \Task \Task ;
13+ use Hhxsv5 \LaravelS \Swoole \Proxy \HttpServerProxy ;
14+ use Hhxsv5 \LaravelS \Swoole \Proxy \WebSocketServerProxy ;
1315use Swoole \Http \Request as SwooleRequest ;
1416use Swoole \Http \Response as SwooleResponse ;
1517use Swoole \Http \Server as HttpServer ;
@@ -22,10 +24,13 @@ class Server
2224 use LogTrait;
2325 use ProcessTitleTrait;
2426
27+ /** Suffix for dynamic table properties to avoid naming conflicts */
28+ public const TABLE_PROPERTY_SUFFIX = 'Table ' ;
29+
2530 /**@var array */
2631 protected $ conf ;
2732
28- /**@var HttpServer|WebSocketServer */
33+ /**@var HttpServer|WebSocketServer|HttpServerProxy|WebSocketServerProxy */
2934 protected $ swoole ;
3035
3136 /**@var bool */
@@ -50,7 +55,10 @@ protected function __construct(array $conf)
5055 $ settings = isset ($ conf ['swoole ' ]) ? $ conf ['swoole ' ] : [];
5156 $ settings ['enable_static_handler ' ] = !empty ($ conf ['handle_static ' ]);
5257
53- $ serverClass = $ this ->enableWebSocket ? WebSocketServer::class : HttpServer::class;
58+ // Use proxy classes to support dynamic properties in PHP 8.2+
59+ $ serverClass = $ this ->enableWebSocket
60+ ? WebSocketServerProxy::class
61+ : HttpServerProxy::class;
5462 if (isset ($ settings ['ssl_cert_file ' ], $ settings ['ssl_key_file ' ])) {
5563 $ this ->swoole = new $ serverClass ($ ip , $ port , SWOOLE_PROCESS , $ socketType | SWOOLE_SSL );
5664 } else {
@@ -235,7 +243,7 @@ protected function bindSwooleTables()
235243 }
236244 }
237245 $ t ->create ();
238- $ name .= ' Table ' ; // Avoid naming conflicts
246+ $ name .= self :: TABLE_PROPERTY_SUFFIX ; // Avoid naming conflicts
239247 $ this ->swoole ->{$ name } = $ t ;
240248 }
241249 }
0 commit comments