INFO: Java 1.8.0_322 Amazon.com Inc. (64-bit)
INFO: Linux 4.4.0-1128-aws amd64
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/src/app/build/libs/sonarlint-core-2.17.0.899.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/src/app/build/libs/sonarlint-cli-2.1.0.566.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
INFO: Index files
INFO: Invalid character encountered in file '/code/docs/requirements.txt' at line 1 for encoding UTF-8. Please fix file content or configure the encoding to be used using property 'sonar.sourceEncoding'.
INFO: 208 files indexed
INFO: 131 source files to be analyzed
ERROR: Unable to parse file: /code/src/SchemaProvider/OpenAPIv3Provider.php
ERROR: Parse error at line 25 column 33:
15: class OpenAPIv3Provider implements SchemaProviderInterface
16: {
17: /** @var array */
18: private $openAPIv3Spec;
19:
20: /**
21: * OpenAPIv3Provider constructor.
22: *
23: * @throws SchemaException
24: */
25: public function __construct(private string $sourceFile)
^
26: {
27: $jsonSchema = file_get_contents($this->sourceFile);
28:
29: if (!$jsonSchema || !($this->openAPIv3Spec = json_decode($jsonSchema, true))) {
30: throw new SchemaException("Invalid JSON-Schema file {$this->sourceFile}");
31: }
32:
33: if (!isset($this->openAPIv3Spec['components']['schemas']) ||
34: empty($this->openAPIv3Spec['components']['schemas'])
35: ) {
ERROR: Unable to parse file: /code/src/SchemaProvider/RecursiveDirectoryProvider.php
ERROR: Parse error at line 21 column 13:
11: use RecursiveIteratorIterator;
12: use RegexIterator;
13:
14: /**
15: * Class RecursiveDirectoryProvider
16: *
17: * @package PHPModelGenerator\SchemaProvider
18: */
19: class RecursiveDirectoryProvider implements SchemaProviderInterface
20: {
21: private string $sourceDirectory;
^
22:
23: /**
24: * RecursiveDirectoryProvider constructor.
25: *
26: * @throws FileSystemException
27: */
28: public function __construct(string $sourceDirectory)
29: {
30: if (!is_dir($sourceDirectory)) {
31: throw new FileSystemException("Source directory '$sourceDirectory' doesn't exist");
ERROR: Unable to parse file: /code/src/ModelGenerator.php
ERROR: Parse error at line 33 column 15:
23: use RecursiveDirectoryIterator;
24: use RecursiveIteratorIterator;
25:
26: /**
27: * Class ModelGenerator
28: *
29: * @package PHPModelGenerator
30: */
31: class ModelGenerator
32: {
33: protected GeneratorConfiguration $generatorConfiguration;
^
34: /** @var PostProcessor[] */
35: protected $postProcessors = [];
36:
37: /**
38: * Generator constructor.
39: *
40: * @param GeneratorConfiguration|null $generatorConfiguration The configuration to apply to the generator
41: */
42: public function __construct(?GeneratorConfiguration $generatorConfiguration = null)
43: {
ERROR: Unable to parse file: /code/src/PropertyProcessor/ComposedValueProcessorFactory.php
ERROR: Parse error at line 24 column 33:
14: *
15: * @package PHPModelGenerator\PropertyProcessor
16: */
17: class ComposedValueProcessorFactory implements ProcessorFactoryInterface
18: {
19: /**
20: * ComposedValueProcessorFactory constructor.
21: *
22: * @param bool $rootLevelComposition is the composed value on object root level (true) or on property level (false)?
23: */
24: public function __construct(private bool $rootLevelComposition) {}
^
25:
26: /**
27: * @inheritdoc
28: *
29: * @throws SchemaException
30: */
31: public function getProcessor(
32: $type,
33: PropertyMetaDataCollection $propertyMetaDataCollection,
34: SchemaProcessor $schemaProcessor,
ERROR: Unable to parse file: /code/src/PropertyProcessor/Property/AbstractPropertyProcessor.php
ERROR: Parse error at line 35 column 9:
25: use PHPModelGenerator\Utils\TypeConverter;
26:
27: /**
28: * Class AbstractPropertyProcessor
29: *
30: * @package PHPModelGenerator\PropertyProcessor\Property
31: */
32: abstract class AbstractPropertyProcessor implements PropertyProcessorInterface
33: {
34: public function __construct(
35: protected PropertyMetaDataCollection $propertyMetaDataCollection,
^
36: protected SchemaProcessor $schemaProcessor,
37: protected Schema $schema
38: ) {}
39:
40: /**
41: * Generates the validators for the property
42: *
43: * @throws SchemaException
44: */
45: protected function generateValidators(PropertyInterface $property, JsonSchema $propertySchema): void
ERROR: Unable to parse file: /code/src/PropertyProcessor/Property/AbstractTypedValueProcessor.php
ERROR: Parse error at line 31 column 5:
21: {
22: protected const TYPE = '';
23:
24: /**
25: * AbstractTypedValueProcessor constructor.
26: */
27: public function __construct(
28: PropertyMetaDataCollection $propertyMetaDataCollection,
29: SchemaProcessor $schemaProcessor,
30: Schema $schema,
31: ) {
^
32: parent::__construct($propertyMetaDataCollection, $schemaProcessor, $schema, static::TYPE);
33: }
34:
35: /**
36: * @throws SchemaException
37: */
38: public function process(string $propertyName, JsonSchema $propertySchema): PropertyInterface
39: {
40: $property = parent::process($propertyName, $propertySchema);
41:
ERROR: Unable to parse file: /code/src/PropertyProcessor/Property/ConstProcessor.php
ERROR: Parse error at line 35 column 9:
25: */
26: public function process(string $propertyName, JsonSchema $propertySchema): PropertyInterface
27: {
28: $json = $propertySchema->getJson();
29:
30: $property = new Property(
31: $propertyName,
32: new PropertyType(TypeConverter::gettypeToInternal(gettype($json['const']))),
33: $propertySchema,
34: $json['description'] ?? '',
35: );
^
36:
37: $property->setRequired($this->propertyMetaDataCollection->isAttributeRequired($propertyName));
38:
39: $check = match(true) {
40: $property->isRequired()
41: => '$value !== ' . var_export($json['const'], true),
42: $this->isImplicitNullAllowed($property)
43: => '!in_array($value, ' . RenderHelper::varExportArray([$json['const'], null]) . ', true)',
44: default
45: => "array_key_exists('{$property->getName()}', \$modelData) && \$value !== " . var_export($json['const'], true),
ERROR: Unable to parse file: /code/src/PropertyProcessor/Property/MultiTypeProcessor.php
ERROR: Parse error at line 46 column 5:
36: * MultiTypePropertyProcessor constructor.
37: *
38: * @throws SchemaException
39: */
40: public function __construct(
41: PropertyProcessorFactory $propertyProcessorFactory,
42: array $types,
43: PropertyMetaDataCollection $propertyMetaDataCollection,
44: SchemaProcessor $schemaProcessor,
45: Schema $schema,
46: ) {
^
47: parent::__construct($propertyMetaDataCollection, $schemaProcessor, $schema);
48:
49: foreach ($types as $type) {
50: $this->propertyProcessors[$type] = $propertyProcessorFactory->getProcessor(
51: $type,
52: $propertyMetaDataCollection,
53: $schemaProcessor,
54: $schema,
55: );
56: }
ERROR: Unable to parse file: /code/src/PropertyProcessor/Property/BaseProcessor.php
ERROR: Parse error at line 102 column 13:
92: {
93: if (!isset($propertySchema->getJson()['propertyNames'])) {
94: return;
95: }
96:
97: $this->schema->addBaseValidator(
98: new PropertyNamesValidator(
99: $this->schemaProcessor,
100: $this->schema,
101: $propertySchema->withJson($propertySchema->getJson()['propertyNames']),
102: )
^
103: );
104: }
105:
106: /**
107: * Add an object validator to specify constraints for properties which are not defined in the schema
108: *
109: * @throws FileSystemException
110: * @throws SchemaException
111: * @throws SyntaxErrorException
112: * @throws UndefinedSymbolException
ERROR: Unable to parse file: /code/src/PropertyProcessor/Property/ReferenceProcessor.php
ERROR: Parse error at line 44 column 21:
34: if ($definition) {
35: if ($this->schema->getClassPath() !== $definition->getSchema()->getClassPath() ||
36: $this->schema->getClassName() !== $definition->getSchema()->getClassName() ||
37: (
38: $this->schema->getClassName() === 'ExternalSchema' &&
39: $definition->getSchema()->getClassName() === 'ExternalSchema'
40: )
41: ) {
42: $this->schema->addNamespaceTransferDecorator(
43: new SchemaNamespaceTransferDecorator($definition->getSchema()),
44: );
^
45: }
46:
47: return $definition->resolveReference($propertyName, $path, $this->propertyMetaDataCollection);
48: }
49: } catch (Exception $exception) {
50: throw new SchemaException(
51: "Unresolved Reference $reference in file {$propertySchema->getFile()}",
52: 0,
53: $exception,
54: );
ERROR: Unable to parse file: /code/src/PropertyProcessor/Property/AbstractNumericProcessor.php
ERROR: Parse error at line 47 column 9:
37:
38: $this->addRangeValidator($property, $propertySchema, self::JSON_FIELD_MINIMUM, '<', MinimumException::class);
39: $this->addRangeValidator($property, $propertySchema, self::JSON_FIELD_MAXIMUM, '>', MaximumException::class);
40:
41: $this->addRangeValidator(
42: $property,
43: $propertySchema,
44: self::JSON_FIELD_MINIMUM_EXCLUSIVE,
45: '<=',
46: ExclusiveMinimumException::class,
47: );
^
48:
49: $this->addRangeValidator(
50: $property,
51: $propertySchema,
52: self::JSON_FIELD_MAXIMUM_EXCLUSIVE,
53: '>=',
54: ExclusiveMaximumException::class,
55: );
56:
57: $this->addMultipleOfValidator($property, $propertySchema);
ERROR: Unable to parse file: /code/src/PropertyProcessor/Property/BasereferenceProcessor.php
ERROR: Parse error at line 38 column 17:
28: ->setUpDefinitionDictionary($this->schemaProcessor, $this->schema);
29:
30: $property = parent::process($propertyName, $propertySchema);
31:
32: if (!$property->getNestedSchema()) {
33: throw new SchemaException(
34: sprintf(
35: 'A referenced schema on base level must provide an object definition for property %s in file %s',
36: $propertyName,
37: $propertySchema->getFile(),
38: )
^
39: );
40: }
41:
42: foreach ($property->getNestedSchema()->getProperties() as $propertiesOfReferencedObject) {
43: $this->schema->addProperty($propertiesOfReferencedObject);
44: }
45:
46: return $property;
47: }
48: }
ERROR: Unable to parse file: /code/src/PropertyProcessor/Property/ArrayProcessor.php
ERROR: Parse error at line 70 column 17:
60:
61: if (!$property->isRequired() &&
62: $this->schemaProcessor->getGeneratorConfiguration()->isDefaultArraysToEmptyArrayEnabled()
63: ) {
64: $property->addDecorator(new DefaultArrayToEmptyArrayDecorator());
65:
66: if ($property->getType()) {
67: $property->setType(
68: $property->getType(),
69: new PropertyType($property->getType(true)->getName(), false),
70: );
^
71: }
72:
73: if (!$property->getDefaultValue()) {
74: $property->setDefaultValue([]);
75: }
76: }
77: }
78:
79: /**
80: * Add the vaidation for the allowed amount of items in the array
ERROR: Unable to parse file: /code/src/PropertyProcessor/Property/StringProcessor.php
ERROR: Parse error at line 64 column 17:
54:
55: $escapedPattern = addcslashes($json[static::JSON_FIELD_PATTERN], '/');
56:
57: if (@preg_match("/$escapedPattern/", '') === false) {
58: throw new SchemaException(
59: sprintf(
60: "Invalid pattern '%s' for property '%s' in file %s",
61: $json[static::JSON_FIELD_PATTERN],
62: $property->getName(),
63: $propertySchema->getFile(),
64: )
^
65: );
66: }
67:
68: $encodedPattern = base64_encode("/$escapedPattern/");
69:
70: $property->addValidator(
71: new PropertyValidator(
72: $property,
73: $this->getTypeCheck() . "!preg_match(base64_decode('$encodedPattern'), \$value)",
74: PatternException::class,
ERROR: Unable to parse file: /code/src/PropertyProcessor/Property/ObjectProcessor.php
ERROR: Parse error at line 38 column 9:
28: */
29: public function process(string $propertyName, JsonSchema $propertySchema): PropertyInterface
30: {
31: $property = parent::process($propertyName, $propertySchema);
32:
33: $className = $this->schemaProcessor->getGeneratorConfiguration()->getClassNameGenerator()->getClassName(
34: $propertyName,
35: $propertySchema,
36: false,
37: $this->schemaProcessor->getCurrentClassName(),
38: );
^
39:
40: $schema = $this->schemaProcessor->processSchema(
41: $propertySchema,
42: $this->schemaProcessor->getCurrentClassPath(),
43: $className,
44: $this->schema->getSchemaDictionary(),
45: );
46:
47: // if the generated schema is located in a different namespace (the schema for the given structure in
48: // $propertySchema is duplicated) add used classes to the current schema. By importing the class which is
ERROR: Unable to parse file: /code/src/PropertyProcessor/Property/AbstractValueProcessor.php
ERROR: Parse error at line 32 column 9:
22: */
23: abstract class AbstractValueProcessor extends AbstractPropertyProcessor
24: {
25: /**
26: * AbstractValueProcessor constructor.
27: */
28: public function __construct(
29: PropertyMetaDataCollection $propertyMetaDataCollection,
30: SchemaProcessor $schemaProcessor,
31: Schema $schema,
32: private string $type = '',
^
33: ) {
34: parent::__construct($propertyMetaDataCollection, $schemaProcessor, $schema);
35: }
36:
37: /**
38: * @inheritdoc
39: *
40: * @throws ReflectionException
41: * @throws SchemaException
42: */
ERROR: Unable to parse file: /code/src/PropertyProcessor/PropertyProcessorFactory.php
ERROR: Parse error at line 29 column 5:
19: /**
20: * @param string|array $type
21: *
22: * @throws SchemaException
23: */
24: public function getProcessor(
25: $type,
26: PropertyMetaDataCollection $propertyMetaDataCollection,
27: SchemaProcessor $schemaProcessor,
28: Schema $schema,
29: ): PropertyProcessorInterface {
^
30: if (is_string($type)) {
31: return $this->getSingleTypePropertyProcessor(
32: $type,
33: $propertyMetaDataCollection,
34: $schemaProcessor,
35: $schema,
36: );
37: }
38:
39: if (is_array($type)) {
ERROR: Unable to parse file: /code/src/PropertyProcessor/PropertyMetaDataCollection.php
ERROR: Parse error at line 25 column 33:
15: {
16: /**
17: * PropertyMetaDataCollection constructor.
18: *
19: * @param array $requiredAttributes Contains a list of all attributes which are required
20: * @param array $dependencies Contains a key-value pair of dependencies. The keys represent the attribute
21: * defines a dependency, the value contains either an array of attributes which
22: * are required if the key attribute is present or a valid schema which must be
23: * fulfilled if the key attribute is present
24: */
25: public function __construct(protected array $requiredAttributes = [], protected array $dependencies = []) {}
^
26:
27: /**
28: * Check if a given attribute is required
29: */
30: public function isAttributeRequired(string $attribute): bool
31: {
32: return in_array($attribute, $this->requiredAttributes);
33: }
34:
35: /**
ERROR: Unable to parse file: /code/src/PropertyProcessor/Decorator/SchemaNamespaceTransferDecorator.php
ERROR: Parse error at line 17 column 33:
7: use PHPModelGenerator\Model\Schema;
8:
9: /**
10: * Class SchemaNamespaceTransferDecorator
11: */
12: class SchemaNamespaceTransferDecorator
13: {
14: /**
15: * SchemaNamespaceTransferDecorator constructor.
16: */
17: public function __construct(private Schema $schema) {}
^
18:
19: /**
20: * Get all used classes to use the referenced schema
21: *
22: * @param Schema[] $visitedSchema
23: */
24: public function resolve(array $visitedSchema): array
25: {
26: // avoid an endless loop while resolving recursive schema objects
27: if (in_array($this->schema, $visitedSchema, true)) {
ERROR: Unable to parse file: /code/src/PropertyProcessor/Decorator/Property/ObjectInstantiationDecorator.php
ERROR: Parse error at line 27 column 33:
17: * @package PHPModelGenerator\PropertyProcessor\Decorator\Property
18: */
19: class ObjectInstantiationDecorator implements PropertyDecoratorInterface
20: {
21: /** @var Render */
22: protected static $renderer;
23:
24: /**
25: * ObjectInstantiationDecorator constructor.
26: */
27: public function __construct(protected string $className, protected GeneratorConfiguration $generatorConfiguration)
^
28: {
29: if (!static::$renderer) {
30: static::$renderer = new Render(
31: join(DIRECTORY_SEPARATOR, [__DIR__, '..', '..', '..', 'Templates']) . DIRECTORY_SEPARATOR,
32: );
33: }
34: }
35:
36: /**
37: * @inheritdoc
ERROR: Unable to parse file: /code/src/PropertyProcessor/Decorator/Property/PropertyTransferDecorator.php
ERROR: Parse error at line 22 column 33:
12: *
13: * Can be used to transfer the decorators of one property to another
14: *
15: * @package PHPModelGenerator\PropertyProcessor\Decorator\Property
16: */
17: class PropertyTransferDecorator implements PropertyDecoratorInterface
18: {
19: /**
20: * PropertyTransferDecorator constructor.
21: */
22: public function __construct(private PropertyInterface $property) {}
^
23:
24: /**
25: * @inheritdoc
26: */
27: public function decorate(string $input, PropertyInterface $property, bool $nestedProperty): string
28: {
29: return $this->property->resolveDecorator($input, $nestedProperty);
30: }
31: }
32:
ERROR: Unable to parse file: /code/src/PropertyProcessor/Decorator/TypeHint/CompositionTypeHintDecorator.php
ERROR: Parse error at line 16 column 33:
6:
7: use PHPModelGenerator\Model\Property\PropertyInterface;
8:
9: /**
10: * Class CompositionTypeHintDecorator
11: *
12: * @package PHPModelGenerator\PropertyProcessor\Decorator\Property
13: */
14: class CompositionTypeHintDecorator implements TypeHintDecoratorInterface
15: {
16: public function __construct(protected PropertyInterface $nestedProperty) {}
^
17:
18: /**
19: * @inheritdoc
20: */
21: public function decorate(string $input, bool $outputType = false): string
22: {
23: return (new TypeHintDecorator(explode('|', $this->nestedProperty->getTypeHint($outputType))))
24: ->decorate($input, $outputType);
25: }
26: }
ERROR: Unable to parse file: /code/src/PropertyProcessor/Decorator/TypeHint/TypeHintDecorator.php
ERROR: Parse error at line 14 column 33:
4:
5: namespace PHPModelGenerator\PropertyProcessor\Decorator\TypeHint;
6:
7: /**
8: * Class TypeHintDecorator
9: *
10: * @package PHPModelGenerator\PropertyProcessor\Decorator\Property
11: */
12: class TypeHintDecorator implements TypeHintDecoratorInterface
13: {
14: public function __construct(protected array $types) {}
^
15:
16: /**
17: * @inheritdoc
18: */
19: public function decorate(string $input, bool $outputType = false): string
20: {
21: return implode('|', array_unique(array_filter(array_merge(explode('|', $input), $this->types))));
22: }
23: }
24:
ERROR: Unable to parse file: /code/src/PropertyProcessor/Decorator/TypeHint/TypeHintTransferDecorator.php
ERROR: Parse error at line 16 column 33:
6:
7: use PHPModelGenerator\Model\Property\PropertyInterface;
8:
9: /**
10: * Class TypeHintTransferDecorator
11: *
12: * @package PHPModelGenerator\PropertyProcessor\Decorator\Property
13: */
14: class TypeHintTransferDecorator implements TypeHintDecoratorInterface
15: {
16: public function __construct(protected PropertyInterface $property) {}
^
17:
18: /**
19: * @inheritdoc
20: */
21: public function decorate(string $input, bool $outputType = false): string
22: {
23: return $this->property->getTypeHint($outputType);
24: }
25: }
26:
ERROR: Unable to parse file: /code/src/PropertyProcessor/Decorator/TypeHint/ArrayTypeHintDecorator.php
ERROR: Parse error at line 16 column 13:
6:
7: use PHPModelGenerator\Model\Property\PropertyInterface;
8:
9: /**
10: * Class ArrayTypeHintDecorator
11: *
12: * @package PHPModelGenerator\PropertyProcessor\Decorator\Property
13: */
14: class ArrayTypeHintDecorator implements TypeHintDecoratorInterface
15: {
16: private int $recursiveArrayCheck = 0;
^
17:
18: public function __construct(protected PropertyInterface $nestedProperty) {}
19:
20: /**
21: * @inheritdoc
22: */
23: public function decorate(string $input, bool $outputType = false): string
24: {
25: // TODO: provide better type hints. Currently provides e.g. "string|array[]" instead of "string|string[]" for a recursive string array
26: if (++$this->recursiveArrayCheck > 1) {
ERROR: Unable to parse file: /code/src/PropertyProcessor/ComposedValue/IfProcessor.php
ERROR: Parse error at line 41 column 17:
31: protected function generateValidators(PropertyInterface $property, JsonSchema $propertySchema): void
32: {
33: $json = $propertySchema->getJson()['propertySchema']->getJson();
34:
35: if (!isset($json['then']) && !isset($json['else'])) {
36: throw new SchemaException(
37: sprintf(
38: 'Incomplete conditional composition for property %s in file %s',
39: $property->getName(),
40: $property->getJsonSchema()->getFile(),
41: )
^
42: );
43: }
44:
45: $propertyFactory = new PropertyFactory(new PropertyProcessorFactory());
46:
47: $properties = [];
48:
49: foreach (['if', 'then', 'else'] as $compositionElement) {
50: if (!isset($json[$compositionElement])) {
51: $properties[$compositionElement] = null;
ERROR: Unable to parse file: /code/src/PropertyProcessor/ComposedValue/AbstractComposedValueProcessor.php
ERROR: Parse error at line 32 column 13:
22: use PHPModelGenerator\SchemaProcessor\SchemaProcessor;
23: use PHPModelGenerator\Utils\RenderHelper;
24:
25: /**
26: * Class AbstractComposedValueProcessor
27: *
28: * @package PHPModelGenerator\PropertyProcessor\ComposedValue
29: */
30: abstract class AbstractComposedValueProcessor extends AbstractValueProcessor
31: {
32: private ?PropertyInterface $mergedProperty = null;
^
33:
34: /**
35: * AbstractComposedValueProcessor constructor.
36: */
37: public function __construct(
38: PropertyMetaDataCollection $propertyMetaDataCollection,
39: SchemaProcessor $schemaProcessor,
40: Schema $schema,
41: private bool $rootLevelComposition,
42: ) {
ERROR: Unable to parse file: /code/src/PropertyProcessor/ComposedValue/NotProcessor.php
ERROR: Parse error at line 35 column 17:
25: $json['not'] = [$json['not']];
26:
27: // strict type checks for not constraint to avoid issues with null
28: $property->setRequired(true);
29: parent::generateValidators(
30: $property,
31: $propertySchema->withJson(
32: array_merge(
33: $propertySchema->getJson(),
34: ['propertySchema' => $propertySchema->getJson()['propertySchema']->withJson($json)],
35: )
^
36: ),
37: );
38: }
39:
40: /**
41: * @inheritdoc
42: */
43: protected function getComposedValueValidation(int $composedElements): string
44: {
45: return '$succeededCompositionElements === 0';
ERROR: Unable to parse file: /code/src/PropertyProcessor/Filter/FilterProcessor.php
ERROR: Parse error at line 43 column 5:
33: {
34: /**
35: * @throws ReflectionException
36: * @throws SchemaException
37: */
38: public function process(
39: PropertyInterface $property,
40: mixed $filterList,
41: GeneratorConfiguration $generatorConfiguration,
42: Schema $schema,
43: ): void {
^
44: if (is_string($filterList) || (is_array($filterList) && isset($filterList['filter']))) {
45: $filterList = [$filterList];
46: }
47:
48: $transformingFilter = null;
49: // apply a different priority to each filter to make sure the order is kept
50: $filterPriority = 10 + count($property->getValidators());
51:
52: foreach ($filterList as $filterToken) {
53: $filterOptions = [];
ERROR: Unable to parse file: /code/src/PropertyProcessor/PropertyFactory.php
ERROR: Parse error at line 20 column 33:
10: use PHPModelGenerator\Model\SchemaDefinition\JsonSchema;
11: use PHPModelGenerator\SchemaProcessor\SchemaProcessor;
12:
13: /**
14: * Class PropertyFactory
15: *
16: * @package PHPModelGenerator\PropertyProcessor
17: */
18: class PropertyFactory
19: {
20: public function __construct(protected ProcessorFactoryInterface $processorFactory) {}
^
21:
22: /**
23: * Create a property
24: *
25: * @throws SchemaException
26: */
27: public function create(
28: PropertyMetaDataCollection $propertyMetaDataCollection,
29: SchemaProcessor $schemaProcessor,
30: Schema $schema,
ERROR: Unable to parse file: /code/src/PropertyProcessor/ProcessorFactoryInterface.php
ERROR: Parse error at line 25 column 5:
15: interface ProcessorFactoryInterface
16: {
17: /**
18: * @param string|array $type
19: */
20: public function getProcessor(
21: $type,
22: PropertyMetaDataCollection $propertyMetaDataCollection,
23: SchemaProcessor $schemaProcessor,
24: Schema $schema,
25: ): PropertyProcessorInterface;
^
26: }
27:
ERROR: Unable to parse file: /code/src/Utils/RenderHelper.php
ERROR: Parse error at line 21 column 33:
11: use PHPModelGenerator\Model\Validator\PropertyTemplateValidator;
12: use PHPModelGenerator\Model\Validator\PropertyValidatorInterface;
13:
14: /**
15: * Class RenderHelper
16: *
17: * @package PHPModelGenerator\Utils
18: */
19: class RenderHelper
20: {
21: public function __construct(protected GeneratorConfiguration $generatorConfiguration) {}
^
22:
23: public function ucfirst(string $value): string
24: {
25: return ucfirst($value);
26: }
27:
28: public function isNull(mixed $value): bool
29: {
30: return $value === null;
31: }
ERROR: Unable to parse file: /code/src/Utils/NormalizedName.php
ERROR: Parse error at line 16 column 20:
6:
7: use PHPModelGenerator\Exception\SchemaException;
8: use PHPModelGenerator\Model\SchemaDefinition\JsonSchema;
9:
10: class NormalizedName
11: {
12: public static function from(string $name, JsonSchema $jsonSchema): string
13: {
14: $attributeName = preg_replace_callback(
15: '/([a-z][a-z0-9]*)([A-Z])/',
16: static fn(array $matches): string => "{$matches[1]}-{$matches[2]}",
^
17: $name,
18: );
19:
20: $elements = array_map(
21: static fn(string $element): string => ucfirst(strtolower($element)),
22: preg_split('/[^a-z0-9]/i', $attributeName),
23: );
24:
25: $attributeName = join('', $elements);
26:
ERROR: Unable to parse file: /code/src/Utils/ClassNameGeneratorInterface.php
ERROR: Parse error at line 30 column 5:
20: * Otherwise the name of the property which contains the nested object
21: * @param JsonSchema $schema The structure of the schema which is represented by the generated class
22: * @param bool $isMergeClass Is it a merge class? example: allOf schema composition
23: * @param string $currentClassName The class name of the parent class if the class represents a nested object
24: */
25: public function getClassName(
26: string $propertyName,
27: JsonSchema $schema,
28: bool $isMergeClass,
29: string $currentClassName = '',
30: ): string;
^
31: }
32:
ERROR: Unable to parse file: /code/src/Utils/ClassNameGenerator.php
ERROR: Parse error at line 24 column 5:
14: class ClassNameGenerator implements ClassNameGeneratorInterface
15: {
16: /**
17: * @inheritDoc
18: */
19: public function getClassName(
20: string $propertyName,
21: JsonSchema $schema,
22: bool $isMergeClass,
23: string $currentClassName = '',
24: ): string {
^
25: $json = $isMergeClass && isset($schema->getJson()['propertySchema'])
26: ? $schema->getJson()['propertySchema']->getJson()
27: : $schema->getJson();
28:
29: $className = sprintf(
30: $isMergeClass ? '%s_Merged_%s' : '%s_%s',
31: $currentClassName,
32: ucfirst(
33: isset($json['$id'])
34: ? str_replace('#', '', $json['$id'])
ERROR: Unable to parse file: /code/src/Model/SchemaDefinition/JsonSchema.php
ERROR: Parse error at line 36 column 15:
26: 'else',
27: 'additionalProperties',
28: 'required',
29: 'propertyNames',
30: 'minProperties',
31: 'maxProperties',
32: 'dependencies',
33: 'patternProperties',
34: ];
35:
36: protected array $json;
^
37:
38: /**
39: * JsonSchema constructor.
40: *
41: * @param string $file the source file for the schema
42: * @param array $json Decoded json schema
43: */
44: public function __construct(private string $file, array $json)
45: {
46: // wrap in an allOf to pass the processing to multiple handlers - ugly hack to be removed after rework
ERROR: Unable to parse file: /code/src/Model/SchemaDefinition/SchemaDefinitionDictionary.php
ERROR: Parse error at line 20 column 13:
10: use PHPModelGenerator\SchemaProcessor\SchemaProcessor;
11:
12: /**
13: * Class SchemaDefinitionDictionary
14: *
15: * @package PHPModelGenerator\Model\SchemaDefinition
16: */
17: class SchemaDefinitionDictionary extends ArrayObject
18: {
19: /** @var Schema[] */
20: private array $parsedExternalFileSchemas = [];
^
21:
22: /**
23: * SchemaDefinitionDictionary constructor.
24: */
25: public function __construct(private string $sourceDirectory)
26: {
27: parent::__construct();
28: }
29:
30: /**
ERROR: Unable to parse file: /code/src/Model/SchemaDefinition/SchemaDefinition.php
ERROR: Parse error at line 26 column 15:
16:
17: /**
18: * Class SchemaDefinition
19: *
20: * Hold a definition from a schema
21: *
22: * @package PHPModelGenerator\Model
23: */
24: class SchemaDefinition
25: {
26: protected ResolvedDefinitionsCollection $resolvedPaths;
^
27: /** @var array */
28: protected $unresolvedProxies = [];
29:
30: /**
31: * SchemaDefinition constructor.
32: */
33: public function __construct(
34: protected JsonSchema $source,
35: protected SchemaProcessor $schemaProcessor,
36: protected Schema $schema,
ERROR: Unable to parse file: /code/src/Model/Property/PropertyInterface.php
ERROR: Parse error at line 44 column 5:
34:
35: /**
36: * @param PropertyType|null $outputType By default the output type will be equal to the base type but due to applied
37: * filters the output type may change
38: * @param bool $reset set to true for a full type reset (including type hint decorators like array, ...)
39: */
40: public function setType(
41: ?PropertyType $type = null,
42: ?PropertyType $outputType = null,
43: bool $reset = false,
44: ): PropertyInterface;
^
45:
46: /**
47: * @param bool $outputType If set to true the output type hint will be returned (may differ from the base type)
48: * @param string[] $skipDecorators Provide a set of decorators (FQCN) which shouldn't be applied
49: * (might be necessary to avoid infinite loops for recursive calls)
50: */
51: public function getTypeHint(bool $outputType = false, array $skipDecorators = []): string;
52:
53: public function addTypeHintDecorator(TypeHintDecoratorInterface $typeHintDecorator): PropertyInterface;
54:
ERROR: Unable to parse file: /code/src/Model/Property/PropertyProxy.php
ERROR: Parse error at line 34 column 9:
24: *
25: * @param string $name The name must be provided separately as the name is not bound to the structure of a
26: * referenced schema. Consequently, two properties with different names can refer an identical schema utilizing the
27: * PropertyProxy. By providing a name to each of the proxies the resulting properties will get the correct names.
28: *
29: * @throws SchemaException
30: */
31: public function __construct(
32: string $name,
33: JsonSchema $jsonSchema,
34: protected ResolvedDefinitionsCollection $definitionsCollection,
^
35: protected string $key,
36: ) {
37: parent::__construct($name, $jsonSchema);
38: }
39:
40: /**
41: * Get the property out of the resolved definitions collection to proxy function calls
42: */
43: protected function getProperty(): PropertyInterface
44: {
ERROR: Unable to parse file: /code/src/Model/Property/Property.php
ERROR: Parse error at line 42 column 13:
32:
33: /** @var Validator[] */
34: protected $validators = [];
35: /** @var Schema */
36: protected $nestedSchema;
37: /** @var PropertyDecoratorInterface[] */
38: public $decorators = [];
39: /** @var TypeHintDecoratorInterface[] */
40: public $typeHintDecorators = [];
41:
42: private array $renderedTypeHints = [];
^
43: /** Track the amount of unresolved validators */
44: private int $pendingValidators = 0;
45:
46: /**
47: * Property constructor.
48: *
49: * @throws SchemaException
50: */
51: public function __construct(
52: string $name,
ERROR: Unable to parse file: /code/src/Model/Property/PropertyType.php
ERROR: Parse error at line 16 column 33:
6:
7: class PropertyType
8: {
9: /**
10: * PropertyType constructor.
11: *
12: * @param string $name The name of the type (eg. 'array', 'int', ...)
13: * @param bool|null $nullable Is the property nullable? if not provided the nullability will be determined
14: * automatically from the required flag/implicitNull setting etc.
15: */
16: public function __construct(private string $name, private ?bool $nullable = null) {}
^
17:
18: public function getName(): string
19: {
20: return $this->name;
21: }
22:
23: public function isNullable(): ?bool
24: {
25: return $this->nullable;
26: }
ERROR: Unable to parse file: /code/src/Model/Property/AbstractProperty.php
ERROR: Parse error at line 22 column 15:
12:
13: /**
14: * Class AbstractProperty
15: *
16: * @package PHPModelGenerator\Model\Property
17: */
18: abstract class AbstractProperty implements PropertyInterface
19: {
20: use JsonSchemaTrait, ResolvableTrait;
21:
22: protected string $attribute;
^
23:
24: /**
25: * Property constructor.
26: *
27: * @throws SchemaException
28: */
29: public function __construct(protected string $name, JsonSchema $jsonSchema)
30: {
31: $this->jsonSchema = $jsonSchema;
32:
ERROR: Unable to parse file: /code/src/Model/Property/CompositionPropertyDecorator.php
ERROR: Parse error at line 40 column 9:
30: *
31: * @throws SchemaException
32: */
33: public function __construct(string $propertyName, JsonSchema $jsonSchema, PropertyInterface $property)
34: {
35: parent::__construct(
36: $propertyName,
37: $jsonSchema,
38: new ResolvedDefinitionsCollection([self::PROPERTY_KEY => $property]),
39: self::PROPERTY_KEY,
40: );
^
41:
42: $property->onResolve(function (): void {
43: $this->resolve();
44: });
45: }
46:
47: /**
48: * Append an object property which is affected by the composition validator
49: */
50: public function appendAffectedObjectProperty(PropertyInterface $property): void
ERROR: Unable to parse file: /code/src/Model/Validator.php
ERROR: Parse error at line 16 column 33:
6:
7: use PHPModelGenerator\Model\Validator\PropertyValidatorInterface;
8:
9: /**
10: * Class Validator
11: *
12: * @package PHPModelGenerator\Model
13: */
14: class Validator
15: {
16: public function __construct(protected PropertyValidatorInterface $validator, protected int $priority) {}
^
17:
18: public function getValidator(): PropertyValidatorInterface
19: {
20: return $this->validator;
21: }
22:
23: public function getPriority(): int
24: {
25: return $this->priority;
26: }
ERROR: Unable to parse file: /code/src/Model/Validator/ComposedPropertyValidator.php
ERROR: Parse error at line 21 column 13:
11: use PHPModelGenerator\Model\Property\PropertyInterface;
12: use PHPModelGenerator\Model\Validator;
13:
14: /**
15: * Class ComposedPropertyValidator
16: *
17: * @package PHPModelGenerator\Model\Validator
18: */
19: class ComposedPropertyValidator extends AbstractComposedPropertyValidator
20: {
21: private string $modifiedValuesMethod;
^
22:
23: public function __construct(
24: GeneratorConfiguration $generatorConfiguration,
25: PropertyInterface $property,
26: array $composedProperties,
27: string $compositionProcessor,
28: array $validatorVariables,
29: ) {
30: $this->modifiedValuesMethod = '_getModifiedValues_' . substr(md5(spl_object_hash($this)), 0, 5);
31: $this->isResolved = true;
ERROR: Unable to parse file: /code/src/Model/Validator/ArrayItemValidator.php
ERROR: Parse error at line 26 column 13:
16: use PHPModelGenerator\SchemaProcessor\SchemaProcessor;
17: use PHPModelGenerator\Utils\RenderHelper;
18:
19: /**
20: * Class ArrayItemValidator
21: *
22: * @package PHPModelGenerator\Model\Validator
23: */
24: class ArrayItemValidator extends ExtractedMethodValidator
25: {
26: private string $variableSuffix;
^
27: private PropertyInterface $nestedProperty;
28:
29: /**
30: * ArrayItemValidator constructor.
31: *
32: * @throws SchemaException
33: */
34: public function __construct(
35: SchemaProcessor $schemaProcessor,
36: Schema $schema,
ERROR: Unable to parse file: /code/src/Model/Validator/InstanceOfValidator.php
ERROR: Parse error at line 27 column 13:
17: /**
18: * InstanceOfValidator constructor.
19: */
20: public function __construct(PropertyInterface $property)
21: {
22: parent::__construct(
23: $property,
24: sprintf(
25: 'is_object($value) && !($value instanceof \Exception) && !($value instanceof %s)',
26: $property->getType()->getName(),
27: ),
^
28: InvalidInstanceOfException::class,
29: [$property->getType()->getName()],
30: );
31: }
32: }
33:
ERROR: Unable to parse file: /code/src/Model/Validator/ReflectionTypeCheckValidator.php
ERROR: Parse error at line 20 column 5:
10: /**
11: * Class ReflectionTypeCheckValidator
12: *
13: * @package PHPModelGenerator\Model\Validator
14: */
15: class ReflectionTypeCheckValidator extends PropertyValidator
16: {
17: public static function fromReflectionType(
18: ReflectionType $reflectionType,
19: PropertyInterface $property,
20: ): self {
^
21: return new self(
22: $reflectionType->isBuiltin(),
23: $reflectionType->getName(),
24: $property,
25: );
26: }
27:
28: public static function fromType(
29: string $type,
30: PropertyInterface $property,
ERROR: Unable to parse file: /code/src/Model/Validator/PassThroughTypeCheckValidator.php
ERROR: Parse error at line 19 column 15:
9: use ReflectionType;
10:
11: /**
12: * Class PassThroughTypeCheckValidator
13: *
14: * @package PHPModelGenerator\Model\Validator
15: */
16: class PassThroughTypeCheckValidator extends PropertyValidator implements TypeCheckInterface
17: {
18: /** @var string[] */
19: protected array $types;
^
20:
21: /**
22: * PassThroughTypeCheckValidator constructor.
23: */
24: public function __construct(
25: ReflectionType $passThroughType,
26: PropertyInterface $property,
27: TypeCheckValidator $typeCheckValidator,
28: ) {
29: $this->types = array_merge($typeCheckValidator->getTypes(), [$passThroughType->getName()]);
ERROR: Unable to parse file: /code/src/Model/Validator/AdditionalPropertiesValidator.php
ERROR: Parse error at line 33 column 13:
23: */
24: class AdditionalPropertiesValidator extends PropertyTemplateValidator
25: {
26: protected const PROPERTY_NAME = 'additional property';
27:
28: protected const PROPERTIES_KEY = 'properties';
29: protected const ADDITIONAL_PROPERTIES_KEY = 'additionalProperties';
30:
31: protected const EXCEPTION_CLASS = InvalidAdditionalPropertiesException::class;
32:
33: private PropertyInterface $validationProperty;
^
34: private bool $collectAdditionalProperties = false;
35:
36: /**
37: * AdditionalPropertiesValidator constructor.
38: *
39: * @throws SchemaException
40: */
41: public function __construct(
42: SchemaProcessor $schemaProcessor,
43: Schema $schema,
ERROR: Unable to parse file: /code/src/Model/Validator/PropertyTemplateValidator.php
ERROR: Parse error at line 25 column 20:
15: *
16: * @package PHPModelGenerator\Model\Validator
17: */
18: class PropertyTemplateValidator extends AbstractPropertyValidator
19: {
20: /** @var array */
21: protected $templateValues;
22: /** @var Schema|null */
23: protected $scope;
24:
25: static private ?Render $renderer = null;
^
26:
27: /**
28: * PropertyTemplateValidator constructor.
29: */
30: public function __construct(
31: PropertyInterface $property,
32: protected string $template,
33: array $templateValues,
34: string $exceptionClass,
35: array $exceptionParams = [],
ERROR: Unable to parse file: /code/src/Model/Validator/MultiTypeCheckValidator.php
ERROR: Parse error at line 22 column 33:
12: *
13: * @package PHPModelGenerator\Model\Validator
14: */
15: class MultiTypeCheckValidator extends PropertyValidator implements TypeCheckInterface
16: {
17: /**
18: * MultiTypeCheckValidator constructor.
19: *
20: * @param string[] $types
21: */
22: public function __construct(protected array $types, PropertyInterface $property, bool $allowImplicitNull)
^
23: {
24: // if null is explicitly allowed we don't need an implicit null pass through
25: if (in_array('null', $this->types)) {
26: $allowImplicitNull = false;
27: }
28:
29: parent::__construct(
30: $property,
31: join(
32: ' && ',
ERROR: Unable to parse file: /code/src/Model/Validator/PatternPropertiesValidator.php
ERROR: Parse error at line 26 column 13:
16: use PHPModelGenerator\SchemaProcessor\SchemaProcessor;
17: use PHPModelGenerator\Utils\RenderHelper;
18:
19: /**
20: * Class PatternPropertiesValidator
21: *
22: * @package PHPModelGenerator\Model\Validator
23: */
24: class PatternPropertiesValidator extends PropertyTemplateValidator
25: {
26: private PropertyInterface $validationProperty;
^
27: private string $key;
28:
29: /**
30: * PatternPropertiesValidator constructor.
31: *
32: * @throws SchemaException
33: */
34: public function __construct(
35: SchemaProcessor $schemaProcessor,
36: Schema $schema,
ERROR: Unable to parse file: /code/src/Model/Validator/ArrayTupleValidator.php
ERROR: Parse error at line 27 column 13:
17: use PHPModelGenerator\Utils\RenderHelper;
18:
19: /**
20: * Class ArrayTupleValidator
21: *
22: * @package PHPModelGenerator\Model\Validator
23: */
24: class ArrayTupleValidator extends PropertyTemplateValidator
25: {
26: /** @var PropertyInterface[] */
27: private array $tupleProperties;
^
28:
29: /**
30: * ArrayTupleValidator constructor.
31: *
32: * @throws SchemaException
33: */
34: public function __construct(
35: SchemaProcessor $schemaProcessor,
36: Schema $schema,
37: JsonSchema $propertiesStructure,
ERROR: Unable to parse file: /code/src/Model/Validator/NoAdditionalPropertiesValidator.php
ERROR: Parse error at line 34 column 9:
24:
25: parent::__construct(
26: $property,
27: DIRECTORY_SEPARATOR . 'Validator' . DIRECTORY_SEPARATOR . 'NoAdditionalProperties.phptpl',
28: [
29: 'properties' => RenderHelper::varExportArray(array_keys($json['properties'] ?? [])),
30: 'pattern' => addcslashes(join('|', array_keys($json['patternProperties'] ?? [])), "'/"),
31: ],
32: AdditionalPropertiesException::class,
33: ['&$additionalProperties'],
34: );
^
35: }
36: }
37:
ERROR: Unable to parse file: /code/src/Model/Validator/PropertyValidator.php
ERROR: Parse error at line 21 column 9:
11: *
12: * @package PHPModelGenerator\Model\Validator
13: */
14: class PropertyValidator extends AbstractPropertyValidator
15: {
16: /**
17: * PropertyValidator constructor.
18: */
19: public function __construct(
20: PropertyInterface $property,
21: protected string $check,
^
22: string $exceptionClass,
23: array $exceptionParams = [],
24: ) {
25: $this->isResolved = true;
26:
27: parent::__construct($property, $exceptionClass, $exceptionParams);
28: }
29:
30: /**
31: * Get the source code for the check to perform
ERROR: Unable to parse file: /code/src/Model/Validator/ConditionalPropertyValidator.php
ERROR: Parse error at line 24 column 5:
14: *
15: * @package PHPModelGenerator\Model\Validator
16: */
17: class ConditionalPropertyValidator extends AbstractComposedPropertyValidator
18: {
19: public function __construct(
20: GeneratorConfiguration $generatorConfiguration,
21: PropertyInterface $property,
22: array $composedProperties,
23: array $validatorVariables,
24: ) {
^
25: $this->isResolved = true;
26:
27: parent::__construct(
28: $generatorConfiguration,
29: $property,
30: DIRECTORY_SEPARATOR . 'Validator' . DIRECTORY_SEPARATOR . 'ConditionalComposedItem.phptpl',
31: $validatorVariables,
32: ConditionalException::class,
33: ['&$ifException', '&$thenException', '&$elseException'],
34: );
ERROR: Unable to parse file: /code/src/Model/Validator/PropertyDependencyValidator.php
ERROR: Parse error at line 33 column 9:
23: $this->isResolved = true;
24:
25: parent::__construct(
26: $property,
27: DIRECTORY_SEPARATOR . 'Validator' . DIRECTORY_SEPARATOR . 'PropertyDependency.phptpl',
28: [
29: 'dependencies' => RenderHelper::varExportArray(array_values($dependencies)),
30: ],
31: InvalidPropertyDependencyException::class,
32: ['&$missingAttributes'],
33: );
^
34: }
35:
36: /**
37: * Initialize all variables which are required to execute a property names validator
38: */
39: public function getValidatorSetUp(): string
40: {
41: return '$missingAttributes = [];';
42: }
43: }
ERROR: Unable to parse file: /code/src/Model/Validator/ExtractedMethodValidator.php
ERROR: Parse error at line 18 column 13:
8: use PHPModelGenerator\Model\MethodInterface;
9: use PHPModelGenerator\Model\Property\PropertyInterface;
10: use PHPModelGenerator\Utils\RenderHelper;
11:
12: /**
13: * Renders the validator in a separate method. Might be required for recursive validations which would otherwise cause
14: * infinite loops during validator rendering
15: */
16: abstract class ExtractedMethodValidator extends PropertyTemplateValidator
17: {
18: private string $extractedMethodName;
^
19:
20: public function __construct(
21: private GeneratorConfiguration $generatorConfiguration,
22: PropertyInterface $property,
23: string $template,
24: array $templateValues,
25: string $exceptionClass,
26: array $exceptionParams = [],
27: ) {
28: $this->extractedMethodName = sprintf(
ERROR: Unable to parse file: /code/src/Model/Validator/AbstractPropertyValidator.php
ERROR: Parse error at line 24 column 9:
14: * @package PHPModelGenerator\Model\Validator
15: */
16: abstract class AbstractPropertyValidator implements PropertyValidatorInterface
17: {
18: use ResolvableTrait;
19:
20: /**
21: * AbstractPropertyValidator constructor.
22: */
23: public function __construct(
24: protected PropertyInterface $property,
^
25: protected string $exceptionClass,
26: protected array $exceptionParams = [],
27: ) {}
28:
29: /**
30: * @inheritDoc
31: */
32: public function withProperty(PropertyInterface $property): PropertyValidatorInterface
33: {
34: $clone = clone $this;
ERROR: Unable to parse file: /code/src/Model/Validator/SchemaDependencyValidator.php
ERROR: Parse error at line 44 column 21:
34: DIRECTORY_SEPARATOR . 'Validator' . DIRECTORY_SEPARATOR . 'SchemaDependency.phptpl',
35: [
36: 'viewHelper' => new RenderHelper($schemaProcessor->getGeneratorConfiguration()),
37: 'generatorConfiguration' => $schemaProcessor->getGeneratorConfiguration(),
38: 'transferProperties' => $schema->getProperties(),
39: // set up a helper property for handling of the nested object
40: 'nestedProperty' => (new Property("{$property->getName()}Dependency", null, $schema->getJsonSchema()))
41: ->addDecorator(new ObjectInstantiationDecorator(
42: $schema->getClassName(),
43: $schemaProcessor->getGeneratorConfiguration(),
44: ))
^
45: ],
46: InvalidSchemaDependencyException::class,
47: ['&$dependencyException'],
48: );
49: }
50:
51: /**
52: * Initialize all variables which are required to execute a property names validator
53: */
54: public function getValidatorSetUp(): string
ERROR: Unable to parse file: /code/src/Model/Validator/FilterValidator.php
ERROR: Parse error at line 33 column 9:
23: class FilterValidator extends PropertyTemplateValidator
24: {
25: /**
26: * FilterValidator constructor.
27: *
28: * @throws SchemaException
29: * @throws ReflectionException
30: */
31: public function __construct(
32: GeneratorConfiguration $generatorConfiguration,
33: protected FilterInterface $filter,
^
34: PropertyInterface $property,
35: protected array $filterOptions = [],
36: ?TransformingFilterInterface $transformingFilter = null,
37: ) {
38: $this->isResolved = true;
39:
40: $transformingFilter === null
41: ? $this->validateFilterCompatibilityWithBaseType($this->filter, $property)
42: : $this->validateFilterCompatibilityWithTransformedType($this->filter, $transformingFilter, $property);
43:
ERROR: Unable to parse file: /code/src/Model/Validator/TypeCheckValidator.php
ERROR: Parse error at line 17 column 15:
7: use PHPModelGenerator\Exception\Generic\InvalidTypeException;
8: use PHPModelGenerator\Model\Property\PropertyInterface;
9:
10: /**
11: * Class TypeCheckValidator
12: *
13: * @package PHPModelGenerator\Model\Validator
14: */
15: class TypeCheckValidator extends PropertyValidator implements TypeCheckInterface
16: {
17: protected string $type;
^
18:
19: /**
20: * TypeCheckValidator constructor.
21: */
22: public function __construct(string $type, PropertyInterface $property, bool $allowImplicitNull)
23: {
24: $this->type = strtolower($type);
25:
26: parent::__construct(
27: $property,
ERROR: Unable to parse file: /code/src/Model/Validator/EnumValidator.php
ERROR: Parse error at line 28 column 9:
18: /**
19: * EnumValidator constructor.
20: */
21: public function __construct(PropertyInterface $property, array $allowedValues)
22: {
23: parent::__construct(
24: $property,
25: '!in_array($value, ' . RenderHelper::varExportArray($allowedValues) . ', true)',
26: EnumException::class,
27: [$allowedValues],
28: );
^
29: }
30: }
31:
ERROR: Unable to parse file: /code/src/Model/Validator/PropertyNamesValidator.php
ERROR: Parse error at line 35 column 5:
25: {
26: /**
27: * PropertyNamesValidator constructor.
28: *
29: * @throws SchemaException
30: */
31: public function __construct(
32: SchemaProcessor $schemaProcessor,
33: Schema $schema,
34: JsonSchema $propertiesNames,
35: ) {
^
36: $this->isResolved = true;
37:
38: $processor = array_key_exists('const', $propertiesNames->getJson())
39: ? ConstProcessor::class
40: : StringProcessor::class;
41:
42: if ($processor === ConstProcessor::class && gettype($propertiesNames->getJson()['const']) !== 'string') {
43: throw new SchemaException("Invalid const property name in file {$propertiesNames->getFile()}");
44: }
45:
ERROR: Unable to parse file: /code/src/Model/Validator/FormatValidator.php
ERROR: Parse error at line 24 column 9:
14: *
15: * @package PHPModelGenerator\Model\Validator
16: */
17: class FormatValidator extends AbstractPropertyValidator
18: {
19: /**
20: * FormatValidator constructor.
21: */
22: public function __construct(
23: PropertyInterface $property,
24: protected FormatValidatorInterface $validator,
^
25: array $exceptionParams = [],
26: ) {
27: $this->isResolved = true;
28:
29: parent::__construct($property, FormatException::class, $exceptionParams);
30: }
31:
32: /**
33: * Get the source code for the check to perform
34: */
ERROR: Unable to parse file: /code/src/Model/GeneratorConfiguration.php
ERROR: Parse error at line 77 column 13:
67: *
68: * @throws Exception
69: * @throws InvalidFilterException
70: */
71: public function addFilter(FilterInterface ...$additionalFilter): self
72: {
73: foreach ($additionalFilter as $filter) {
74: $this->validateFilterCallback(
75: $filter->getFilter(),
76: "Invalid filter callback for filter {$filter->getToken()}",
77: );
^
78:
79: if ($filter instanceof TransformingFilterInterface) {
80: $this->validateFilterCallback(
81: $filter->getSerializer(),
82: "Invalid serializer callback for filter {$filter->getToken()}"
83: );
84: }
85:
86: foreach ($filter->getAcceptedTypes() as $acceptedType) {
87: if (!in_array($acceptedType, ['integer', 'number', 'boolean', 'string', 'array', 'null']) &&
ERROR: Unable to parse file: /code/src/Model/RenderJob.php
ERROR: Parse error at line 33 column 9:
23: {
24: /**
25: * Create a new class render job
26: *
27: * @param string $fileName The file name
28: * @param string $classPath The relative path of the class for namespace generation
29: * @param string $className The class name
30: * @param Schema $schema The Schema object which holds properties and validators
31: */
32: public function __construct(
33: protected string $fileName,
^
34: protected string $classPath,
35: protected string $className,
36: protected Schema $schema,
37: ) {}
38:
39: /**
40: * @param PostProcessor[] $postProcessors
41: */
42: public function postProcess(array $postProcessors, GeneratorConfiguration $generatorConfiguration): void
43: {
ERROR: Unable to parse file: /code/src/Model/Schema.php
ERROR: Parse error at line 50 column 15:
40: * before adding properties to the model
41: */
42: protected $baseValidators = [];
43: /** @var string[] */
44: protected $usedClasses = [];
45: /** @var SchemaNamespaceTransferDecorator[] */
46: protected $namespaceTransferDecorators = [];
47: /** @var SchemaHookInterface[] */
48: protected $schemaHooks = [];
49:
50: protected SchemaDefinitionDictionary $schemaDefinitionDictionary;
^
51:
52: private int $resolvedProperties = 0;
53: /** @var callable[] */
54: private array $onAllPropertiesResolvedCallbacks = [];
55:
56: /**
57: * Schema constructor.
58: */
59: public function __construct(
60: protected string $classPath,
ERROR: Unable to parse file: /code/src/SchemaProcessor/PostProcessor/Internal/ExtendObjectPropertiesMatchingPatternPropertiesPostProcessor.php
ERROR: Parse error at line 31 column 45:
21: {
22: /**
23: * @throws SchemaException
24: */
25: public function process(Schema $schema, GeneratorConfiguration $generatorConfiguration): void
26: {
27: $this->transferPatternPropertiesFilterToProperty($schema, $generatorConfiguration);
28:
29: $schema->addSchemaHook(
30: new class ($schema) implements SetterBeforeValidationHookInterface {
31: public function __construct(private Schema $schema) {}
^
32:
33: public function getCode(PropertyInterface $property, bool $batchUpdate = false): string
34: {
35: $json = $this->schema->getJsonSchema()->getJson();
36: // A batch update must execute the base validators to check the integrity of the object.
37: // Consequently, the schema hook must not add validation code in that places.
38: if ($batchUpdate || !isset($json['patternProperties'])) {
39: return '';
40: }
41:
ERROR: Unable to parse file: /code/src/SchemaProcessor/PostProcessor/Internal/SerializationPostProcessor.php
ERROR: Parse error at line 61 column 5:
51: }
52: }
53:
54: /**
55: * Each transforming filter must provide a method to serialize the value. Add a method to the schema to call the
56: * serialization for each property with a transforming filter
57: */
58: private function addSerializeFunctionsForTransformingFilters(
59: Schema $schema,
60: GeneratorConfiguration $generatorConfiguration,
61: ): void {
^
62: foreach ($schema->getProperties() as $property) {
63: foreach ($property->getValidators() as $validator) {
64: $validator = $validator->getValidator();
65:
66: if ($validator instanceof FilterValidator &&
67: $validator->getFilter() instanceof TransformingFilterInterface
68: ) {
69: [$serializerClass, $serializerMethod] = $validator->getFilter()->getSerializer();
70:
71: $schema->addMethod(
ERROR: Unable to parse file: /code/src/SchemaProcessor/PostProcessor/Internal/PatternPropertiesPostProcessor.php
ERROR: Parse error at line 46 column 21:
36: $patternHashes = [];
37: $schemaProperties = array_keys($json['properties'] ?? []);
38:
39: foreach ($schema->getBaseValidators() as $validator) {
40: if (is_a($validator, PatternPropertiesValidator::class)) {
41: if (array_key_exists($validator->getKey(), $patternHashes)) {
42: $key = $json['patternProperties'][$validator->getPattern()]['key'] ?? $validator->getPattern();
43:
44: throw new SchemaException(
45: "Duplicate pattern property access key '$key' in file {$schema->getJsonSchema()->getFile()}",
46: );
^
47: }
48:
49: $patternHashes[$validator->getKey()] = array_reduce(
50: $schema->getProperties(),
51: static function (
52: array $carry,
53: PropertyInterface $property,
54: ) use ($schemaProperties, $validator): array {
55: if (in_array($property->getName(), $schemaProperties) &&
56: preg_match('/' . addcslashes($validator->getPattern(), '/') . '/', $property->getName())
ERROR: Unable to parse file: /code/src/SchemaProcessor/PostProcessor/Internal/CompositionValidationPostProcessor.php
ERROR: Parse error at line 81 column 17:
71: }
72: }
73:
74: if (!empty($validatorPropertyMap)) {
75: $schema->addProperty(
76: (new Property(
77: 'propertyValidationState',
78: new PropertyType('array'),
79: new JsonSchema(__FILE__, []),
80: 'Track the internal validation state of composed validations',
81: ))
^
82: ->setInternal(true)
83: ->setDefaultValue(
84: array_fill_keys(
85: array_unique(
86: array_merge(...array_values($validatorPropertyMap)),
87: ),
88: [],
89: )
90: ),
91: );
ERROR: Unable to parse file: /code/src/SchemaProcessor/PostProcessor/Internal/AdditionalPropertiesPostProcessor.php
ERROR: Parse error at line 57 column 9:
47: $validator->setCollectAdditionalProperties(true);
48: $validationProperty = $validator->getValidationProperty();
49: }
50: }
51:
52: $additionalPropertiesCollectionProperty = (new Property(
53: 'additionalProperties',
54: new PropertyType('array'),
55: new JsonSchema(__FILE__, []),
56: 'Collect all additional properties provided to the schema',
57: ))
^
58: ->setDefaultValue([])
59: ->setInternal(true);
60:
61: if ($validationProperty) {
62: $additionalPropertiesCollectionProperty->addTypeHintDecorator(
63: new ArrayTypeHintDecorator($validationProperty),
64: );
65: }
66:
67: $schema->addProperty($additionalPropertiesCollectionProperty);
ERROR: Unable to parse file: /code/src/SchemaProcessor/PostProcessor/RenderedMethod.php
ERROR: Parse error at line 23 column 20:
13: use PHPModelGenerator\Model\Schema;
14: use PHPModelGenerator\Utils\RenderHelper;
15:
16: /**
17: * Class RenderedMethod
18: *
19: * @package PHPModelGenerator\SchemaProcessor\PostProcessor
20: */
21: class RenderedMethod implements MethodInterface
22: {
23: static private ?Render $renderer = null;
^
24:
25: public function __construct(
26: private Schema $schema,
27: private GeneratorConfiguration $generatorConfiguration,
28: private string $template,
29: private array $templateValues = [],
30: ) {}
31:
32: /**
33: * @inheritDoc
ERROR: Unable to parse file: /code/src/SchemaProcessor/PostProcessor/EnumPostProcessor.php
ERROR: Parse error at line 31 column 13:
21: use PHPModelGenerator\ModelGenerator;
22: use PHPModelGenerator\PropertyProcessor\Filter\FilterProcessor;
23: use PHPModelGenerator\Utils\ArrayHash;
24: use PHPModelGenerator\Utils\NormalizedName;
25:
26: /**
27: * Generates a PHP enum for enums from JSON schemas which are automatically mapped for properties holding the enum
28: */
29: class EnumPostProcessor extends PostProcessor
30: {
31: private array $generatedEnums = [];
^
32:
33: private string $namespace;
34: private Render $renderer;
35: private string $targetDirectory;
36:
37: /**
38: * @param string $targetDirectory The directory where to put the generated PHP enums
39: * @param string $namespace The namespace for the generated enums
40: * @param bool $skipNonMappedEnums By default, enums which not contain only strings and don't provide a mapping for
41: * the enum will throw an exception. If set to true, those enums will be skipped
ERROR: Unable to parse file: /code/src/SchemaProcessor/PostProcessor/PatternPropertiesAccessorPostProcessor.php
ERROR: Parse error at line 54 column 5:
44:
45: /**
46: * Adds a method to get a list of pattern properties by property key or pattern
47: *
48: * @param PropertyType[] $patternTypes
49: */
50: private function addGetPatternPropertiesMethod(
51: Schema $schema,
52: GeneratorConfiguration $generatorConfiguration,
53: array $patternTypes,
54: ): void {
^
55: $schema
56: ->addUsedClass(UnknownPatternPropertyException::class)
57: ->addMethod(
58: 'getPatternProperties',
59: new RenderedMethod(
60: $schema,
61: $generatorConfiguration,
62: 'PatternProperties/GetPatternProperties.phptpl',
63: [
64: 'returnTypeAnnotation' => $this->getReturnTypeAnnotationForGetPatternProperties($patternTypes),
ERROR: Unable to parse file: /code/src/SchemaProcessor/PostProcessor/AdditionalPropertiesAccessorPostProcessor.php
ERROR: Parse error at line 39 column 33:
29: class AdditionalPropertiesAccessorPostProcessor extends PostProcessor
30: {
31: /**
32: * AdditionalPropertiesAccessorPostProcessor constructor.
33: *
34: * @param bool $addForModelsWithoutAdditionalPropertiesDefinition By default, the additional properties accessor
35: * methods will be added only to schemas defining additionalProperties constraints as these models expect additional
36: * properties. If set to true the accessor methods will be generated for models which don't define
37: * additionalProperties constraints.
38: */
39: public function __construct(private bool $addForModelsWithoutAdditionalPropertiesDefinition = false) {}
^
40:
41: /**
42: * Add methods to handle additional properties to the provided schema
43: *
44: * @throws SchemaException
45: */
46: public function process(Schema $schema, GeneratorConfiguration $generatorConfiguration): void
47: {
48: $json = $schema->getJsonSchema()->getJson();
49:
ERROR: Unable to parse file: /code/src/SchemaProcessor/PostProcessor/PopulatePostProcessor.php
ERROR: Parse error at line 30 column 13:
20: $schema->addMethod(
21: 'populate',
22: new RenderedMethod(
23: $schema,
24: $generatorConfiguration,
25: 'Populate.phptpl',
26: [
27: 'schemaHookResolver' => new SchemaHookResolver($schema),
28: 'true' => true,
29: ],
30: )
^
31: );
32: }
33: }
34:
ERROR: Unable to parse file: /code/src/SchemaProcessor/SchemaProcessor.php
ERROR: Parse error at line 47 column 9:
37: protected $processedSchema = [];
38: /** @var PropertyInterface[] Collect processed schemas to avoid duplicated classes */
39: protected $processedMergedProperties = [];
40: /** @var string[] */
41: protected $generatedFiles = [];
42:
43: /**
44: * SchemaProcessor constructor.
45: */
46: public function __construct(
47: protected string $baseSource,
^
48: protected string $destination,
49: protected GeneratorConfiguration $generatorConfiguration,
50: protected RenderQueue $renderQueue,
51: ) {}
52:
53: /**
54: * Process a given json schema file
55: *
56: * @throws SchemaException
57: */
ERROR: Unable to parse file: /code/src/SchemaProcessor/Hook/SchemaHookResolver.php
ERROR: Parse error at line 12 column 33:
2:
3: declare(strict_types=1);
4:
5: namespace PHPModelGenerator\SchemaProcessor\Hook;
6:
7: use PHPModelGenerator\Model\Property\PropertyInterface;
8: use PHPModelGenerator\Model\Schema;
9:
10: class SchemaHookResolver
11: {
12: public function __construct(private Schema $schema) {}
^
13:
14: public function resolveConstructorBeforeValidationHook(): string
15: {
16: return $this->resolveHook(ConstructorBeforeValidationHookInterface::class);
17: }
18:
19: public function resolveConstructorAfterValidationHook(): string
20: {
21: return $this->resolveHook(ConstructorAfterValidationHookInterface::class);
22: }
ERROR: Unable to parse file: /code/rector.php
ERROR: Parse error at line 22 column 17:
12: use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector;
13: use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictSetUpRector;
14:
15: return RectorConfig::configure()
16: ->withPaths([
17: __DIR__ . '/src',
18: __DIR__ . '/tests',
19: ])
20: ->withPhpSets()
21: ->withPreparedSets(
22: deadCode: true,
^
23: typeDeclarations: true,
24: privatization: true,
25: earlyReturn: true,
26: phpunitCodeQuality: true,
27: )
28: ->withRules([
29: ClassPropertyAssignToConstructorPromotionRector::class,
30: ])
31: ->withSkip([
32: GetDebugTypeRector::class,
INFO: 131/131 source files have been analyzed
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 0.689s
INFO: Final Memory: 6M/95M
INFO: ------------------------------------------------------------------------
|