• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

wol-soft / php-json-schema-model-generator-production / 29520360842

16 Jul 2026 05:32PM UTC coverage: 43.546% (+22.0%) from 21.548%
29520360842

Pull #19

github

claude
Add a data-instance JSON pointer to ValidationException

Addresses the "full property path" request from issue #131: alongside the
existing getJsonPointer() (which points into the schema), every
ValidationException now exposes getInstancePointer() — an RFC 6901 pointer
into the data that was validated (e.g. "/goals/0/kind").

Resolution is lazy, via a parent-chain set up by setInstancePointerParent():
each wrapping exception (InvalidItemException, InvalidTupleException,
InvalidAdditionalPropertiesException, InvalidPatternPropertiesException,
NestedObjectException, InvalidComposedValueException, ConditionalException)
links the exceptions it collects to itself as exceptions bubble up from the
point of failure to the root. Resolving lazily (rather than eagerly
concatenating strings at each level) is what makes arbitrarily deep nesting
work correctly — composition inside an array item inside another array, for
example — since a wrapper added after a child was constructed is still
picked up when the pointer is finally read.

Two wrinkles handled along the way:
- Composition/conditional branches validate the same value at the same
  position as their parent, so they link to it without replacing their own
  segment (they contribute nothing themselves); array/tuple items and
  additional/pattern properties instead replace their child's segment,
  since those children were constructed with a placeholder propertyName
  shared by every instance of the collection.
- InvalidAdditionalPropertiesException and InvalidPatternPropertiesException
  themselves run as base validators with no access to the property name
  their parent used to reach them, so they fall back to the generated class
  name for message text only; that placeholder is suppressed from their own
  instance pointer segment so it doesn't leak into the resolved path.
Pull Request #19: Re-indent nested composition/conditional messages under their own bullet

57 of 59 new or added lines in 8 files covered. (96.61%)

1 existing line in 1 file now uncovered.

361 of 829 relevant lines covered (43.55%)

1.38 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

78.95
/src/Exception/Object/NestedObjectException.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace PHPModelGenerator\Exception\Object;
6

7
use Exception;
8
use PHPModelGenerator\Exception\ErrorRegistryExceptionInterface;
9
use PHPModelGenerator\Exception\ValidationException;
10

11
/**
12
 * Class NotAllowedAdditionalPropertiesException
13
 *
14
 * @package PHPModelGenerator\Exception\Object
15
 */
16
class NestedObjectException extends ValidationException
17
{
18
    /**
19
     * NotAllowedAdditionalPropertiesException constructor.
20
     *
21
     * @param $providedValue
22
     */
23
    public function __construct(
2✔
24
        $providedValue,
25
        string $propertyName,
26
        string $jsonPointer,
27
        private readonly Exception $nestedException
28
    ) {
29
        if ($this->nestedException instanceof ErrorRegistryExceptionInterface) {
2✔
NEW
30
            foreach ($this->nestedException->getErrors() as $error) {
×
NEW
31
                $error->setInstancePointerParent($this);
×
32
            }
33
        } elseif ($this->nestedException instanceof ValidationException) {
2✔
34
            $this->nestedException->setInstancePointerParent($this);
2✔
35
        }
36

37
        parent::__construct(
2✔
38
            "Invalid nested object for property $propertyName:\n  - " .
2✔
39
                preg_replace(
2✔
40
                    "/\n([^\s])/m",
2✔
41
                    "\n  - $1",
2✔
42
                    (string) preg_replace("/\n\s/m", "\n     ", $this->nestedException->getMessage())
2✔
43
                ),
2✔
44
            $propertyName,
2✔
45
            $providedValue,
2✔
46
            $jsonPointer
2✔
47
        );
2✔
48
    }
49

50
    public function getNestedException(): Exception
×
51
    {
52
        return $this->nestedException;
×
53
    }
54
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc