PHPackages                             friends-of-behat/variadic-extension - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. friends-of-behat/variadic-extension

ActiveLibrary[Testing &amp; Quality](/categories/testing)

friends-of-behat/variadic-extension
===================================

Variadic support for behat context arguments

v1.7.0(3mo ago)2276.4M↓28.7%820MITGherkinPHP ^8.1CI passing

Since Aug 25Pushed 3mo ago4 watchersCompare

[ Source](https://github.com/FriendsOfBehat/VariadicExtension)[ Packagist](https://packagist.org/packages/friends-of-behat/variadic-extension)[ RSS](/packages/friends-of-behat-variadic-extension/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (9)Dependencies (6)Versions (10)Used By (20)

Variadic Extension [![License](https://camo.githubusercontent.com/f80717ae3767971038a92af0ee17d45fb5cac9d5caff1043dcc92da35491497e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f667269656e64732d6f662d62656861742f76617269616469632d657874656e73696f6e2e737667)](https://packagist.org/packages/friends-of-behat/variadic-extension) [![Version](https://camo.githubusercontent.com/a67e284ea82d3558ddf67a3233cf1f97bb1a61f4214d7fd3c7c8a6195bae030a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f667269656e64732d6f662d62656861742f76617269616469632d657874656e73696f6e2e737667)](https://packagist.org/packages/friends-of-behat/variadic-extension) [![Build](https://github.com/FriendsOfBehat/VariadicExtension/actions/workflows/build.yml/badge.svg)](https://github.com/FriendsOfBehat/VariadicExtension/actions/workflows/build.yml) [![Scrutinizer Quality Score](https://camo.githubusercontent.com/85947f570df200351979635cf058722759d63418e31860be4e8a528b695387a4/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f467269656e64734f6642656861742f5661726961646963457874656e73696f6e2e737667)](https://scrutinizer-ci.com/g/FriendsOfBehat/VariadicExtension/)
======================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#variadic-extension----)

Adds variadic arguments support to Behat steps definitions.

The why
-------

[](#the-why)

In Behat, if you want a step definition to accept different numbers of arguments, you normally have to define separate methods for each variation. This quickly becomes repetitive and hard to maintain as the number of argument combinations grows.

This extension solves that by letting you use PHP's variadic syntax (`...$args`) in your step definitions. A single method can capture many argument variations, keeping your context classes clean and concise.

Usage
-----

[](#usage)

1. Install it:

    ```
    $ composer require friends-of-behat/variadic-extension --dev
    ```
2. Enable it in your Behat configuration:

    ```
    # behat.yml
    default:
        # ...
        extensions:
            FriendsOfBehat\VariadicExtension: ~
    ```

    or if you use a PHP-based configuration:

    ```
    # behat.php
    use Behat\Config\Config;
    use Behat\Config\Extension;
    use Behat\Config\Profile;
    use FriendsOfBehat\VariadicExtension\ServiceContainer\VariadicExtension;

    return (new Config())
        ->withProfile(
            (new Profile('default'))
                ->withExtension(new Extension(VariadicExtension::class))
        );
    ```
3. You can use variadic arguments in steps definitions!

    ```
    /**
     * @Given the store has( also) :firstProductName and :secondProductName products
     * @Given the store has( also) :firstProductName, :secondProductName and :thirdProductName products
     * @Given the store has( also) :firstProductName, :secondProductName, :thirdProductName and :fourthProductName products
     */
    public function theStoreHasProducts(...$productsNames)
    {
        foreach ($productsNames as $productName) {
            $this->saveProduct($this->createProduct($productName));
        }
    }

    /**
     * @Given /^(this channel) has "([^"]+)" and "([^"]+)" products$/
     * @Given /^(this channel) has "([^"]+)", "([^"]+)" and "([^"]+)" products$/
     * @Given /^(this channel) has "([^"]+)", "([^"]+)", "([^"]+)" and "([^"]+)" products$/
     */
    public function thisChannelHasProducts(ChannelInterface $channel, ...$productsNames)
    {
        foreach ($productsNames as $productName) {
            $product = $this->createProduct($productName, 0, $channel);

            $this->saveProduct($product);
        }
    }
    ```

###  Health Score

68

—

FairBetter than 99% of packages

Maintenance81

Actively maintained with recent releases

Popularity60

Solid adoption and visibility

Community42

Growing community involvement

Maturity78

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~437 days

Recently: every ~557 days

Total

9

Last Release

103d ago

Major Versions

v0.1.0 → v1.0.02017-07-10

PHP version history (4 changes)v0.1.0PHP ^5.6|^7.0

v1.0.0PHP ^7.1

v1.4.0PHP ^7.4 || ^8.0

v1.6.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/75c5d927b0434111db9720dd78af8c83385cf28bb9aeafd031ba8cb0c4ffc558?d=identicon)[Stof](/maintainers/Stof)

![](https://www.gravatar.com/avatar/ddce56b3ed9857e5c4a25511e5925b793a1f04bd5fb8f19f42932a0b6dba914f?d=identicon)[pamil](/maintainers/pamil)

![](https://www.gravatar.com/avatar/71d7213c43a9c1d5cf9c3db5afd36687d92e51f9a5d3864a8f662b741a4ec45b?d=identicon)[lchrusciel](/maintainers/lchrusciel)

---

Top Contributors

[![pamil](https://avatars.githubusercontent.com/u/1897953?v=4)](https://github.com/pamil "pamil (46 commits)")[![lchrusciel](https://avatars.githubusercontent.com/u/6213903?v=4)](https://github.com/lchrusciel "lchrusciel (35 commits)")[![loic425](https://avatars.githubusercontent.com/u/8329789?v=4)](https://github.com/loic425 "loic425 (6 commits)")[![emodric](https://avatars.githubusercontent.com/u/362286?v=4)](https://github.com/emodric "emodric (4 commits)")[![NoResponseMate](https://avatars.githubusercontent.com/u/9448101?v=4)](https://github.com/NoResponseMate "NoResponseMate (4 commits)")

---

Tags

behatbehat-extensionphpvariadic-arguments

### Embed Badge

![Health badge](/badges/friends-of-behat-variadic-extension/health.svg)

```
[![Health](https://phpackages.com/badges/friends-of-behat-variadic-extension/health.svg)](https://phpackages.com/packages/friends-of-behat-variadic-extension)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
