Skip to content
This repository was archived by the owner on Mar 1, 2023. It is now read-only.

Commit 13dbc87

Browse files
committed
updated phpunit
updated README.md with how to use composer cs and how to overwrite rules update all rules update travis build to stages fixed spelling in CONTRIBUTING.md using Localheinz php-cs-fixer-config as base
1 parent 2eb7e71 commit 13dbc87

15 files changed

+878
-699
lines changed

.gitattributes

+16-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
1-
/bin export-ignore
1+
* text=auto
2+
*.php text eol=lf
3+
4+
build export-ignore
5+
.github export-ignore
6+
7+
.php_cs export-ignore
28
.gitattributes export-ignore
39
.gitignore export-ignore
4-
.php_cs export-ignore
510
.travis.yml export-ignore
6-
phpunit.xml.dist export-ignore
7-
*.php text eol=lf
11+
.editorconfig export-ignore
12+
phpstan.neon export-ignore
13+
14+
phpunit.xml.dist export-ignore
15+
phpunit.php export-ignore
16+
17+
CONTRIBUTING.md export-ignore
18+
README.md export-ignore
19+
CODE_OF_CONDUCT.md export-ignore

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/vendor
2-
/build
2+
/build/logs
33

44
composer.phar
55
.php_cs.cache

.php_cs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types=1);
23
use Narrowspark\CS\Config\Config;
34

45
$config = new Config();

.travis.yml

+46-30
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,59 @@
1+
dist: trusty
2+
sudo: required
13
language: php
24

3-
php:
4-
- 7.1
5-
65
env:
76
global:
8-
- SEND_COVERAGE=false
9-
- PHPSTAN=false
10-
11-
matrix:
12-
fast_finish: true
13-
include:
14-
- php: 7.1
15-
env: SEND_COVERAGE=true
16-
# phpstan
17-
- php: 7.1
18-
env: PHPSTAN=true
19-
20-
sudo: false
7+
- TEST="./vendor/bin/phpunit --verbose"
8+
- COMPOSER_UP="composer update --no-interaction --prefer-dist --no-progress --profile --no-suggest"
219

2210
cache:
2311
directories:
24-
- $HOME/.composer/cache
12+
- $HOME/.composer/cache/files
2513
- $HOME/.php-cs-fixer
2614

2715
before_install:
28-
- composer validate
16+
- stty cols 120
17+
- mkdir -p ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d
18+
- chmod a+x ./build/travis/configure_php.sh
19+
- ./build/travis/configure_php.sh
2920

3021
install:
31-
- composer install --no-interaction --prefer-dist --no-progress --profile
22+
- composer global require hirak/prestissimo
23+
- $COMPOSER_UP
3224

33-
before_script:
34-
- mkdir -p "$HOME/.php-cs-fixer"
35-
36-
script:
37-
- mkdir -p build/logs
38-
- if [[ "$PHPSTAN" = false && "$SEND_COVERAGE" = true ]]; then ./vendor/bin/php-cs-fixer fix --verbose --diff --dry-run; fi
39-
- if [[ "$PHPSTAN" = false && "$SEND_COVERAGE" = true ]]; then ./vendor/bin/phpunit -c phpunit.xml.dist --verbose --coverage-clover=coverage.xml; fi
40-
- if [[ "$PHPSTAN" = true && "$SEND_COVERAGE" = false ]]; then ./vendor/bin/phpstan analyse -c phpstan.neon -l 6 src; fi
41-
42-
after_success:
43-
- if [[ "$PHPSTAN" = false && "$SEND_COVERAGE" = true ]]; then bash <(curl -s https://codecov.io/bash); fi
25+
jobs:
26+
include:
27+
- stage: Test
28+
php: 7.1
29+
env: REMOVE_XDEBUG=true
30+
- stage: Test
31+
php: 7.2
32+
env: REMOVE_XDEBUG=true
33+
34+
- stage: Coding standard
35+
if: type != cron
36+
php: 7.2
37+
env: REMOVE_XDEBUG=true
38+
script:
39+
- ./vendor/bin/php-cs-fixer fix --verbose --diff --dry-run
40+
- stage: Coding standard
41+
if: type != cron
42+
php: 7.2
43+
env: REMOVE_XDEBUG=false
44+
script:
45+
- ./vendor/bin/phpstan analyse -c phpstan.neon -l 7 src
46+
47+
- stage: Coverage
48+
if: type != cron
49+
php: 7.2
50+
env: REMOVE_XDEBUG=false
51+
script:
52+
- bash -xc "$TEST -c ./phpunit.xml.dist --coverage-clover=coverage.xml"
53+
after_success:
54+
- bash <(curl -s https://codecov.io/bash)
55+
56+
notifications:
57+
email:
58+
on_success: never
59+
on_failure: change

CONTRIBUTING.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# php-cs-fixer-config contributing guidelines
1+
<h1 align="center">Narrowspark Contributing Guidelines</h1>
22

3-
Thank you for wanting to contribute to php-cs-fixer-config!
3+
Thank you for wanting to contribute to narrowspark!
44

55
You can find below our guidelines for contribution, explaining how to send [pull requests](#pull-requests), [report issues](#filling-bugs) and [ask questions](#asking-questions), as well as which [workflow](#workflow) we're using while developing php-cs-fixer-config.
66

77
## Maintainers
88

9-
Current maintainers of php-cs-fixer-config are:
9+
Current maintainers of narrowspark are:
1010

1111
- [Daniel Bannert](https://github.com/prisis),
1212

@@ -34,7 +34,7 @@ If you fixed or added something useful to the project, you can send a pull-reque
3434

3535
1. Make sure you have tests for your modifications.
3636
2. Run phpunit test locally to catch any errors.
37-
3. It should follow [PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - Check the code style with ``$ vendor/bin/php-cs-fixer fix --config-file=.php_cs -v --diff --dry-run`` and fix it with ``$ vendor/bin/php-cs-fixer fix --config-file=.php_cs -v``.
37+
3. Check the code style with ``$ php vendor/bin/php-cs-fixer fix --config-file=.php_cs -v --diff --dry-run`` and fix it with ``$ php vendor/bin/php-cs-fixer fix --config-file=.php_cs -v``.
3838

3939
#### Why did you close my pull request or issue?
4040

@@ -59,11 +59,11 @@ If you found an error, typo, or any other flaw in the project, please report it
5959

6060
When it comes to bugs, the more details you provide, the easier it is to reproduce the issue and the faster it could be fixed.
6161

62-
The best case would be if you'd provide a minimal reproducible test case illustrating a bug. For most cases just a code snippet would be enough, for more complex cases you can create gists or even test repos on GitHub — we would be glad to look into any problems you'll have with php-cs-fixer-config.
62+
The best case would be if you'd provide a minimal reproducible test case illustrating a bug. For most cases just a code snippet would be enough, for more complex cases you can create gists or even test repos on GitHub — we would be glad to look into any problems you'll have with narrowspark php-cs-fixer-config.
6363

6464
### Asking questions
6565

66-
GitHub issues is not the best place for asking questions like “why my code won't work” or “is there a way to do X in php-cs-fixer-config”, but we are constantly monitoring the [php-cs-fixer-config tag at StackOverflow](http://stackoverflow.com/unanswered/tagged/php-cs-fixer-config), so feel free to ask there! It would make it easier for other people to get answers and to keep GitHub Issues for bugs and feature requests.
66+
GitHub issues is not the best place for asking questions like “why my code won't work” or “is there a way to do X in narrowspark”, but we are constantly monitoring the [narrowspark tag at StackOverflow](http://stackoverflow.com/unanswered/tagged/narrowspark), so feel free to ask there! It would make it easier for other people to get answers and to keep GitHub Issues for bugs and feature requests.
6767

6868
### Fixing existing issues
6969

@@ -73,13 +73,13 @@ If you'd like to work on an existing issue, just leave a comment on the issue sa
7373

7474
If you've got an idea for a new feature, file an issue providing some details on your idea. Try searching the issues to see if there is an existing proposal for your feature and feel free to bump it by providing your use case or explaining why this feature is important for you.
7575

76-
We should note that not everything should be done as a “php-cs-fixer-config feature”, some features better be a php-cs-fixer-config plug-ins, some are just not in the scope of the project.
76+
We should note that not everything should be done as a “narrowspark php-cs-fixer-config feature”, some features better be a narrowspark php-cs-fixer-config plug-ins, some are just not in the scope of the project.
7777

7878
* * *
7979

8080
## Workflow
8181

82-
This section describes the workflow we use for php-cs-fixer-config releases, the naming of the branches and the meaning behind them.
82+
This section describes the workflow we use for narrowspark releases, the naming of the branches and the meaning behind them.
8383

8484
### Branches
8585

@@ -103,7 +103,7 @@ The following branches should always be there. Do not fork them directly, always
103103

104104
### Releasing workflow
105105

106-
We follow [semver](http://semver.org/). We're in `0.x` at the moment, however, as php-cs-fixer-config is already widely used, we don't introduce backwards-incompatible changes to our minor releases.
106+
We follow [semver](http://semver.org/). We're in `0.x` at the moment, however, as narrowspark is already widely used, we don't introduce backwards-incompatible changes to our minor releases.
107107

108108
Each minor release should be first compiled into `rc-`branch. Minor release *should not* have fixes in it, as patch-release should be published before a minor one if there are fixes. This would deliver the fixes to the people using the fixed minor, but `x` at patch version.
109109

@@ -113,4 +113,4 @@ Patch releases don't need their own `rc` branches, as they could be released fro
113113

114114
This document is inspired my many other Contributing.md files.
115115

116-
**Happy coding**!
116+
**Happy coding**!

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2015-2016 Narrowspark
3+
Copyright (c) 2015-2018 Narrowspark
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+49-4
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ Usage
2323

2424
Create a configuration file '.php_cs' in the root of your project:
2525

26-
``` php
26+
```php
2727
<?php
28+
declare(strict_types=1);
2829
use Narrowspark\CS\Config\Config;
2930

3031
$config = new Config();
@@ -58,6 +59,37 @@ EOF;
5859
$config = new Narrowspark\CS\Config\Config($header);
5960
```
6061

62+
Configuration with override rules
63+
-------------
64+
65+
:bulb: Optionally override rules from a rule set by passing in an array of rules to be merged in:
66+
67+
```php
68+
<?php
69+
declare(strict_types=1);
70+
71+
use Narrowspark\CS\Config\Config;
72+
73+
$config = new Config(null /* if you dont need a header */, [
74+
'mb_str_functions' => false,
75+
'strict_comparison' => false,
76+
]);
77+
$config->getFinder()
78+
->files()
79+
->in(__DIR__)
80+
->exclude('build')
81+
->exclude('vendor')
82+
->name('*.php')
83+
->ignoreDotFiles(true)
84+
->ignoreVCS(true);
85+
86+
$cacheDir = getenv('TRAVIS') ? getenv('HOME') . '/.php-cs-fixer' : __DIR__;
87+
88+
$config->setCacheFile($cacheDir . '/.php_cs.cache');
89+
90+
return $config;
91+
```
92+
6193
Git
6294
-------------
6395
Add `.php_cs.cache` (this is the cache file created by `php-cs-fixer`) to `.gitignore`:
@@ -97,6 +129,19 @@ script:
97129
- if [[ "$WITH_CS" == "true" ]]; then ./vendor/bin/php-cs-fixer fix --config=.php_cs --verbose --diff --dry-run; fi
98130
```
99131

132+
Composer
133+
-------------
134+
Update ``composer.json`` script section with this line ``"cs": "php-cs-fixer fix"`` to run php-cs-fixer call ``composer cs``.
135+
136+
```json
137+
{
138+
"scripts": {
139+
"cs": "php-cs-fixer fix"
140+
}
141+
}
142+
```
143+
144+
100145
Testing
101146
-------------
102147

@@ -107,18 +152,18 @@ $ vendor/bin/phpunit
107152
Contributing
108153
------------
109154

110-
If you would like to help take a look at the [list of issues](http://github.com/narrowspark/testing-helper/issues) and check our [Contributing](CONTRIBUTING.md) guild.
155+
If you would like to help take a look at the [list of issues](http://github.com/narrowspark/php-cs-fixer-config/issues) and check our [Contributing](CONTRIBUTING.md) guild.
111156

112157
> **Note:** Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
113158

114159
Credits
115160
-------------
116161

117162
- [Daniel Bannert](https://github.com/prisis)
118-
- [refinery29](https://github.com/refinery29/php-cs-fixer-config)
163+
- [Andreas Möller](https://github.com/localheinz)
119164
- [All Contributors](../../contributors)
120165

121166
License
122167
-------------
123168

124-
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
169+
The MIT License (MIT). Please see [License File](LICENSE) for more information.

build/travis/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Build Scripts
2+
3+
This directory contains the scripts that travis uses to build the project.
4+
5+
Tests on the entire [`narrowspark/php-cs-fixer-config`](https://github.com/narrowspark/php-cs-fixer-config) repository,
6+
and then sends code coverage reports out to [Codecov](https://codecov.io/github/narrowspark/php-cs-fixer-config).

build/travis/configure_php.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
3+
if [[ "$REMOVE_XDEBUG" = true ]]; then
4+
phpenv config-rm xdebug.ini;
5+
fi

composer.json

+31-27
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,57 @@
11
{
2-
"name" : "narrowspark/php-cs-fixer-config",
2+
"name": "narrowspark/php-cs-fixer-config",
3+
"type": "library",
34
"description": "Provides a configuration for friendsofphp/php-cs-fixer, used within Narrowspark.",
4-
"type" : "library",
5-
"keywords" : [
5+
"keywords": [
66
"narrowspark",
77
"cs",
88
"cs-fixer",
99
"config",
1010
"php-cs-fixer"
1111
],
12-
"license" : "MIT",
13-
"homepage" : "https://github.com/narrowspark/php-cs-fixer-config",
14-
"support" : {
15-
"issues": "https://github.com/narrowspark/php-cs-fixer-config/issues",
16-
"source": "https://github.com/narrowspark/php-cs-fixer-config"
17-
},
18-
"authors" : [
12+
"homepage": "https://github.com/narrowspark/php-cs-fixer-config",
13+
"license": "MIT",
14+
"authors": [
1915
{
20-
"name" : "Daniel Bannert",
21-
"email" : "[email protected]",
22-
"homepage": "http://www.anolilab.de",
23-
"role" : "Developer"
16+
"name": "Daniel Bannert",
17+
"email": "[email protected]",
18+
"homepage": "http://www.anolilab.de",
19+
"role": "Developer"
2420
}
2521
],
2622
"require": {
27-
"php" : "^7.1",
28-
"friendsofphp/php-cs-fixer" : "~2.8"
23+
"php": "^7.1",
24+
"localheinz/php-cs-fixer-config": "^1.13.1"
2925
},
3026
"require-dev": {
31-
"phpstan/phpstan" : "^0.8",
32-
"phpunit/phpunit" : "^6.1"
27+
"phpstan/phpstan": "^0.9.0",
28+
"phpstan/phpstan-phpunit": "^0.9.0",
29+
"phpstan/phpstan-strict-rules": "^0.9.0",
30+
"phpunit/phpunit": "^7.0.0"
31+
},
32+
"config": {
33+
"sort-packages": true
3334
},
3435
"autoload": {
3536
"psr-4": {
36-
"Narrowspark\\CS\\Config\\" : "src"
37+
"Narrowspark\\CS\\Config\\": "src"
3738
}
3839
},
3940
"autoload-dev": {
4041
"psr-4": {
41-
"Narrowspark\\CS\\Config\\Test\\" : "tests"
42+
"Narrowspark\\CS\\Config\\Test\\": "tests"
4243
}
4344
},
44-
"config": {
45-
"sort-packages": true
46-
},
45+
"minimum-stability": "dev",
46+
"prefer-stable": true,
4747
"scripts": {
48-
"cs" : "sh vendor/bin/php-cs-fixer fix",
49-
"phpstan" : "sh vendor/bin/phpstan analyse -c phpstan.neon -l 6 src/"
48+
"coverage": "phpunit --coverage-html=\"build/logs\"",
49+
"cs": "php-cs-fixer fix",
50+
"phpstan": "phpstan analyse -c phpstan.neon -l 7 src --memory-limit=-1",
51+
"test": "phpunit"
5052
},
51-
"minimum-stability" : "dev",
52-
"prefer-stable" : true
53+
"support": {
54+
"issues": "https://github.com/narrowspark/php-cs-fixer-config/issues",
55+
"source": "https://github.com/narrowspark/php-cs-fixer-config"
56+
}
5357
}

0 commit comments

Comments
 (0)