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

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

31 Oct 2026 04:56PM UTC coverage: 38.961% (+1.0%) from 37.962%
41222065034

Pull #23

github

claude
Fix off-by-one in the instance pointer of nested tuple errors

InvalidTupleException is keyed by the 1-based tuple position (the message
reports the first element as "invalid tuple #1"), but passed that key
unchanged to setInstancePointerParent(). A JSON pointer addresses the
0-based array index, so every nested error pointed at the following
element: for the value [["a", "x"], "b"] of the tuple "pair" the error at
the second item of the first tuple was reported at /pair/1/2 instead of
/pair/0/1.

The pointer now uses position - 1. The message numbering and the keys
returned by getInvalidTuples() are unchanged. The key contracts of
InvalidTupleException (1-based) and InvalidItemException (0-based) are
documented, and the previous tuple pointer test is corrected: it used the
key 0, which a tuple exception is never given.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U1R7TJejqtBJGe1uPS2p1L
Pull Request #23: Fix off-by-one in the instance pointer of nested tuple errors

10 of 15 new or added lines in 4 files covered. (66.67%)

15 existing lines in 4 files now uncovered.

390 of 1001 relevant lines covered (38.96%)

2.12 hits per line

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

88.89
/src/Exception/Object/InvalidAdditionalPropertiesException.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace PHPModelGenerator\Exception\Object;
6

7
use PHPModelGenerator\Exception\MessageFormatter;
8
use PHPModelGenerator\Exception\ValidationException;
9

10
/**
11
 * Class InvalidAdditionalPropertiesException
12
 *
13
 * @package PHPModelGenerator\Exception\Object
14
 */
15
class InvalidAdditionalPropertiesException extends ValidationException
16
{
17
    protected const MAIN_MESSAGE = "Provided JSON for '%s' contains invalid additional properties";
18
    protected const TYPE = 'additional property';
19

20
    /**
21
     * InvalidAdditionalPropertiesException constructor.
22
     *
23
     * @param $providedValue
24
     * @param ValidationException[][] $nestedExceptions
25
     */
26
    public function __construct($providedValue, string $propertyName, string $jsonPointer, protected $nestedExceptions)
1 ✔
27
    {
28
        foreach ($this->nestedExceptions as $nestedPropertyName => $exceptions) {
1 ✔
29
            foreach ($exceptions as $exception) {
1 ✔
30
                $exception->setInstancePointerParent($this, $nestedPropertyName);
1 ✔
31
            }
32
        }
33

34
        parent::__construct($this->getErrorMessage($propertyName), $propertyName, $providedValue, $jsonPointer);
1 ✔
35

36
        // This exception validates the enclosing object's own additionalProperties/items
37
        // constraint. $propertyName is the generated class name (a base validator has no access
38
        // to the property name its parent used to reach this object) — a message-text label only,
39
        // never a real instance-path segment.
40
        $this->suppressOwnInstancePointerSegment();
1 ✔
41
    }
42

43
    /**
44
     * Get a list of nested exceptions containing all failed validations indexed by the property name
45
     *
46
     * @return ValidationException[][]
47
     */
UNCOV
48
    public function getNestedExceptions(): array
×
49
    {
50
        return $this->nestedExceptions;
×
51
    }
52

53
    protected function getErrorMessage(string $propertyName): string
1 ✔
54
    {
55
        $output = '';
1 ✔
56
        foreach ($this->nestedExceptions as $nestedPropertyName => $exceptions) {
1 ✔
57
            $output .= sprintf(
1 ✔
58
                "\n  - invalid %s '%s'\n    * %s",
1 ✔
59
                static::TYPE,
1 ✔
60
                $nestedPropertyName,
1 ✔
61
                MessageFormatter::bulletList($exceptions),
1 ✔
62
            );
1 ✔
63
        }
64

65
        return sprintf(static::MAIN_MESSAGE, $propertyName) . $output;
1 ✔
66
    }
67
}
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