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

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

16 Jul 2026 07:57PM UTC coverage: 46.172% (+24.6%) from 21.548%
29530702040

Pull #19

github

claude
Make enum/const messages self-descriptive

EnumException and InvalidConstException were the only constraint violations
that didn't say what would have satisfied them — "declined by enum
constraint" / "declined by const constraint" gave no indication of the
allowed/expected value or what was actually provided, unlike every other
constraint (Minimum, MaxLength, Pattern, Format, ...), which states its
bound directly in the message. Both getters (getAllowedValues(),
getExpectedValue()) already existed, but reading them meant an extra call
just to explain a common failure.

Messages now read "Value for 'x' must be <expected>, got <got>" (const) /
"... must be one of [<allowed>], got <got>" (enum). Values render through a
shared ValueFormatter (json_encode-based, with a var_export fallback for
values json_encode can't handle) since these are constraints on JSON data —
scalars, arrays, and objects all render consistently rather than needing
separate handling. Enum's allowed-values list is capped at 8 entries before
truncating to a 5-item preview + count, so a large enum doesn't turn the
message into a single unreadable line.
Pull Request #19: Fix nested composition indentation + add data-instance JSON pointer (issue #131)

79 of 81 new or added lines in 11 files covered. (97.53%)

1 existing line in 1 file now uncovered.

392 of 849 relevant lines covered (46.17%)

1.57 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