diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dcb4d72e..7fdbacb6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: '8.2' - tools: phpstan + tools: phpstan,flex extensions: zip - name: Get composer cache directory @@ -48,6 +48,8 @@ jobs: - name: Install dependencies run: composer install --prefer-dist + env: + SYMFONY_REQUIRE: 7.0.* - name: Install PHPUnit dependencies run: vendor/bin/simple-phpunit --version diff --git a/composer.json b/composer.json index f0271aef..f072313d 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,11 @@ "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" + }, + "minimum-stability": "dev", + "prefer-stable": true } diff --git a/src/Client.php b/src/Client.php index a1b08939..e2885092 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 @@ -272,6 +272,7 @@ public function request(string $method, string $uri, array $parameters = [], arr $this->get($uri); + // @phpstan-ignore-next-line The above call to get() sets the proper crawler return $this->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