Skip to content

Commit f542afa

Browse files
authored
Merge pull request #18 from colinodell/code-quality-and-tests
Code quality and tests
2 parents 760706a + 28e7155 commit f542afa

File tree

16 files changed

+289
-57
lines changed

16 files changed

+289
-57
lines changed

.editorconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
; top-most EditorConfig file
2+
root = true
3+
4+
# All files.
5+
[*]
6+
end_of_line = LF
7+
indent_style = space
8+
indent_size = 4
9+
charset = utf-8
10+
trim_trailing_whitespace = true
11+
insert_final_newline = true

.gitattributes

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Path-based git attributes
2+
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html
3+
4+
# Ignore all test and documentation with "export-ignore".
5+
/.editorconfig export-ignore
6+
/.gitattributes export-ignore
7+
/.github export-ignore
8+
/.gitignore export-ignore
9+
/phpcs.xml.dist export-ignore
10+
/phpstan.neon.dist export-ignore
11+
/phpunit.xml.dist export-ignore
12+
/psalm.xml.dist export-ignore
13+
/tests export-ignore

.github/CONTRIBUTING.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Contributing
2+
3+
Contributions are **welcome** and will be fully **credited**. We accept contributions via Pull Requests on [GitHub](https://github.com/dflydev/dflydev-dot-access-data).
4+
5+
## Pull Requests
6+
7+
- **[PSR-12 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-12-extended-coding-style-guide.md)** - The easiest way to apply the conventions is to run `./vendor/bin/phpcbf`.
8+
9+
- **Add tests!** - Your patch won't be accepted if it doesn't have tests.
10+
11+
- **Tests must pass** - All automated tests, including things like code style checks, but be passing before we'll consider merging the change.
12+
13+
- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.
14+
15+
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option.
16+
17+
- **Create feature branches** - Don't ask us to pull from your default branch.
18+
19+
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
20+
21+
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before submitting.
22+
23+
24+
## Running Tests
25+
26+
``` bash
27+
$ composer test
28+
```
29+
30+
31+
**Happy coding**!

.github/workflows/tests.yml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: Tests
2+
3+
on:
4+
push: ~
5+
pull_request: ~
6+
7+
jobs:
8+
phpcs:
9+
name: PHPCS
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v2
14+
15+
- uses: shivammathur/setup-php@v2
16+
with:
17+
php-version: 7.1
18+
extensions: curl, mbstring
19+
coverage: none
20+
tools: composer:v2, cs2pr
21+
22+
- run: composer update --no-progress
23+
24+
- run: vendor/bin/phpcs -q --report=checkstyle | cs2pr
25+
26+
phpunit:
27+
name: PHPUnit on ${{ matrix.php }} ${{ matrix.composer-flags }}
28+
runs-on: ubuntu-latest
29+
strategy:
30+
matrix:
31+
php: ['7.2', '7.3', '7.4']
32+
coverage: [pcov]
33+
composer-flags: ['']
34+
include:
35+
- php: '7.1'
36+
coverage: xdebug
37+
composer-flags: ''
38+
- php: '8.0'
39+
coverage: false
40+
composer-flags: '--ignore-platform-req=php'
41+
42+
steps:
43+
- uses: actions/checkout@v2
44+
45+
- uses: shivammathur/setup-php@v2
46+
with:
47+
php-version: ${{ matrix.php }}
48+
extensions: curl
49+
coverage: ${{ matrix.coverage }}
50+
tools: composer:v2
51+
52+
- run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
53+
54+
- name: "Use PHPUnit 9.3+ on PHP 8"
55+
run: composer require --no-update --dev phpunit/phpunit:^9.3
56+
if: "matrix.php == '8.0'"
57+
58+
- run: composer update --no-progress ${{ matrix.composer-flags }}
59+
60+
- run: vendor/bin/phpunit --no-coverage
61+
if: ${{ matrix.coverage == 'none' }}
62+
63+
- run: vendor/bin/phpunit --coverage-text
64+
if: ${{ matrix.coverage != 'none' }}
65+
66+
phpstan:
67+
name: PHPStan
68+
runs-on: ubuntu-latest
69+
70+
steps:
71+
- uses: actions/checkout@v2
72+
73+
- uses: shivammathur/setup-php@v2
74+
with:
75+
php-version: 7.1
76+
extensions: curl
77+
coverage: none
78+
tools: composer:v2
79+
80+
- run: composer update --no-progress
81+
82+
- run: vendor/bin/phpstan analyse --no-progress
83+
84+
psalm:
85+
name: Psalm
86+
runs-on: ubuntu-latest
87+
88+
steps:
89+
- uses: actions/checkout@v2
90+
91+
- uses: shivammathur/setup-php@v2
92+
with:
93+
php-version: 7.1
94+
extensions: curl
95+
coverage: none
96+
tools: composer:v2
97+
98+
- run: composer update --no-progress
99+
100+
- run: vendor/bin/psalm --no-progress --output-format=github

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1+
.phpcs-cache
2+
.phpunit.result.cache
13
composer.lock
4+
phpcs.xml
5+
phpstan.neon
6+
phpunit.xml
7+
psalm.xml
28
vendor

.travis.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Given a deep data structure, access data by dot notation.
77
Requirements
88
------------
99

10-
* PHP (7.0+)
10+
* PHP (7.1+)
1111

1212
> For PHP (5.3+) please refer to version `1.0`.
1313

composer.json

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,13 @@
2323
}
2424
],
2525
"require": {
26-
"php": "^7.0"
26+
"php": "^7.1 || ^8.0"
2727
},
2828
"require-dev": {
29-
"phpunit/phpunit": "^6.0"
29+
"phpstan/phpstan": "^0.12.42",
30+
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.3",
31+
"squizlabs/php_codesniffer": "^3.5",
32+
"vimeo/psalm": "^3.14"
3033
},
3134
"autoload": {
3235
"psr-4": {
@@ -42,5 +45,17 @@
4245
"branch-alias": {
4346
"dev-master": "2.0-dev"
4447
}
48+
},
49+
"scripts": {
50+
"phpcs": "phpcs",
51+
"phpstan": "phpstan analyse",
52+
"phpunit": "phpunit --no-coverage",
53+
"psalm": "psalm",
54+
"test": [
55+
"@phpcs",
56+
"@phpstan",
57+
"@psalm",
58+
"@phpunit"
59+
]
4560
}
4661
}

phpcs.xml.dist

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0"?>
2+
<ruleset>
3+
<arg name="basepath" value="."/>
4+
<arg name="extensions" value="php"/>
5+
<arg name="parallel" value="80"/>
6+
<arg name="cache" value=".phpcs-cache"/>
7+
<arg name="colors"/>
8+
9+
<!-- Ignore warnings, show progress of the run and show sniff names -->
10+
<arg value="nps"/>
11+
12+
<!-- Directories to be checked -->
13+
<file>src</file>
14+
<file>tests</file>
15+
16+
<rule ref="PSR12"/>
17+
</ruleset>

phpstan.neon.dist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
parameters:
2+
level: max
3+
paths:
4+
- src

0 commit comments

Comments
 (0)