From e1c774af994f84e57f70ef374eee8af9cd1e44ea Mon Sep 17 00:00:00 2001 From: Kevin Bond Date: Tue, 26 Sep 2023 14:15:13 -0400 Subject: [PATCH] Allow Symfony 7.0 --- composer.json | 20 ++++++++++---------- src/Client.php | 4 ++-- src/DomCrawler/Crawler.php | 4 ++-- src/DomCrawler/Field/FileFormField.php | 7 ------- src/DomCrawler/Form.php | 1 + src/DomCrawler/Image.php | 1 + 6 files changed, 16 insertions(+), 21 deletions(-) diff --git a/composer.json b/composer.json index f0271aef..a7dbc2a9 100644 --- a/composer.json +++ b/composer.json @@ -21,13 +21,13 @@ "ext-dom": "*", "ext-libxml": "*", "php-webdriver/webdriver": "^1.8.2", - "symfony/browser-kit": "^5.3 || ^6.0", - "symfony/dependency-injection": "^5.3 || ^6.0", + "symfony/browser-kit": "^5.3 || ^6.0 || ^7.0", + "symfony/dependency-injection": "^5.3 || ^6.0 || ^7.0", "symfony/deprecation-contracts": "^2.4 || ^3", - "symfony/dom-crawler": "^5.3 || ^6.0", - "symfony/http-client": "^5.3 || ^6.0", - "symfony/http-kernel": "^5.3 || ^6.0", - "symfony/process": "^5.3 || ^6.0" + "symfony/dom-crawler": "^5.3 || ^6.0 || ^7.0", + "symfony/http-client": "^5.3 || ^6.0 || ^7.0", + "symfony/http-kernel": "^5.3 || ^6.0 || ^7.0", + "symfony/process": "^5.3 || ^6.0 || ^7.0" }, "autoload": { "psr-4": { "Symfony\\Component\\Panther\\": "src/" } @@ -44,9 +44,9 @@ "sort-packages": true }, "require-dev": { - "symfony/css-selector": "^5.3 || ^6.0", - "symfony/framework-bundle": "^5.3 || ^6.0", - "symfony/mime": "^5.3 || ^6.0", - "symfony/phpunit-bridge": "^5.3 || ^6.0" + "symfony/css-selector": "^5.3 || ^6.0 || ^7.0", + "symfony/framework-bundle": "^5.3 || ^6.0 || ^7.0", + "symfony/mime": "^5.3 || ^6.0 || ^7.0", + "symfony/phpunit-bridge": "^5.3 || ^6.0 || ^7.0" } } diff --git a/src/Client.php b/src/Client.php index a1b08939..71be876c 100644 --- a/src/Client.php +++ b/src/Client.php @@ -197,7 +197,7 @@ public function getHistory(): History throw new \LogicException('History is not available when using WebDriver.'); } - public function click(Link $link): Crawler + public function click(Link $link, array $serverParameters = []): Crawler { if ($link instanceof PantherLink) { $link->getElement()->click(); @@ -205,7 +205,7 @@ public function click(Link $link): Crawler return $this->crawler = $this->createCrawler(); } - return parent::click($link); + return parent::click($link, $serverParameters); } public function submit(Form $form, array $values = [], array $serverParameters = []): Crawler diff --git a/src/DomCrawler/Crawler.php b/src/DomCrawler/Crawler.php index 9fe6a4f4..5798d50d 100644 --- a/src/DomCrawler/Crawler.php +++ b/src/DomCrawler/Crawler.php @@ -188,14 +188,14 @@ public function children(string $selector = null): static return $this->createSubCrawlerFromXpath($xpath); } - public function attr($attribute): ?string + public function attr($attribute, $default = null): ?string { $element = $this->getElementOrThrow(); if ('_text' === $attribute) { return $this->text(); } - return (string) $element->getAttribute($attribute); + return $element->getAttribute($attribute) ?? $default; } public function nodeName(): string diff --git a/src/DomCrawler/Field/FileFormField.php b/src/DomCrawler/Field/FileFormField.php index 528cf4e1..2b170ed8 100644 --- a/src/DomCrawler/Field/FileFormField.php +++ b/src/DomCrawler/Field/FileFormField.php @@ -22,13 +22,6 @@ final class FileFormField extends BaseFileFormField { use FormFieldTrait; - /** - * @var array - * - * @phpstan-ignore-next-line - */ - protected $value; - public function getValue(): array|string|null { return $this->value; diff --git a/src/DomCrawler/Form.php b/src/DomCrawler/Form.php index 6afeeaeb..a375def6 100644 --- a/src/DomCrawler/Form.php +++ b/src/DomCrawler/Form.php @@ -47,6 +47,7 @@ public function __construct(WebDriverElement $element, WebDriver $webDriver) $this->setElement($element); $this->currentUri = $webDriver->getCurrentURL(); + $this->method = null; } private function setElement(WebDriverElement $element): void diff --git a/src/DomCrawler/Image.php b/src/DomCrawler/Image.php index f6524a8f..0c80dba4 100644 --- a/src/DomCrawler/Image.php +++ b/src/DomCrawler/Image.php @@ -34,6 +34,7 @@ public function __construct(WebDriverElement $element) $this->element = $element; $this->method = 'GET'; + $this->currentUri = null; } public function getNode(): \DOMElement