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

wol-soft / php-json-schema-model-generator / 23736910562

30 Mar 2026 09:08AM UTC coverage: 98.331% (-0.4%) from 98.717%
23736910562

Pull #123

github

Enno Woortmann
Merge remote-tracking branch 'origin/master' into drafts
Pull Request #123: Introduce Draft-based architecture: eliminate legacy processors, centralize modifier/validator registration

1374 of 1399 new or added lines in 60 files covered. (98.21%)

3 existing lines in 2 files now uncovered.

4243 of 4315 relevant lines covered (98.33%)

588.89 hits per line

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

96.43
/src/Draft/Modifier/ObjectType/ObjectModifier.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace PHPModelGenerator\Draft\Modifier\ObjectType;
6

7
use PHPModelGenerator\Draft\Modifier\ModifierInterface;
8
use PHPModelGenerator\Exception\SchemaException;
9
use PHPModelGenerator\Model\Property\BaseProperty;
10
use PHPModelGenerator\Model\Property\PropertyInterface;
11
use PHPModelGenerator\Model\Property\PropertyType;
12
use PHPModelGenerator\Model\Schema;
13
use PHPModelGenerator\Model\SchemaDefinition\JsonSchema;
14
use PHPModelGenerator\Model\Validator\InstanceOfValidator;
15
use PHPModelGenerator\PropertyProcessor\Decorator\Property\ObjectInstantiationDecorator;
16
use PHPModelGenerator\PropertyProcessor\Decorator\SchemaNamespaceTransferDecorator;
17
use PHPModelGenerator\SchemaProcessor\SchemaProcessor;
18

19
class ObjectModifier implements ModifierInterface
20
{
21
    /**
22
     * Wire the instantiation linkage for a nested object property.
23
     *
24
     * The nested Schema is already set on the property by PropertyFactory before the modifier
25
     * list runs. This modifier reads it and attaches ObjectInstantiationDecorator,
26
     * InstanceOfValidator, PropertyType, and namespace transfer decorators to the outer property.
27
     *
28
     * Skips for BaseProperty (root-level schema) — no instantiation is needed there.
29
     *
30
     * @throws SchemaException
31
     */
32
    public function modify(
2,120✔
33
        SchemaProcessor $schemaProcessor,
34
        Schema $schema,
35
        PropertyInterface $property,
36
        JsonSchema $propertySchema,
37
    ): void {
38
        if ($property instanceof BaseProperty) {
2,120✔
39
            return;
2,120✔
40
        }
41

42
        $nestedSchema = $property->getNestedSchema();
959✔
43
        if ($nestedSchema === null) {
959✔
NEW
44
            return;
×
45
        }
46

47
        if (
48
            $nestedSchema->getClassPath() !== $schema->getClassPath() ||
959✔
49
            $nestedSchema->getClassName() !== $schema->getClassName()
959✔
50
        ) {
51
            $schema->addUsedClass(
952✔
52
                join(
952✔
53
                    '\\',
952✔
54
                    array_filter([
952✔
55
                        $schemaProcessor->getGeneratorConfiguration()->getNamespacePrefix(),
952✔
56
                        $nestedSchema->getClassPath(),
952✔
57
                        $nestedSchema->getClassName(),
952✔
58
                    ]),
952✔
59
                )
952✔
60
            );
952✔
61

62
            $schema->addNamespaceTransferDecorator(new SchemaNamespaceTransferDecorator($nestedSchema));
952✔
63
        }
64

65
        $property
959✔
66
            ->addDecorator(
959✔
67
                new ObjectInstantiationDecorator(
959✔
68
                    $nestedSchema->getClassName(),
959✔
69
                    $schemaProcessor->getGeneratorConfiguration(),
959✔
70
                )
959✔
71
            )
959✔
72
            ->setType(new PropertyType($nestedSchema->getClassName()));
959✔
73

74
        $property->addValidator(new InstanceOfValidator($property), 3);
959✔
75
    }
76
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc