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

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

06 Mar 2026 10:23PM UTC coverage: 98.658% (-0.04%) from 98.693%
22784825213

Pull #115

github

Enno Woortmann
Add tests to cover new PropertyMerger code paths

- testAllOfIntersectionNarrowsMultiTypeToSubset: covers the allOf
  intersection body (lines 239, 249, 256–263) where the intersection
  narrows a [integer, string] root to ?int via an allOf branch.

- testAllOfIntersectionPreservesExplicitNullableMultiType: covers the
  explicit-nullable preservation path (lines 245–246) where an
  explicitly-nullable root type keeps its null after allOf intersection.

- testRootObjectPropertyNotOverwrittenByAnyOfObjectBranch: covers the
  nested-schema early return (line 57) in PropertyMerger::merge() when
  both existing and incoming properties carry a nested schema.

- testWarningIsEmittedWhenBranchTypeConflictsWithRootType: covers the
  warning echo (lines 112–116) in guardRootPrecedence() by using
  generateDirectory() with output enabled and asserting the printed
  warning text.

Also adds the four corresponding test schema files.
Pull Request #115: Type system (Type widening for compositions, union types)

254 of 259 new or added lines in 22 files covered. (98.07%)

16 existing lines in 6 files now uncovered.

3677 of 3727 relevant lines covered (98.66%)

554.85 hits per line

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

95.24
/src/PropertyProcessor/Property/ReferenceProcessor.php
1
<?php
2

3
declare(strict_types = 1);
4

5
namespace PHPModelGenerator\PropertyProcessor\Property;
6

7
use Exception;
8
use PHPModelGenerator\Exception\SchemaException;
9
use PHPModelGenerator\Model\Property\PropertyInterface;
10
use PHPModelGenerator\Model\SchemaDefinition\JsonSchema;
11
use PHPModelGenerator\PropertyProcessor\Decorator\SchemaNamespaceTransferDecorator;
12

13
/**
14
 * Class ReferenceProcessor
15
 *
16
 * @package PHPModelGenerator\PropertyProcessor\Property
17
 */
18
class ReferenceProcessor extends AbstractTypedValueProcessor
19
{
20
    /**
21
     * @inheritdoc
22
     *
23
     * @throws SchemaException
24
     */
25
    public function process(string $propertyName, JsonSchema $propertySchema): PropertyInterface
529✔
26
    {
27
        $path = [];
529✔
28
        $reference = $propertySchema->getJson()['$ref'];
529✔
29
        $dictionary = $this->schema->getSchemaDictionary();
529✔
30

31
        try {
32
            $definition = $dictionary->getDefinition($reference, $this->schemaProcessor, $path);
529✔
33

34
            if ($definition) {
522✔
35
                if ($this->schema->getClassPath() !== $definition->getSchema()->getClassPath() ||
522✔
36
                    $this->schema->getClassName() !== $definition->getSchema()->getClassName() ||
522✔
37
                    (
38
                        $this->schema->getClassName() === 'ExternalSchema' &&
522✔
39
                        $definition->getSchema()->getClassName() === 'ExternalSchema'
522✔
40
                    )
41
                ) {
42
                    $this->schema->addNamespaceTransferDecorator(
243✔
43
                        new SchemaNamespaceTransferDecorator($definition->getSchema()),
243✔
44
                    );
243✔
45
                }
46

47
                return $definition->resolveReference($propertyName, $path, $this->propertyMetaDataCollection);
522✔
48
            }
49
        } catch (Exception $exception) {
7✔
50
            throw new SchemaException(
7✔
51
                "Unresolved Reference $reference in file {$propertySchema->getFile()}",
7✔
52
                0,
7✔
53
                $exception,
7✔
54
            );
7✔
55
        }
56

UNCOV
57
        throw new SchemaException("Unresolved Reference $reference in file {$propertySchema->getFile()}");
×
58
    }
59
}
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