- Replace all local-variable @var annotations with proper type guards:
- MinkExtension configure closure: build inner array directly
($sessions[$driverType] = [$driverType => ...]) to avoid mixed offset access
- MinkExtension loadSessions: add is_array($session) guard inside foreach
so PHPStan narrows $session from mixed to array before key() call
- DriverFactory::buildDriver @param broadened from array<string, mixed>
to array<mixed> — is_array() only narrows to array<mixed> (key type
unknown), so array<string, mixed> was unreachable at the call site
- MinkAwareInitializer: move @var from inside constructor parameter list
to a proper @param on the method docblock
- SessionsListenerSpec: replace 'goutte' (deleted driver) with
'browserkit_http' as the example default session name
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
66 lines
2.1 KiB
PHP
66 lines
2.1 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Behat MinkExtension.
|
|
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Behat\MinkExtension\ServiceContainer\Driver;
|
|
|
|
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
|
|
use Symfony\Component\DependencyInjection\Definition;
|
|
|
|
class SahiFactory implements DriverFactory
|
|
{
|
|
public function getDriverName(): string
|
|
{
|
|
return 'sahi';
|
|
}
|
|
|
|
public function supportsJavascript(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public function configure(ArrayNodeDefinition $builder): void
|
|
{
|
|
$builder
|
|
->children()
|
|
->scalarNode('sid')->defaultNull()->end()
|
|
->scalarNode('host')->defaultValue('localhost')->end()
|
|
->scalarNode('port')->defaultValue(9999)->end()
|
|
->scalarNode('browser')->defaultNull()->end()
|
|
->scalarNode('limit')->defaultValue(600)->end()
|
|
->end()
|
|
;
|
|
}
|
|
|
|
/**
|
|
* @param array<mixed> $config
|
|
*/
|
|
public function buildDriver(array $config): Definition
|
|
{
|
|
trigger_deprecation('friends-of-behat/mink-extension', '2.8.0', 'Configuration for the "sahi" driver is deprecated, since the client implementation has been abandoned. Support for it will be removed in the next major version of this extension.');
|
|
|
|
if (!class_exists('Behat\Mink\Driver\SahiDriver')) {
|
|
throw new \RuntimeException('Install MinkSahiDriver in order to use sahi driver.');
|
|
}
|
|
|
|
return new Definition('Behat\Mink\Driver\SahiDriver', [
|
|
'%mink.browser_name%',
|
|
new Definition('Behat\SahiClient\Client', [
|
|
new Definition('Behat\SahiClient\Connection', [
|
|
$config['sid'],
|
|
$config['host'],
|
|
$config['port'],
|
|
$config['browser'],
|
|
$config['limit'],
|
|
]),
|
|
]),
|
|
]);
|
|
}
|
|
}
|