Skip to content

Commit 3945ece

Browse files
authored
ci: fixed static analysis (#655)
1 parent 0fa5f65 commit 3945ece

File tree

5 files changed

+12
-19
lines changed

5 files changed

+12
-19
lines changed

phpstan.neon

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ parameters:
1313
ignoreErrors:
1414
# False positive
1515
- '#Call to an undefined method ReflectionType::getName\(\)\.#'
16+
# False positive : assertNotEmpty assert that count() !== 0 on Countable
17+
- '#Call to static method PHPUnit\\Framework\\Assert::assert(Not)?Empty\(\) with Symfony\\Component\\DomCrawler\\Crawler will always evaluate to (true|false)\.#'
18+
# False positive : getStatus exists for PHPUnit < 10 only
19+
- '#Call to function method_exists\(\) with \$this\(Symfony\\Component\\Panther\\PantherTestCase\) and ''getStatus'' will always evaluate to true\.#'
20+
# False positive : PantherTestCase has no getClient method when symfony/framework-bundle (and WebTestCase) are not available
21+
- '#Call to function method_exists\(\) with ''Symfony\\\\Component\\\\Panther\\\\PantherTestCase'' and ''getClient'' will always evaluate to true\.#'
1622
# To fix in PHP WebDriver
1723
- '#Parameter \#2 \$desired_capabilities of static method Facebook\\WebDriver\\Remote\\RemoteWebDriver::create\(\) expects array\|Facebook\\WebDriver\\Remote\\DesiredCapabilities\|null, Facebook\\WebDriver\\WebDriverCapabilities given\.#'
1824
# Require a redesign of the underlying Symfony components

src/DomCrawler/Form.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,7 @@ public function set(FormField $field): void
211211
$this->setValue($field->getName(), $field->getValue());
212212
}
213213

214-
/**
215-
* @return FormField|FormField[]|FormField[][]
216-
*/
217-
public function get($name): FormField|array
214+
public function get($name): FormField
218215
{
219216
return $this->getFormField($this->getFormElement($name));
220217
}
@@ -238,10 +235,8 @@ public function offsetExists($name): bool
238235
* Gets the value of a field.
239236
*
240237
* @param string $name
241-
*
242-
* @return FormField|FormField[]|FormField[][]
243238
*/
244-
public function offsetGet($name): FormField|array
239+
public function offsetGet($name): FormField
245240
{
246241
return $this->get($name);
247242
}

src/WebTestAssertionsTrait.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ public static function assertSelectorExists(string $selector, string $message =
3939
$client = self::getClient();
4040

4141
if ($client instanceof PantherClient) {
42-
$element = self::findElement($selector);
43-
self::assertNotNull($element, $message);
42+
$by = $client::createWebDriverByFromLocator($selector);
43+
$elements = $client->findElements($by);
44+
self::assertNotEmpty($elements, $message);
4445

4546
return;
4647
}
@@ -92,12 +93,6 @@ public static function assertPageTitleContains(string $expectedTitle, string $me
9293
{
9394
$client = self::getClient();
9495
if ($client instanceof PantherClient) {
95-
if (method_exists(self::class, 'assertStringContainsString')) {
96-
self::assertStringContainsString($expectedTitle, $client->getTitle());
97-
98-
return;
99-
}
100-
10196
self::assertStringContainsString($expectedTitle, $client->getTitle());
10297

10398
return;

tests/DomCrawler/CrawlerTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,6 @@ public function testParents(callable $clientFactory): void
288288
public function testAncestors(callable $clientFactory): void
289289
{
290290
$crawler = $this->request($clientFactory, '/basic.html');
291-
if (!method_exists($crawler, 'ancestors')) {
292-
$this->markTestSkipped('Crawler::ancestors() doesn\'t exist.');
293-
}
294291

295292
$names = [];
296293
$crawler->filter('main > h1')->ancestors()->each(function (Crawler $c, int $i) use (&$names) {

tests/ScreenshotTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function testTakeScreenshot(): void
3737

3838
$screen = $client->takeScreenshot();
3939

40-
$this->assertIsString($screen);
40+
$this->assertNotEmpty($screen);
4141
}
4242

4343
public function testTakeScreenshotAndSaveToFile(): void

0 commit comments

Comments
 (0)