@@ -87,11 +87,10 @@ protected static function startWebServer(?string $webServerDir = null, string $h
87
87
self ::$ baseUri = "http:// $ hostname: $ port " ;
88
88
}
89
89
90
- /**
91
- * @param array $kernelOptions An array of options to pass to the createKernel method
92
- */
93
- protected static function createPantherClient (string $ hostname = '127.0.0.1 ' , int $ port = 9000 , array $ kernelOptions = []): PantherClient
90
+ protected static function createPantherClient (string $ hostname = '127.0.0.1 ' , ?int $ port = null , array $ kernelOptions = []): PantherClient
94
91
{
92
+ $ port = (int ) ($ port ?? $ _SERVER ['PANTHER_WEB_SERVER_PORT ' ] ?? 9000 );
93
+
95
94
self ::startWebServer (null , $ hostname , $ port );
96
95
if (null === self ::$ pantherClient ) {
97
96
self ::$ pantherClient = Client::createChromeClient (null , null , [], self ::$ baseUri );
@@ -104,15 +103,14 @@ protected static function createPantherClient(string $hostname = '127.0.0.1', in
104
103
return self ::$ pantherClient ;
105
104
}
106
105
107
- /**
108
- * @param array $kernelOptions An array of options to pass to the createKernel method
109
- */
110
- protected static function createGoutteClient (string $ hostname = '127.0.0.1 ' , int $ port = 9000 , array $ kernelOptions = []): GoutteClient
106
+ protected static function createGoutteClient (string $ hostname = '127.0.0.1 ' , ?int $ port = null , array $ kernelOptions = []): GoutteClient
111
107
{
112
108
if (!\class_exists (GoutteClient::class)) {
113
109
throw new \RuntimeException ('Goutte is not installed. Run "composer req fabpot/goutte". ' );
114
110
}
115
111
112
+ $ port = (int ) ($ port ?? $ _SERVER ['PANTHER_WEB_SERVER_PORT ' ] ?? 9000 );
113
+
116
114
self ::startWebServer (null , $ hostname , $ port );
117
115
if (null === self ::$ goutteClient ) {
118
116
$ goutteClient = new GoutteClient ();
0 commit comments