From b08f2e9e2cd5c564cfa141ba1744a85d8f1d0df6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Sat, 18 May 2024 12:56:13 +0200 Subject: [PATCH] add new dependencies --- .github/dependabot.yml | 9 ++- .github/renovate.json5 | 67 +++++++++------- .github/workflows/continuous-integration.yml | 2 + composer.json | 10 ++- phpstan.neon | 83 +++++++++++++++++++- src/StreamFormatter.php | 26 +++++- src/StreamFormatterFactory.php | 2 + 7 files changed, 159 insertions(+), 40 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 3e7f136..5c97a80 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -55,9 +55,12 @@ updates: - dependency-name: "laminas/laminas-servicemanager" versions: - ">= 0" -# - dependency-name: phpunit/phpunit -# versions: -# - ">= 0" + - dependency-name: "nikic/php-parser" + versions: + - ">= 0" + - dependency-name: "infection/infection" + versions: + - ">= 0" - package-ecosystem: "github-actions" diff --git a/.github/renovate.json5 b/.github/renovate.json5 index 63fcb7c..7b97440 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -1,25 +1,25 @@ { "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": ["github>whitesource/merge-confidence:beta"], + "extends": ["mergeConfidence:all-badges"], + + "enabled": true, - "enabled": false, "assignees": [ "mimmi20" ], - "automerge": false, + "branchConcurrentLimit": 0, "commitBody": "Signed-off-by: {{{gitAuthor}}}", "commitBodyTable": true, - "dependencyDashboard": false, - "enabledManagers": ["composer", "github-actions", "npm"], - "ignoreUnstable": true, + "configMigration": true, + "configWarningReuseIssue": false, + "dependencyDashboard": true, + "dependencyDashboardApproval": true, + "dependencyDashboardOSVVulnerabilitySummary": "all", "labels": [ - "dependencies", - "patch" + "dependencies" ], - "lockFileMaintenance": { - "enabled": false - }, + "osvVulnerabilityAlerts": true, "platformAutomerge": false, "prBodyColumns": [ "Package", @@ -33,41 +33,52 @@ "Update": "{{{updateType}}}", "Change": "[{{#if displayFrom}}`{{{displayFrom}}}` -> {{else}}{{#if currentValue}}`{{{currentValue}}}` -> {{/if}}{{/if}}{{#if displayTo}}`{{{displayTo}}}`{{else}}`{{{newValue}}}`{{/if}}]({{#if depName}}https://renovatebot.com/diffs/npm/{{replace '/' '%2f' depName}}/{{{currentVersion}}}/{{{newVersion}}}{{/if}})" }, + "prConcurrentLimit": 0, "prCreation": "immediate", + "prHourlyLimit": 0, "rangeStrategy": "bump", "rebaseWhen": "behind-base-branch", "reviewers": [ "mimmi20" ], - "rollbackPrs": true, - "schedule": ["at 4:00 pm on Friday"], + "schedule": ["at 4:00 am on Friday"], "semanticCommits": "disabled", - "separateMajorMinor": true, - "separateMinorPatch": false, "timezone": "Europe/Berlin", - "updateLockFiles": false, - "updateNotScheduled": false, "packageRules": [ + { + "groupName": "PHP", + "matchDepNames": ["php"], + "allowedVersions": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0", + "ignoreUnstable": false, + "rangeStrategy": "widen" + }, + { + "groupName": "Node", + "matchDepNames": ["node"], + "allowedVersions": "~19.5.0 || ~20.0.0 || ~21.0.0 || ~22.0.0", + "ignoreUnstable": false, + "rangeStrategy": "widen" + }, + { + "groupName": "devDependencies", + "matchDepTypes": ["devDependencies", "peerDependencies"], + "rangeStrategy": "widen" + }, + { + "matchPackageNames": ["nikic/php-parser", "infection/infection"], + "rangeStrategy": "widen" + }, { "groupName": "all non-major dependencies", "groupSlug": "all-minor-patch-dependencies", - "matchPackagePatterns": [ - "*" - ], "matchUpdateTypes": [ "minor", "patch" ] - }, - { - "groupName": "PHP", - "matchPackageNames": ["php"], - "allowedVersions": "^8.1", - "ignoreUnstable": false, - "rangeStrategy": "widen" } ], "vulnerabilityAlerts": { - "enabled": true + "enabled": true, + "labels": ["security"] } } diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 011c7ed..af45d42 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -39,6 +39,8 @@ jobs: extensions: "ctype, curl, dom, iconv, intl, mbstring, simplexml, tokenizer, xml, xmlwriter" ini-values: "opcache.enable=1, opcache.fast_shutdown=0, zend.assertions=1, assert.exception=On, intl.default_locale=de, intl.use_exceptions=1, zend.exception_ignore_args=0" composer-options: "--optimize-autoloader --prefer-dist --prefer-stable -v" + skip-php-install: false + skip-npm-install: true analytics: name: "Project Analysis" diff --git a/composer.json b/composer.json index 0937d0f..7c289fc 100644 --- a/composer.json +++ b/composer.json @@ -30,17 +30,21 @@ "ext-tokenizer": "*", "ext-xml": "*", "ext-xmlwriter": "*", - "infection/infection": "^0.27.11", + "infection/infection": "^0.27.11 || ^0.28.1", "laminas/laminas-modulemanager": "^2.15.0", "laminas/laminas-servicemanager": "^3.22.1 || ^4.0.0", "mimmi20/coding-standard": "^5.2.30", - "nikic/php-parser": "^v4.19.1", + "nikic/php-parser": "^v4.19.1 || ^v5.0.2", "phpstan/extension-installer": "^1.3.1", "phpstan/phpstan": "^1.11.1", "phpstan/phpstan-deprecation-rules": "^1.2.0", "phpstan/phpstan-phpunit": "^1.4.0", "phpunit/phpunit": "^10.5.20", - "rector/rector": "^1.0.5" + "rector/rector": "^1.0.5", + "symplify/phpstan-rules": "^12.4.9", + "tomasvotruba/cognitive-complexity": "^0.2.3", + "tomasvotruba/type-coverage": "^0.2.8", + "tomasvotruba/unused-public": "^0.3.9" }, "autoload": { "psr-4": { diff --git a/phpstan.neon b/phpstan.neon index 1b1b6f4..ce15274 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -35,9 +35,6 @@ parameters: # reports function and method calls with incorrect name case checkFunctionNameCase: true - # it requires type variables always be specified in typehints - checkGenericClassInNonGenericObjectType: true - # be strict about values with an unspecified (implicit mixed) type checkImplicitMixed: true @@ -97,6 +94,86 @@ parameters: missingCheckedExceptionInThrows: true tooWideThrowType: true + cognitive_complexity: + class: 138 + function: 24 + + type_coverage: + return: 100 + param: 98.4 + property: 100 + # also, how many files has declare strict types + declare: 100 + + unused_public: + methods: true + properties: true + constants: true + local_methods: true + ignoreErrors: # - '~is not subtype of Throwable~' - '~Call to static method PHPUnit\\Framework\\Assert::assert.*\(\) with .* will always evaluate to true~' + +rules: + # code complexity + - Symplify\PHPStanRules\Rules\Explicit\NoMixedPropertyFetcherRule + - Symplify\PHPStanRules\Rules\Explicit\NoMixedMethodCallerRule + - Symplify\PHPStanRules\Rules\Enum\RequireEnumDocBlockOnConstantListPassRule + - Symplify\PHPStanRules\Rules\NoDynamicNameRule + # - Symplify\PHPStanRules\Rules\Explicit\NoRelativeFilePathRule + # - Symplify\PHPStanRules\Rules\NoReturnArrayVariableListRule # todo: fix + + - Symplify\PHPStanRules\Rules\NoProtectedClassElementRule + - Symplify\PHPStanRules\Rules\ForbiddenExtendOfNonAbstractClassRule + - Symplify\PHPStanRules\Rules\Complexity\ForbiddenSameNamedNewInstanceRule + + # domain + - Symplify\PHPStanRules\Rules\Domain\RequireExceptionNamespaceRule + - Symplify\PHPStanRules\Rules\Domain\RequireAttributeNamespaceRule + - Symplify\PHPStanRules\Rules\Enum\RequireUniqueEnumConstantRule + - Symplify\PHPStanRules\Rules\ForbiddenParamTypeRemovalRule + - Symplify\PHPStanRules\Rules\PreventParentMethodVisibilityOverrideRule + + # paths + - Symplify\PHPStanRules\Rules\NoMissingDirPathRule + - Symplify\PHPStanRules\Rules\NoAbstractMethodRule + - Symplify\PHPStanRules\Rules\NoReferenceRule # References are required + - Symplify\PHPStanRules\Rules\NoArrayAccessOnObjectRule + + - Symplify\PHPStanRules\Rules\NoNullableArrayPropertyRule + - Symplify\PHPStanRules\Rules\BoolishClassMethodPrefixRule + + # dead-code + - Symplify\PHPStanRules\Rules\NoIssetOnObjectRule + + # explicit naming + - Symplify\PHPStanRules\Rules\ForbiddenMultipleClassLikeInOneFileRule + + # comlexity + - Symplify\PHPStanRules\Rules\Complexity\ForbiddenSameNamedNewInstanceRule + - Symplify\PHPStanRules\Rules\NarrowType\NoReturnFalseInNonBoolClassMethodRule + + - Symplify\PHPStanRules\Rules\Complexity\ForbiddenArrayMethodCallRule + # - Symplify\PHPStanRules\Rules\CheckRequiredInterfaceInContractNamespaceRule + - Symplify\PHPStanRules\Rules\NoEmptyClassRule + + # naming + - Symplify\PHPStanRules\Rules\RequireAttributeNameRule + + # regexes + - Symplify\PHPStanRules\Rules\AnnotateRegexClassConstWithRegexLinkRule + - Symplify\PHPStanRules\Rules\NoInlineStringRegexRule + - Symplify\PHPStanRules\Rules\RegexSuffixInRegexConstantRule + + # naming + - Symplify\PHPStanRules\Rules\Explicit\ExplicitClassPrefixSuffixRule + - Symplify\PHPStanRules\Rules\NoReturnSetterMethodRule + - Symplify\PHPStanRules\Rules\NoVoidGetterMethodRule + - Symplify\PHPStanRules\Rules\UppercaseConstantRule + - Symplify\PHPStanRules\Rules\ClassNameRespectsParentSuffixRule + - Symplify\PHPStanRules\Rules\CheckTypehintCallerTypeRule + - Symplify\PHPStanRules\Rules\CheckClassNamespaceFollowPsr4Rule + +includes: + - vendor/symplify/phpstan-rules/config/collector-rules.neon diff --git a/src/StreamFormatter.php b/src/StreamFormatter.php index 25b1e0d..ab73743 100644 --- a/src/StreamFormatter.php +++ b/src/StreamFormatter.php @@ -35,20 +35,28 @@ final class StreamFormatter extends NormalizerFormatter { + /** @api */ public const SIMPLE_FORMAT = '%message%'; + /** @api */ public const BOX_STYLE = 'box'; + /** @api */ public const WIDTH_FIRST_COLUMN = 20; + /** @api */ public const WIDTH_SECOND_COLUMN = 20; + /** @api */ public const WIDTH_THIRD_COLUMN = 220; + /** @api */ public const FULL_WIDTH = self::WIDTH_FIRST_COLUMN + self::WIDTH_SECOND_COLUMN + self::WIDTH_THIRD_COLUMN + 10; + /** @api */ public const SPAN_ALL_COLUMS = 3; + /** @api */ public const SPAN_LAST_COLUMNS = 2; private readonly string $format; @@ -87,7 +95,11 @@ public function __construct( ); } - /** @throws void */ + /** + * @throws void + * + * @api + */ public function includeStacktraces(bool $include = true): self { $this->includeStacktraces = $include; @@ -99,7 +111,11 @@ public function includeStacktraces(bool $include = true): self return $this; } - /** @throws void */ + /** + * @throws void + * + * @api + */ public function allowInlineLineBreaks(bool $allow = true): self { $this->allowInlineLineBreaks = $allow; @@ -107,7 +123,11 @@ public function allowInlineLineBreaks(bool $allow = true): self return $this; } - /** @throws void */ + /** + * @throws void + * + * @api + */ public function setFormatter(LineFormatter $formatter): void { $this->formatter = $formatter; diff --git a/src/StreamFormatterFactory.php b/src/StreamFormatterFactory.php index 0eabda7..47daa5d 100644 --- a/src/StreamFormatterFactory.php +++ b/src/StreamFormatterFactory.php @@ -25,8 +25,10 @@ final class StreamFormatterFactory implements FactoryInterface { + /** @api */ public const DEFAULT_NORMALIZER_DEPTH = 9; + /** @api */ public const DEFAULT_NORMALIZER_ITEM_COUNT = 1000; /**