66
77use PHPModelGenerator \Exception \Object \InvalidAdditionalPropertiesException ;
88use PHPModelGenerator \Exception \SchemaException ;
9+ use PHPModelGenerator \Model \Property \PropertyInterface ;
910use PHPModelGenerator \Model \Schema ;
1011use PHPModelGenerator \PropertyProcessor \PropertyMetaDataCollection ;
1112use PHPModelGenerator \PropertyProcessor \PropertyFactory ;
@@ -27,6 +28,9 @@ class AdditionalPropertiesValidator extends PropertyTemplateValidator
2728
2829 protected const EXCEPTION_CLASS = InvalidAdditionalPropertiesException::class;
2930
31+ /** @var PropertyInterface */
32+ private $ validationProperty ;
33+
3034 /**
3135 * AdditionalPropertiesValidator constructor.
3236 *
@@ -45,33 +49,41 @@ public function __construct(
4549 ) {
4650 $ propertyFactory = new PropertyFactory (new PropertyProcessorFactory ());
4751
48- $ validationProperty = $ propertyFactory ->create (
52+ $ this -> validationProperty = $ propertyFactory ->create (
4953 new PropertyMetaDataCollection ([static ::PROPERTY_NAME ]),
5054 $ schemaProcessor ,
5155 $ schema ,
5256 static ::PROPERTY_NAME ,
5357 $ propertiesStructure [static ::ADDITIONAL_PROPERTIES_KEY ]
5458 );
5559
56- $ this ->removeRequiredPropertyValidator ($ validationProperty );
57-
5860 parent ::__construct (
5961 DIRECTORY_SEPARATOR . 'Validator ' . DIRECTORY_SEPARATOR . 'AdditionalProperties.phptpl ' ,
6062 [
61- 'validationProperty ' => $ validationProperty ,
62- 'additionalProperties ' => preg_replace (
63+ 'validationProperty ' => $ this -> validationProperty ,
64+ 'additionalProperties ' => preg_replace (
6365 '(\d+\s=>) ' ,
6466 '' ,
6567 var_export (array_keys ($ propertiesStructure [static ::PROPERTIES_KEY ] ?? []), true )
6668 ),
6769 'generatorConfiguration ' => $ schemaProcessor ->getGeneratorConfiguration (),
68- 'viewHelper ' => new RenderHelper ($ schemaProcessor ->getGeneratorConfiguration ()),
70+ 'viewHelper ' => new RenderHelper ($ schemaProcessor ->getGeneratorConfiguration ()),
6971 ],
7072 static ::EXCEPTION_CLASS ,
7173 [$ propertyName ?? $ schema ->getClassName (), '&$invalidProperties ' ]
7274 );
7375 }
7476
77+ /**
78+ * @inheritDoc
79+ */
80+ public function getCheck (): string
81+ {
82+ $ this ->removeRequiredPropertyValidator ($ this ->validationProperty );
83+
84+ return parent ::getCheck ();
85+ }
86+
7587 /**
7688 * Initialize all variables which are required to execute a property names validator
7789 *
0 commit comments