Skip to content

Commit 41529be

Browse files
zahergsimensen
andauthored
Enforcing PSR 12 code style (#12)
* adding PHPCS and the rules for using PSR-12 * small modification to fix the code style Co-authored-by: Beau Simensen <[email protected]>
1 parent efdf659 commit 41529be

21 files changed

+139
-99
lines changed

.github/workflows/tests.yml

Lines changed: 54 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,57 @@ on:
66

77
jobs:
88

9-
phpunit:
10-
name: PHPUnit on ${{ matrix.php }} ${{ matrix.composer-flags }}
11-
runs-on: ubuntu-latest
12-
strategy:
13-
matrix:
14-
php: ['7.4', '8.0', '8.1']
15-
16-
steps:
17-
- name: Checkout
18-
uses: actions/checkout@v3
19-
with:
20-
fetch-depth: 1
21-
22-
- name: Setup PHP
23-
uses: shivammathur/setup-php@v2
24-
with:
25-
php-version: ${{ matrix.php }}
26-
extensions: curl
27-
coverage: pcov
28-
29-
- name: Install Composer dependencies
30-
uses: ramsey/composer-install@v2
31-
with:
32-
composer-options: "--no-progress --prefer-dist --optimize-autoloader"
33-
34-
- name: Configure matchers
35-
uses: mheap/phpunit-matcher-action@v1
36-
37-
- name: PHPUnit
38-
run: ./vendor/bin/phpunit --coverage-text --teamcity
9+
phpunit:
10+
name: PHPUnit on ${{ matrix.php }} ${{ matrix.composer-flags }}
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
php: ['7.4', '8.0', '8.1']
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v3
19+
with:
20+
fetch-depth: 1
21+
22+
- name: Setup PHP
23+
uses: shivammathur/setup-php@v2
24+
with:
25+
php-version: ${{ matrix.php }}
26+
extensions: curl
27+
coverage: pcov
28+
29+
- name: Install Composer dependencies
30+
uses: ramsey/composer-install@v2
31+
with:
32+
composer-options: "--no-progress --prefer-dist --optimize-autoloader"
33+
34+
- name: Configure matchers
35+
uses: mheap/phpunit-matcher-action@v1
36+
37+
- name: PHPUnit
38+
run: ./vendor/bin/phpunit --coverage-text --teamcity
39+
40+
phpcs:
41+
name: phpcs
42+
runs-on: ubuntu-latest
43+
44+
steps:
45+
- name: Checkout
46+
uses: actions/checkout@v3
47+
with:
48+
fetch-depth: 1
49+
50+
- name: Set up PHP
51+
uses: shivammathur/setup-php@v2
52+
with:
53+
php-version: 8.1
54+
tools: cs2pr
55+
56+
- name: Install Composer dependencies
57+
uses: ramsey/composer-install@v2
58+
with:
59+
composer-options: "--no-progress --prefer-dist --optimize-autoloader"
60+
61+
- name: phpcs
62+
run: ./vendor/bin/phpcs -q --report=checkstyle | cs2pr

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.phpunit.result.cache
2+
.phpcs-cache
23
composer.lock
34
vendor

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
},
2525
"require-dev": {
2626
"symfony/yaml": "^5.4 || ^6.0",
27-
"phpunit/phpunit": "^9.3"
27+
"phpunit/phpunit": "^9.3",
28+
"squizlabs/php_codesniffer": "^3.5"
2829
},
2930
"suggest": {
3031
"symfony/yaml": "Required for using the YAML Configuration Builders"

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>

src/Dflydev/DotAccessConfiguration/AbstractConfiguration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ protected function resolveValues(&$input = null)
166166
protected function data()
167167
{
168168
if (null === $this->data) {
169-
$this->data = new Data;
169+
$this->data = new Data();
170170
}
171171

172172
return $this->data;

src/Dflydev/DotAccessConfiguration/AbstractConfigurationBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function setConfigurationFactory(ConfigurationFactoryInterface $configura
3838
protected function configurationFactory()
3939
{
4040
if (null === $this->configurationFactory) {
41-
$this->configurationFactory = new ConfigurationFactory;
41+
$this->configurationFactory = new ConfigurationFactory();
4242
}
4343

4444
return $this->configurationFactory;

src/Dflydev/DotAccessConfiguration/AbstractPlaceholderResolverFactory.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/*
44
* This file is a part of dflydev/dot-access-configuration.
5-
*
5+
*
66
* (c) Dragonfly Development Inc.
77
*
88
* For the full copyright and license information, please view the LICENSE
@@ -25,10 +25,10 @@ public function create(ConfigurationInterface $configuration)
2525

2626
/**
2727
* Internal create
28-
*
28+
*
2929
* @param ConfigurationInterface $configuration
3030
* @param DataSourceInterface $dataSource
31-
*
31+
*
3232
* @return PlaceholderResolverInterface
3333
*/
3434
abstract protected function createInternal(ConfigurationInterface $configuration, DataSourceInterface $dataSource);

src/Dflydev/DotAccessConfiguration/ConfigurationDataSource.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/*
44
* This file is a part of dflydev/dot-access-configuration.
5-
*
5+
*
66
* (c) Dragonfly Development Inc.
77
*
88
* For the full copyright and license information, please view the LICENSE
@@ -19,7 +19,7 @@ class ConfigurationDataSource implements DataSourceInterface
1919

2020
/**
2121
* Constructor
22-
*
22+
*
2323
* @param ConfigurationInterface $configuration
2424
*/
2525
public function __construct(ConfigurationInterface $configuration)
@@ -53,9 +53,9 @@ public function get($key, $system = false)
5353

5454
/**
5555
* Set Configuration
56-
*
56+
*
5757
* @param ConfigurationInterface $configuration
58-
*
58+
*
5959
* @return ConfigurationDataSource
6060
*/
6161
public function setConfiguration(ConfigurationInterface $configuration)

src/Dflydev/DotAccessConfiguration/ConfigurationFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ class ConfigurationFactory implements ConfigurationFactoryInterface
1818
*/
1919
public function create()
2020
{
21-
return new Configuration;
21+
return new Configuration();
2222
}
2323
}

src/Dflydev/DotAccessConfiguration/ConfigurationInterface.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/*
44
* This file is a part of dflydev/dot-access-configuration.
5-
*
5+
*
66
* (c) Dragonfly Development Inc.
77
*
88
* For the full copyright and license information, please view the LICENSE
@@ -18,93 +18,93 @@ interface ConfigurationInterface
1818
{
1919
/**
2020
* Get a value (with placeholders unresolved)
21-
*
21+
*
2222
* @param string $key
23-
*
23+
*
2424
* @return mixed
2525
*/
2626
public function getRaw($key);
2727

2828
/**
2929
* Get a value (with placeholders resolved)
30-
*
30+
*
3131
* @param string $key
32-
*
32+
*
3333
* @return mixed
3434
*/
3535
public function get($key);
3636

3737
/**
3838
* Set a value
39-
*
39+
*
4040
* @param string $key
4141
* @param mixed $value
4242
*/
4343
public function set($key, $value = null);
4444

4545
/**
4646
* Append a value
47-
*
47+
*
4848
* Will force key to be an array if it is only a string
49-
*
49+
*
5050
* @param string $key
5151
* @param mixed $value
5252
*/
5353
public function append($key, $value = null);
5454

5555
/**
5656
* Export configuration data as an associtaive array (with placeholders unresolved)
57-
*
57+
*
5858
* @return array
59-
*/
59+
*/
6060
public function exportRaw();
6161

6262
/**
6363
* Export configuration data as an associtaive array (with placeholders resolved)
64-
*
64+
*
6565
* @return array
66-
*/
66+
*/
6767
public function export();
6868

6969
/**
7070
* Underlying Data representation
71-
*
71+
*
7272
* Will have all placeholders resolved.
73-
*
73+
*
7474
* @return Data
7575
*/
7676
public function exportData();
7777

7878
/**
7979
* Import another Configuration
80-
*
80+
*
8181
* @param array $imported
8282
* @param bool $clobber
83-
*/
83+
*/
8484
public function importRaw($imported, $clobber = true);
8585

8686
/**
8787
* Import another Configuration
88-
*
88+
*
8989
* @param ConfigurationInterface $imported
9090
* @param bool $clobber
91-
*/
91+
*/
9292
public function import(ConfigurationInterface $imported, $clobber = true);
9393

9494
/**
9595
* Resolve placeholders in value from configuration
96-
*
96+
*
9797
* @param string|null $value
98-
*
98+
*
9999
* @return string
100100
*/
101101
public function resolve($value = null);
102102

103103
/**
104104
* Set Placeholder Resolver
105-
*
105+
*
106106
* @param PlaceholderResolver $placeholderResolver
107-
*
107+
*
108108
* @return ConfigurationInterface
109109
*/
110110
public function setPlaceholderResolver(PlaceholderResolverInterface $placeholderResolver);

0 commit comments

Comments
 (0)