Skip to content

Commit ed72f33

Browse files
committed
Remove dependency on zumba/json-serializer
Instead of deserializing the data and then comparing it with the actual objects, this serializes the actual object and then compares it with the serialized data. Signed-off-by: Maurício Meneghini Fauth <mauricio@mfauth.com.br>
1 parent 6397892 commit ed72f33

525 files changed

Lines changed: 333140 additions & 45033 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎composer.json‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@
3636
"phpstan/phpstan-strict-rules": "^2.0.10",
3737
"phpunit/phpunit": "^11.5",
3838
"psalm/plugin-phpunit": "^0.19.6",
39-
"vimeo/psalm": "^6.16.1",
40-
"zumba/json-serializer": "~3.2.4"
39+
"vimeo/psalm": "^6.16.1"
4140
},
4241
"conflict": {
4342
"phpmyadmin/motranslator": "<5.2"

‎phpstan-baseline.neon‎

Lines changed: 0 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,90 +1644,6 @@ parameters:
16441644
count: 1
16451645
path: src/Tools/ContextGenerator.php
16461646

1647-
-
1648-
message: '#^Binary operation "\." between ''Unable to find…'' and mixed results in an error\.$#'
1649-
identifier: binaryOp.invalid
1650-
count: 1
1651-
path: src/Tools/CustomJsonSerializer.php
1652-
1653-
-
1654-
message: '#^Binary operation "\." between non\-falsy\-string and mixed results in an error\.$#'
1655-
identifier: binaryOp.invalid
1656-
count: 1
1657-
path: src/Tools/CustomJsonSerializer.php
1658-
1659-
-
1660-
message: '#^Cannot access offset 0 on mixed\.$#'
1661-
identifier: offsetAccess.nonOffsetAccessible
1662-
count: 1
1663-
path: src/Tools/CustomJsonSerializer.php
1664-
1665-
-
1666-
message: '#^Cannot call method unserialize\(\) on mixed\.$#'
1667-
identifier: method.nonObject
1668-
count: 1
1669-
path: src/Tools/CustomJsonSerializer.php
1670-
1671-
-
1672-
message: '#^Method PhpMyAdmin\\SqlParser\\Tools\\CustomJsonSerializer\:\:extractObjectData\(\) has parameter \$ref with generic class ReflectionClass but does not specify its types\: T$#'
1673-
identifier: missingType.generics
1674-
count: 1
1675-
path: src/Tools/CustomJsonSerializer.php
1676-
1677-
-
1678-
message: '#^Method PhpMyAdmin\\SqlParser\\Tools\\CustomJsonSerializer\:\:unserializeObject\(\) should return object but returns mixed\.$#'
1679-
identifier: return.type
1680-
count: 4
1681-
path: src/Tools/CustomJsonSerializer.php
1682-
1683-
-
1684-
message: '#^Parameter \#1 \$class of function class_exists expects string, mixed given\.$#'
1685-
identifier: argument.type
1686-
count: 1
1687-
path: src/Tools/CustomJsonSerializer.php
1688-
1689-
-
1690-
message: '#^Parameter \#1 \$data of method SplDoublyLinkedList\<mixed\>\:\:unserialize\(\) expects string, mixed given\.$#'
1691-
identifier: argument.type
1692-
count: 1
1693-
path: src/Tools/CustomJsonSerializer.php
1694-
1695-
-
1696-
message: '#^Parameter \#1 \$key of function array_key_exists expects int\|string, mixed given\.$#'
1697-
identifier: argument.type
1698-
count: 1
1699-
path: src/Tools/CustomJsonSerializer.php
1700-
1701-
-
1702-
message: '#^Parameter \#1 \$string of function substr expects string, mixed given\.$#'
1703-
identifier: argument.type
1704-
count: 1
1705-
path: src/Tools/CustomJsonSerializer.php
1706-
1707-
-
1708-
message: '#^Parameter \#2 \$name of method Zumba\\JsonSerializer\\JsonSerializer\:\:getReflectionProperty\(\) expects string, \(int\|string\) given\.$#'
1709-
identifier: argument.type
1710-
count: 1
1711-
path: src/Tools/CustomJsonSerializer.php
1712-
1713-
-
1714-
message: '#^Parameter \#3 \$properties \(array\<string\>\) of method PhpMyAdmin\\SqlParser\\Tools\\CustomJsonSerializer\:\:extractObjectData\(\) should be contravariant with parameter \$properties \(array\) of method Zumba\\JsonSerializer\\JsonSerializer\:\:extractObjectData\(\)$#'
1715-
identifier: method.childParameterType
1716-
count: 1
1717-
path: src/Tools/CustomJsonSerializer.php
1718-
1719-
-
1720-
message: '#^Variable \$ref might not be defined\.$#'
1721-
identifier: variable.undefined
1722-
count: 1
1723-
path: src/Tools/CustomJsonSerializer.php
1724-
1725-
-
1726-
message: '#^Variable property access on object\.$#'
1727-
identifier: property.dynamicName
1728-
count: 2
1729-
path: src/Tools/CustomJsonSerializer.php
1730-
17311647
-
17321648
message: '#^Argument of an invalid type list\<string\>\|false supplied for foreach, only iterables are supported\.$#'
17331649
identifier: foreach.nonIterable
@@ -2619,54 +2535,6 @@ parameters:
26192535
count: 5
26202536
path: tests/Parser/WithStatementTest.php
26212537

2622-
-
2623-
message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#'
2624-
identifier: empty.notAllowed
2625-
count: 1
2626-
path: tests/TestCase.php
2627-
2628-
-
2629-
message: '#^Dynamic call to static method PHPUnit\\Framework\\Assert\:\:assertArrayHasKey\(\)\.$#'
2630-
identifier: staticMethod.dynamicCall
2631-
count: 6
2632-
path: tests/TestCase.php
2633-
2634-
-
2635-
message: '#^Dynamic call to static method PHPUnit\\Framework\\Assert\:\:assertEquals\(\)\.$#'
2636-
identifier: staticMethod.dynamicCall
2637-
count: 4
2638-
path: tests/TestCase.php
2639-
2640-
-
2641-
message: '#^Dynamic call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\)\.$#'
2642-
identifier: staticMethod.dynamicCall
2643-
count: 2
2644-
path: tests/TestCase.php
2645-
2646-
-
2647-
message: '#^Dynamic call to static method PHPUnit\\Framework\\Assert\:\:assertIsArray\(\)\.$#'
2648-
identifier: staticMethod.dynamicCall
2649-
count: 2
2650-
path: tests/TestCase.php
2651-
2652-
-
2653-
message: '#^Dynamic call to static method PHPUnit\\Framework\\Assert\:\:assertIsList\(\)\.$#'
2654-
identifier: staticMethod.dynamicCall
2655-
count: 2
2656-
path: tests/TestCase.php
2657-
2658-
-
2659-
message: '#^Dynamic call to static method PHPUnit\\Framework\\Assert\:\:assertIsString\(\)\.$#'
2660-
identifier: staticMethod.dynamicCall
2661-
count: 3
2662-
path: tests/TestCase.php
2663-
2664-
-
2665-
message: '#^Method PhpMyAdmin\\SqlParser\\Tests\\TestCase\:\:getData\(\) should return array\{query\: string, lexer\: PhpMyAdmin\\SqlParser\\Lexer, parser\: PhpMyAdmin\\SqlParser\\Parser\|null, errors\: array\{lexer\: list\<array\{string, string, int, int\}\>, parser\: list\<array\{string, PhpMyAdmin\\SqlParser\\Token, int\}\>\}\} but returns non\-empty\-array\.$#'
2666-
identifier: return.type
2667-
count: 1
2668-
path: tests/TestCase.php
2669-
26702538
-
26712539
message: '#^Dynamic call to static method PHPUnit\\Framework\\Assert\:\:assertEquals\(\)\.$#'
26722540
identifier: staticMethod.dynamicCall

‎psalm-baseline.xml‎

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -906,56 +906,6 @@
906906
<code><![CDATA[$files]]></code>
907907
</PossiblyFalseIterator>
908908
</file>
909-
<file src="src/Tools/CustomJsonSerializer.php">
910-
<MixedArgument>
911-
<code><![CDATA[$className]]></code>
912-
<code><![CDATA[$className]]></code>
913-
<code><![CDATA[$className]]></code>
914-
<code><![CDATA[$ref]]></code>
915-
<code><![CDATA[$value['value']]]></code>
916-
</MixedArgument>
917-
<MixedArgumentTypeCoercion>
918-
<code><![CDATA[$property]]></code>
919-
</MixedArgumentTypeCoercion>
920-
<MixedArrayAccess>
921-
<code><![CDATA[$className[0]]]></code>
922-
</MixedArrayAccess>
923-
<MixedAssignment>
924-
<code><![CDATA[$data[$property]]]></code>
925-
<code><![CDATA[$data[$property]]]></code>
926-
<code><![CDATA[$obj]]></code>
927-
<code><![CDATA[$obj]]></code>
928-
<code><![CDATA[$obj]]></code>
929-
<code><![CDATA[$propertyValue]]></code>
930-
</MixedAssignment>
931-
<MixedMethodCall>
932-
<code><![CDATA[new $className()]]></code>
933-
<code><![CDATA[unserialize]]></code>
934-
</MixedMethodCall>
935-
<MixedOperand>
936-
<code><![CDATA[$className]]></code>
937-
<code><![CDATA[$value['name']]]></code>
938-
</MixedOperand>
939-
<MixedReturnStatement>
940-
<code><![CDATA[$obj]]></code>
941-
<code><![CDATA[$obj]]></code>
942-
<code><![CDATA[$obj]]></code>
943-
<code><![CDATA[$this->objectMapping[$index]]]></code>
944-
</MixedReturnStatement>
945-
<MoreSpecificImplementedParamType>
946-
<code><![CDATA[$properties]]></code>
947-
</MoreSpecificImplementedParamType>
948-
<PossiblyUndefinedVariable>
949-
<code><![CDATA[$ref]]></code>
950-
</PossiblyUndefinedVariable>
951-
<PropertyNotSetInConstructor>
952-
<code><![CDATA[CustomJsonSerializer]]></code>
953-
</PropertyNotSetInConstructor>
954-
<TypeDoesNotContainType>
955-
<code><![CDATA[$className === 'DateTime']]></code>
956-
<code><![CDATA[$className === 'DateTimeImmutable']]></code>
957-
</TypeDoesNotContainType>
958-
</file>
959909
<file src="src/Tools/TestGenerator.php">
960910
<MixedAssignment>
961911
<code><![CDATA[$file]]></code>
@@ -1205,32 +1155,13 @@
12051155
<code><![CDATA[testBuildKill]]></code>
12061156
</InvalidArgument>
12071157
</file>
1208-
<file src="tests/TestCase.php">
1209-
<InvalidReturnStatement>
1210-
<code><![CDATA[$data]]></code>
1211-
</InvalidReturnStatement>
1212-
<InvalidReturnType>
1213-
<code><![CDATA[array{
1214-
* query: string,
1215-
* lexer: Lexer,
1216-
* parser: Parser|null,
1217-
* errors: array{lexer: list<array{string, string, int, int}>, parser: list<array{string, Token, int}>}
1218-
* }]]></code>
1219-
</InvalidReturnType>
1220-
</file>
12211158
<file src="tests/Tools/ContextGeneratorTest.php">
12221159
<PossiblyFalseOperand>
12231160
<code><![CDATA[getcwd()]]></code>
12241161
<code><![CDATA[getcwd()]]></code>
12251162
<code><![CDATA[getcwd()]]></code>
12261163
</PossiblyFalseOperand>
12271164
</file>
1228-
<file src="tests/UtfStringSerializer.php">
1229-
<PossiblyUnusedMethod>
1230-
<code><![CDATA[serialize]]></code>
1231-
<code><![CDATA[unserialize]]></code>
1232-
</PossiblyUnusedMethod>
1233-
</file>
12341165
<file src="tests/Utils/CLITest.php">
12351166
<UndefinedAttributeClass>
12361167
<code><![CDATA[AllowMockObjectsWithoutExpectations]]></code>

‎src/Components/AlterOperation.php‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
namespace PhpMyAdmin\SqlParser\Components;
66

7-
use PhpMyAdmin\SqlParser\Component;
87
use PhpMyAdmin\SqlParser\Parsers\PartitionDefinitions;
8+
use PhpMyAdmin\SqlParser\SerializableComponent;
99
use PhpMyAdmin\SqlParser\Token;
1010
use PhpMyAdmin\SqlParser\TokensList;
1111

@@ -14,7 +14,7 @@
1414
/**
1515
* Parses an alter operation.
1616
*/
17-
final class AlterOperation implements Component
17+
final class AlterOperation extends SerializableComponent
1818
{
1919
/**
2020
* Options of this operation.
@@ -75,9 +75,4 @@ public function build(): string
7575

7676
return trim($ret);
7777
}
78-
79-
public function __toString(): string
80-
{
81-
return $this->build();
82-
}
8378
}

‎src/Components/ArrayObj.php‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
namespace PhpMyAdmin\SqlParser\Components;
66

7-
use PhpMyAdmin\SqlParser\Component;
7+
use PhpMyAdmin\SqlParser\SerializableComponent;
88

99
use function implode;
1010

1111
/**
1212
* Parses an array.
1313
*/
14-
final class ArrayObj implements Component
14+
final class ArrayObj extends SerializableComponent
1515
{
1616
/**
1717
* The array that contains the unprocessed value of each token.
@@ -45,9 +45,4 @@ public function build(): string
4545

4646
return '(' . implode(', ', $this->values) . ')';
4747
}
48-
49-
public function __toString(): string
50-
{
51-
return $this->build();
52-
}
5348
}

‎src/Components/CaseExpression.php‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44

55
namespace PhpMyAdmin\SqlParser\Components;
66

7-
use PhpMyAdmin\SqlParser\Component;
87
use PhpMyAdmin\SqlParser\Context;
98
use PhpMyAdmin\SqlParser\Parsers\Conditions;
9+
use PhpMyAdmin\SqlParser\SerializableComponent;
1010

1111
use function count;
1212

1313
/**
1414
* Parses a reference to a CASE expression.
1515
*/
16-
final class CaseExpression implements Component
16+
final class CaseExpression extends SerializableComponent
1717
{
1818
/**
1919
* The value to be compared.
@@ -90,9 +90,4 @@ public function build(): string
9090

9191
return $ret;
9292
}
93-
94-
public function __toString(): string
95-
{
96-
return $this->build();
97-
}
9893
}

‎src/Components/Condition.php‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
namespace PhpMyAdmin\SqlParser\Components;
66

7-
use PhpMyAdmin\SqlParser\Component;
7+
use PhpMyAdmin\SqlParser\SerializableComponent;
88

99
use function trim;
1010

11-
final class Condition implements Component
11+
final class Condition extends SerializableComponent
1212
{
1313
/**
1414
* Identifiers recognized.
@@ -41,9 +41,4 @@ public function build(): string
4141
{
4242
return $this->expr;
4343
}
44-
45-
public function __toString(): string
46-
{
47-
return $this->build();
48-
}
4944
}

‎src/Components/CreateDefinition.php‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
namespace PhpMyAdmin\SqlParser\Components;
66

7-
use PhpMyAdmin\SqlParser\Component;
87
use PhpMyAdmin\SqlParser\Context;
8+
use PhpMyAdmin\SqlParser\SerializableComponent;
99

1010
use function trim;
1111

@@ -14,7 +14,7 @@
1414
*
1515
* Used for parsing `CREATE TABLE` statement.
1616
*/
17-
final class CreateDefinition implements Component
17+
final class CreateDefinition extends SerializableComponent
1818
{
1919
/**
2020
* The name of the new column.
@@ -100,9 +100,4 @@ public function build(): string
100100

101101
return trim($tmp);
102102
}
103-
104-
public function __toString(): string
105-
{
106-
return $this->build();
107-
}
108103
}

0 commit comments

Comments
 (0)