From d91cfc9dbec23e74ccd7cdf7802152ba8e58a96a Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Mon, 11 Oct 2021 22:01:04 +0200 Subject: [PATCH] fix phpstan and phpcs --- .github/workflows/main.yml | 2 +- Models/Bill.php | 4 +-- Models/BillElement.php | 4 +-- Models/BillType.php | 4 +-- Models/BillTypeL11n.php | 4 +-- Models/PurchaseBillMapper.php | 48 +++++++++++++++++++++++++++++++ Models/SalesBillMapper.php | 54 +++++++++++++++++++++++++++++++++++ Models/StockBillMapper.php | 6 ++++ composer.json | 2 +- 9 files changed, 114 insertions(+), 14 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 295f795..9e8ad00 100755 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,7 +26,7 @@ jobs: - name: Setup Composer run: composer install - name: Autoformat - run: 'vendor/bin/php-cs-fixer fix ./ --rules=''{"array_syntax": {"syntax": "short"}, "blank_line_after_namespace": true, "binary_operator_spaces": {"operators": {"=": "align", ".=": "align", "+=": "align", "-=": "align", "*=": "align", "/=": "align", "|=": "align", "&=": "align", "=>": "align", "??=": "align"}}, "cast_spaces": {"space": "single"}, "class_attributes_separation": { "elements": ["const", "method", "property"] }, "combine_consecutive_issets": true, "compact_nullable_typehint": true, "declare_strict_types": true, "declare_equal_normalize": {"space": "none"}, "elseif": true, "encoding": true, "explicit_indirect_variable": true, "explicit_string_variable": true, "function_to_constant": true, "implode_call": true, "increment_style": {"style": "pre"}, "is_null": {"use_yoda_style": false}, "line_ending": true, "logical_operators": true, "lowercase_cast": true, "lowercase_constants": true, "lowercase_keywords": true, "modernize_types_casting": true, "native_constant_invocation": true, "native_function_casing": true, "native_function_invocation": true, "new_with_braces": true, "no_extra_blank_lines": ["break", "case", "continue", "curly_brace_block", "extra", "return", "switch", "throw", "use"], "no_spaces_after_function_name": true, "no_alias_functions": true, "no_closing_tag": true, "no_empty_comment": true, "no_empty_phpdoc": true, "no_empty_statement": true, "no_homoglyph_names": true, "no_mixed_echo_print": {"use": "echo"}, "no_php4_constructor": true, "no_singleline_whitespace_before_semicolons": true, "no_spaces_inside_parenthesis": true, "no_trailing_whitespace": true, "no_unneeded_final_method": true, "no_unused_imports": true, "no_useless_return": true, "no_whitespace_before_comma_in_array": true, "no_whitespace_in_blank_line": true, "non_printable_character": true, "normalize_index_brace": true, "ordered_imports": {"sort_algorithm": "alpha"}, "ordered_interfaces": {"order": "alpha"}, "php_unit_construct": true, "php_unit_internal_class": true, "php_unit_ordered_covers": true, "php_unit_set_up_tear_down_visibility": true, "phpdoc_indent": true, "phpdoc_align": {"align": "vertical"}, "phpdoc_annotation_without_dot": true, "phpdoc_scalar": true, "phpdoc_return_self_reference": {"this": "self"}, "phpdoc_trim": true, "phpdoc_trim_consecutive_blank_line_separation": true, "random_api_migration": true, "self_accessor": true, "return_type_declaration": {"space_before": "one"}, "semicolon_after_instruction": true, "set_type_to_cast": true, "short_scalar_cast": true, "single_blank_line_at_eof": true, "single_line_after_imports": true, "standardize_increment": true, "trailing_comma_in_multiline_array": true, "trim_array_spaces": true, "visibility_required": true, "void_return": true}'' --allow-risky=yes' + run: 'vendor/bin/php-cs-fixer fix ./ --rules=''{"array_syntax": {"syntax": "short"}, "blank_line_after_namespace": true, "binary_operator_spaces": {"operators": {"=": "align", ".=": "align", "+=": "align", "-=": "align", "*=": "align", "/=": "align", "|=": "align", "&=": "align", "=>": "align", "??=": "align"}}, "cast_spaces": {"space": "single"}, "class_attributes_separation": { "elements": {"const": "one", "method": "one", "property": "one"} }, "combine_consecutive_issets": true, "compact_nullable_typehint": true, "declare_strict_types": true, "declare_equal_normalize": {"space": "none"}, "elseif": true, "encoding": true, "explicit_indirect_variable": true, "explicit_string_variable": true, "function_to_constant": true, "implode_call": true, "increment_style": {"style": "pre"}, "is_null": true, "yoda_style": {"equal": false, "identical": false, "less_and_greater": false}, "line_ending": true, "logical_operators": true, "lowercase_cast": true, "constant_case": {"case": "lower"}, "lowercase_keywords": true, "modernize_types_casting": true, "native_constant_invocation": true, "native_function_casing": true, "native_function_invocation": true, "new_with_braces": true, "no_extra_blank_lines": {"tokens": ["break", "case", "continue", "curly_brace_block", "extra", "return", "switch", "throw", "use"]}, "no_spaces_after_function_name": true, "no_alias_functions": true, "no_closing_tag": true, "no_empty_comment": true, "no_empty_phpdoc": true, "no_empty_statement": true, "no_homoglyph_names": true, "no_mixed_echo_print": {"use": "echo"}, "no_php4_constructor": true, "no_singleline_whitespace_before_semicolons": true, "no_spaces_inside_parenthesis": true, "no_trailing_whitespace": true, "no_unneeded_final_method": true, "no_unused_imports": true, "no_useless_return": true, "no_whitespace_before_comma_in_array": true, "no_whitespace_in_blank_line": true, "non_printable_character": true, "normalize_index_brace": true, "ordered_imports": {"sort_algorithm": "alpha"}, "ordered_interfaces": {"order": "alpha"}, "php_unit_construct": true, "php_unit_internal_class": true, "php_unit_set_up_tear_down_visibility": true, "phpdoc_indent": true, "phpdoc_align": {"align": "vertical"}, "phpdoc_annotation_without_dot": true, "phpdoc_scalar": true, "phpdoc_return_self_reference": {"replacements": {"this": "self"}}, "phpdoc_trim": true, "phpdoc_trim_consecutive_blank_line_separation": true, "random_api_migration": true, "self_accessor": true, "return_type_declaration": {"space_before": "one"}, "semicolon_after_instruction": true, "set_type_to_cast": true, "short_scalar_cast": true, "single_blank_line_at_eof": true, "single_line_after_imports": true, "standardize_increment": true, "trailing_comma_in_multiline": true, "trim_array_spaces": true, "visibility_required": true, "void_return": true}'' --allow-risky=yes' - name: Check for modified files id: git-check run: echo ::set-output name=modified::$(if git diff-index --quiet HEAD --; then echo "false"; else echo "true"; fi) diff --git a/Models/Bill.php b/Models/Bill.php index ea38ca4..c7ed4ca 100755 --- a/Models/Bill.php +++ b/Models/Bill.php @@ -55,9 +55,7 @@ class Bill implements \JsonSerializable * @var int|BillType * @since 1.0.0 */ - public int | - -BillType $type = 0; + public int | BillType $type = 0; /** * Bill status. diff --git a/Models/BillElement.php b/Models/BillElement.php index 9a8d03b..cd61756 100755 --- a/Models/BillElement.php +++ b/Models/BillElement.php @@ -91,9 +91,7 @@ class BillElement implements \JsonSerializable */ public int $promotion = 0; - public int | - -Bill $bill = 0; + public int | Bill $bill = 0; /** * Constructor. diff --git a/Models/BillType.php b/Models/BillType.php index af50dfc..c69ab39 100755 --- a/Models/BillType.php +++ b/Models/BillType.php @@ -43,9 +43,7 @@ class BillType * * @var string|BillTypeL11n */ - protected string | - -BillTypeL11n $l11n; + protected string | BillTypeL11n $l11n; /** * Constructor. diff --git a/Models/BillTypeL11n.php b/Models/BillTypeL11n.php index df51dfd..c8ba61c 100755 --- a/Models/BillTypeL11n.php +++ b/Models/BillTypeL11n.php @@ -41,9 +41,7 @@ class BillTypeL11n implements \JsonSerializable, ArrayableInterface * @var int * @since 1.0.0 */ - protected int | - -BillType $type = 0; + protected int | BillType $type = 0; /** * Language. diff --git a/Models/PurchaseBillMapper.php b/Models/PurchaseBillMapper.php index 495979c..248062e 100755 --- a/Models/PurchaseBillMapper.php +++ b/Models/PurchaseBillMapper.php @@ -38,6 +38,9 @@ final class PurchaseBillMapper extends BillMapper */ protected static string $model = Bill::class; + /** + * Placeholder + */ public static function getPurchaseBeforePivot( mixed $pivot, string $column = null, @@ -53,6 +56,9 @@ final class PurchaseBillMapper extends BillMapper return self::getBeforePivot($pivot, $column, $limit, $relations, $depth, $query); } + /** + * Placeholder + */ public static function getPurchaseAfterPivot( mixed $pivot, string $column = null, @@ -68,6 +74,9 @@ final class PurchaseBillMapper extends BillMapper return self::getAfterPivot($pivot, $column, $limit, $relations, $depth, $query); } + /** + * Placeholder + */ public static function getPurchaseByItemId(int $id, \DateTime $start, \DateTime $end) : Money { $query = new Builder(self::$db); @@ -84,6 +93,9 @@ final class PurchaseBillMapper extends BillMapper return new Money((int) $result[0]); } + /** + * Placeholder + */ public static function getPurchaseBySupplierId(int $id, \DateTime $start, \DateTime $end) : Money { $query = new Builder(self::$db); @@ -98,6 +110,9 @@ final class PurchaseBillMapper extends BillMapper return new Money((int) $result[0]); } + /** + * Placeholder + */ public static function getAvgPurchasePriceByItemId(int $id, \DateTime $start, \DateTime $end) : Money { $query = new Builder(self::$db); @@ -114,6 +129,9 @@ final class PurchaseBillMapper extends BillMapper return new Money($result === false || $result[1] == 0 ? 0 : (int) (((int) $result[0]) / ((int) $result[1]))); } + /** + * Placeholder + */ public static function getLastOrderDateByItemId(int $id) : ?\DateTimeImmutable { // @todo: only delivers/invoice/production (no offers ...) @@ -131,6 +149,9 @@ final class PurchaseBillMapper extends BillMapper return $result === false ? null : new \DateTimeImmutable($result[0]); } + /** + * Placeholder + */ public static function getLastOrderDateBySupplierId(int $id) : ?\DateTimeImmutable { // @todo: only delivers/invoice/production (no offers ...) @@ -146,16 +167,25 @@ final class PurchaseBillMapper extends BillMapper return $result === false ? null : new \DateTimeImmutable($result[0]); } + /** + * Placeholder + */ public static function getItemRetentionRate(int $id, \DateTime $start, \DateTime $end) : float { return 0.0; } + /** + * Placeholder + */ public static function getItemLivetimeValue(int $id, \DateTime $start, \DateTime $end) : Money { return new Money(); } + /** + * Placeholder + */ public static function getNewestItemInvoices(int $id, int $limit = 10) : array { $depth = 3; @@ -177,6 +207,9 @@ final class PurchaseBillMapper extends BillMapper return self::getAllByQuery($query, RelationType::ALL, $depth); } + /** + * Placeholder + */ public static function getNewestSupplierInvoices(int $id, int $limit = 10) : array { $depth = 3; @@ -196,6 +229,9 @@ final class PurchaseBillMapper extends BillMapper return self::getAllByQuery($query, RelationType::ALL, $depth); } + /** + * Placeholder + */ public static function getItemTopSuppliers(int $id, \DateTime $start, \DateTime $end, int $limit = 10) : array { $depth = 3; @@ -219,6 +255,9 @@ final class PurchaseBillMapper extends BillMapper return [$suppliers, $data]; } + /** + * Placeholder + */ public static function getItemRegionPurchase(int $id, \DateTime $start, \DateTime $end) : array { $query = new Builder(self::$db); @@ -239,6 +278,9 @@ final class PurchaseBillMapper extends BillMapper return $result; } + /** + * Placeholder + */ public static function getItemCountryPurchase(int $id, \DateTime $start, \DateTime $end, int $limit = 10) : array { $query = new Builder(self::$db); @@ -261,6 +303,9 @@ final class PurchaseBillMapper extends BillMapper return $result; } + /** + * Placeholder + */ public static function getItemMonthlyPurchaseCosts(int $id, \DateTime $start, \DateTime $end) : array { $query = new Builder(self::$db); @@ -282,6 +327,9 @@ final class PurchaseBillMapper extends BillMapper return $result; } + /** + * Placeholder + */ public static function getSupplierMonthlyPurchaseCosts(int $id, \DateTime $start, \DateTime $end) : array { $query = new Builder(self::$db); diff --git a/Models/SalesBillMapper.php b/Models/SalesBillMapper.php index a00ca12..8f34bbf 100755 --- a/Models/SalesBillMapper.php +++ b/Models/SalesBillMapper.php @@ -38,6 +38,9 @@ final class SalesBillMapper extends BillMapper */ protected static string $model = Bill::class; + /** + * Placeholder + */ public static function getSalesBeforePivot( mixed $pivot, string $column = null, @@ -53,6 +56,9 @@ final class SalesBillMapper extends BillMapper return self::getBeforePivot($pivot, $column, $limit, $relations, $depth, $query); } + /** + * Placeholder + */ public static function getSalesAfterPivot( mixed $pivot, string $column = null, @@ -68,6 +74,9 @@ final class SalesBillMapper extends BillMapper return self::getAfterPivot($pivot, $column, $limit, $relations, $depth, $query); } + /** + * Placeholder + */ public static function getSalesByItemId(int $id, \DateTime $start, \DateTime $end) : Money { $query = new Builder(self::$db); @@ -84,6 +93,9 @@ final class SalesBillMapper extends BillMapper return new Money((int) $result[0]); } + /** + * Placeholder + */ public static function getSalesByClientId(int $id, \DateTime $start, \DateTime $end) : Money { $query = new Builder(self::$db); @@ -98,6 +110,9 @@ final class SalesBillMapper extends BillMapper return new Money((int) $result[0]); } + /** + * Placeholder + */ public static function getAvgSalesPriceByItemId(int $id, \DateTime $start, \DateTime $end) : Money { $query = new Builder(self::$db); @@ -114,6 +129,9 @@ final class SalesBillMapper extends BillMapper return new Money($result === false || $result[1] == 0 ? 0 : (int) (((int) $result[0]) / ((int) $result[1]))); } + /** + * Placeholder + */ public static function getLastOrderDateByItemId(int $id) : ?\DateTimeImmutable { // @todo: only delivers/invoice/production (no offers ...) @@ -131,6 +149,9 @@ final class SalesBillMapper extends BillMapper return $result === false ? null : new \DateTimeImmutable($result[0]); } + /** + * Placeholder + */ public static function getLastOrderDateByClientId(int $id) : ?\DateTimeImmutable { // @todo: only delivers/invoice/production (no offers ...) @@ -146,16 +167,25 @@ final class SalesBillMapper extends BillMapper return $result === false ? null : new \DateTimeImmutable($result[0]); } + /** + * Placeholder + */ public static function getItemRetentionRate(int $id, \DateTime $start, \DateTime $end) : float { return 0.0; } + /** + * Placeholder + */ public static function getItemLivetimeValue(int $id, \DateTime $start, \DateTime $end) : Money { return new Money(); } + /** + * Placeholder + */ public static function getNewestItemInvoices(int $id, int $limit = 10) : array { $depth = 3; @@ -177,6 +207,9 @@ final class SalesBillMapper extends BillMapper return self::getAllByQuery($query, RelationType::ALL, $depth); } + /** + * Placeholder + */ public static function getNewestClientInvoices(int $id, int $limit = 10) : array { $depth = 3; @@ -196,6 +229,9 @@ final class SalesBillMapper extends BillMapper return self::getAllByQuery($query, RelationType::ALL, $depth); } + /** + * Placeholder + */ public static function getItemTopCustomers(int $id, \DateTime $start, \DateTime $end, int $limit = 10) : array { $depth = 3; @@ -219,6 +255,9 @@ final class SalesBillMapper extends BillMapper return [$clients, $data]; } + /** + * Placeholder + */ public static function getItemBills(int $id, \DateTime $start, \DateTime $end) : array { $depth = 3; @@ -240,6 +279,9 @@ final class SalesBillMapper extends BillMapper return self::getAllByQuery($query, RelationType::ALL, $depth); } + /** + * Placeholder + */ public static function getClientItem(int $client, \DateTime $start, \DateTime $end) : array { $depth = 3; @@ -261,6 +303,9 @@ final class SalesBillMapper extends BillMapper return BillElementMapper::getAllByQuery($query, RelationType::ALL, $depth); } + /** + * Placeholder + */ public static function getItemRegionSales(int $id, \DateTime $start, \DateTime $end) : array { $query = new Builder(self::$db); @@ -281,6 +326,9 @@ final class SalesBillMapper extends BillMapper return $result; } + /** + * Placeholder + */ public static function getItemCountrySales(int $id, \DateTime $start, \DateTime $end, int $limit = 10) : array { $query = new Builder(self::$db); @@ -303,6 +351,9 @@ final class SalesBillMapper extends BillMapper return $result; } + /** + * Placeholder + */ public static function getItemMonthlySalesCosts(int $id, \DateTime $start, \DateTime $end) : array { $query = new Builder(self::$db); @@ -324,6 +375,9 @@ final class SalesBillMapper extends BillMapper return $result; } + /** + * Placeholder + */ public static function getClientMonthlySalesCosts(int $id, \DateTime $start, \DateTime $end) : array { $query = new Builder(self::$db); diff --git a/Models/StockBillMapper.php b/Models/StockBillMapper.php index 52866fe..73865fd 100755 --- a/Models/StockBillMapper.php +++ b/Models/StockBillMapper.php @@ -35,6 +35,9 @@ final class StockBillMapper extends BillMapper */ protected static string $model = Bill::class; + /** + * Placeholder + */ public static function getStockBeforePivot( mixed $pivot, string $column = null, @@ -50,6 +53,9 @@ final class StockBillMapper extends BillMapper return self::getBeforePivot($pivot, $column, $limit, $relations, $depth, $query); } + /** + * Placeholder + */ public static function getStockAfterPivot( mixed $pivot, string $column = null, diff --git a/composer.json b/composer.json index 7cf5769..63e524b 100755 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ ], "require-dev": { "phpunit/phpunit": ">=9.4", - "friendsofphp/php-cs-fixer": ">=3.0", + "friendsofphp/php-cs-fixer": ">=3.2", "squizlabs/php_codesniffer": ">=3.6", "phpmd/phpmd": ">=2.9", "phpstan/phpstan": ">=0.12.58",