Skip to content

Commit d3a686c

Browse files
authored
Overhaul tool usage in CI and for contribution (#591)
1 parent b80fc00 commit d3a686c

File tree

12 files changed

+94
-145
lines changed

12 files changed

+94
-145
lines changed

README.md

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,61 @@
11
# Exercism PHP Track
22

3-
![Configlet Status](https://github.com/exercism/php/workflows/Configlet%20CI/badge.svg)
4-
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/68242198cd124a3ebcbdc291d0e0eda4)](https://www.codacy.com/app/borgogelli/php?utm_source=github.com&utm_medium=referral&utm_content=borgogelli/php&utm_campaign=Badge_Grade)
5-
63
Exercism exercises in PHP
74

5+
Follow these instructions to contribute to the PHP track.
6+
To solve the exercises, head to the [PHP track][exercism-track-home] and check the [documentation][exercism-track-installation].
7+
88
## Install Dependencies
99

10-
### All dependencies
10+
The following system dependencies are required:
1111

12-
```shell
13-
> ./bin/install.sh
14-
```
12+
- `composer`, as recommended in the [PHP track installation docs][exercism-track-installation-composer].
13+
- [`bash` shell][gnu-bash]
1514

16-
### Only tests dependencies
15+
Run the following commands to get started with this project:
1716

1817
```shell
19-
> ./bin/install-phpunit-9.sh
18+
bin/fetch-configlet # The official tool for managing Exercism language track repositories
19+
composer install # Required dependencies to develop this track
2020
```
2121

22-
### Only style-check dependencies
22+
## Running Exercism resources management
2323

24-
```shell
25-
> ./bin/install-phpcs.sh
26-
```
24+
`bin/configlet` is a tool to manage exercism resources in this track.
25+
See [Building Exercism docs][exercism-configlet].
2726

2827
## Running Unit Test Suite
2928

30-
### PHPUnit 9
29+
The tests are run with PHPUnit. A shell loop injecting `exemplar.php` is provided to ease testing.
30+
31+
Execute the following command to run the tests:
3132

3233
```shell
33-
> PHPUNIT_BIN="./bin/phpunit-9.phar" ./bin/test.sh
34+
composer test:run
3435
```
3536

3637
## Running Style Checker
3738

38-
### PSR-12 rules
39+
This project use a slightly [modified][local-file-phpcs-config] version of [PSR-12].
40+
Use the following commands to apply code style:
3941

4042
```shell
41-
> PHPCS_BIN="./bin/phpcs.phar" PHPCS_RULES="./phpcs-php.xml" ./bin/lint.sh
43+
composer lint:check # Checks the files against the code style rules
44+
composer lint:fix # Automatically fix codestyle issues
4245
```
4346

4447
## Contributing
4548

46-
- Read the documentation at [Exercism][docs].
47-
- Follow the [PSR-12] coding style (PHP uses a slightly [modified] version of [PSR-12]).
49+
- Read the documentation at [Exercism][exercism-docs].
50+
- Follow the [PSR-12] coding style (Exercisms PHP track uses a slightly [modified][local-file-phpcs-config] version of [PSR-12]).
4851
- CI is run on all pull requests, it must pass the required checks for merge.
49-
52+
- CI is running all tests on PHP 8.0 to PHP 8.2
53+
54+
[exercism-configlet]: https://exercism.org/docs/building/configlet
55+
[exercism-docs]: https://exercism.org/docs
56+
[exercism-track-home]: https://exercism.org/docs/tracks/php
57+
[exercism-track-installation]: https://exercism.org/docs/tracks/php/installation
58+
[exercism-track-installation-composer]: https://exercism.org/docs/tracks/php/installation#h-install-composer
59+
[gnu-bash]: https://www.gnu.org/software/bash/
60+
[local-file-phpcs-config]: phpcs.xml
5061
[psr-12]: https://www.php-fig.org/psr/psr-12
51-
[docs]: https://exercism.org/docs
52-
[@group annotation]: https://phpunit.de/manual/4.1/en/appendixes.annotations.html#appendixes.annotations.group
53-
[modified]: phpcs-php.xml

bin/install-phpcs.sh

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

bin/install-phpunit-9.sh

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

bin/install.sh

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

bin/lint.sh

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

composer.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@
1111
},
1212
"require-dev": {
1313
"php": "^7.4|^8.0",
14+
"phpunit/phpunit": "^9.6",
1415
"slevomat/coding-standard": "^8.14.1",
15-
"squizlabs/php_codesniffer": "^3.8"
16+
"squizlabs/php_codesniffer": "^3.9"
1617
},
1718
"scripts": {
18-
"lint:check": "./vendor/bin/phpcs --ignore=*/hello-world/*,*/concept/* --standard=phpcs-php.xml ./exercises",
19-
"lint:fix": "./vendor/bin/phpcbf --standard=phpcs-php.xml ./exercises"
19+
"lint:check": "phpcs",
20+
"lint:fix": "phpcbf",
21+
"tests:run": "PHPUNIT_BIN='phpunit' bin/test.sh"
2022
}
2123
}

exercises/concept/annalyns-infiltration/.meta/exemplar.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,3 @@ public function canLiberate(
3434
);
3535
}
3636
}
37-

exercises/concept/city-office/ReflectionAssertions.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ private function assertMethodParameter(
4545
if (is_null($parameter)) {
4646
$this->fail(
4747
"Method '$parameter_name' missing parameter $parameter_index"
48-
. " named '$parameter_name'");
48+
. " named '$parameter_name'"
49+
);
4950
}
5051

5152
if ($parameter->getName() !== $parameter_name) {

exercises/concept/lucky-numbers/.meta/exemplar.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ public function isPalindrome(int $number): bool
1717

1818
public function validate(string $input): string
1919
{
20-
if ($input === '')
20+
if ($input === '') {
2121
return 'Required field';
22+
}
2223

23-
if ((int) $input <= 0)
24+
if ((int) $input <= 0) {
2425
return 'Must be a whole number larger than 0';
26+
}
2527

2628
return '';
2729
}

exercises/concept/sweethearts/.meta/exemplar.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,3 @@ public function pair(
4646
HEART;
4747
}
4848
}
49-

0 commit comments

Comments
 (0)