From 0d747fa1e7a12393f3869e074ee1af8fe6f54d14 Mon Sep 17 00:00:00 2001 From: Neur0toxine Date: Mon, 11 Mar 2024 18:37:34 +0300 Subject: [PATCH] cq tools fixes --- phpcs.xml.dist | 3 + phpmd.xml | 2 + phpstan-baseline-serializer.neon | 191 +++++++++++++++++++++++ phpstan-baseline.neon | 95 ----------- phpstan.neon | 1 + src/Model/Entity/References/Currency.php | 2 + 6 files changed, 199 insertions(+), 95 deletions(-) create mode 100644 phpstan-baseline-serializer.neon diff --git a/phpcs.xml.dist b/phpcs.xml.dist index d12440d..5001cfd 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -10,4 +10,7 @@ src/ tests/ + + src/Component/Serializer/Generator/* + src/Component/Serializer/Parser/* diff --git a/phpmd.xml b/phpmd.xml index 3cd0206..0e11758 100644 --- a/phpmd.xml +++ b/phpmd.xml @@ -44,4 +44,6 @@ tests/* + src/Component/Serializer/Generator/* + src/Component/Serializer/Parser/* diff --git a/phpstan-baseline-serializer.neon b/phpstan-baseline-serializer.neon new file mode 100644 index 0000000..46a7126 --- /dev/null +++ b/phpstan-baseline-serializer.neon @@ -0,0 +1,191 @@ +parameters: + ignoreErrors: + - + message: "#^Parameter \\#1 \\$config of static method Liip\\\\Serializer\\\\Configuration\\\\GeneratorConfiguration\\:\\:createFomArray\\(\\) expects array\\{default_group_combinations\\?\\: array\\\\>\\|null, default_versions\\?\\: array\\\\|null, classes\\?\\: array\\\\>\\|null, options\\?\\: array\\\\}, array\\{default_group_combinations\\: array\\{\\}, default_versions\\: array\\{\\}, classes\\: non\\-empty\\-array\\\\} given\\.$#" + count: 1 + path: src/Component/ModelsGenerator.php + + - + message: "#^Parameter \\#3 \\$classesToGenerate of class RetailCrm\\\\Api\\\\Component\\\\Serializer\\\\Generator\\\\DeserializerGenerator constructor expects array\\, array\\ given\\.$#" + count: 1 + path: src/Component/ModelsGenerator.php + + - + message: "#^Parameter \\#2 \\$method of method Liip\\\\Serializer\\\\Template\\\\Deserialization\\:\\:renderSetter\\(\\) expects string, string\\|null given\\.$#" + count: 1 + path: src/Component/Serializer/Generator/DeserializerGenerator.php + + - + message: "#^Parameter \\#4 \\$stack of method RetailCrm\\\\Api\\\\Component\\\\Serializer\\\\Generator\\\\DeserializerGenerator\\:\\:generateCodeForClass\\(\\) expects array\\\\>, array given\\.$#" + count: 2 + path: src/Component/Serializer/Generator/DeserializerGenerator.php + + - + message: "#^Method RetailCrm\\\\Api\\\\Component\\\\Serializer\\\\Generator\\\\SerializerGenerator\\:\\:buildSerializerFunctionName\\(\\) should return string but returns string\\|null\\.$#" + count: 1 + path: src/Component/Serializer/Generator/SerializerGenerator.php + + - + message: "#^Parameter \\#2 \\$method of method Liip\\\\Serializer\\\\Template\\\\Serialization\\:\\:renderGetter\\(\\) expects string, string\\|null given\\.$#" + count: 1 + path: src/Component/Serializer/Generator/SerializerGenerator.php + + - + message: "#^Parameter \\#3 \\$serializerGroups of method RetailCrm\\\\Api\\\\Component\\\\Serializer\\\\Generator\\\\SerializerGenerator\\:\\:generateCodeForClass\\(\\) expects array\\, array given\\.$#" + count: 4 + path: src/Component/Serializer/Generator/SerializerGenerator.php + + - + message: "#^Class RetailCrm\\\\Api\\\\Component\\\\Serializer\\\\Parser\\\\JMSCore\\\\Type\\\\Lexer extends generic class Doctrine\\\\Common\\\\Lexer\\\\AbstractLexer but does not specify its types\\: T, V$#" + count: 1 + path: src/Component/Serializer/Parser/JMSCore/Type/Lexer.php + + - + message: "#^Method RetailCrm\\\\Api\\\\Component\\\\Serializer\\\\Parser\\\\JMSCore\\\\Type\\\\Lexer\\:\\:getType\\(\\) has parameter \\$value with no type specified\\.$#" + count: 1 + path: src/Component/Serializer/Parser/JMSCore/Type/Lexer.php + + - + message: "#^Method RetailCrm\\\\Api\\\\Component\\\\Serializer\\\\Parser\\\\JMSCore\\\\Type\\\\Lexer\\:\\:parse\\(\\) has no return type specified\\.$#" + count: 1 + path: src/Component/Serializer/Parser/JMSCore/Type/Lexer.php + + - + message: "#^Parameter \\#1 \\$haystack of function stripos expects string, float\\|int\\|string given\\.$#" + count: 1 + path: src/Component/Serializer/Parser/JMSCore/Type/Lexer.php + + - + message: "#^Parameter \\#1 \\$haystack of function strpos expects string, float\\|int\\|string given\\.$#" + count: 1 + path: src/Component/Serializer/Parser/JMSCore/Type/Lexer.php + + - + message: "#^Cannot access property \\$value on Doctrine\\\\Common\\\\Lexer\\\\Token\\\\|null\\.$#" + count: 2 + path: src/Component/Serializer/Parser/JMSCore/Type/Parser.php + + - + message: "#^Method RetailCrm\\\\Api\\\\Component\\\\Serializer\\\\Parser\\\\JMSCore\\\\Type\\\\Parser\\:\\:getConstant\\(\\) should return string but returns string\\|false\\.$#" + count: 1 + path: src/Component/Serializer/Parser/JMSCore/Type/Parser.php + + - + message: "#^Method RetailCrm\\\\Api\\\\Component\\\\Serializer\\\\Parser\\\\JMSCore\\\\Type\\\\Parser\\:\\:parse\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/Component/Serializer/Parser/JMSCore/Type/Parser.php + + - + message: "#^Method RetailCrm\\\\Api\\\\Component\\\\Serializer\\\\Parser\\\\JMSCore\\\\Type\\\\Parser\\:\\:parse\\(\\) should return array but returns mixed\\.$#" + count: 1 + path: src/Component/Serializer/Parser/JMSCore/Type/Parser.php + + - + message: "#^Method RetailCrm\\\\Api\\\\Component\\\\Serializer\\\\Parser\\\\JMSCore\\\\Type\\\\Parser\\:\\:visitArrayType\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/Component/Serializer/Parser/JMSCore/Type/Parser.php + + - + message: "#^Method RetailCrm\\\\Api\\\\Component\\\\Serializer\\\\Parser\\\\JMSCore\\\\Type\\\\Parser\\:\\:visitCompoundType\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/Component/Serializer/Parser/JMSCore/Type/Parser.php + + - + message: "#^Method RetailCrm\\\\Api\\\\Component\\\\Serializer\\\\Parser\\\\JMSCore\\\\Type\\\\Parser\\:\\:visitSimpleType\\(\\) never returns string so it can be removed from the return type\\.$#" + count: 1 + path: src/Component/Serializer/Parser/JMSCore/Type/Parser.php + + - + message: "#^Parameter \\#1 \\$value of method RetailCrm\\\\Api\\\\Component\\\\Serializer\\\\Parser\\\\JMSCore\\\\Type\\\\Parser\\:\\:getConstant\\(\\) expects int, int\\\\|int\\<4, 8\\>\\|int\\<11, max\\>\\|string\\|UnitEnum\\|null given\\.$#" + count: 1 + path: src/Component/Serializer/Parser/JMSCore/Type/Parser.php + + - + message: "#^Parameter \\#1 \\$value of method RetailCrm\\\\Api\\\\Component\\\\Serializer\\\\Parser\\\\JMSCore\\\\Type\\\\Parser\\:\\:getConstant\\(\\) expects int, int\\|string\\|UnitEnum\\|null given\\.$#" + count: 1 + path: src/Component/Serializer/Parser/JMSCore/Type/Parser.php + + - + message: "#^Method RetailCrm\\\\Api\\\\Component\\\\Serializer\\\\Parser\\\\JMSCore\\\\Type\\\\ParserInterface\\:\\:parse\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/Component/Serializer/Parser/JMSCore/Type/ParserInterface.php + + - + message: "#^Method RetailCrm\\\\Api\\\\Component\\\\Serializer\\\\Parser\\\\JMSParser\\:\\:gatherClassAnnotations\\(\\) has parameter \\$reflectionClass with generic class ReflectionClass but does not specify its types\\: T$#" + count: 1 + path: src/Component/Serializer/Parser/JMSParser.php + + - + message: "#^Method RetailCrm\\\\Api\\\\Component\\\\Serializer\\\\Parser\\\\JMSParser\\:\\:getMethodName\\(\\) has parameter \\$annotations with no value type specified in iterable type array\\.$#" + count: 1 + path: src/Component/Serializer/Parser/JMSParser.php + + - + message: "#^Method RetailCrm\\\\Api\\\\Component\\\\Serializer\\\\Parser\\\\JMSParser\\:\\:getProperty\\(\\) has parameter \\$annotations with no value type specified in iterable type array\\.$#" + count: 1 + path: src/Component/Serializer/Parser/JMSParser.php + + - + message: "#^Method RetailCrm\\\\Api\\\\Component\\\\Serializer\\\\Parser\\\\JMSParser\\:\\:getReturnType\\(\\) has parameter \\$reflClass with generic class ReflectionClass but does not specify its types\\: T$#" + count: 1 + path: src/Component/Serializer/Parser/JMSParser.php + + - + message: "#^Method RetailCrm\\\\Api\\\\Component\\\\Serializer\\\\Parser\\\\JMSParser\\:\\:getSerializedName\\(\\) has parameter \\$annotations with no value type specified in iterable type array\\.$#" + count: 1 + path: src/Component/Serializer/Parser/JMSParser.php + + - + message: "#^Method RetailCrm\\\\Api\\\\Component\\\\Serializer\\\\Parser\\\\JMSParser\\:\\:isPostDeserializeMethod\\(\\) has parameter \\$annotations with no value type specified in iterable type array\\.$#" + count: 1 + path: src/Component/Serializer/Parser/JMSParser.php + + - + message: "#^Method RetailCrm\\\\Api\\\\Component\\\\Serializer\\\\Parser\\\\JMSParser\\:\\:isVirtualProperty\\(\\) has parameter \\$annotations with no value type specified in iterable type array\\.$#" + count: 1 + path: src/Component/Serializer/Parser/JMSParser.php + + - + message: "#^Method RetailCrm\\\\Api\\\\Component\\\\Serializer\\\\Parser\\\\JMSParser\\:\\:parseClass\\(\\) has parameter \\$reflClass with generic class ReflectionClass but does not specify its types\\: T$#" + count: 1 + path: src/Component/Serializer/Parser/JMSParser.php + + - + message: "#^Method RetailCrm\\\\Api\\\\Component\\\\Serializer\\\\Parser\\\\JMSParser\\:\\:parseMethods\\(\\) has parameter \\$reflClass with generic class ReflectionClass but does not specify its types\\: T$#" + count: 1 + path: src/Component/Serializer/Parser/JMSParser.php + + - + message: "#^Method RetailCrm\\\\Api\\\\Component\\\\Serializer\\\\Parser\\\\JMSParser\\:\\:parseProperties\\(\\) has parameter \\$reflClass with generic class ReflectionClass but does not specify its types\\: T$#" + count: 1 + path: src/Component/Serializer/Parser/JMSParser.php + + - + message: "#^Method RetailCrm\\\\Api\\\\Component\\\\Serializer\\\\Parser\\\\JMSParser\\:\\:parsePropertyAnnotations\\(\\) has parameter \\$annotations with no value type specified in iterable type array\\.$#" + count: 1 + path: src/Component/Serializer/Parser/JMSParser.php + + - + message: "#^Parameter \\#1 \\$objectOrClass of class ReflectionClass constructor expects class\\-string\\\\|T of object, string given\\.$#" + count: 1 + path: src/Component/Serializer/Parser/JMSParser.php + + - + message: "#^Class Doctrine\\\\Common\\\\Collections\\\\ArrayCollection not found\\.$#" + count: 1 + path: src/Component/Serializer/Parser/JMSTypeParser.php + + - + message: "#^Class Doctrine\\\\Common\\\\Collections\\\\Collection not found\\.$#" + count: 1 + path: src/Component/Serializer/Parser/JMSTypeParser.php + + - + message: "#^Method RetailCrm\\\\Api\\\\Component\\\\Serializer\\\\Parser\\\\JMSTypeParser\\:\\:parseType\\(\\) has parameter \\$typeInfo with no value type specified in iterable type array\\.$#" + count: 1 + path: src/Component/Serializer/Parser/JMSTypeParser.php + + - + message: "#^Parameter \\#4 \\$traversableClass of class Liip\\\\MetadataParser\\\\Metadata\\\\PropertyTypeIterable constructor expects class\\-string\\\\|null, string\\|null given\\.$#" + count: 2 + path: src/Component/Serializer/Parser/JMSTypeParser.php diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 971ac59..47a94db 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -210,36 +210,6 @@ parameters: count: 2 path: src/Component/Serializer/ArraySupportDecorator.php - - - message: "#^Unsafe access to private constant RetailCrm\\\\Api\\\\Component\\\\Serializer\\\\Generator\\\\DeserializerGenerator\\:\\:FILENAME_PREFIX through static\\:\\:\\.$#" - count: 1 - path: src/Component/Serializer/Generator/DeserializerGenerator.php - - - - message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#" - count: 1 - path: src/Component/Serializer/Generator/SerializerGenerator.php - - - - message: "#^Cannot call method getClassName\\(\\) on mixed\\.$#" - count: 1 - path: src/Component/Serializer/Generator/SerializerGenerator.php - - - - message: "#^Cannot call method getGroups\\(\\) on mixed\\.$#" - count: 3 - path: src/Component/Serializer/Generator/SerializerGenerator.php - - - - message: "#^Cannot call method getVersions\\(\\) on mixed\\.$#" - count: 1 - path: src/Component/Serializer/Generator/SerializerGenerator.php - - - - message: "#^Unsafe access to private constant RetailCrm\\\\Api\\\\Component\\\\Serializer\\\\Generator\\\\SerializerGenerator\\:\\:FILENAME_PREFIX through static\\:\\:\\.$#" - count: 1 - path: src/Component/Serializer/Generator/SerializerGenerator.php - - message: "#^Method RetailCrm\\\\Api\\\\Component\\\\Serializer\\\\ModelsChecksumGenerator\\:\\:getStoredChecksums\\(\\) should return array\\ but returns mixed\\.$#" count: 1 @@ -250,41 +220,6 @@ parameters: count: 4 path: src/Component/Serializer/ModelsChecksumGenerator.php - - - message: "#^Cannot cast mixed to float\\.$#" - count: 1 - path: src/Component/Serializer/Parser/BaseJMSParser.php - - - - message: "#^Cannot cast mixed to int\\.$#" - count: 1 - path: src/Component/Serializer/Parser/BaseJMSParser.php - - - - message: "#^Method RetailCrm\\\\Api\\\\Component\\\\Serializer\\\\Parser\\\\BaseJMSParser\\:\\:parse\\(\\) should return array but returns mixed\\.$#" - count: 1 - path: src/Component/Serializer/Parser/BaseJMSParser.php - - - - message: "#^Parameter \\#2 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, mixed given\\.$#" - count: 2 - path: src/Component/Serializer/Parser/BaseJMSParser.php - - - - message: "#^Class RetailCrm\\\\Api\\\\Component\\\\Serializer\\\\Parser\\\\JMSLexer extends generic class Doctrine\\\\Common\\\\Lexer\\\\AbstractLexer but does not specify its types\\: T, V$#" - count: 1 - path: src/Component/Serializer/Parser/JMSLexer.php - - - - message: "#^Method RetailCrm\\\\Api\\\\Component\\\\Serializer\\\\Parser\\\\JMSLexer\\:\\:parse\\(\\) should return int\\|string\\|null but returns int\\|string\\|UnitEnum\\|null\\.$#" - count: 1 - path: src/Component/Serializer/Parser/JMSLexer.php - - - - message: "#^Parameter \\#1 \\$object of function get_class expects object, mixed given\\.$#" - count: 2 - path: src/Component/Serializer/Parser/JMSParser.php - - message: "#^Parameter \\#2 \\$string2 of function strncmp expects string, class\\-string\\|false given\\.$#" count: 1 @@ -295,36 +230,6 @@ parameters: count: 1 path: src/Component/Serializer/Parser/JMSParser.php - - - message: "#^Parameter \\#1 \\$className of class Liip\\\\MetadataParser\\\\Metadata\\\\PropertyTypeClass constructor expects string, mixed given\\.$#" - count: 1 - path: src/Component/Serializer/Parser/JMSTypeParser.php - - - - message: "#^Parameter \\#1 \\$className of static method Liip\\\\MetadataParser\\\\Metadata\\\\PropertyTypeDateTime\\:\\:fromDateTimeClass\\(\\) expects string, mixed given\\.$#" - count: 2 - path: src/Component/Serializer/Parser/JMSTypeParser.php - - - - message: "#^Parameter \\#1 \\$typeName of class Liip\\\\MetadataParser\\\\Metadata\\\\PropertyTypePrimitive constructor expects string, mixed given\\.$#" - count: 1 - path: src/Component/Serializer/Parser/JMSTypeParser.php - - - - message: "#^Parameter \\#1 \\$typeName of static method Liip\\\\MetadataParser\\\\Metadata\\\\PropertyTypeDateTime\\:\\:isTypeDateTime\\(\\) expects string, mixed given\\.$#" - count: 2 - path: src/Component/Serializer/Parser/JMSTypeParser.php - - - - message: "#^Parameter \\#1 \\$typeName of static method Liip\\\\MetadataParser\\\\Metadata\\\\PropertyTypePrimitive\\:\\:isTypePrimitive\\(\\) expects string, mixed given\\.$#" - count: 1 - path: src/Component/Serializer/Parser/JMSTypeParser.php - - - - message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#" - count: 1 - path: src/Component/Serializer/Parser/JMSTypeParser.php - - message: "#^Unsafe call to private method RetailCrm\\\\Api\\\\Component\\\\Transformer\\\\DateTimeTransformer\\:\\:createFromFormat\\(\\) through static\\:\\:\\.$#" count: 3 diff --git a/phpstan.neon b/phpstan.neon index d0feec5..ade0673 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,4 +1,5 @@ includes: + - phpstan-baseline-serializer.neon - phpstan-baseline.neon # TODO: This should be removed eventually. parameters: diff --git a/src/Model/Entity/References/Currency.php b/src/Model/Entity/References/Currency.php index 96abbe2..596852e 100644 --- a/src/Model/Entity/References/Currency.php +++ b/src/Model/Entity/References/Currency.php @@ -16,6 +16,8 @@ use RetailCrm\Api\Component\Serializer\Annotation as JMS; * * @category Currency * @package RetailCrm\Api\Model\Entity\References + * + * @SuppressWarnings(PHPMD.LongVariable) */ class Currency {