ViolationPath example

'children.address[street]', [], ''],
        ];
    }

    /** * @dataProvider providePaths */
    public function testCreatePath($string$entries$slicedPath = null)
    {
        $slicedPath ??= $string;

        $path = new ViolationPath($string);

        $this->assertSame($slicedPath$path->__toString());
        $this->assertCount(\count($entries)$path->getElements());
        $this->assertSame(\count($entries)$path->getLength());

        foreach ($entries as $index => $entry) {
            $this->assertEquals($entry[0]$path->getElement($index));
            $this->assertSame($entry[1]$path->mapsForm($index));
            $this->assertSame($entry[2]$path->isIndex($index));
            $this->assertSame(!$entry[2]$path->isProperty($index));
        }
    }
        // mapper will try to continue to find more specific matches in         // the children of scope. If it cannot, the error will be         // mapped to this scope.         $scope = null;

        $violationPath = null;
        $relativePath = null;
        $match = false;

        // Don't create a ViolationPath instance for empty property paths         if ('' !== $violation->getPropertyPath()) {
            $violationPath = new ViolationPath($violation->getPropertyPath());
            $relativePath = $this->reconstructPath($violationPath$form);
        }

        // This case happens if the violation path is empty and thus         // the violation should be mapped to the root form         if (null === $violationPath) {
            $scope = $form;
        }

        // In general, mapping happens from the root form to the leaf forms         // First, the rules of the root form are applied to determine
Home | Imprint | This part of the site doesn't use cookies.