Add PHP CS Fixer and PHPStan max to CI; remove abandoned GoutteFactory

- Add friendsofphp/php-cs-fixer ^3.75 and phpstan/phpstan ^2.0 to
  require-dev; add .php-cs-fixer.dist.php (@Symfony ruleset with
  phpdoc_to_comment ignored_tags) and phpstan.neon (level max,
  treatPhpDocTypesAsCertain: false)
- Run CS Fixer and PHPStan in every CI matrix job alongside tests
- Add composer scripts: cs, cs-check, phpstan
- Add .php-cs-fixer.cache to .gitignore
- Fix all PHPStan max violations across src/: add return/param types,
  narrow mixed config values with is_string()/is_array() guards,
  use TaggedNodeInterface for scenario tag access in SessionsListener
- Remove GoutteFactory and its spec — the goutte driver and its
  underlying client library are abandoned

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Kamil Kokot
2026-06-12 17:43:01 +02:00
parent dff5cbd479
commit 47a9d45cd1
38 changed files with 436 additions and 720 deletions

View File

@@ -11,21 +11,16 @@
namespace Behat\MinkExtension\ServiceContainer\Driver;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\DependencyInjection\Definition;
class SauceLabsFactory extends Selenium2Factory
{
/**
* {@inheritdoc}
*/
public function getDriverName()
public function getDriverName(): string
{
return 'sauce_labs';
}
/**
* {@inheritdoc}
*/
public function configure(ArrayNodeDefinition $builder)
public function configure(ArrayNodeDefinition $builder): void
{
$builder
->children()
@@ -39,21 +34,21 @@ class SauceLabsFactory extends Selenium2Factory
}
/**
* {@inheritdoc}
* @param array<string, mixed> $config
*/
public function buildDriver(array $config)
public function buildDriver(array $config): Definition
{
$host = 'ondemand.saucelabs.com';
if ($config['connect']) {
if (is_bool($config['connect']) ? $config['connect'] : (bool) $config['connect']) {
$host = 'localhost:4445';
}
$config['wd_host'] = sprintf('%s:%s@%s/wd/hub', $config['username'], $config['access_key'], $host);
$config['wd_host'] = sprintf('%s:%s@%s/wd/hub', is_string($config['username']) ? $config['username'] : '', is_string($config['access_key']) ? $config['access_key'] : '', $host);
return parent::buildDriver($config);
}
protected function getCapabilitiesNode()
protected function getCapabilitiesNode(): ArrayNodeDefinition
{
$node = parent::getCapabilitiesNode();
@@ -84,9 +79,11 @@ class SauceLabsFactory extends Selenium2Factory
->booleanNode('disable-popup-handler')->end()
->end()
->validate()
->ifTrue(function ($v) {return empty($v['custom-data']);})
->then(function ($v) {
unset ($v['custom-data']);
->ifTrue(function (mixed $v): bool {return !is_array($v) || empty($v['custom-data']); })
->then(function (mixed $v): mixed {
if (is_array($v)) {
unset($v['custom-data']);
}
return $v;
})