diff --git a/src/Client.php b/src/Client.php index 75d059e2..738e3d7f 100644 --- a/src/Client.php +++ b/src/Client.php @@ -268,7 +268,7 @@ public function request(string $method, string $uri, array $parameters = [], arr foreach (['parameters', 'files', 'server'] as $arg) { if ([] !== $$arg) { - throw new InvalidArgumentException(sprintf('The parameter "$%s" is not supported when using WebDriver.', $arg)); + throw new InvalidArgumentException(\sprintf('The parameter "$%s" is not supported when using WebDriver.', $arg)); } } @@ -775,9 +775,9 @@ public function ping(int $timeout = 1000): bool private function createException(string $implementableClass): \Exception { if (null === $this->webDriver) { - return new \LogicException(sprintf('WebDriver not started yet. Call method `start()` first before calling any `%s` method.', $implementableClass)); + return new \LogicException(\sprintf('WebDriver not started yet. Call method `start()` first before calling any `%s` method.', $implementableClass)); } - return new \RuntimeException(sprintf('"%s" does not implement "%s".', \get_class($this->webDriver), $implementableClass)); + return new \RuntimeException(\sprintf('"%s" does not implement "%s".', \get_class($this->webDriver), $implementableClass)); } } diff --git a/src/DomCrawler/Crawler.php b/src/DomCrawler/Crawler.php index bf2ab0b1..877fb5c2 100644 --- a/src/DomCrawler/Crawler.php +++ b/src/DomCrawler/Crawler.php @@ -276,19 +276,19 @@ public function filter($selector): static public function selectLink($value): static { return $this->selectFromXpath( - sprintf('descendant-or-self::a[contains(concat(\' \', normalize-space(string(.)), \' \'), %1$s) or ./img[contains(concat(\' \', normalize-space(string(@alt)), \' \'), %1$s)]]', self::xpathLiteral(' '.$value.' ')) + \sprintf('descendant-or-self::a[contains(concat(\' \', normalize-space(string(.)), \' \'), %1$s) or ./img[contains(concat(\' \', normalize-space(string(@alt)), \' \'), %1$s)]]', self::xpathLiteral(' '.$value.' ')) ); } public function selectImage($value): static { - return $this->selectFromXpath(sprintf('descendant-or-self::img[contains(normalize-space(string(@alt)), %s)]', self::xpathLiteral($value))); + return $this->selectFromXpath(\sprintf('descendant-or-self::img[contains(normalize-space(string(@alt)), %s)]', self::xpathLiteral($value))); } public function selectButton($value): static { return $this->selectFromXpath( - sprintf( + \sprintf( 'descendant-or-self::input[((contains(%1$s, "submit") or contains(%1$s, "button")) and contains(concat(\' \', normalize-space(string(@value)), \' \'), %2$s)) or (contains(%1$s, "image") and contains(concat(\' \', normalize-space(string(@alt)), \' \'), %2$s)) or @id=%3$s or @name=%3$s] | descendant-or-self::button[contains(concat(\' \', normalize-space(string(.)), \' \'), %2$s) or @id=%3$s or @name=%3$s]', 'translate(@type, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz")', self::xpathLiteral(' '.$value.' '), diff --git a/src/DomCrawler/Field/ChoiceFormField.php b/src/DomCrawler/Field/ChoiceFormField.php index 5690ecfb..0f456059 100644 --- a/src/DomCrawler/Field/ChoiceFormField.php +++ b/src/DomCrawler/Field/ChoiceFormField.php @@ -54,7 +54,7 @@ public function select($value): void public function tick(): void { if ('checkbox' !== $type = $this->element->getAttribute('type')) { - throw new LogicException(sprintf('You cannot tick "%s" as it is not a checkbox (%s).', $this->element->getAttribute('name'), $type)); + throw new LogicException(\sprintf('You cannot tick "%s" as it is not a checkbox (%s).', $this->element->getAttribute('name'), $type)); } $this->setValue(true); @@ -68,7 +68,7 @@ public function tick(): void public function untick(): void { if ('checkbox' !== $type = $this->element->getAttribute('type')) { - throw new LogicException(sprintf('You cannot tick "%s" as it is not a checkbox (%s).', $this->element->getAttribute('name'), $type)); + throw new LogicException(\sprintf('You cannot tick "%s" as it is not a checkbox (%s).', $this->element->getAttribute('name'), $type)); } $this->setValue(false); @@ -116,7 +116,7 @@ public function setValue($value): void { if (\is_bool($value)) { if ('checkbox' !== $this->type) { - throw new InvalidArgumentException(sprintf('Invalid argument of type "%s"', \gettype($value))); + throw new InvalidArgumentException(\sprintf('Invalid argument of type "%s"', \gettype($value))); } if ($value) { @@ -191,12 +191,12 @@ protected function initialize(): void { $tagName = $this->element->getTagName(); if ('input' !== $tagName && 'select' !== $tagName) { - throw new LogicException(sprintf('A ChoiceFormField can only be created from an input or select tag (%s given).', $tagName)); + throw new LogicException(\sprintf('A ChoiceFormField can only be created from an input or select tag (%s given).', $tagName)); } $type = strtolower((string) $this->element->getAttribute('type')); if ('input' === $tagName && 'checkbox' !== $type && 'radio' !== $type) { - throw new LogicException(sprintf('A ChoiceFormField can only be created from an input tag with a type of checkbox or radio (given type is %s).', $type)); + throw new LogicException(\sprintf('A ChoiceFormField can only be created from an input tag with a type of checkbox or radio (given type is %s).', $type)); } $this->type = 'select' === $tagName ? 'select' : $type; diff --git a/src/DomCrawler/Field/FileFormField.php b/src/DomCrawler/Field/FileFormField.php index e52b9b33..ac948476 100644 --- a/src/DomCrawler/Field/FileFormField.php +++ b/src/DomCrawler/Field/FileFormField.php @@ -68,12 +68,12 @@ protected function initialize(): void { $tagName = $this->element->getTagName(); if ('input' !== $tagName) { - throw new LogicException(sprintf('A FileFormField can only be created from an input tag (%s given).', $tagName)); + throw new LogicException(\sprintf('A FileFormField can only be created from an input tag (%s given).', $tagName)); } $type = strtolower($this->element->getAttribute('type')); if ('file' !== $type) { - throw new LogicException(sprintf('A FileFormField can only be created from an input tag with a type of file (given type is %s).', $type)); + throw new LogicException(\sprintf('A FileFormField can only be created from an input tag with a type of file (given type is %s).', $type)); } $value = $this->element->getAttribute('value'); diff --git a/src/DomCrawler/Field/InputFormField.php b/src/DomCrawler/Field/InputFormField.php index 5b51a716..5da1f6ef 100644 --- a/src/DomCrawler/Field/InputFormField.php +++ b/src/DomCrawler/Field/InputFormField.php @@ -49,7 +49,7 @@ protected function initialize(): void { $tagName = $this->element->getTagName(); if ('input' !== $tagName && 'button' !== $tagName) { - throw new LogicException(sprintf('An InputFormField can only be created from an input or button tag (%s given).', $tagName)); + throw new LogicException(\sprintf('An InputFormField can only be created from an input or button tag (%s given).', $tagName)); } $type = strtolower((string) $this->element->getAttribute('type')); diff --git a/src/DomCrawler/Field/TextareaFormField.php b/src/DomCrawler/Field/TextareaFormField.php index 73106f4f..715d3b24 100644 --- a/src/DomCrawler/Field/TextareaFormField.php +++ b/src/DomCrawler/Field/TextareaFormField.php @@ -37,7 +37,7 @@ protected function initialize(): void { $tagName = $this->element->getTagName(); if ('textarea' !== $tagName) { - throw new LogicException(sprintf('A TextareaFormField can only be created from a textarea tag (%s given).', $tagName)); + throw new LogicException(\sprintf('A TextareaFormField can only be created from a textarea tag (%s given).', $tagName)); } } } diff --git a/src/DomCrawler/Form.php b/src/DomCrawler/Form.php index 951f0153..7fd1dd88 100644 --- a/src/DomCrawler/Form.php +++ b/src/DomCrawler/Form.php @@ -62,7 +62,7 @@ private function setElement(WebDriverElement $element): void try { $form = $this->webDriver->findElement(WebDriverBy::id($formId)); } catch (NoSuchElementException $e) { - throw new LogicException(sprintf('The selected node has an invalid form attribute (%s).', $formId)); + throw new LogicException(\sprintf('The selected node has an invalid form attribute (%s).', $formId)); } $this->element = $form; @@ -78,7 +78,7 @@ private function setElement(WebDriverElement $element): void } } while ('form' !== $element->getTagName()); } elseif ('form' !== $tagName = $element->getTagName()) { - throw new LogicException(sprintf('Unable to submit on a "%s" tag.', $tagName)); + throw new LogicException(\sprintf('Unable to submit on a "%s" tag.', $tagName)); } $this->element = $element; @@ -168,7 +168,7 @@ public function getFiles(): array continue; } - if ($field instanceof Field\FileFormField) { + if ($field instanceof FileFormField) { $files[$field->getName()] = $field->getValue(); } } @@ -272,7 +272,7 @@ protected function getRawUri(): string private function getFormElement(string $name): WebDriverElement { return $this->element->findElement(WebDriverBy::xpath( - sprintf('.//input[@name=%1$s] | .//textarea[@name=%1$s] | .//select[@name=%1$s] | .//button[@name=%1$s] | .//input[@name=%2$s] | .//textarea[@name=%2$s] | .//select[@name=%2$s] | .//button[@name=%2$s]', XPathEscaper::escapeQuotes($name), XPathEscaper::escapeQuotes($name.'[]')) + \sprintf('.//input[@name=%1$s] | .//textarea[@name=%1$s] | .//select[@name=%1$s] | .//button[@name=%1$s] | .//input[@name=%2$s] | .//textarea[@name=%2$s] | .//select[@name=%2$s] | .//button[@name=%2$s]', XPathEscaper::escapeQuotes($name), XPathEscaper::escapeQuotes($name.'[]')) )); } diff --git a/src/DomCrawler/Image.php b/src/DomCrawler/Image.php index 88eccc1c..c88ad40e 100644 --- a/src/DomCrawler/Image.php +++ b/src/DomCrawler/Image.php @@ -30,7 +30,7 @@ final class Image extends BaseImage public function __construct(WebDriverElement $element) { if ('img' !== $tagName = $element->getTagName()) { - throw new LogicException(sprintf('Unable to visualize a "%s" tag.', $tagName)); + throw new LogicException(\sprintf('Unable to visualize a "%s" tag.', $tagName)); } $this->element = $element; diff --git a/src/DomCrawler/Link.php b/src/DomCrawler/Link.php index 3e04760d..78cdc328 100644 --- a/src/DomCrawler/Link.php +++ b/src/DomCrawler/Link.php @@ -31,7 +31,7 @@ public function __construct(WebDriverElement $element, string $currentUri) { $tagName = $element->getTagName(); if ('a' !== $tagName && 'area' !== $tagName && 'link' !== $tagName) { - throw new LogicException(sprintf('Unable to navigate from a "%s" tag.', $tagName)); + throw new LogicException(\sprintf('Unable to navigate from a "%s" tag.', $tagName)); } $this->element = $element; diff --git a/src/Exception/ExceptionInterface.php b/src/Exception/ExceptionInterface.php index 007772f3..3bbe2830 100644 --- a/src/Exception/ExceptionInterface.php +++ b/src/Exception/ExceptionInterface.php @@ -9,6 +9,8 @@ * file that was distributed with this source code. */ +declare(strict_types=1); + namespace Symfony\Component\Panther\Exception; /** diff --git a/src/Exception/InvalidArgumentException.php b/src/Exception/InvalidArgumentException.php index 69c3a30b..b1843a07 100644 --- a/src/Exception/InvalidArgumentException.php +++ b/src/Exception/InvalidArgumentException.php @@ -9,6 +9,8 @@ * file that was distributed with this source code. */ +declare(strict_types=1); + namespace Symfony\Component\Panther\Exception; /** diff --git a/src/Exception/LogicException.php b/src/Exception/LogicException.php index 54da0f43..f5ff4760 100644 --- a/src/Exception/LogicException.php +++ b/src/Exception/LogicException.php @@ -9,6 +9,8 @@ * file that was distributed with this source code. */ +declare(strict_types=1); + namespace Symfony\Component\Panther\Exception; /** diff --git a/src/Exception/RuntimeException.php b/src/Exception/RuntimeException.php index 12ba78dd..d75d3260 100644 --- a/src/Exception/RuntimeException.php +++ b/src/Exception/RuntimeException.php @@ -9,6 +9,8 @@ * file that was distributed with this source code. */ +declare(strict_types=1); + namespace Symfony\Component\Panther\Exception; /** diff --git a/src/ExceptionThrower.php b/src/ExceptionThrower.php index 5a0d530a..d13069cb 100644 --- a/src/ExceptionThrower.php +++ b/src/ExceptionThrower.php @@ -22,6 +22,6 @@ trait ExceptionThrower { private function createNotSupportedException(string $method): \InvalidArgumentException { - return new \InvalidArgumentException(sprintf('The "%s" method is not supported when using WebDriver.', $method)); + return new \InvalidArgumentException(\sprintf('The "%s" method is not supported when using WebDriver.', $method)); } } diff --git a/src/PantherTestCaseTrait.php b/src/PantherTestCaseTrait.php index 901a932c..df730cee 100644 --- a/src/PantherTestCaseTrait.php +++ b/src/PantherTestCaseTrait.php @@ -119,7 +119,7 @@ public static function startWebServer(array $options = []): void self::$webServerManager = new WebServerManager(...array_values($options)); self::$webServerManager->start(); - self::$baseUri = sprintf('http://%s:%s', $options['hostname'], $options['port']); + self::$baseUri = \sprintf('http://%s:%s', $options['hostname'], $options['port']); } public static function isWebServerStarted(): bool @@ -181,19 +181,19 @@ protected static function createPantherClient(array $options = [], array $kernel $browserArguments = $options['browser_arguments'] ?? null; if (null !== $browserArguments && !\is_array($browserArguments)) { - throw new \TypeError(sprintf('Expected key "browser_arguments" to be an array or null, "%s" given.', get_debug_type($browserArguments))); + throw new \TypeError(\sprintf('Expected key "browser_arguments" to be an array or null, "%s" given.', get_debug_type($browserArguments))); } if (PantherTestCase::FIREFOX === $browser) { - self::$pantherClients[0] = self::$pantherClient = Client::createFirefoxClient(null, $browserArguments, $managerOptions, self::$baseUri); + self::$pantherClients[0] = self::$pantherClient = PantherClient::createFirefoxClient(null, $browserArguments, $managerOptions, self::$baseUri); } else { try { - self::$pantherClients[0] = self::$pantherClient = Client::createChromeClient(null, $browserArguments, $managerOptions, self::$baseUri); + self::$pantherClients[0] = self::$pantherClient = PantherClient::createChromeClient(null, $browserArguments, $managerOptions, self::$baseUri); } catch (RuntimeException $e) { if (PantherTestCase::CHROME === $browser) { throw $e; } - self::$pantherClients[0] = self::$pantherClient = Client::createFirefoxClient(null, $browserArguments, $managerOptions, self::$baseUri); + self::$pantherClients[0] = self::$pantherClient = PantherClient::createFirefoxClient(null, $browserArguments, $managerOptions, self::$baseUri); } if (null === $browser) { @@ -237,7 +237,7 @@ protected static function createHttpBrowserClient(array $options = [], array $ke if (null === self::$httpBrowserClient) { $httpClientOptions = $options['http_client_options'] ?? []; if (!\is_array($httpClientOptions)) { - throw new \TypeError(sprintf('Expected key "http_client_options" to be an array, "%s" given.', get_debug_type($httpClientOptions))); + throw new \TypeError(\sprintf('Expected key "http_client_options" to be an array, "%s" given.', get_debug_type($httpClientOptions))); } // The ScopingHttpClient can't be used cause the HttpBrowser only supports absolute URLs, @@ -250,7 +250,7 @@ protected static function createHttpBrowserClient(array $options = [], array $ke } $urlComponents = parse_url(self::$baseUri); - self::$httpBrowserClient->setServerParameter('HTTP_HOST', sprintf('%s:%s', $urlComponents['host'], $urlComponents['port'])); + self::$httpBrowserClient->setServerParameter('HTTP_HOST', \sprintf('%s:%s', $urlComponents['host'], $urlComponents['port'])); if ('https' === $urlComponents['scheme']) { self::$httpBrowserClient->setServerParameter('HTTPS', 'true'); } diff --git a/src/ProcessManager/SeleniumManager.php b/src/ProcessManager/SeleniumManager.php index a49fd649..b90d1014 100644 --- a/src/ProcessManager/SeleniumManager.php +++ b/src/ProcessManager/SeleniumManager.php @@ -30,7 +30,7 @@ final class SeleniumManager implements BrowserManagerInterface public function __construct( ?string $host = 'http://127.0.0.1:4444/wd/hub', WebDriverCapabilities $capabilities = null, - ?array $options = [] + ?array $options = [], ) { $this->host = $host; $this->capabilities = $capabilities ?? DesiredCapabilities::chrome(); diff --git a/src/ProcessManager/WebServerManager.php b/src/ProcessManager/WebServerManager.php index 68b51613..4eda31b8 100644 --- a/src/ProcessManager/WebServerManager.php +++ b/src/ProcessManager/WebServerManager.php @@ -57,7 +57,7 @@ public function __construct(string $documentRoot, string $hostname, int $port, s [ '-dvariables_order=EGPCS', '-S', - sprintf('%s:%d', $this->hostname, $this->port), + \sprintf('%s:%d', $this->hostname, $this->port), '-t', $documentRoot, $router, diff --git a/src/ProcessManager/WebServerReadinessProbeTrait.php b/src/ProcessManager/WebServerReadinessProbeTrait.php index 74c5be65..668a0a8d 100644 --- a/src/ProcessManager/WebServerReadinessProbeTrait.php +++ b/src/ProcessManager/WebServerReadinessProbeTrait.php @@ -37,7 +37,7 @@ private function checkPortAvailable(string $hostname, int $port, bool $throw = t if (\is_resource($resource)) { fclose($resource); if ($throw) { - throw new RuntimeException(sprintf('The port %d is already in use.', $port)); + throw new RuntimeException(\sprintf('The port %d is already in use.', $port)); } } } @@ -51,7 +51,7 @@ public function waitUntilReady(Process $process, string $url, string $service, b while (true) { $status = $process->getStatus(); if (Process::STATUS_TERMINATED === $status) { - throw new RuntimeException(sprintf('Could not start %s. Exit code: %d (%s). Error output: %s', $service, $process->getExitCode(), $process->getExitCodeText(), $process->getErrorOutput())); + throw new RuntimeException(\sprintf('Could not start %s. Exit code: %d (%s). Error output: %s', $service, $process->getExitCode(), $process->getExitCodeText(), $process->getErrorOutput())); } if (Process::STATUS_STARTED !== $status) { diff --git a/src/ServerExtensionLegacy.php b/src/ServerExtensionLegacy.php index 8cbdbd8b..7088365c 100644 --- a/src/ServerExtensionLegacy.php +++ b/src/ServerExtensionLegacy.php @@ -55,12 +55,12 @@ public function executeAfterLastTest(): void public function executeAfterTestError(string $test, string $message, float $time): void { - $this->pause(sprintf('Error: %s', $message)); + $this->pause(\sprintf('Error: %s', $message)); } public function executeAfterTestFailure(string $test, string $message, float $time): void { - $this->pause(sprintf('Failure: %s', $message)); + $this->pause(\sprintf('Failure: %s', $message)); } private static function reset(): void @@ -75,7 +75,7 @@ public static function takeScreenshots(string $type, string $test): void } foreach (self::$registeredClients as $i => $client) { - $screenshotPath = sprintf('%s/%s_%s_%s-%d.png', + $screenshotPath = \sprintf('%s/%s_%s_%s-%d.png', $_SERVER['PANTHER_ERROR_SCREENSHOT_DIR'], date('Y-m-d_H-i-s'), $type, diff --git a/src/WebDriver/WebDriverCheckbox.php b/src/WebDriver/WebDriverCheckbox.php index 635dda6a..0b3055fa 100644 --- a/src/WebDriver/WebDriverCheckbox.php +++ b/src/WebDriver/WebDriverCheckbox.php @@ -176,7 +176,7 @@ private function byValue($value, $select = true): void } if (!$matched) { - throw new NoSuchElementException(sprintf('Cannot locate option with value: %s', $value)); + throw new NoSuchElementException(\sprintf('Cannot locate option with value: %s', $value)); } } @@ -184,7 +184,7 @@ private function byIndex($index, $select = true): void { $options = $this->getRelatedElements(); if (!isset($options[$index])) { - throw new NoSuchElementException(sprintf('Cannot locate option with index: %d', $index)); + throw new NoSuchElementException(\sprintf('Cannot locate option with index: %d', $index)); } $select ? $this->selectOption($options[$index]) : $this->deselectOption($options[$index]); @@ -193,15 +193,15 @@ private function byIndex($index, $select = true): void private function byVisibleText($text, $partial = false, $select = true): void { foreach ($this->getRelatedElements() as $element) { - $normalizeFilter = sprintf($partial ? 'contains(normalize-space(.), %s)' : 'normalize-space(.) = %s', XPathEscaper::escapeQuotes($text)); + $normalizeFilter = \sprintf($partial ? 'contains(normalize-space(.), %s)' : 'normalize-space(.) = %s', XPathEscaper::escapeQuotes($text)); $xpath = 'ancestor::label'; - $xpathNormalize = sprintf('%s[%s]', $xpath, $normalizeFilter); + $xpathNormalize = \sprintf('%s[%s]', $xpath, $normalizeFilter); if (null !== $id = $element->getAttribute('id')) { - $idFilter = sprintf('@for = %s', XPathEscaper::escapeQuotes($id)); + $idFilter = \sprintf('@for = %s', XPathEscaper::escapeQuotes($id)); - $xpath .= sprintf(' | //label[%s]', $idFilter); - $xpathNormalize .= sprintf(' | //label[%s and %s]', $idFilter, $normalizeFilter); + $xpath .= \sprintf(' | //label[%s]', $idFilter); + $xpathNormalize .= \sprintf(' | //label[%s and %s]', $idFilter, $normalizeFilter); } try { @@ -231,16 +231,16 @@ private function byVisibleText($text, $partial = false, $select = true): void private function getRelatedElements($value = null): array { - $valueSelector = $value ? sprintf(' and @value = %s', XPathEscaper::escapeQuotes($value)) : ''; + $valueSelector = $value ? \sprintf(' and @value = %s', XPathEscaper::escapeQuotes($value)) : ''; if (null === $formId = $this->element->getAttribute('form')) { $form = $this->element->findElement(WebDriverBy::xpath('ancestor::form')); if ('' === $formId = (string) $form->getAttribute('id')) { - return $form->findElements(WebDriverBy::xpath(sprintf('.//input[@name = %s%s]', XPathEscaper::escapeQuotes($this->name), $valueSelector))); + return $form->findElements(WebDriverBy::xpath(\sprintf('.//input[@name = %s%s]', XPathEscaper::escapeQuotes($this->name), $valueSelector))); } } return $this->element->findElements(WebDriverBy::xpath( - sprintf('//form[@id = %1$s]//input[@name = %2$s%3$s] | //input[@form = %1$s and @name = %2$s%3$s]', XPathEscaper::escapeQuotes($formId), XPathEscaper::escapeQuotes($this->name), $valueSelector) + \sprintf('//form[@id = %1$s]//input[@name = %2$s%3$s] | //input[@form = %1$s and @name = %2$s%3$s]', XPathEscaper::escapeQuotes($formId), XPathEscaper::escapeQuotes($this->name), $valueSelector) )); } diff --git a/src/WebDriver/WebDriverMouse.php b/src/WebDriver/WebDriverMouse.php index 3f9adaf9..f9cd7a58 100644 --- a/src/WebDriver/WebDriverMouse.php +++ b/src/WebDriver/WebDriverMouse.php @@ -110,7 +110,7 @@ private function toCoordinates($cssSelector): WebDriverCoordinates $element = $this->client->getCrawler()->filter($cssSelector)->getElement(0); if (!$element instanceof WebDriverLocatable) { - throw new RuntimeException(sprintf('The element of "%s" CSS selector does not implement "%s".', $cssSelector, WebDriverLocatable::class)); + throw new RuntimeException(\sprintf('The element of "%s" CSS selector does not implement "%s".', $cssSelector, WebDriverLocatable::class)); } return $element->getCoordinates(); diff --git a/src/WebTestAssertionsTrait.php b/src/WebTestAssertionsTrait.php index 09cb761d..ae08088e 100644 --- a/src/WebTestAssertionsTrait.php +++ b/src/WebTestAssertionsTrait.php @@ -259,7 +259,7 @@ private static function findElement(string $locator): WebDriverElement { $client = self::getClient(); if (!$client instanceof PantherClient) { - throw new LogicException(sprintf('Using a client that is not an instance of "%s" is not supported.', PantherClient::class)); + throw new LogicException(\sprintf('Using a client that is not an instance of "%s" is not supported.', PantherClient::class)); } $by = $client::createWebDriverByFromLocator($locator); diff --git a/tests/DomCrawler/CrawlerTest.php b/tests/DomCrawler/CrawlerTest.php index cc313b8a..94b09d4a 100644 --- a/tests/DomCrawler/CrawlerTest.php +++ b/tests/DomCrawler/CrawlerTest.php @@ -81,7 +81,7 @@ public function testFilterXpath(callable $clientFactory): void $this->assertSame('36', $crawler->text(null, true)); break; default: - $this->fail(sprintf('Unexpected index "%d".', $i)); + $this->fail(\sprintf('Unexpected index "%d".', $i)); } }); } diff --git a/tests/DomCrawler/Field/FileFormFieldTest.php b/tests/DomCrawler/Field/FileFormFieldTest.php index 13cbc928..7e4ad01b 100644 --- a/tests/DomCrawler/Field/FileFormFieldTest.php +++ b/tests/DomCrawler/Field/FileFormFieldTest.php @@ -126,7 +126,7 @@ public function testPreventIsNotCanonicalError(callable $clientFactory): void $fileFormField = $form['file_upload']; $this->assertInstanceOf(FileFormField::class, $fileFormField); - $nonCanonicalPath = sprintf('%s/../fixtures/%s', self::$webServerDir, self::$uploadFileName); + $nonCanonicalPath = \sprintf('%s/../fixtures/%s', self::$webServerDir, self::$uploadFileName); $fileFormField->upload($nonCanonicalPath); $fileFormField->setValue($nonCanonicalPath); diff --git a/tests/DummyKernel.php b/tests/DummyKernel.php index 87141281..a0ebb123 100644 --- a/tests/DummyKernel.php +++ b/tests/DummyKernel.php @@ -85,7 +85,7 @@ public function getRootDir(): string public function getContainer(): ContainerInterface { - return new class() implements ContainerInterface { + return new class implements ContainerInterface { public function get($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE): ?object { return new \stdClass(); diff --git a/tests/TestCase.php b/tests/TestCase.php index 2541a58b..d59d043f 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -49,6 +49,6 @@ protected function request(callable $clientFactory, string $path): Crawler protected function getUploadFilePath(string $fileName): string { - return sprintf('%s/%s', self::$webServerDir, $fileName); + return \sprintf('%s/%s', self::$webServerDir, $fileName); } }