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

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

24 Jul 2026 02:22AM UTC coverage: 37.186% (+19.9%) from 17.248%
30094849029

push

github

wol-soft
Sync 2019-09-specific exception wording to the quoting/no-trailing-period convention

The draft-2019-09 keyword exceptions (unevaluatedItems, unevaluatedProperties,
minContains/maxContains) were added on this branch before master's wording pass
landed here via merge, so they still had unquoted property names, an unquoted
list of unevaluated property names, and a trailing period on a bulleted-list
header. Also replace InvalidUnevaluatedItemsException's hand-rolled bullet-list
joining with MessageFormatter::bulletList(), which already does the same thing,
and align RegularPropertyAsUnevaluatedPropertyException's wording (quoting,
"Could not" instead of "Couldn't") with its sibling
RegularPropertyAsAdditionalPropertyException.

0 of 13 new or added lines in 6 files covered. (0.0%)

34 existing lines in 10 files now uncovered.

370 of 995 relevant lines covered (37.19%)

1.5 hits per line

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

71.43
/src/Exception/ValidationException.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace PHPModelGenerator\Exception;
6

7
use PHPModelGenerator\Attributes\JsonPointer;
8
use Throwable;
9

10
/**
11
 * Class ValidationException
12
 *
13
 * @package PHPModelGeneratorException
14
 */
15
abstract class ValidationException extends JSONModelValidationException
16
{
17
    private string $instancePointerSegment;
18
    private ?ValidationException $instancePointerParent = null;
19

20
    /**
21
     * ValidationException constructor.
22
     *
23
     * @param int $code
24
     */
25
    public function __construct(
24✔
26
        string $message,
27
        protected string $propertyName,
28
        protected mixed $providedValue,
29
        protected string $jsonPointer,
30
        $code = 0,
31
        ?Throwable $previous = null
32
    ) {
33
        parent::__construct($message, $code, $previous);
24✔
34

35
        $this->instancePointerSegment = '/' . self::escapeInstancePointerSegment($propertyName);
24✔
36
    }
37

UNCOV
38
    public function getPropertyName(): string
×
39
    {
UNCOV
40
        return $this->propertyName;
×
41
    }
42

43
    /**
44
     * @return mixed
45
     */
UNCOV
46
    public function getProvidedValue()
×
47
    {
UNCOV
48
        return $this->providedValue;
×
49
    }
50

51
    /**
52
     * The JSON pointer to the schema location of the constraint that rejected the value.
53
     */
UNCOV
54
    public function getJsonPointer(): JsonPointer
×
55
    {
UNCOV
56
        return new JsonPointer($this->jsonPointer);
×
57
    }
58

59
    /**
60
     * The JSON pointer (RFC 6901) to this value's location within the validated data instance
61
     * (e.g. "/goals/0/kind"), as opposed to getJsonPointer() which points into the schema.
62
     *
63
     * Resolved lazily by walking the parent chain set up via setInstancePointerParent(), so a
64
     * wrapper added after this exception was constructed (e.g. an array item later found to be
65
     * nested inside another array) is still reflected correctly.
66
     */
67
    public function getInstancePointer(): JsonPointer
9✔
68
    {
69
        return new JsonPointer(
9✔
70
            ($this->instancePointerParent?->getInstancePointer()->pointer ?? '') . $this->instancePointerSegment
9✔
71
        );
9✔
72
    }
73

74
    /**
75
     * Link this exception's instance pointer to continue from an enclosing exception's, as
76
     * exceptions bubble up from the point of failure to the root. Called by wrapping exceptions
77
     * (InvalidItemException, InvalidTupleException, InvalidAdditionalPropertiesException,
78
     * InvalidPatternPropertiesException, NestedObjectException, InvalidComposedValueException,
79
     * ConditionalException) on the nested exceptions they collect.
80
     *
81
     * Pass $segment when this exception's own propertyName is a placeholder shared by every
82
     * instance of an enclosing collection (an array item, an additional/pattern property) rather
83
     * than this value's real position — it replaces the auto-seeded segment with the caller's
84
     * actual position (an array index, the real property key). Omit it when this exception's own
85
     * propertyName is already a real, distinct name (composition branches, conditional branches,
86
     * and nested object properties all keep their own name and only need the parent link).
87
     */
88
    public function setInstancePointerParent(ValidationException $parent, int|string|null $segment = null): void
11✔
89
    {
90
        $this->instancePointerParent = $parent;
11✔
91

92
        if ($segment !== null) {
11✔
93
            $this->instancePointerSegment = '/' . self::escapeInstancePointerSegment((string) $segment);
9✔
94
        }
95
    }
96

97
    /**
98
     * Clear this exception's own instance pointer segment, leaving only whatever a parent link
99
     * (set via setInstancePointerParent()) contributes. Used by exceptions whose propertyName is
100
     * a class-name placeholder rather than a real instance-path segment: base validators that
101
     * validate the current object itself (additionalProperties/patternProperties checks) run
102
     * inside the generated class's own code, with no access to the property name their parent
103
     * used to reach this object, so they fall back to the class name purely for message text.
104
     */
105
    protected function suppressOwnInstancePointerSegment(): void
2✔
106
    {
107
        $this->instancePointerSegment = '';
2✔
108
    }
109

110
    private static function escapeInstancePointerSegment(string $segment): string
24✔
111
    {
112
        return str_replace(['~', '/'], ['~0', '~1'], $segment);
24✔
113
    }
114
}
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