Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Symfony 7.0 #604

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
24 changes: 13 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/" }
Expand All @@ -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
}
5 changes: 3 additions & 2 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,15 @@ 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();

return $this->crawler = $this->createCrawler();
}

return parent::click($link);
return parent::click($link, $serverParameters);
}

public function submit(Form $form, array $values = [], array $serverParameters = []): Crawler
Expand Down Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions src/DomCrawler/Crawler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 0 additions & 7 deletions src/DomCrawler/Field/FileFormField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/DomCrawler/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/DomCrawler/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public function __construct(WebDriverElement $element)

$this->element = $element;
$this->method = 'GET';
$this->currentUri = null;
}

public function getNode(): \DOMElement
Expand Down
Loading