Skip to content

Commit 99bc9e5

Browse files
committed
Tools - don't preinstall any QA tools
- it simplifies composer installation and conflicts (install what you need) - abandoned tools can be ignored - it slightly complicates default UX if user does not use docker image - update composer in dockerfile otherwise 7.2 cannot install deptrac + it prevents errors caused by deprecated composer
1 parent 5eea6ca commit 99bc9e5

7 files changed

Lines changed: 30 additions & 33 deletions

File tree

.docker/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ ARG COMPOSER_VERSION=1.8.0
22
FROM composer:$COMPOSER_VERSION
33

44
RUN apk add --update libxslt-dev && \
5-
docker-php-ext-install xsl
5+
docker-php-ext-install xsl && \
6+
composer self-update
67

78
COPY ./composer.json ./bin/suggested-tools.sh /phpqa/
89
RUN (cd /phpqa && \

.github/workflows/php.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
if [[ $INSTALL_SUGGESTED_TOOLS == "yes" ]]; then
5858
PHP_VERSION=$PHP_VERSION bin/suggested-tools.sh install;
5959
else
60-
composer install --no-interaction --no-progress;
60+
PREINSTALLED_TOOLS=legacy bin/suggested-tools.sh install;
6161
fi
6262
php tests/.phpunit/fix-typehints.php;
6363

README.md

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,19 @@ Will you create e.g. Jenkins project/task for each bundle?
3333

3434
## Available [tools](https://github.com/ziadoz/awesome-php#code-analysis)
3535

36-
Tool| Description
37-
----------------------------------------------------------------------- | ----------------------------- |
38-
[phploc](https://github.com/sebastianbergmann/phploc) | Measure the size of a PHP project |
39-
[phpcpd](https://github.com/sebastianbergmann/phpcpd) | Copy/Paste Detector (CPD) for PHP code |
40-
[phpcs](https://github.com/squizlabs/PHP_CodeSniffer) | Detect violations of a coding standard |
41-
[pdepend](https://github.com/pdepend/pdepend) | PHP adaptation of JDepend |
42-
[phpmd](https://github.com/phpmd/phpmd) | Scan PHP project for messy code |
43-
[phpmetrics](https://github.com/Halleck45/PhpMetrics) | Static analysis tool for PHP |
36+
**Since version [1.27] no tools are preinstalled if you run `composer require`!**
4437

45-
##### Suggested tools
46-
47-
Newly added tools aren't preinstalled. You have to install relevant composer packages if
48-
you want to use them.
38+
You have to install relevant composer packages if you want to use them,
39+
or define `binary` path in `.phpqa.yml`, or use official docker image with preinstalled tools.
4940

5041
Tool | PHP | Supported since | Description |
5142
---- | --- | --------------- | ----------- |
43+
[phploc](https://github.com/sebastianbergmann/phploc) | `>= 5.4` | `1.0` | Measure the size of a PHP project |
44+
[phpcpd](https://github.com/sebastianbergmann/phpcpd) | `>= 5.4` | `1.0` | Copy/Paste Detector (CPD) for PHP code |
45+
[phpcs](https://github.com/squizlabs/PHP_CodeSniffer) | `>= 5.4` | `1.0` | Detect violations of a coding standard |
46+
[pdepend](https://github.com/pdepend/pdepend) | `>= 5.4` | `1.0` | PHP adaptation of JDepend |
47+
[phpmd](https://github.com/phpmd/phpmd) | `>= 5.4` | `1.0` | Scan PHP project for messy code |
48+
[phpmetrics](https://github.com/Halleck45/PhpMetrics) | `>= 5.4` | `1.0` | Static analysis tool for PHP |
5249
[security-checker](https://github.com/enlightn/security-checker) | `>= 5.6` | `1.24` | Check composer.lock for known security issues |
5350
[php-cs-fixer](http://cs.sensiolabs.org/) | [`>= 5.3`](https://github.com/EdgedesignCZ/phpqa/pull/66#discussion_r115206573) | `1.12` | Automatically detect and fix PHP coding standards issues |
5451
[phpunit](https://github.com/phpunit/phpunit) | `>= 5.3` | `1.13` | The PHP Unit Testing framework |

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ install:
4242
- appveyor-retry appveyor DownloadFile https://getcomposer.org/composer.phar
4343
# install
4444
- cd c:\projects\phpqa
45-
- appveyor-retry composer install --no-progress --profile
45+
- appveyor-retry composer require squizlabs/php_codesniffer phpmd/phpmd pdepend/pdepend phpmetrics/phpmetrics phploc/phploc sebastian/phpcpd --no-progress --profile
4646

4747
test_script:
4848
- cd C:\projects\phpqa

bin/suggested-tools.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ SELECTED_MODE="$1"
1616
COMPOSER_REQUIRE_MODES="$2"
1717

1818
PHP_VERSION=${PHP_VERSION:-"7"}
19+
PREINSTALLED_TOOLS=${PREINSTALLED_TOOLS:-""}
1920

2021
run () {
2122
TOOLS=$(get_tools)
@@ -40,9 +41,12 @@ show_help() {
4041
}
4142

4243
get_tools () {
43-
TOOLS="php-parallel-lint/php-parallel-lint php-parallel-lint/php-console-highlighter friendsofphp/php-cs-fixer"
44-
if [[ ${PHP_VERSION:0:1} != "5" ]]; then
45-
TOOLS="${TOOLS} psalm/phar phpstan/phpstan nette/neon deptrac/deptrac enlightn/security-checker"
44+
TOOLS="squizlabs/php_codesniffer phpmd/phpmd pdepend/pdepend phpmetrics/phpmetrics phploc/phploc sebastian/phpcpd"
45+
if [[ $PREINSTALLED_TOOLS != "legacy" ]]; then
46+
TOOLS="${TOOLS} php-parallel-lint/php-parallel-lint php-parallel-lint/php-console-highlighter friendsofphp/php-cs-fixer"
47+
if [[ ${PHP_VERSION:0:1} != "5" ]]; then
48+
TOOLS="${TOOLS} psalm/phar phpstan/phpstan nette/neon deptrac/deptrac enlightn/security-checker"
49+
fi
4650
fi
4751
echo $TOOLS
4852
}

composer.json

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,23 @@
2020
"php": ">=5.4",
2121
"ext-xsl": "*",
2222
"consolidation/robo": "~0.5|>=1",
23-
"phpmd/phpmd" : "*",
24-
"phploc/phploc": "*",
25-
"symfony/dependency-injection": ">=2.8.50",
26-
"symfony/filesystem": ">=2.8",
27-
"symfony/process": ">=2.8",
28-
"symfony/finder": ">=2.8",
29-
"symfony/yaml": ">=2.8",
30-
"twig/twig": "~1.38|~2.7|~3",
31-
"pdepend/pdepend": "*",
32-
"sebastian/phpcpd": "*",
33-
"squizlabs/php_codesniffer": "*",
34-
"phpmetrics/phpmetrics": "*"
23+
"twig/twig": "~1.38|~2.7|>=3"
3524
},
3625
"suggest": {
26+
"squizlabs/php_codesniffer": "Detect coding standard violation (phpcs) and fix them (phpcbf)",
3727
"enlightn/security-checker": "Check composer.lock for known security issues",
3828
"friendsofphp/php-cs-fixer": "A tool to automatically fix PHP coding standards issues",
3929
"phpunit/phpunit": "The PHP Unit Testing framework",
4030
"phpstan/phpstan": "PHP Static Analysis Tool - discover bugs in your code without running it!",
4131
"psalm/phar": "A static analysis tool for finding errors in PHP applications",
4232
"php-parallel-lint/php-parallel-lint": "Check PHP syntax",
4333
"php-parallel-lint/php-console-highlighter": "Colored output in parallel-lint",
44-
"deptrac/deptrac": "Enforce rules for dependencies between software layers"
34+
"deptrac/deptrac": "Enforce rules for dependencies between software layers",
35+
"phpmd/phpmd" : "user friendly metrics from pdepend",
36+
"pdepend/pdepend": "Analyze you the quality of your design in terms of extensibility, reusability and maintainability",
37+
"phpmetrics/phpmetrics": "Metrics about PHP project and classes in HTML report",
38+
"phploc/phploc": "Abandoned measuring the size of a PHP project",
39+
"sebastian/phpcpd": "Abandoned copy-paste detector"
4540
},
4641
"require-dev": {
4742
"hamcrest/hamcrest-php": ">=2.0.1",

phpqa

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ if (getenv('COMPOSER_BIN_DIR') && getenv('COMPOSER_VENDOR_DIR')) {
2020
"{$projectRoot}/" . getenv('COMPOSER_BIN_DIR'),
2121
];
2222
foreach ($binPaths as $bin) {
23-
if (is_file("{$bin}/phploc")) {
23+
if (is_file("{$bin}/phpqa")) {
2424
define('COMPOSER_BINARY_DIR', "{$bin}/");
2525
break;
2626
}
2727
}
2828
}
2929

30-
if (!defined('COMPOSER_BINARY_DIR') || !is_file(COMPOSER_BINARY_DIR . 'phploc')) {
30+
if (!defined('COMPOSER_BINARY_DIR') || !is_dir(COMPOSER_BINARY_DIR)) {
3131
die("Composer binary directory was not found (define path in environment variable 'COMPOSER_BIN_DIR')\n");
3232
}
3333

0 commit comments

Comments
 (0)