Skip to content

Commit 30ae77f

Browse files
authored
Add PHP Coding Standards Fixer in CI (#1196)
* Update composer.json * Update .gitignore * Update php.yml * Apply PHPCSFixer fixes * Switch to php-cs-fixer/shim * Create .php-cs-fixer.dist.php
1 parent c83b9da commit 30ae77f

File tree

141 files changed

+331
-1898
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+331
-1898
lines changed

.github/workflows/php.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,19 @@ jobs:
4949
- name: Install dependencies
5050
run: composer install --no-progress
5151
- name: Run PHPStan
52-
run: composer run-script analyse
52+
run: composer run-script analyse
53+
54+
php-cs-fixer:
55+
runs-on: ubuntu-latest
56+
name: PHP CS Fixer
57+
steps:
58+
- uses: actions/checkout@v3
59+
- name: Use PHP 8.2
60+
uses: shivammathur/setup-php@v2
61+
with:
62+
php-version: 8.2
63+
extensions: curl
64+
- name: Install dependencies
65+
run: composer install --no-progress
66+
- name: Run PHPStan
67+
run: composer run-script cs

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ composer.lock
33
composer.phar
44
phpunit.xml
55
.phpunit.result.cache
6-
php-cs-fixer.phar
6+
.php-cs-fixer.cache
77
.puli/

.php-cs-fixer.dist.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
$finder = (new PhpCsFixer\Finder())
4+
->in('src')
5+
;
6+
7+
return (new PhpCsFixer\Config())
8+
->setRules([
9+
'@Symfony' => true,
10+
])
11+
->setFinder($finder);

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"geoip2/geoip2": "~2.0",
3737
"nyholm/nsa": "^1.1",
3838
"nyholm/psr7": "^1.0",
39+
"php-cs-fixer/shim": "^3.22",
3940
"php-http/curl-client": "^2.2",
4041
"php-http/message": "^1.0",
4142
"php-http/mock-client": "^1.0",
@@ -82,6 +83,8 @@
8283
},
8384
"scripts": {
8485
"analyse": "vendor/bin/phpstan analyse",
86+
"cs": "vendor/bin/php-cs-fixer fix -v --dry-run",
87+
"cs:fix": "vendor/bin/php-cs-fixer fix -v",
8588
"test": "vendor/bin/phpunit"
8689
}
8790
}

src/Common/Assert.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
class Assert
1818
{
1919
/**
20-
* @param float $value
21-
* @param string $message
20+
* @param float $value
2221
*/
2322
public static function latitude($value, string $message = '')
2423
{
@@ -29,8 +28,7 @@ public static function latitude($value, string $message = '')
2928
}
3029

3130
/**
32-
* @param float $value
33-
* @param string $message
31+
* @param float $value
3432
*/
3533
public static function longitude($value, string $message = '')
3634
{
@@ -40,10 +38,6 @@ public static function longitude($value, string $message = '')
4038
}
4139
}
4240

43-
/**
44-
* @param mixed $value
45-
* @param string $message
46-
*/
4741
public static function notNull($value, string $message = '')
4842
{
4943
if (null === $value) {
@@ -56,10 +50,6 @@ private static function typeToString($value): string
5650
return is_object($value) ? get_class($value) : gettype($value);
5751
}
5852

59-
/**
60-
* @param $value
61-
* @param $message
62-
*/
6353
private static function float($value, string $message)
6454
{
6555
if (!is_float($value)) {

src/Common/Collection.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,30 +26,20 @@
2626
interface Collection extends \IteratorAggregate, \Countable
2727
{
2828
/**
29-
* @return Location
30-
*
3129
* @throws CollectionIsEmpty
3230
*/
3331
public function first(): Location;
3432

35-
/**
36-
* @return bool
37-
*/
3833
public function isEmpty(): bool;
3934

4035
/**
4136
* @return Location[]
4237
*/
4338
public function slice(int $offset, int $length = null);
4439

45-
/**
46-
* @return bool
47-
*/
4840
public function has(int $index): bool;
4941

5042
/**
51-
* @return Location
52-
*
5343
* @throws OutOfBounds
5444
*/
5545
public function get(int $index): Location;

src/Common/Dumper/AbstractArrayDumper.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@
1919
*/
2020
abstract class AbstractArrayDumper
2121
{
22-
/**
23-
* @param Location $location
24-
*
25-
* @return array
26-
*/
2722
protected function getArray(Location $location): array
2823
{
2924
$properties = array_filter($location->toArray(), function ($value) {

src/Common/Dumper/AbstractDumper.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@
1616

1717
abstract class AbstractDumper
1818
{
19-
/**
20-
* @param Location $address
21-
*
22-
* @return string
23-
*/
2419
protected function formatName(Location $address): string
2520
{
2621
$name = [];

src/Common/Dumper/Dumper.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ interface Dumper
2222
/**
2323
* Dumps an `Location` object as a string representation of
2424
* the implemented format.
25-
*
26-
* @param Location $location
27-
*
28-
* @return mixed
2925
*/
3026
public function dump(Location $location);
3127
}

src/Common/Dumper/GeoArray.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
*/
2020
final class GeoArray extends AbstractArrayDumper implements Dumper
2121
{
22-
/**
23-
* {@inheritdoc}
24-
*/
2522
public function dump(Location $location): array
2623
{
2724
return $this->getArray($location);

0 commit comments

Comments
 (0)