From 47a9d45cd13fc286277348168d0da86ba77ae7c6 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Fri, 12 Jun 2026 17:43:01 +0200 Subject: [PATCH] Add PHP CS Fixer and PHPStan max to CI; remove abandoned GoutteFactory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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) --- .github/workflows/test.yaml | 6 + .gitignore | 1 + .php-cs-fixer.dist.php | 19 +++ composer.json | 7 +- phpstan.neon | 5 + .../Initializer/MinkAwareInitializerSpec.php | 12 +- .../Listener/SessionsListenerSpec.php | 60 +++---- .../Driver/AppiumFactorySpec.php | 6 +- .../Driver/BrowserKitFactorySpec.php | 8 +- .../Driver/BrowserStackFactorySpec.php | 7 +- .../Driver/GoutteFactorySpec.php | 23 --- .../Driver/SahiFactorySpec.php | 6 +- .../Driver/SauceLabsFactorySpec.php | 6 +- .../Driver/Selenium2FactorySpec.php | 6 +- .../Driver/SeleniumFactorySpec.php | 6 +- .../Driver/WebdriverClassicFactorySpec.php | 2 +- .../Driver/ZombieFactorySpec.php | 6 +- .../ServiceContainer/MinkExtensionSpec.php | 4 +- .../Initializer/MinkAwareInitializer.php | 2 +- .../Context/MinkAwareContext.php | 6 +- .../MinkExtension/Context/MinkContext.php | 117 +++++++------ .../MinkExtension/Context/RawMinkContext.php | 70 +++----- .../Listener/FailureShowListener.php | 39 +++-- .../Listener/SessionsListener.php | 83 ++++------ .../ServiceContainer/Driver/AppiumFactory.php | 24 +-- .../Driver/BrowserKitFactory.php | 23 +-- .../Driver/BrowserStackFactory.php | 19 +-- .../ServiceContainer/Driver/DriverFactory.php | 35 +--- .../Driver/EnvironmentCapabilities.php | 13 +- .../ServiceContainer/Driver/GoutteFactory.php | 156 ------------------ .../ServiceContainer/Driver/SahiFactory.php | 35 ++-- .../Driver/SauceLabsFactory.php | 29 ++-- .../Driver/Selenium2Factory.php | 56 +++---- .../Driver/Selenium4Factory.php | 32 ++-- .../Driver/SeleniumFactory.php | 31 ++-- .../Driver/WebdriverClassicFactory.php | 18 +- .../ServiceContainer/Driver/ZombieFactory.php | 31 ++-- .../ServiceContainer/MinkExtension.php | 147 ++++++++--------- 38 files changed, 436 insertions(+), 720 deletions(-) create mode 100644 .php-cs-fixer.dist.php create mode 100644 phpstan.neon delete mode 100644 spec/Behat/MinkExtension/ServiceContainer/Driver/GoutteFactorySpec.php delete mode 100644 src/Behat/MinkExtension/ServiceContainer/Driver/GoutteFactory.php diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index fd2664f..6b3a2a7 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -67,6 +67,12 @@ jobs: - name: Install dependencies run: composer install --prefer-dist --no-progress + - name: CS Fixer + run: vendor/bin/php-cs-fixer fix --dry-run + + - name: PHPStan + run: vendor/bin/phpstan analyse --memory-limit=512M + - name: PHPSpec run: vendor/bin/phpspec run -f pretty diff --git a/.gitignore b/.gitignore index e389710..c0fe44b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ *.phar composer.lock vendor +.php-cs-fixer.cache diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 0000000..a196623 --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,19 @@ +in(__DIR__.'/src') + ->in(__DIR__.'/spec') +; + +return (new Config()) + ->setRules([ + '@Symfony' => true, + 'phpdoc_to_comment' => ['ignored_tags' => ['psalm-suppress', 'phpstan-ignore']], + ]) + ->setFinder($finder) +; diff --git a/composer.json b/composer.json index 9aec045..6744bfd 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,9 @@ "behat/mink-browserkit-driver": "^2.0", "phpspec/phpspec": "^8.0", "symfony/browser-kit": "^7.4 || ^8.0", - "symfony/http-client": "^7.4 || ^8.0" + "symfony/http-client": "^7.4 || ^8.0", + "friendsofphp/php-cs-fixer": "^3.75", + "phpstan/phpstan": "^2.0" }, "replace": { "behat/mink-extension": "self.version" @@ -46,6 +48,9 @@ } }, "scripts": { + "cs": "vendor/bin/php-cs-fixer fix", + "cs-check": "vendor/bin/php-cs-fixer fix --dry-run", + "phpstan": "vendor/bin/phpstan analyse --memory-limit=512M", "test": [ "vendor/bin/phpspec run -f pretty", "vendor/bin/behat --config behat.dist.php -fprogress --strict" diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..b74b10f --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,5 @@ +parameters: + level: max + paths: + - src + treatPhpDocTypesAsCertain: false diff --git a/spec/Behat/MinkExtension/Context/Initializer/MinkAwareInitializerSpec.php b/spec/Behat/MinkExtension/Context/Initializer/MinkAwareInitializerSpec.php index 84b208a..9c50c1c 100644 --- a/spec/Behat/MinkExtension/Context/Initializer/MinkAwareInitializerSpec.php +++ b/spec/Behat/MinkExtension/Context/Initializer/MinkAwareInitializerSpec.php @@ -9,25 +9,25 @@ use PhpSpec\ObjectBehavior; class MinkAwareInitializerSpec extends ObjectBehavior { - function let(Mink $mink) + public function let(Mink $mink) { - $this->beConstructedWith($mink, array('base_url' => 'foo')); + $this->beConstructedWith($mink, ['base_url' => 'foo']); } - function it_is_a_context_initializer() + public function it_is_a_context_initializer() { $this->shouldHaveType('Behat\Behat\Context\Initializer\ContextInitializer'); } - function it_does_nothing_for_basic_contexts(Context $context) + public function it_does_nothing_for_basic_contexts(Context $context) { $this->initializeContext($context); } - function it_injects_mink_and_parameters_in_mink_aware_contexts(MinkAwareContext $context, $mink) + public function it_injects_mink_and_parameters_in_mink_aware_contexts(MinkAwareContext $context, $mink) { $context->setMink($mink)->shouldBeCalled(); - $context->setMinkParameters(array('base_url' => 'foo'))->shouldBeCalled(); + $context->setMinkParameters(['base_url' => 'foo'])->shouldBeCalled(); $this->initializeContext($context); } } diff --git a/spec/Behat/MinkExtension/Listener/SessionsListenerSpec.php b/spec/Behat/MinkExtension/Listener/SessionsListenerSpec.php index be72e21..07bf4dd 100644 --- a/spec/Behat/MinkExtension/Listener/SessionsListenerSpec.php +++ b/spec/Behat/MinkExtension/Listener/SessionsListenerSpec.php @@ -13,9 +13,9 @@ use PhpSpec\ObjectBehavior; class SessionsListenerSpec extends ObjectBehavior { - function let(Mink $mink, ScenarioTested $event, FeatureNode $feature, ScenarioNode $scenario, Suite $suite) + public function let(Mink $mink, ScenarioTested $event, FeatureNode $feature, ScenarioNode $scenario, Suite $suite) { - $this->beConstructedWith($mink, 'goutte', 'selenium2', array('selenium2', 'sahi')); + $this->beConstructedWith($mink, 'goutte', 'selenium2', ['selenium2', 'sahi']); $event->getSuite()->willReturn($suite); $event->getFeature()->willReturn($feature); @@ -25,17 +25,17 @@ class SessionsListenerSpec extends ObjectBehavior $suite->getName()->willReturn('default'); $feature->hasTag('insulated')->willReturn(false); - $feature->getTags()->willReturn(array()); + $feature->getTags()->willReturn([]); $scenario->hasTag('insulated')->willReturn(false); - $scenario->getTags()->willReturn(array()); + $scenario->getTags()->willReturn([]); } - function it_is_an_event_subscriber() + public function it_is_an_event_subscriber() { $this->shouldHaveType('Symfony\Component\EventDispatcher\EventSubscriberInterface'); } - function it_resets_the_default_session_before_scenarios($event, $mink) + public function it_resets_the_default_session_before_scenarios($event, $mink) { $mink->resetSessions()->shouldBeCalled(); $mink->setDefaultSessionName('goutte')->shouldBeCalled(); @@ -43,7 +43,7 @@ class SessionsListenerSpec extends ObjectBehavior $this->prepareDefaultMinkSession($event); } - function it_supports_changing_the_default_session_per_suite($event, $mink, $suite) + public function it_supports_changing_the_default_session_per_suite($event, $mink, $suite) { $suite->hasSetting('mink_session')->willReturn(true); $suite->getSetting('mink_session')->willReturn('test'); @@ -54,100 +54,100 @@ class SessionsListenerSpec extends ObjectBehavior $this->prepareDefaultMinkSession($event); } - function it_fails_for_non_string_default_suite_session($event, $suite) + public function it_fails_for_non_string_default_suite_session($event, $suite) { $suite->hasSetting('mink_session')->willReturn(true); - $suite->getSetting('mink_session')->willReturn(array()); + $suite->getSetting('mink_session')->willReturn([]); $this->shouldThrow(new SuiteConfigurationException('`mink_session` setting of the "default" suite is expected to be a string, array given.', 'default')) ->duringPrepareDefaultMinkSession($event); } - function it_switches_to_the_javascript_session_for_tagged_scenarios($event, $mink, $scenario, $suite) + public function it_switches_to_the_javascript_session_for_tagged_scenarios($event, $mink, $scenario, $suite) { $suite->hasSetting('mink_javascript_session')->willReturn(false); - $scenario->getTags()->willReturn(array('javascript')); + $scenario->getTags()->willReturn(['javascript']); $mink->resetSessions()->shouldBeCalled(); $mink->setDefaultSessionName('selenium2')->shouldBeCalled(); $this->prepareDefaultMinkSession($event); } - function it_switches_to_the_javascript_session_for_tagged_features($event, $mink, $feature, $suite) + public function it_switches_to_the_javascript_session_for_tagged_features($event, $mink, $feature, $suite) { $suite->hasSetting('mink_javascript_session')->willReturn(false); - $feature->getTags()->willReturn(array('javascript')); + $feature->getTags()->willReturn(['javascript']); $mink->resetSessions()->shouldBeCalled(); $mink->setDefaultSessionName('selenium2')->shouldBeCalled(); $this->prepareDefaultMinkSession($event); } - function it_supports_changing_the_default_javascript_session_per_suite($event, $mink, $scenario, $suite) + public function it_supports_changing_the_default_javascript_session_per_suite($event, $mink, $scenario, $suite) { $suite->hasSetting('mink_javascript_session')->willReturn(true); $suite->getSetting('mink_javascript_session')->willReturn('sahi'); - $scenario->getTags()->willReturn(array('javascript')); + $scenario->getTags()->willReturn(['javascript']); $mink->resetSessions()->shouldBeCalled(); $mink->setDefaultSessionName('sahi')->shouldBeCalled(); $this->prepareDefaultMinkSession($event); } - function it_fails_for_non_string_javascript_suite_session($event, $scenario, $suite) + public function it_fails_for_non_string_javascript_suite_session($event, $scenario, $suite) { $suite->hasSetting('mink_javascript_session')->willReturn(true); - $suite->getSetting('mink_javascript_session')->willReturn(array()); + $suite->getSetting('mink_javascript_session')->willReturn([]); - $scenario->getTags()->willReturn(array('javascript')); + $scenario->getTags()->willReturn(['javascript']); $this->shouldThrow(new SuiteConfigurationException('`mink_javascript_session` setting of the "default" suite is expected to be a string, array given.', 'default')) ->duringPrepareDefaultMinkSession($event); } - function it_fails_for_invalid_javascript_suite_session($event, $scenario, $suite) + public function it_fails_for_invalid_javascript_suite_session($event, $scenario, $suite) { $suite->hasSetting('mink_javascript_session')->willReturn(true); $suite->getSetting('mink_javascript_session')->willReturn('test'); - $scenario->getTags()->willReturn(array('javascript')); + $scenario->getTags()->willReturn(['javascript']); $this->shouldThrow(new SuiteConfigurationException('`mink_javascript_session` setting of the "default" suite is not a javascript session. test given but expected one of selenium2, sahi.', 'default')) ->duringPrepareDefaultMinkSession($event); } - function it_fails_when_the_javascript_session_is_used_but_not_defined($event, $mink, $feature, $suite) + public function it_fails_when_the_javascript_session_is_used_but_not_defined($event, $mink, $feature, $suite) { $suite->hasSetting('mink_javascript_session')->willReturn(false); $this->beConstructedWith($mink, 'goutte', null); - $feature->getTags()->willReturn(array('javascript')); + $feature->getTags()->willReturn(['javascript']); $this->shouldThrow(new ProcessingException('The @javascript tag cannot be used without enabling a javascript session')) ->duringPrepareDefaultMinkSession($event); } - function it_switches_to_a_named_session($event, $mink, $scenario) + public function it_switches_to_a_named_session($event, $mink, $scenario) { - $scenario->getTags()->willReturn(array('mink:test')); + $scenario->getTags()->willReturn(['mink:test']); $mink->resetSessions()->shouldBeCalled(); $mink->setDefaultSessionName('test')->shouldBeCalled(); $this->prepareDefaultMinkSession($event); } - function it_prefers_the_scenario_over_the_feature($event, $mink, $scenario, $feature, $suite) + public function it_prefers_the_scenario_over_the_feature($event, $mink, $scenario, $feature, $suite) { $suite->hasSetting('mink_javascript_session')->willReturn(false); - $scenario->getTags()->willReturn(array('mink:test')); - $feature->getTags()->willReturn(array('javascript')); + $scenario->getTags()->willReturn(['mink:test']); + $feature->getTags()->willReturn(['javascript']); $mink->resetSessions()->shouldBeCalled(); $mink->setDefaultSessionName('test')->shouldBeCalled(); $this->prepareDefaultMinkSession($event); } - function it_stops_the_sessions_for_insulated_scenarios($event, $mink, $scenario) + public function it_stops_the_sessions_for_insulated_scenarios($event, $mink, $scenario) { $scenario->hasTag('insulated')->willReturn(true); $mink->stopSessions()->shouldBeCalled(); @@ -156,7 +156,7 @@ class SessionsListenerSpec extends ObjectBehavior $this->prepareDefaultMinkSession($event); } - function it_stops_the_sessions_for_insulated_features($event, $mink, $feature) + public function it_stops_the_sessions_for_insulated_features($event, $mink, $feature) { $feature->hasTag('insulated')->willReturn(true); $mink->stopSessions()->shouldBeCalled(); @@ -165,7 +165,7 @@ class SessionsListenerSpec extends ObjectBehavior $this->prepareDefaultMinkSession($event); } - function it_stops_the_sessions_at_the_end_of_the_exercise($mink) + public function it_stops_the_sessions_at_the_end_of_the_exercise($mink) { $mink->stopSessions()->shouldBeCalled(); diff --git a/spec/Behat/MinkExtension/ServiceContainer/Driver/AppiumFactorySpec.php b/spec/Behat/MinkExtension/ServiceContainer/Driver/AppiumFactorySpec.php index bfc9bf1..4141b92 100644 --- a/spec/Behat/MinkExtension/ServiceContainer/Driver/AppiumFactorySpec.php +++ b/spec/Behat/MinkExtension/ServiceContainer/Driver/AppiumFactorySpec.php @@ -6,17 +6,17 @@ use PhpSpec\ObjectBehavior; class AppiumFactorySpec extends ObjectBehavior { - function it_is_a_driver_factory() + public function it_is_a_driver_factory() { $this->shouldHaveType('Behat\MinkExtension\ServiceContainer\Driver\DriverFactory'); } - function it_is_named_appium() + public function it_is_named_appium() { $this->getDriverName()->shouldReturn('appium'); } - function it_supports_javascript() + public function it_supports_javascript() { $this->supportsJavascript()->shouldBe(true); } diff --git a/spec/Behat/MinkExtension/ServiceContainer/Driver/BrowserKitFactorySpec.php b/spec/Behat/MinkExtension/ServiceContainer/Driver/BrowserKitFactorySpec.php index e7d8e8b..6be5ed6 100644 --- a/spec/Behat/MinkExtension/ServiceContainer/Driver/BrowserKitFactorySpec.php +++ b/spec/Behat/MinkExtension/ServiceContainer/Driver/BrowserKitFactorySpec.php @@ -2,22 +2,22 @@ namespace spec\Behat\MinkExtension\ServiceContainer\Driver; -use PhpSpec\ObjectBehavior; use Behat\MinkExtension\ServiceContainer\Driver\DriverFactory; +use PhpSpec\ObjectBehavior; class BrowserKitFactorySpec extends ObjectBehavior { - function it_is_a_driver_factory() + public function it_is_a_driver_factory() { $this->shouldHaveType(DriverFactory::class); } - function it_is_named_browserkit() + public function it_is_named_browserkit() { $this->getDriverName()->shouldReturn('browserkit_http'); } - function it_does_not_support_javascript() + public function it_does_not_support_javascript() { $this->supportsJavascript()->shouldBe(false); } diff --git a/spec/Behat/MinkExtension/ServiceContainer/Driver/BrowserStackFactorySpec.php b/spec/Behat/MinkExtension/ServiceContainer/Driver/BrowserStackFactorySpec.php index 00922e7..482c883 100644 --- a/spec/Behat/MinkExtension/ServiceContainer/Driver/BrowserStackFactorySpec.php +++ b/spec/Behat/MinkExtension/ServiceContainer/Driver/BrowserStackFactorySpec.php @@ -3,21 +3,20 @@ namespace spec\Behat\MinkExtension\ServiceContainer\Driver; use PhpSpec\ObjectBehavior; -use Prophecy\Argument; class BrowserStackFactorySpec extends ObjectBehavior { - function it_is_a_driver_factory() + public function it_is_a_driver_factory() { $this->shouldHaveType('Behat\MinkExtension\ServiceContainer\Driver\DriverFactory'); } - function it_is_named_browser_stack() + public function it_is_named_browser_stack() { $this->getDriverName()->shouldReturn('browser_stack'); } - function it_supports_javascript() + public function it_supports_javascript() { $this->supportsJavascript()->shouldBe(true); } diff --git a/spec/Behat/MinkExtension/ServiceContainer/Driver/GoutteFactorySpec.php b/spec/Behat/MinkExtension/ServiceContainer/Driver/GoutteFactorySpec.php deleted file mode 100644 index 484e6e7..0000000 --- a/spec/Behat/MinkExtension/ServiceContainer/Driver/GoutteFactorySpec.php +++ /dev/null @@ -1,23 +0,0 @@ -shouldHaveType('Behat\MinkExtension\ServiceContainer\Driver\DriverFactory'); - } - - function it_is_named_goutte() - { - $this->getDriverName()->shouldReturn('goutte'); - } - - function it_does_not_support_javascript() - { - $this->supportsJavascript()->shouldBe(false); - } -} diff --git a/spec/Behat/MinkExtension/ServiceContainer/Driver/SahiFactorySpec.php b/spec/Behat/MinkExtension/ServiceContainer/Driver/SahiFactorySpec.php index abdb7d5..4eec4cf 100644 --- a/spec/Behat/MinkExtension/ServiceContainer/Driver/SahiFactorySpec.php +++ b/spec/Behat/MinkExtension/ServiceContainer/Driver/SahiFactorySpec.php @@ -6,17 +6,17 @@ use PhpSpec\ObjectBehavior; class SahiFactorySpec extends ObjectBehavior { - function it_is_a_driver_factory() + public function it_is_a_driver_factory() { $this->shouldHaveType('Behat\MinkExtension\ServiceContainer\Driver\DriverFactory'); } - function it_is_named_sahi() + public function it_is_named_sahi() { $this->getDriverName()->shouldReturn('sahi'); } - function it_supports_javascript() + public function it_supports_javascript() { $this->supportsJavascript()->shouldBe(true); } diff --git a/spec/Behat/MinkExtension/ServiceContainer/Driver/SauceLabsFactorySpec.php b/spec/Behat/MinkExtension/ServiceContainer/Driver/SauceLabsFactorySpec.php index 21bb10c..419bc40 100644 --- a/spec/Behat/MinkExtension/ServiceContainer/Driver/SauceLabsFactorySpec.php +++ b/spec/Behat/MinkExtension/ServiceContainer/Driver/SauceLabsFactorySpec.php @@ -6,17 +6,17 @@ use PhpSpec\ObjectBehavior; class SauceLabsFactorySpec extends ObjectBehavior { - function it_is_a_driver_factory() + public function it_is_a_driver_factory() { $this->shouldHaveType('Behat\MinkExtension\ServiceContainer\Driver\DriverFactory'); } - function it_is_named_sauce_labs() + public function it_is_named_sauce_labs() { $this->getDriverName()->shouldReturn('sauce_labs'); } - function it_supports_javascript() + public function it_supports_javascript() { $this->supportsJavascript()->shouldBe(true); } diff --git a/spec/Behat/MinkExtension/ServiceContainer/Driver/Selenium2FactorySpec.php b/spec/Behat/MinkExtension/ServiceContainer/Driver/Selenium2FactorySpec.php index 5ec5c16..23b5dd7 100644 --- a/spec/Behat/MinkExtension/ServiceContainer/Driver/Selenium2FactorySpec.php +++ b/spec/Behat/MinkExtension/ServiceContainer/Driver/Selenium2FactorySpec.php @@ -6,17 +6,17 @@ use PhpSpec\ObjectBehavior; class Selenium2FactorySpec extends ObjectBehavior { - function it_is_a_driver_factory() + public function it_is_a_driver_factory() { $this->shouldHaveType('Behat\MinkExtension\ServiceContainer\Driver\DriverFactory'); } - function it_is_named_selenium2() + public function it_is_named_selenium2() { $this->getDriverName()->shouldReturn('selenium2'); } - function it_supports_javascript() + public function it_supports_javascript() { $this->supportsJavascript()->shouldBe(true); } diff --git a/spec/Behat/MinkExtension/ServiceContainer/Driver/SeleniumFactorySpec.php b/spec/Behat/MinkExtension/ServiceContainer/Driver/SeleniumFactorySpec.php index a1fb505..0be34c2 100644 --- a/spec/Behat/MinkExtension/ServiceContainer/Driver/SeleniumFactorySpec.php +++ b/spec/Behat/MinkExtension/ServiceContainer/Driver/SeleniumFactorySpec.php @@ -6,17 +6,17 @@ use PhpSpec\ObjectBehavior; class SeleniumFactorySpec extends ObjectBehavior { - function it_is_a_driver_factory() + public function it_is_a_driver_factory() { $this->shouldHaveType('Behat\MinkExtension\ServiceContainer\Driver\DriverFactory'); } - function it_is_named_selenium() + public function it_is_named_selenium() { $this->getDriverName()->shouldReturn('selenium'); } - function it_supports_javascript() + public function it_supports_javascript() { $this->supportsJavascript()->shouldBe(true); } diff --git a/spec/Behat/MinkExtension/ServiceContainer/Driver/WebdriverClassicFactorySpec.php b/spec/Behat/MinkExtension/ServiceContainer/Driver/WebdriverClassicFactorySpec.php index ddb0ca9..3f078d9 100644 --- a/spec/Behat/MinkExtension/ServiceContainer/Driver/WebdriverClassicFactorySpec.php +++ b/spec/Behat/MinkExtension/ServiceContainer/Driver/WebdriverClassicFactorySpec.php @@ -2,8 +2,8 @@ namespace spec\Behat\MinkExtension\ServiceContainer\Driver; -use PhpSpec\ObjectBehavior; use Behat\MinkExtension\ServiceContainer\Driver\DriverFactory; +use PhpSpec\ObjectBehavior; class WebdriverClassicFactorySpec extends ObjectBehavior { diff --git a/spec/Behat/MinkExtension/ServiceContainer/Driver/ZombieFactorySpec.php b/spec/Behat/MinkExtension/ServiceContainer/Driver/ZombieFactorySpec.php index f0e0445..92642c9 100644 --- a/spec/Behat/MinkExtension/ServiceContainer/Driver/ZombieFactorySpec.php +++ b/spec/Behat/MinkExtension/ServiceContainer/Driver/ZombieFactorySpec.php @@ -6,17 +6,17 @@ use PhpSpec\ObjectBehavior; class ZombieFactorySpec extends ObjectBehavior { - function it_is_a_driver_factory() + public function it_is_a_driver_factory() { $this->shouldHaveType('Behat\MinkExtension\ServiceContainer\Driver\DriverFactory'); } - function it_is_named_zombie() + public function it_is_named_zombie() { $this->getDriverName()->shouldReturn('zombie'); } - function it_supports_javascript() + public function it_supports_javascript() { $this->supportsJavascript()->shouldBe(true); } diff --git a/spec/Behat/MinkExtension/ServiceContainer/MinkExtensionSpec.php b/spec/Behat/MinkExtension/ServiceContainer/MinkExtensionSpec.php index c16533b..4e7e028 100644 --- a/spec/Behat/MinkExtension/ServiceContainer/MinkExtensionSpec.php +++ b/spec/Behat/MinkExtension/ServiceContainer/MinkExtensionSpec.php @@ -6,12 +6,12 @@ use PhpSpec\ObjectBehavior; class MinkExtensionSpec extends ObjectBehavior { - function it_is_a_testwork_extension() + public function it_is_a_testwork_extension() { $this->shouldHaveType('Behat\Testwork\ServiceContainer\Extension'); } - function it_is_named_mink() + public function it_is_named_mink() { $this->getConfigKey()->shouldReturn('mink'); } diff --git a/src/Behat/MinkExtension/Context/Initializer/MinkAwareInitializer.php b/src/Behat/MinkExtension/Context/Initializer/MinkAwareInitializer.php index 74bfa66..d9bc814 100644 --- a/src/Behat/MinkExtension/Context/Initializer/MinkAwareInitializer.php +++ b/src/Behat/MinkExtension/Context/Initializer/MinkAwareInitializer.php @@ -12,7 +12,6 @@ namespace Behat\MinkExtension\Context\Initializer; use Behat\Behat\Context\Context; use Behat\Behat\Context\Initializer\ContextInitializer; - use Behat\Mink\Mink; use Behat\MinkExtension\Context\MinkAwareContext; @@ -26,6 +25,7 @@ class MinkAwareInitializer implements ContextInitializer { public function __construct( private readonly Mink $mink, + /** @var array */ private readonly array $parameters, ) { } diff --git a/src/Behat/MinkExtension/Context/MinkAwareContext.php b/src/Behat/MinkExtension/Context/MinkAwareContext.php index 11aaa4f..816017f 100644 --- a/src/Behat/MinkExtension/Context/MinkAwareContext.php +++ b/src/Behat/MinkExtension/Context/MinkAwareContext.php @@ -25,12 +25,12 @@ interface MinkAwareContext extends Context * * @param Mink $mink Mink session manager */ - public function setMink(Mink $mink); + public function setMink(Mink $mink): void; /** * Sets parameters provided for Mink. * - * @param array $parameters + * @param array $parameters */ - public function setMinkParameters(array $parameters); + public function setMinkParameters(array $parameters): void; } diff --git a/src/Behat/MinkExtension/Context/MinkContext.php b/src/Behat/MinkExtension/Context/MinkContext.php index aa7c36d..5a1e993 100644 --- a/src/Behat/MinkExtension/Context/MinkContext.php +++ b/src/Behat/MinkExtension/Context/MinkContext.php @@ -23,45 +23,45 @@ class MinkContext extends RawMinkContext implements TranslatableContext { #[\Behat\Step\Given('/^(?:|I )am on (?:|the )homepage$/')] #[\Behat\Step\When('/^(?:|I )go to (?:|the )homepage$/')] - public function iAmOnHomepage() + public function iAmOnHomepage(): void { $this->visitPath('/'); } #[\Behat\Step\Given('/^(?:|I )am on "(?P[^"]+)"$/')] #[\Behat\Step\When('/^(?:|I )go to "(?P[^"]+)"$/')] - public function visit($page) + public function visit(string $page): void { $this->visitPath($page); } #[\Behat\Step\When('/^(?:|I )reload the page$/')] - public function reload() + public function reload(): void { $this->getSession()->reload(); } #[\Behat\Step\When('/^(?:|I )move backward one page$/')] - public function back() + public function back(): void { $this->getSession()->back(); } #[\Behat\Step\When('/^(?:|I )move forward one page$/')] - public function forward() + public function forward(): void { $this->getSession()->forward(); } #[\Behat\Step\When('/^(?:|I )press "(?P