Skip to content

Commit 6c96377

Browse files
committed
cs
1 parent 735bc55 commit 6c96377

29 files changed

+74
-172
lines changed

docs/examples/browser_choice.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
$playwright = PlaywrightFactory::create();
1717
$browsers = [
18-
'chromium' => $playwright->chromium(...),
19-
'firefox' => $playwright->firefox(...),
18+
'chromium' => $playwright->chromium(...),
19+
'firefox' => $playwright->firefox(...),
2020
'webkit' => $playwright->webkit(...),
2121
];
2222

@@ -27,7 +27,7 @@
2727
$page = $browser->newPage();
2828
$page->goto('https://www.whatismybrowser.com/');
2929
$page->locator('text=Your Browser is:')->waitFor();
30-
echo sprintf('Browser: %s %s | URL: %s',$type, $browser->version(), $page->url())."\n";
30+
echo sprintf('Browser: %s %s | URL: %s', $type, $browser->version(), $page->url())."\n";
3131

3232
$page->close();
3333
$browser->close();

src/Browser/Browser.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public function __construct(
3535
private readonly string $version,
3636
private readonly ?PlaywrightConfig $config = null,
3737
) {
38-
3938
$this->defaultContext = new BrowserContext($this->transport, $this->defaultContextId, $this->config);
4039
$this->contexts[] = $this->defaultContext;
4140
}
@@ -63,7 +62,7 @@ public function newContext(array $options = []): BrowserContextInterface
6362
if (!is_string($response['contextId'])) {
6463
throw new \RuntimeException('Invalid contextId returned from transport');
6564
}
66-
65+
6766
$context = new BrowserContext($this->transport, $response['contextId'], $this->config);
6867
$this->contexts[] = $context;
6968

@@ -73,7 +72,6 @@ public function newContext(array $options = []): BrowserContextInterface
7372
public function newPage(array $options = []): PageInterface
7473
{
7574
if (null === $this->defaultContext) {
76-
7775
$this->defaultContext = new BrowserContext($this->transport, $this->defaultContextId, $this->config);
7876
}
7977

src/Browser/BrowserContext.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ public function newPage(array $options = []): PageInterface
133133
throw new \RuntimeException('No valid pageId returned from transport in newPage');
134134
}
135135

136-
137136
$page = new Page($this->transport, $this, $response['pageId'], $this->config);
138137
$this->pages[$response['pageId']] = $page;
139138

@@ -214,7 +213,6 @@ public function cookies(?array $urls = null): array
214213
throw new \RuntimeException('Invalid cookies response');
215214
}
216215

217-
218216
/** @phpstan-var array<array<string, mixed>> $cookies */
219217
$cookies = $response['cookies'];
220218

@@ -276,7 +274,6 @@ public function storageState(?string $path = null): array
276274
throw new \RuntimeException('Invalid storageState response');
277275
}
278276

279-
280277
/** @phpstan-var array<string, mixed> $storageState */
281278
$storageState = $response['storageState'];
282279

src/Configuration/PlaywrightConfig.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,31 +30,30 @@ final class PlaywrightConfig
3030
* }|null $proxy
3131
*/
3232
public function __construct(
33-
3433
public readonly ?string $nodePath = null,
3534
public readonly string $minNodeVersion = '18.0.0',
36-
35+
3736
public readonly BrowserType $browser = BrowserType::CHROMIUM,
3837
public readonly ?string $channel = null,
3938
public readonly bool $headless = true,
40-
39+
4140
public readonly int $timeoutMs = 30000,
4241
public readonly int $slowMoMs = 0,
43-
42+
4443
public readonly array $args = [],
4544
public readonly array $env = [],
46-
45+
4746
public readonly ?string $downloadsDir = null,
4847
public readonly ?string $videosDir = null,
4948
public readonly ?string $screenshotDir = null,
50-
49+
5150
public readonly bool $tracingEnabled = false,
5251
public readonly ?string $traceDir = null,
5352
public readonly bool $traceScreenshots = false,
5453
public readonly bool $traceSnapshots = false,
55-
54+
5655
public readonly ?array $proxy = null,
57-
56+
5857
public readonly ?LoggerInterface $logger = null,
5958
) {
6059
}
@@ -70,7 +69,6 @@ public function getScreenshotDirectory(): string
7069
return $this->screenshotDir;
7170
}
7271

73-
7472
return rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'playwright';
7573
}
7674

src/Configuration/PlaywrightConfigBuilder.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,13 @@ public static function fromEnv(): self
6868
return (false === $v || '' === $v) ? null : $v;
6969
};
7070

71-
7271
if ($node = $get('PLAYWRIGHT_NODE_PATH')) {
7372
$b->withNodePath($node);
7473
}
7574
if ($min = $get('PLAYWRIGHT_NODE_MIN_VERSION')) {
7675
$b->withMinNodeVersion($min);
7776
}
7877

79-
8078
if ($browser = $get('PW_BROWSER')) {
8179
$browser = strtolower($browser);
8280
$map = [
@@ -102,20 +100,17 @@ public static function fromEnv(): self
102100
$b->withSlowMoMs((int) $slow);
103101
}
104102

105-
106103
if (($trace = $get('PW_TRACING')) !== null) {
107104
$b->withTracing(self::strToBool($trace), $get('PW_TRACE_DIR') ?: null);
108105
}
109106

110-
111107
if ($dl = $get('PW_DOWNLOADS_DIR')) {
112108
$b->withDownloadsDir($dl);
113109
}
114110
if ($vd = $get('PW_VIDEOS_DIR')) {
115111
$b->withVideosDir($vd);
116112
}
117113

118-
119114
if ($proxy = $get('PW_PROXY_SERVER')) {
120115
$b->withProxy(
121116
server: $proxy,
@@ -263,7 +258,6 @@ public function withLogger(?LoggerInterface $logger): self
263258

264259
public function build(): PlaywrightConfig
265260
{
266-
267261
if ($this->timeoutMs < 0) {
268262
throw new \InvalidArgumentException('timeoutMs must be >= 0');
269263
}

src/Console/ConsoleMessage.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ public function text(): string
5353
*/
5454
public function args(): array
5555
{
56-
57-
5856
$args = $this->data['args'];
5957
if (!is_array($args)) {
6058
throw new \RuntimeException('Invalid console message args');

src/Input/Keyboard.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ public function press(string $key, array $options = []): void
4444
'options' => $options,
4545
]);
4646

47-
4847
$this->transport->processEvents();
4948
}
5049

src/Input/Mouse.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ public function click(float $x, float $y, array $options = []): void
3636
'options' => $options,
3737
]);
3838

39-
4039
$this->transport->processEvents();
4140
}
4241

src/Locator/Locator.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -263,15 +263,13 @@ public function selectOption(string|array $values, array $options = []): array
263263
*/
264264
public function setInputFiles(string|array $files, array $options = []): void
265265
{
266-
267266
$fileArray = \is_array($files) ? $files : [$files];
268267

269268
$this->logger->debug('Setting input files on locator', [
270269
'selector' => (string) $this->selectorChain,
271270
'files' => $fileArray,
272271
]);
273272

274-
275273
foreach ($fileArray as $file) {
276274
if (!\file_exists($file)) {
277275
$this->logger->error('File not found for input upload', ['file' => $file]);
@@ -344,7 +342,6 @@ public function hover(array $options = []): void
344342
{
345343
$this->sendCommand('locator.hover', ['options' => $options]);
346344

347-
348345
$this->transport->processEvents();
349346
}
350347

@@ -456,7 +453,7 @@ private function sendCommand(string $action, array $params = []): array
456453
*/
457454
private function waitForActionable(array $options = []): void
458455
{
459-
$timeout = $this->extractTimeout($options);
456+
$timeout = $this->extractTimeout($options);
460457
$this->waitForCondition(
461458
fn () => $this->isVisible() && $this->isEnabled(),
462459
$timeout,
@@ -485,10 +482,9 @@ private function waitForCondition(callable $condition, int $timeoutMs, string $m
485482
return;
486483
}
487484
} catch (PlaywrightException $e) {
488-
489485
}
490486

491-
usleep(100000);
487+
usleep(100000);
492488
}
493489

494490
throw new TimeoutException(sprintf('%s (timeout: %dms)', $message, $timeoutMs));

src/Network/NetworkThrottling.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ public static function none(): self
4242
public static function slow3G(): self
4343
{
4444
return new self(
45-
downloadThroughput: 50 * 1024,
46-
uploadThroughput: 50 * 1024,
47-
latency: 2000,
45+
downloadThroughput: 50 * 1024,
46+
uploadThroughput: 50 * 1024,
47+
latency: 2000,
4848
);
4949
}
5050

@@ -54,9 +54,9 @@ public static function slow3G(): self
5454
public static function fast3G(): self
5555
{
5656
return new self(
57-
downloadThroughput: 150 * 1024,
58-
uploadThroughput: 75 * 1024,
59-
latency: 562,
57+
downloadThroughput: 150 * 1024,
58+
uploadThroughput: 75 * 1024,
59+
latency: 562,
6060
);
6161
}
6262

@@ -66,9 +66,9 @@ public static function fast3G(): self
6666
public static function fast4G(): self
6767
{
6868
return new self(
69-
downloadThroughput: (int) (1.6 * 1024 * 1024),
70-
uploadThroughput: 750 * 1024,
71-
latency: 150,
69+
downloadThroughput: (int) (1.6 * 1024 * 1024),
70+
uploadThroughput: 750 * 1024,
71+
latency: 150,
7272
);
7373
}
7474

@@ -78,9 +78,9 @@ public static function fast4G(): self
7878
public static function dsl(): self
7979
{
8080
return new self(
81-
downloadThroughput: 2 * 1024 * 1024,
82-
uploadThroughput: 1 * 1024 * 1024,
83-
latency: 5,
81+
downloadThroughput: 2 * 1024 * 1024,
82+
uploadThroughput: 1 * 1024 * 1024,
83+
latency: 5,
8484
);
8585
}
8686

@@ -90,9 +90,9 @@ public static function dsl(): self
9090
public static function wifi(): self
9191
{
9292
return new self(
93-
downloadThroughput: 30 * 1024 * 1024,
94-
uploadThroughput: 15 * 1024 * 1024,
95-
latency: 2,
93+
downloadThroughput: 30 * 1024 * 1024,
94+
uploadThroughput: 15 * 1024 * 1024,
95+
latency: 2,
9696
);
9797
}
9898

0 commit comments

Comments
 (0)