@@ -35,7 +35,7 @@ |
||
35 | 35 | if (!$item->getSchemaElementKind()->isEntityContainer()) |
36 | 36 | { |
37 | 37 | $function = $item; |
38 | - if ( $function instanceof IFunction) |
|
38 | + if ($function instanceof IFunction) |
|
39 | 39 | { |
40 | 40 | // If a non-function already exists with the same name, stop processing as a function, as it is irrelevant it will always be an error. |
41 | 41 | if ($nonFunctionNameList->contains($fullName)) |
@@ -28,63 +28,43 @@ |
||
28 | 28 | assert($model instanceof IModel); |
29 | 29 | $nonFunctionNameList = new HashSetInternal(); |
30 | 30 | $functionDictionary = []; |
31 | - foreach ($model->getSchemaElements() as $item) |
|
32 | - { |
|
31 | + foreach ($model->getSchemaElements() as $item) { |
|
33 | 32 | $duplicate = false; |
34 | 33 | $fullName = $item->FullName(); |
35 | - if (!$item->getSchemaElementKind()->isEntityContainer()) |
|
36 | - { |
|
34 | + if (!$item->getSchemaElementKind()->isEntityContainer()) { |
|
37 | 35 | $function = $item; |
38 | - if ( $function instanceof IFunction) |
|
39 | - { |
|
36 | + if ( $function instanceof IFunction) { |
|
40 | 37 | // If a non-function already exists with the same name, stop processing as a function, as it is irrelevant it will always be an error. |
41 | - if ($nonFunctionNameList->contains($fullName)) |
|
42 | - { |
|
38 | + if ($nonFunctionNameList->contains($fullName)) { |
|
43 | 39 | $duplicate = true; |
44 | - } |
|
45 | - else |
|
46 | - { |
|
40 | + } else { |
|
47 | 41 | $functionList = null; |
48 | - if (isset($function[$fullName])) |
|
49 | - { |
|
50 | - if (count(array_filter($function[$fullName], [EdmElementComparer::class, 'isFunctionSignatureEquivalentTo'])) !== 0) |
|
51 | - { |
|
42 | + if (isset($function[$fullName])) { |
|
43 | + if (count(array_filter($function[$fullName], [EdmElementComparer::class, 'isFunctionSignatureEquivalentTo'])) !== 0) { |
|
52 | 44 | $duplicate = true; |
53 | 45 | } |
54 | - } |
|
55 | - else |
|
56 | - { |
|
46 | + } else { |
|
57 | 47 | $functionDictionary[$fullName] = []; |
58 | 48 | } |
59 | 49 | $functionDictionary[$fullName][] = $function; |
60 | 50 | } |
61 | 51 | |
62 | - if (!$duplicate) |
|
63 | - { |
|
52 | + if (!$duplicate) { |
|
64 | 53 | $duplicate = ValidationHelper::FunctionOrNameExistsInReferencedModel($model, $function, $fullName, false); |
65 | 54 | } |
66 | - } |
|
67 | - else |
|
68 | - { |
|
69 | - if (!$nonFunctionNameList->add($fullName)) |
|
70 | - { |
|
55 | + } else { |
|
56 | + if (!$nonFunctionNameList->add($fullName)) { |
|
71 | 57 | $duplicate = true; |
72 | - } |
|
73 | - else |
|
74 | - { |
|
75 | - if (isset($functionDictionary[$fullName])) |
|
76 | - { |
|
58 | + } else { |
|
59 | + if (isset($functionDictionary[$fullName])) { |
|
77 | 60 | $duplicate = true; |
78 | - } |
|
79 | - else |
|
80 | - { |
|
61 | + } else { |
|
81 | 62 | $duplicate = ValidationHelper::ItemExistsInReferencedModel($model, $fullName, false); |
82 | 63 | } |
83 | 64 | } |
84 | 65 | } |
85 | 66 | |
86 | - if ($duplicate) |
|
87 | - { |
|
67 | + if ($duplicate) { |
|
88 | 68 | $context->AddError( |
89 | 69 | $item->Location(), |
90 | 70 | EdmErrorCode::AlreadyDefined(), |
@@ -27,7 +27,7 @@ |
||
27 | 27 | $entityContainerNameList = new HashSetInternal(); |
28 | 28 | foreach ($model->getSchemaElements() as $item) |
29 | 29 | { |
30 | - if(!$item instanceof IEntityContainer){ |
|
30 | + if (!$item instanceof IEntityContainer) { |
|
31 | 31 | continue; |
32 | 32 | } |
33 | 33 | ValidationHelper::AddMemberNameToHashSet( |
@@ -25,9 +25,8 @@ |
||
25 | 25 | { |
26 | 26 | assert($model instanceof IModel); |
27 | 27 | $entityContainerNameList = new HashSetInternal(); |
28 | - foreach ($model->getSchemaElements() as $item) |
|
29 | - { |
|
30 | - if(!$item instanceof IEntityContainer){ |
|
28 | + foreach ($model->getSchemaElements() as $item) { |
|
29 | + if(!$item instanceof IEntityContainer) { |
|
31 | 30 | continue; |
32 | 31 | } |
33 | 32 | ValidationHelper::AddMemberNameToHashSet( |
@@ -75,7 +75,7 @@ |
||
75 | 75 | } |
76 | 76 | else |
77 | 77 | { |
78 | - $duplicate = ValidationHelper::ItemExistsInReferencedModel($model,$fullName, true); |
|
78 | + $duplicate = ValidationHelper::ItemExistsInReferencedModel($model, $fullName, true); |
|
79 | 79 | } |
80 | 80 | } |
81 | 81 | } |
@@ -27,61 +27,42 @@ |
||
27 | 27 | assert($model instanceof IModel); |
28 | 28 | $nonFunctionNameList = new HashSetInternal(); |
29 | 29 | $functionDictionary = []; |
30 | - foreach ($model->getSchemaElements() as $item) |
|
31 | - { |
|
30 | + foreach ($model->getSchemaElements() as $item) { |
|
32 | 31 | $duplicate = false; |
33 | 32 | $fullName = $item->FullName(); |
34 | 33 | $function = $item; |
35 | - if ($function instanceof IFunction) |
|
36 | - { |
|
34 | + if ($function instanceof IFunction) { |
|
37 | 35 | // If a non-function already exists with the same name, stop processing as a function, as it is irrelevant it will always be an error. |
38 | - if ($nonFunctionNameList->contains($fullName)) |
|
39 | - { |
|
36 | + if ($nonFunctionNameList->contains($fullName)) { |
|
40 | 37 | $duplicate = true; |
41 | - } |
|
42 | - else |
|
43 | - { |
|
38 | + } else { |
|
44 | 39 | $functionList = null; |
45 | - if (isset($function[$fullName])) |
|
46 | - { |
|
47 | - if (count(array_filter($function[$fullName], [EdmElementComparer::class, 'isFunctionSignatureEquivalentTo'])) !== 0) |
|
48 | - { |
|
40 | + if (isset($function[$fullName])) { |
|
41 | + if (count(array_filter($function[$fullName], [EdmElementComparer::class, 'isFunctionSignatureEquivalentTo'])) !== 0) { |
|
49 | 42 | $duplicate = true; |
50 | 43 | } |
51 | - } |
|
52 | - else |
|
53 | - { |
|
44 | + } else { |
|
54 | 45 | $functionDictionary[$fullName] = []; |
55 | 46 | } |
56 | 47 | $functionDictionary[$fullName][] = $function; |
57 | 48 | } |
58 | 49 | |
59 | - if (!$duplicate) |
|
60 | - { |
|
50 | + if (!$duplicate) { |
|
61 | 51 | $duplicate = ValidationHelper::FunctionOrNameExistsInReferencedModel($model, $function, $fullName, true); |
62 | 52 | } |
63 | - } |
|
64 | - else |
|
65 | - { |
|
66 | - if (!$nonFunctionNameList->add($fullName)) |
|
67 | - { |
|
53 | + } else { |
|
54 | + if (!$nonFunctionNameList->add($fullName)) { |
|
68 | 55 | $duplicate = true; |
69 | - } |
|
70 | - else |
|
71 | - { |
|
72 | - if (isset($functionDictionary[$fullName])) |
|
73 | - { |
|
56 | + } else { |
|
57 | + if (isset($functionDictionary[$fullName])) { |
|
74 | 58 | $duplicate = true; |
75 | - } |
|
76 | - else |
|
77 | - { |
|
59 | + } else { |
|
78 | 60 | $duplicate = ValidationHelper::ItemExistsInReferencedModel($model,$fullName, true); |
79 | 61 | } |
80 | 62 | } |
81 | 63 | } |
82 | 64 | |
83 | - if ($duplicate) |
|
84 | - { |
|
65 | + if ($duplicate) { |
|
85 | 66 | $context->AddError( |
86 | 67 | $item->Location(), |
87 | 68 | EdmErrorCode::AlreadyDefined(), |
@@ -20,10 +20,8 @@ |
||
20 | 20 | public function __invoke(ValidationContext $context, ?IEdmElement $function) |
21 | 21 | { |
22 | 22 | assert($function instanceof IFunctionImport); |
23 | - foreach ($function->getParameters() as $parameter) |
|
24 | - { |
|
25 | - if ($parameter->getMode()->isNone() && !$context->checkIsBad($function)) |
|
26 | - { |
|
23 | + foreach ($function->getParameters() as $parameter) { |
|
24 | + if ($parameter->getMode()->isNone() && !$context->checkIsBad($function)) { |
|
27 | 25 | $context->AddError( |
28 | 26 | $parameter->Location(), |
29 | 27 | EdmErrorCode::InvalidFunctionImportParameterMode(), |
@@ -20,8 +20,7 @@ |
||
20 | 20 | public function __invoke(ValidationContext $context, ?IEdmElement $functionImport) |
21 | 21 | { |
22 | 22 | assert($functionImport instanceof IFunctionImport); |
23 | - if ($functionImport->isComposable() && $functionImport->isSideEffecting()) |
|
24 | - { |
|
23 | + if ($functionImport->isComposable() && $functionImport->isSideEffecting()) { |
|
25 | 24 | $context->AddError( |
26 | 25 | $functionImport->Location(), |
27 | 26 | EdmErrorCode::ComposableFunctionImportCannotBeSideEffecting(), |
@@ -21,14 +21,12 @@ |
||
21 | 21 | public function __invoke(ValidationContext $context, ?IEdmElement $functionImport) |
22 | 22 | { |
23 | 23 | assert($functionImport instanceof IFunctionImport); |
24 | - if ($functionImport->getReturnType() != null && $functionImport->getEntitySet() == null) |
|
25 | - { |
|
24 | + if ($functionImport->getReturnType() != null && $functionImport->getEntitySet() == null) { |
|
26 | 25 | $elementType = $functionImport->getReturnType()->IsCollection() ? |
27 | 26 | $functionImport->getReturnType()->AsCollection()->ElementType() |
28 | 27 | : |
29 | 28 | $functionImport->getReturnType(); |
30 | - if ($elementType->IsEntity() && !$context->checkIsBad($elementType->getDefinition())) |
|
31 | - { |
|
29 | + if ($elementType->IsEntity() && !$context->checkIsBad($elementType->getDefinition())) { |
|
32 | 30 | $context->AddError( |
33 | 31 | $functionImport->Location(), |
34 | 32 | EdmErrorCode::FunctionImportReturnsEntitiesButDoesNotSpecifyEntitySet(), |
@@ -20,13 +20,11 @@ |
||
20 | 20 | public function __invoke(ValidationContext $context, ?IEdmElement $functionImport) |
21 | 21 | { |
22 | 22 | assert($functionImport instanceof IFunctionImport); |
23 | - foreach ($functionImport->getParameters() as $functionParameter) |
|
24 | - { |
|
23 | + foreach ($functionImport->getParameters() as $functionParameter) { |
|
25 | 24 | $type = $functionParameter->getType(); |
26 | 25 | if ( |
27 | 26 | !$type->IsPrimitive() && !$type->IsComplex() && !$context->checkIsBad($type->getDefinition()) |
28 | - ) |
|
29 | - { |
|
27 | + ) { |
|
30 | 28 | $context->AddError( |
31 | 29 | $functionParameter->Location(), |
32 | 30 | EdmErrorCode::FunctionImportParameterIncorrectType(), |
@@ -27,8 +27,7 @@ |
||
27 | 27 | if ($functionImport->getEntitySet() != null && $functionImport->getReturnType() != null) |
28 | 28 | { |
29 | 29 | $elementType = $functionImport->getReturnType()->IsCollection() ? |
30 | - $functionImport->getReturnType()->AsCollection()->ElementType() : |
|
31 | - $functionImport->getReturnType(); |
|
30 | + $functionImport->getReturnType()->AsCollection()->ElementType() : $functionImport->getReturnType(); |
|
32 | 31 | if ($elementType->IsEntity()) |
33 | 32 | { |
34 | 33 | $returnedEntityType = $elementType->AsEntity()->EntityDefinition(); |
@@ -24,13 +24,11 @@ discard block |
||
24 | 24 | public function __invoke(ValidationContext $context, ?IEdmElement $functionImport) |
25 | 25 | { |
26 | 26 | assert($functionImport instanceof IFunctionImport); |
27 | - if ($functionImport->getEntitySet() != null && $functionImport->getReturnType() != null) |
|
28 | - { |
|
27 | + if ($functionImport->getEntitySet() != null && $functionImport->getReturnType() != null) { |
|
29 | 28 | $elementType = $functionImport->getReturnType()->IsCollection() ? |
30 | 29 | $functionImport->getReturnType()->AsCollection()->ElementType() : |
31 | 30 | $functionImport->getReturnType(); |
32 | - if ($elementType->IsEntity()) |
|
33 | - { |
|
31 | + if ($elementType->IsEntity()) { |
|
34 | 32 | $returnedEntityType = $elementType->AsEntity()->EntityDefinition(); |
35 | 33 | |
36 | 34 | /** |
@@ -45,8 +43,7 @@ discard block |
||
45 | 43 | * @var INavigationProperty[] $path |
46 | 44 | */ |
47 | 45 | $path = null; |
48 | - if ($functionImport->TryGetStaticEntitySet($entitySet)) |
|
49 | - { |
|
46 | + if ($functionImport->TryGetStaticEntitySet($entitySet)) { |
|
50 | 47 | $errorMessage = StringConst::EdmModel_Validator_Semantic_FunctionImportEntityTypeDoesNotMatchEntitySet( |
51 | 48 | $functionImport->getName(), |
52 | 49 | $returnedEntityType->FullName(), |
@@ -59,22 +56,18 @@ discard block |
||
59 | 56 | !$context->checkIsBad($returnedEntityType) && |
60 | 57 | !$context->checkIsBad($entitySet) && |
61 | 58 | !$context->checkIsBad($entitySetElementType) |
62 | - ) |
|
63 | - { |
|
59 | + ) { |
|
64 | 60 | $context->AddError( |
65 | 61 | $functionImport->Location(), |
66 | 62 | EdmErrorCode::FunctionImportEntityTypeDoesNotMatchEntitySet(), |
67 | 63 | $errorMessage); |
68 | 64 | } |
69 | - } |
|
70 | - else if ($functionImport->TryGetRelativeEntitySetPath($context->getModel(), $parameter, $path)) |
|
71 | - { |
|
65 | + } else if ($functionImport->TryGetRelativeEntitySetPath($context->getModel(), $parameter, $path)) { |
|
72 | 66 | $relativePathType = count($path) == 0 ? $parameter->getType() : end($path)->getType(); |
73 | 67 | $relativePathElementType = $relativePathType->IsCollection() ? $relativePathType->AsCollection()->ElementType() : $relativePathType; |
74 | 68 | if ( |
75 | 69 | !$returnedEntityType->IsOrInheritsFrom($relativePathElementType->getDefinition()) && |
76 | - !$context->checkIsBad($returnedEntityType) && !$context->checkIsBad($relativePathElementType->getDefinition())) |
|
77 | - { |
|
70 | + !$context->checkIsBad($returnedEntityType) && !$context->checkIsBad($relativePathElementType->getDefinition())) { |
|
78 | 71 | $context->AddError( |
79 | 72 | $functionImport->Location(), |
80 | 73 | EdmErrorCode::FunctionImportEntityTypeDoesNotMatchEntitySet(), |
@@ -83,9 +76,7 @@ discard block |
||
83 | 76 | } |
84 | 77 | |
85 | 78 | // The case when all try gets fail is caught by the FunctionImportEntitySetExpressionIsInvalid rule. |
86 | - } |
|
87 | - else if (!$context->checkIsBad($elementType->getDefinition())) |
|
88 | - { |
|
79 | + } else if (!$context->checkIsBad($elementType->getDefinition())) { |
|
89 | 80 | $context->AddError( |
90 | 81 | $functionImport->Location(), |
91 | 82 | EdmErrorCode::FunctionImportSpecifiesEntitySetButDoesNotReturnEntityType(), |
@@ -20,8 +20,7 @@ |
||
20 | 20 | public function __invoke(ValidationContext $context, ?IEdmElement $functionImport) |
21 | 21 | { |
22 | 22 | assert($functionImport instanceof IFunctionImport); |
23 | - if ($functionImport->isBindable() != CsdlConstants::Default_IsBindable) |
|
24 | - { |
|
23 | + if ($functionImport->isBindable() != CsdlConstants::Default_IsBindable) { |
|
25 | 24 | $context->AddError( |
26 | 25 | $functionImport->Location(), |
27 | 26 | EdmErrorCode::FunctionImportBindableNotSupportedBeforeV3(), |