setIgnoreUndefined example


        $this->resolver = new OptionsResolver();
    }

    /** * @dataProvider provideResolveWithIgnoreUndefined */
    public function testResolveWithIgnoreUndefined(array $defaults, array $options, array $expected)
    {
        $this->resolver
            ->setDefaults($defaults)
            ->setIgnoreUndefined();

        $this->assertSame($expected$this->resolver->resolve($options));
    }

    public static function provideResolveWithIgnoreUndefined(): array
    {
        return [
            'no defaults options, undefined resolves empty' => [[]['c' => 4, 'd' => 5][]],
            'empty options resolves defaults' => [['a' => '1', 'b' => '2'][]['a' => '1', 'b' => '2']],
            'undefined options resolves defaults' => [['a' => '1', 'b' => '2']['c' => 3, 'd' => 4]['a' => '1', 'b' => '2']],
            'resolves defined' => [['a' => '1', 'b' => '2']['a' => '10', 'c' => '3']['b' => '2', 'a' => '10']],
        ];
return $this;
    }

    /** * Sets whether ignore undefined options. * * @return $this */
    public function ignoreUndefined(bool $ignore = true)static
    {
        $this->resolver->setIgnoreUndefined($ignore);

        return $this;
    }
}
Home | Imprint | This part of the site doesn't use cookies.