Skip to content

Commit 0097cd1

Browse files
authored
Merge pull request #29 from kubawerlos/composer-scripts
Use composer scripts
2 parents 016d794 + 0de4fb1 commit 0097cd1

File tree

5 files changed

+27
-27
lines changed

5 files changed

+27
-27
lines changed

.travis.yml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,9 @@ before_install:
1616
- composer self-update --stable
1717
- composer global show hirak/prestissimo -q || composer global require hirak/prestissimo
1818

19-
install:
20-
- composer install
19+
install: composer install
2120

22-
script:
23-
- vendor/bin/phpcs --exclude=Generic.Files.LineLength --report-full --standard=PSR2 src tests
24-
- vendor/bin/php-cs-fixer fix --config=tests/php-cs-fixer.config.php --diff --dry-run
25-
- vendor/bin/types-checker src tests
26-
- vendor/bin/psalm --config=tests/psalm.xml
27-
- phpdbg -qrr vendor/bin/phpunit --configuration=tests
21+
script: composer check
2822

2923
jobs:
3024
include:
@@ -45,15 +39,14 @@ jobs:
4539
stage: Test
4640
php: '7.2'
4741
install: composer require --dev php-coveralls/php-coveralls
48-
script: phpdbg -qrr vendor/bin/phpunit --configuration=tests --coverage-clover=build/logs/clover.xml
42+
script: composer phpunit -- --coverage-clover=build/logs/clover.xml
4943
after_success: vendor/bin/php-coveralls
5044

5145
-
5246
stage: Verify correctness for PHP CS Fixer
5347
php: '7.2'
5448
install: ~
55-
before_script:
56-
- phpenv config-rm xdebug.ini || return 0
49+
before_script: phpenv config-rm xdebug.ini || return 0
5750
script:
5851
# prepare PHP CS Fixer
5952
- composer create-project --no-interaction --prefer-source friendsofphp/php-cs-fixer tmp

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# CHANGELOG for PHP CS Fixer: custom fixers
22

33
## [Unreleased]
4+
- Use composer scripts
45
- Switch from Codecov to Coveralls
56
- Add NoUselessDoctrineRepositoryCommentFixer
67

README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,6 @@ src/Readme/run > README.md
165165
```
166166
make sure all checks pass:
167167
```bash
168-
vendor/bin/phpcs --exclude=Generic.Files.LineLength --report-full --standard=PSR2 src tests
169-
vendor/bin/php-cs-fixer fix --config=tests/php-cs-fixer.config.php --diff --dry-run
170-
vendor/bin/types-checker src tests
171-
vendor/bin/psalm --config=tests/psalm.xml
172-
phpdbg -qrr vendor/bin/phpunit --configuration=tests
168+
composer check
173169
```
174170
and submit a pull request.

composer.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"friendsofphp/php-cs-fixer": "^2.12"
2121
},
2222
"require-dev": {
23+
"kubawerlos/composer-json-fixer": "^2.1",
2324
"kubawerlos/types-checker": "^1.1",
2425
"phpunit/phpunit": "^7.2",
2526
"sebastian/diff": "^3.0",
@@ -38,5 +39,21 @@
3839
"psr-4": {
3940
"Tests\\": "tests/"
4041
}
42+
},
43+
"scripts": {
44+
"check": [
45+
"@analyse",
46+
"@phpunit"
47+
],
48+
"analyse": [
49+
"vendor/bin/composer-json-fixer",
50+
"vendor/bin/phpcs --exclude=Generic.Files.LineLength --report-full --standard=PSR2 src tests",
51+
"vendor/bin/php-cs-fixer fix --config=tests/php-cs-fixer.config.php --diff --dry-run",
52+
"vendor/bin/types-checker src tests",
53+
"vendor/bin/psalm --config=tests/psalm.xml"
54+
],
55+
"phpunit": [
56+
"phpdbg -qrr vendor/bin/phpunit --configuration=tests/phpunit.xml"
57+
]
4158
}
4259
}

src/Readme/ReadmeCommand.php

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use Symfony\Component\Console\Command\Command as BaseCommand;
1313
use Symfony\Component\Console\Input\InputInterface;
1414
use Symfony\Component\Console\Output\OutputInterface;
15-
use Symfony\Component\Yaml\Yaml;
1615

1716
class ReadmeCommand extends BaseCommand
1817
{
@@ -138,11 +137,6 @@ private function fixers() : string
138137
return $output;
139138
}
140139

141-
private function composer() : \stdClass
142-
{
143-
return \json_decode(\file_get_contents(__DIR__ . '/../../composer.json'));
144-
}
145-
146140
private function diff(string $from, string $to) : string
147141
{
148142
return \str_replace(
@@ -168,16 +162,15 @@ private function contributing() : string
168162
```
169163
make sure all checks pass:
170164
```bash
171-
%s
165+
composer check
172166
```
173167
and submit a pull request.',
174-
$this->composer()->name,
175-
\implode("\n", $this->travisScripts())
168+
$this->composer()->name
176169
);
177170
}
178171

179-
private function travisScripts() : array
172+
private function composer() : \stdClass
180173
{
181-
return Yaml::parse(\file_get_contents(__DIR__ . '/../../.travis.yml'))['script'];
174+
return \json_decode(\file_get_contents(__DIR__ . '/../../composer.json'));
182175
}
183176
}

0 commit comments

Comments
 (0)