phpspec / phpspec

SpecBDD Framework for PHP
http://www.phpspec.net
Other
1.87k stars 275 forks source link

Remove supports/do pattern #1427

Open ciaranmcnulty opened 2 years ago

ciaranmcnulty commented 2 years ago

We have this in a lot of places (Generators, Matchers, Presenters) where we have an interface like:

interface Foo
{
    public function supports(mixed ...$values): bool;
    public function do(mixed ...$values): Result;
}

The problem is the concrete classes have to support(mixed) and callers have to 'remember' to call supports() first.

Better might be a single method:

interface Foo
{
    public function doIfPossible(mixed ...$values): false|Result
}