N°8796 - Add PHP code style validation in iTop and extensions - format whole code base

This commit is contained in:
odain
2025-11-07 15:39:53 +01:00
parent 12f23113f5
commit 890a2568c8
2110 changed files with 53099 additions and 63885 deletions

View File

@@ -1,6 +1,5 @@
<?php
namespace Combodo\iTop\Test\UnitTest\Core;
use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
@@ -28,47 +27,47 @@ class ExpressionTranslateTest extends ItopDataTestCase
'simplest illustration of the concept: field translated into a scalar' => [
'before' => "alias1.column1",
'map' => "['alias1' => ['column1' => new \ScalarExpression('hello')]]",
'after' => "'hello'"
'after' => "'hello'",
],
'field translated wherever it is in the expression tree' => [
'before' => "1 + (2 * (3 / (4 - (5 + FLOOR(alias1.column1)))))",
'map' => "['alias1' => ['column1' => new \ScalarExpression('hello')]]",
'after' => "(1 + (2 * (3 / (4 - (5 + FLOOR('hello'))))))"
'after' => "(1 + (2 * (3 / (4 - (5 + FLOOR('hello'))))))",
],
'each and every occurrences of a field are translated' => [
'before' => "CONCAT(alias1.column1, alias1.column1)",
'map' => "['alias1' => ['column1' => new \ScalarExpression('hello')]]",
'after' => "CONCAT('hello', 'hello')"
'after' => "CONCAT('hello', 'hello')",
],
'field translated into a complex expression (decomposition)' => [
'before' => "alias1.column1",
'map' => "['alias1' => ['column1' => \Expression::FromOQL(\"CONCAT(person.first_name, ' ', contact.name)\")]]",
'after' => "CONCAT(`person`.`first_name`, ' ', `contact`.`name`)"
'after' => "CONCAT(`person`.`first_name`, ' ', `contact`.`name`)",
],
'translate several fields at once' => [
'before' => "CONCAT(`person`.`first_name`, ' ', `contact`.`name`)",
'map' => "['person' => ['*' => 'table_person'], 'contact' => ['*' => 'table_contact']]",
'after' => "CONCAT(`table_person`.`first_name`, ' ', `table_contact`.`name`)"
'after' => "CONCAT(`table_person`.`first_name`, ' ', `table_contact`.`name`)",
],
'translation is done once and only once' => [
'before' => "alias1.column1",
'map' => "['alias1' => ['column1' => \Expression::FromOQL('alias2.column1')], 'alias2' => ['column1' => new \ScalarExpression('translated again?')]]",
'after' => "`alias2`.`column1`"
'after' => "`alias2`.`column1`",
],
'translation of aliases, basic' => [
'before' => "alias1.column1",
'map' => "['alias1' => ['*' => 'A']]",
'after' => "`A`.`column1`"
'after' => "`A`.`column1`",
],
'translation of aliases, several hits and mappings' => [
'before' => "CONCAT(alias1.column1, alias1.column2, alias2.column1)",
'map' => "['alias1' => ['*' => 'A'], 'alias2' => ['*' => 'B']]",
'after' => "CONCAT(`A`.`column1`, `A`.`column2`, `B`.`column1`)"
'after' => "CONCAT(`A`.`column1`, `A`.`column2`, `B`.`column1`)",
],
'nothing to change (+ map exceeds translation needs)' => [
'before' => "CONCAT('hello', 1 + 2, :paramX)",
'map' => "['alias1' => ['*' => 'alias2']]",
'after' => "CONCAT('hello', (1 + 2), :paramX)"
'after' => "CONCAT('hello', (1 + 2), :paramX)",
],
];
}
@@ -106,7 +105,6 @@ class ExpressionTranslateTest extends ItopDataTestCase
static::assertEquals($sclassForExpressionAfter, get_class($oExpressionAfter));
}
public function TranslateMarksFieldsAsResolvedOrNotProvider()
{
return [
@@ -114,19 +112,19 @@ class ExpressionTranslateTest extends ItopDataTestCase
'before' => "alias1.column1",
'map' => "['alias1' => ['*' => 'alias2']]",
'mark-as-resolved' => true,
'class-for-expression-after' => "FieldExpressionResolved"
'class-for-expression-after' => "FieldExpressionResolved",
],
'Translation of class/table alias and opt-out on bMarkFieldsAsResolved' => [
'before' => "alias1.column1",
'map' => "['alias1' => ['*' => 'alias2']]",
'mark-as-resolved' => false,
'class-for-expression-after' => "FieldExpression"
'class-for-expression-after' => "FieldExpression",
],
'Decomposition of fields' => [
'before' => "alias1.column1",
'map' => "['alias1' => ['column1' => new \FieldExpression('col2', 'alias2')]]",
'mark-as-resolved' => true,
'class-for-expression-after' => "FieldExpression"
'class-for-expression-after' => "FieldExpression",
],
];
}