Passed
Pull Request — master (#40)
by Alex
03:15
created
Edm/Validation/ValidationRules/IModel/ModelDuplicateEntityContainerName.php 1 patch
Braces   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -25,9 +25,8 @@
 block discarded – undo
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(
Please login to merge, or discard this patch.
Edm/Validation/ValidationRules/IModel/ModelDuplicateSchemaElementName.php 1 patch
Braces   +14 added lines, -33 removed lines patch added patch discarded remove patch
@@ -27,61 +27,42 @@
 block discarded – undo
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(),
Please login to merge, or discard this patch.
IFunctionImport/FunctionImportParametersCannotHaveModeOfNone.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -20,10 +20,8 @@
 block discarded – undo
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(),
Please login to merge, or discard this patch.
FunctionImportComposableFunctionImportCannotBeSideEffecting.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,8 +20,7 @@
 block discarded – undo
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(),
Please login to merge, or discard this patch.
IFunctionImport/FunctionImportReturnEntitiesButDoesNotSpecifyEntitySet.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -21,14 +21,12 @@
 block discarded – undo
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(),
Please login to merge, or discard this patch.
IFunctionImport/FunctionImportParametersIncorrectTypeBeforeV3.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -20,13 +20,11 @@
 block discarded – undo
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(),
Please login to merge, or discard this patch.
IFunctionImport/FunctionImportEntityTypeDoesNotMatchEntitySet.php 1 patch
Braces   +7 added lines, -16 removed lines patch added patch discarded remove patch
@@ -24,13 +24,11 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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(),
Please login to merge, or discard this patch.
IFunctionImport/FunctionImportIsBindableNotSupportedBeforeV3.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,8 +20,7 @@
 block discarded – undo
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(),
Please login to merge, or discard this patch.
ValidationRules/IFunctionImport/FunctionImportUnsupportedReturnTypeV1.php 1 patch
Braces   +4 added lines, -9 removed lines patch added patch discarded remove patch
@@ -21,20 +21,15 @@
 block discarded – undo
21 21
     public function __invoke(ValidationContext $context, ?IEdmElement $functionImport)
22 22
     {
23 23
         assert($functionImport instanceof IFunctionImport);
24
-        if ($functionImport->getReturnType() != null)
25
-        {
26
-            if ($functionImport->getReturnType()->IsCollection())
27
-            {
24
+        if ($functionImport->getReturnType() != null) {
25
+            if ($functionImport->getReturnType()->IsCollection()) {
28 26
                 $elementType = $functionImport->getReturnType()->AsCollection()->ElementType();
29 27
                 $reportError = !$elementType->IsPrimitive() && !$elementType->IsEntity() && !$context->checkIsBad($elementType->getDefinition());
30
-            }
31
-            else
32
-            {
28
+            } else {
33 29
                 $reportError = true;
34 30
             }
35 31
 
36
-            if ($reportError && !$context->checkIsBad($functionImport->getReturnType()->getDefinition()))
37
-            {
32
+            if ($reportError && !$context->checkIsBad($functionImport->getReturnType()->getDefinition())) {
38 33
                 $context->AddError(
39 34
                     $functionImport->Location(),
40 35
                     EdmErrorCode::FunctionImportUnsupportedReturnType(),
Please login to merge, or discard this patch.