From 7e6d4b26547d1c7b3cc3015ab6fe63a050526da3 Mon Sep 17 00:00:00 2001 From: Jan Nedbal Date: Wed, 17 Jul 2024 13:49:05 +0200 Subject: [PATCH 1/3] Initialize dead-code detector --- composer.json | 1 + composer.lock | 68 +++++++++++++++++++++++++++++++++++++++++++++-- phpstan.neon.dist | 6 +++++ 3 files changed, 73 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index cd9262f..97e165b 100644 --- a/composer.json +++ b/composer.json @@ -21,6 +21,7 @@ "phpstan/phpstan-strict-rules": "^1.6.0", "phpunit/phpunit": "^9.5.20", "shipmonk/composer-dependency-analyser": "^1.3.0", + "shipmonk/dead-code-detector": "dev-master", "shipmonk/name-collision-detector": "^2.0.0", "slevomat/coding-standard": "^8.0.1" }, diff --git a/composer.lock b/composer.lock index deaecd7..74f12b8 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "7d6d87492fb9ef19646e4e02113ce034", + "content-hash": "d8a113601a59fea07643db5a5d711144", "packages": [ { "name": "phpstan/phpstan", @@ -2855,6 +2855,68 @@ }, "time": "2024-08-08T08:12:32+00:00" }, + { + "name": "shipmonk/dead-code-detector", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/shipmonk-rnd/dead-code-detector.git", + "reference": "c3edd158d5beff2073af5515aa43c473f7503df1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/shipmonk-rnd/dead-code-detector/zipball/c3edd158d5beff2073af5515aa43c473f7503df1", + "reference": "c3edd158d5beff2073af5515aa43c473f7503df1", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0", + "phpstan/phpstan": "^1.11.0" + }, + "require-dev": { + "editorconfig-checker/editorconfig-checker": "^10.3.0", + "ergebnis/composer-normalize": "^2.28", + "phpstan/phpstan-phpunit": "^1.1.1", + "phpstan/phpstan-strict-rules": "^1.2.3", + "phpunit/phpunit": "^9.5.20", + "shipmonk/name-collision-detector": "^2.0.0", + "shipmonk/phpstan-rules": "^3.1", + "slevomat/coding-standard": "^8.0.1", + "symfony/contracts": "^2.5 || ^3.0", + "symfony/event-dispatcher": "^5.4 || ^6.0 || ^7.0", + "symfony/routing": "^5.4 || ^6.0 || ^7.0" + }, + "default-branch": true, + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "rules.neon" + ] + } + }, + "autoload": { + "psr-4": { + "ShipMonk\\PHPStan\\DeadCode\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan rules and collectors to find dead and unused code", + "keywords": [ + "PHPStan", + "dead code", + "static analysis", + "unused code" + ], + "support": { + "issues": "https://github.com/shipmonk-rnd/dead-code-detector/issues", + "source": "https://github.com/shipmonk-rnd/dead-code-detector/tree/master" + }, + "time": "2024-07-17T11:47:43+00:00" + }, { "name": "shipmonk/name-collision-detector", "version": "2.1.1", @@ -3111,7 +3173,9 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "shipmonk/dead-code-detector": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 49bae49..3589f30 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -4,6 +4,7 @@ includes: - ./vendor/phpstan/phpstan-strict-rules/rules.neon - ./vendor/phpstan/phpstan-phpunit/extension.neon - ./vendor/phpstan/phpstan-phpunit/rules.neon + - ./vendor/shipmonk/dead-code-detector/rules.neon - ./rules.neon parameters: @@ -44,6 +45,11 @@ parameters: enforceClosureParamNativeTypehint: enabled: false # we support even PHP 7.4, some typehints cannot be used + shipmonkDeadCode: + entrypoints: + phpunit: + enabled: true + ignoreErrors: - message: "#Class BackedEnum not found\\.#" From bb8f29bbb485f61f1541ed134df0bd5f51235763 Mon Sep 17 00:00:00 2001 From: Jan Nedbal Date: Wed, 24 Jul 2024 14:00:29 +0200 Subject: [PATCH 2/3] Zero config! --- composer.lock | 13 ++++++++----- phpstan.neon.dist | 5 ----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/composer.lock b/composer.lock index 74f12b8..7d0a1a6 100644 --- a/composer.lock +++ b/composer.lock @@ -2861,12 +2861,12 @@ "source": { "type": "git", "url": "https://github.com/shipmonk-rnd/dead-code-detector.git", - "reference": "c3edd158d5beff2073af5515aa43c473f7503df1" + "reference": "b778a9aa4e56c6deb50aab7f1accd2c93c188ada" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/shipmonk-rnd/dead-code-detector/zipball/c3edd158d5beff2073af5515aa43c473f7503df1", - "reference": "c3edd158d5beff2073af5515aa43c473f7503df1", + "url": "https://api.github.com/repos/shipmonk-rnd/dead-code-detector/zipball/b778a9aa4e56c6deb50aab7f1accd2c93c188ada", + "reference": "b778a9aa4e56c6deb50aab7f1accd2c93c188ada", "shasum": "" }, "require": { @@ -2874,14 +2874,17 @@ "phpstan/phpstan": "^1.11.0" }, "require-dev": { + "doctrine/orm": "^2.19 || ^3.0", "editorconfig-checker/editorconfig-checker": "^10.3.0", "ergebnis/composer-normalize": "^2.28", "phpstan/phpstan-phpunit": "^1.1.1", "phpstan/phpstan-strict-rules": "^1.2.3", + "phpstan/phpstan-symfony": "^1.4", "phpunit/phpunit": "^9.5.20", + "shipmonk/composer-dependency-analyser": "^1.6", "shipmonk/name-collision-detector": "^2.0.0", "shipmonk/phpstan-rules": "^3.1", - "slevomat/coding-standard": "^8.0.1", + "slevomat/coding-standard": "^8.15.0", "symfony/contracts": "^2.5 || ^3.0", "symfony/event-dispatcher": "^5.4 || ^6.0 || ^7.0", "symfony/routing": "^5.4 || ^6.0 || ^7.0" @@ -2915,7 +2918,7 @@ "issues": "https://github.com/shipmonk-rnd/dead-code-detector/issues", "source": "https://github.com/shipmonk-rnd/dead-code-detector/tree/master" }, - "time": "2024-07-17T11:47:43+00:00" + "time": "2024-07-24T11:59:35+00:00" }, { "name": "shipmonk/name-collision-detector", diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 3589f30..5d98a82 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -45,11 +45,6 @@ parameters: enforceClosureParamNativeTypehint: enabled: false # we support even PHP 7.4, some typehints cannot be used - shipmonkDeadCode: - entrypoints: - phpunit: - enabled: true - ignoreErrors: - message: "#Class BackedEnum not found\\.#" From 2d16f21f7cbd6e7d9124cedcbd3a6f0b741b9806 Mon Sep 17 00:00:00 2001 From: Jan Nedbal Date: Mon, 9 Sep 2024 11:46:42 +0200 Subject: [PATCH 3/3] Stable version --- composer.json | 2 +- composer.lock | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/composer.json b/composer.json index 97e165b..44c9dc6 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "phpstan/phpstan-strict-rules": "^1.6.0", "phpunit/phpunit": "^9.5.20", "shipmonk/composer-dependency-analyser": "^1.3.0", - "shipmonk/dead-code-detector": "dev-master", + "shipmonk/dead-code-detector": "^0.2.1", "shipmonk/name-collision-detector": "^2.0.0", "slevomat/coding-standard": "^8.0.1" }, diff --git a/composer.lock b/composer.lock index 7d0a1a6..9aa5bad 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "d8a113601a59fea07643db5a5d711144", + "content-hash": "00033ad4202097cc32b2c8047b71e707", "packages": [ { "name": "phpstan/phpstan", @@ -2857,16 +2857,16 @@ }, { "name": "shipmonk/dead-code-detector", - "version": "dev-master", + "version": "0.2.1", "source": { "type": "git", "url": "https://github.com/shipmonk-rnd/dead-code-detector.git", - "reference": "b778a9aa4e56c6deb50aab7f1accd2c93c188ada" + "reference": "780dc3f6d6a1551703c65bbf127dd63f94cc2166" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/shipmonk-rnd/dead-code-detector/zipball/b778a9aa4e56c6deb50aab7f1accd2c93c188ada", - "reference": "b778a9aa4e56c6deb50aab7f1accd2c93c188ada", + "url": "https://api.github.com/repos/shipmonk-rnd/dead-code-detector/zipball/780dc3f6d6a1551703c65bbf127dd63f94cc2166", + "reference": "780dc3f6d6a1551703c65bbf127dd63f94cc2166", "shasum": "" }, "require": { @@ -2877,6 +2877,9 @@ "doctrine/orm": "^2.19 || ^3.0", "editorconfig-checker/editorconfig-checker": "^10.3.0", "ergebnis/composer-normalize": "^2.28", + "nette/application": "^3.1", + "nette/component-model": "^3.0", + "nette/utils": "^3.0 || ^4.0", "phpstan/phpstan-phpunit": "^1.1.1", "phpstan/phpstan-strict-rules": "^1.2.3", "phpstan/phpstan-symfony": "^1.4", @@ -2889,7 +2892,6 @@ "symfony/event-dispatcher": "^5.4 || ^6.0 || ^7.0", "symfony/routing": "^5.4 || ^6.0 || ^7.0" }, - "default-branch": true, "type": "phpstan-extension", "extra": { "phpstan": { @@ -2916,9 +2918,9 @@ ], "support": { "issues": "https://github.com/shipmonk-rnd/dead-code-detector/issues", - "source": "https://github.com/shipmonk-rnd/dead-code-detector/tree/master" + "source": "https://github.com/shipmonk-rnd/dead-code-detector/tree/0.2.1" }, - "time": "2024-07-24T11:59:35+00:00" + "time": "2024-09-05T11:28:14+00:00" }, { "name": "shipmonk/name-collision-detector", @@ -3176,9 +3178,7 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": { - "shipmonk/dead-code-detector": 20 - }, + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": {