setIgnoreExtraKeys example

$this->prototype->parent = $node;
            $node->setPrototype($this->prototype->getNode());
        }

        $node->setAllowNewKeys($this->allowNewKeys);
        $node->addEquivalentValue(null, $this->nullEquivalent);
        $node->addEquivalentValue(true, $this->trueEquivalent);
        $node->addEquivalentValue(false, $this->falseEquivalent);
        $node->setPerformDeepMerging($this->performDeepMerging);
        $node->setRequired($this->required);
        $node->setIgnoreExtraKeys($this->ignoreExtraKeys, $this->removeExtraKeys);
        $node->setNormalizeKeys($this->normalizeKeys);

        if ($this->deprecation) {
            $node->setDeprecated($this->deprecation['package']$this->deprecation['version']$this->deprecation['message']);
        }

        if (isset($this->normalization)) {
            $node->setNormalizationClosures($this->normalization->before);
            $node->setNormalizedTypes($this->normalization->declaredTypes);
            $node->setXmlRemappings($this->normalization->remappings);
        }

        
/** * @dataProvider ignoreAndRemoveMatrixProvider */
    public function testIgnoreAndRemoveBehaviors(bool $ignore, bool $remove, array|\Exception $expected, string $message = '')
    {
        if ($expected instanceof \Exception) {
            $this->expectException($expected::class);
            $this->expectExceptionMessage($expected->getMessage());
        }
        $node = new ArrayNode('root');
        $node->setIgnoreExtraKeys($ignore$remove);
        $result = $node->normalize(['foo' => 'bar']);
        $this->assertSame($expected$result$message);
    }

    /** * @dataProvider getPreNormalizationTests */
    public function testPreNormalize(array $denormalized, array $normalized)
    {
        $node = new ArrayNode('foo');

        
Home | Imprint | This part of the site doesn't use cookies.