Skip to content

Commit ab717b6

Browse files
committed
PHP CS-Fix
1 parent 6a83377 commit ab717b6

11 files changed

+237
-112
lines changed

src/CachedConfig.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ final class CachedConfig implements ConfigInterface
3434
* This constructor SHALL accept a PSR-16 cache implementation and a configuration instance
3535
* to be cached. It MUST defer reading and writing the configuration until invoked.
3636
*
37-
* @param CacheInterface $cache the cache implementation used for storing configuration data
37+
* @param CacheInterface $cache the cache implementation used for storing configuration data
3838
* @param ConfigInterface $defaultConfig the configuration source to be cached
3939
*/
4040
public function __construct(

src/functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* @return ConfigInterface the aggregated configuration instance
2929
*/
3030
function config(
31-
string|array|ConfigInterface ...$configs,
31+
array|ConfigInterface|string ...$configs,
3232
): ConfigInterface {
3333
foreach ($configs as $index => $config) {
3434
if (\is_array($config)) {

tests/AggregateConfigTest.php

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
declare(strict_types=1);
44

5+
/**
6+
* This file is part of php-fast-forward/config.
7+
*
8+
* This source file is subject to the license bundled
9+
* with this source code in the file LICENSE.
10+
*
11+
* @link https://github.com/php-fast-forward/config
12+
* @copyright Copyright (c) 2025 Felipe Sayão Lobato Abreu <github@mentordosnerds.com>
13+
* @license https://opensource.org/licenses/MIT MIT License
14+
*/
15+
516
namespace FastForward\Config\Tests;
617

718
use FastForward\Config\AggregateConfig;
@@ -12,19 +23,21 @@
1223
use PHPUnit\Framework\Attributes\UsesClass;
1324
use PHPUnit\Framework\TestCase;
1425
use Prophecy\PhpUnit\ProphecyTrait;
15-
use Prophecy\Prophecy\ObjectProphecy;
1626

27+
/**
28+
* @internal
29+
*/
1730
#[CoversClass(AggregateConfig::class)]
1831
#[UsesClass(ArrayConfig::class)]
1932
final class AggregateConfigTest extends TestCase
2033
{
2134
use ProphecyTrait;
2235

2336
#[Test]
24-
public function testInvokeWillAggregateAllConfigsIntoOne()
37+
public function testInvokeWillAggregateAllConfigsIntoOne(): void
2538
{
2639
$data1 = [uniqid() => uniqid()];
27-
$data2 = [uniqid() => mt_rand(PHP_INT_MIN, PHP_INT_MAX)];
40+
$data2 = [uniqid() => random_int(PHP_INT_MIN, PHP_INT_MAX)];
2841

2942
$config1 = $this->prophesize(ConfigInterface::class);
3043
$config1->toArray()->willReturn($data1);
@@ -39,7 +52,7 @@ public function testInvokeWillAggregateAllConfigsIntoOne()
3952

4053
$result = $aggregate();
4154

42-
$this->assertInstanceOf(ArrayConfig::class, $result);
43-
$this->assertSame(array_merge($data1, $data2), $result->toArray());
55+
self::assertInstanceOf(ArrayConfig::class, $result);
56+
self::assertSame(array_merge($data1, $data2), $result->toArray());
4457
}
4558
}

tests/ArrayConfigTest.php

Lines changed: 44 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,76 +2,89 @@
22

33
declare(strict_types=1);
44

5+
/**
6+
* This file is part of php-fast-forward/config.
7+
*
8+
* This source file is subject to the license bundled
9+
* with this source code in the file LICENSE.
10+
*
11+
* @link https://github.com/php-fast-forward/config
12+
* @copyright Copyright (c) 2025 Felipe Sayão Lobato Abreu <github@mentordosnerds.com>
13+
* @license https://opensource.org/licenses/MIT MIT License
14+
*/
15+
516
namespace FastForward\Config\Tests;
617

718
use FastForward\Config\ArrayConfig;
8-
use FastForward\Config\ConfigInterface;
919
use FastForward\Config\Exception\InvalidArgumentException;
1020
use PHPUnit\Framework\Attributes\CoversClass;
1121
use PHPUnit\Framework\Attributes\Test;
1222
use PHPUnit\Framework\Attributes\UsesClass;
1323
use PHPUnit\Framework\TestCase;
1424

25+
/**
26+
* @internal
27+
*/
1528
#[CoversClass(ArrayConfig::class)]
1629
#[UsesClass(InvalidArgumentException::class)]
1730
final class ArrayConfigTest extends TestCase
1831
{
1932
#[Test]
20-
public function testGetWillReturnPrimitiveOrNestedConfig()
33+
public function testGetWillReturnPrimitiveOrNestedConfig(): void
2134
{
22-
$key = uniqid('key_');
35+
$key = uniqid('key_');
2336
$nestedKey = $key . '.nested';
24-
$val = uniqid('val_');
25-
$default = uniqid('def_');
37+
$val = uniqid('val_');
38+
$default = uniqid('def_');
2639

2740
$config = new ArrayConfig([$nestedKey => $val]);
2841

29-
$this->assertSame($val, $config->get($nestedKey));
30-
$this->assertSame($default, $config->get(uniqid('missing_'), $default));
42+
self::assertSame($val, $config->get($nestedKey));
43+
self::assertSame($default, $config->get(uniqid('missing_'), $default));
3144

3245
$nested = $config->get($key);
33-
$this->assertInstanceOf(ArrayConfig::class, $nested);
34-
$this->assertSame([$key => ['nested' => $val]], $config->toArray());
46+
self::assertInstanceOf(ArrayConfig::class, $nested);
47+
self::assertSame([$key => ['nested' => $val]], $config->toArray());
3548
}
3649

3750
#[Test]
38-
public function testHasReturnsExpectedResults()
51+
public function testHasReturnsExpectedResults(): void
3952
{
40-
$key = uniqid('foo.') . 'bar';
53+
$key = uniqid('foo.') . 'bar';
4154
$config = new ArrayConfig([$key => 'value']);
4255

43-
$this->assertTrue($config->has($key));
44-
$this->assertFalse($config->has(uniqid('nope_', true)));
56+
self::assertTrue($config->has($key));
57+
self::assertFalse($config->has(uniqid('nope_', true)));
4558
}
4659

4760
#[Test]
48-
public function testSetWithArrayMergesCorrectly()
61+
public function testSetWithArrayMergesCorrectly(): void
4962
{
5063
$key1 = uniqid('x_');
5164
$key2 = uniqid('y_');
52-
$v1 = mt_rand(1, 100);
53-
$v2 = mt_rand(101, 200);
65+
$v1 = random_int(1, 100);
66+
$v2 = random_int(101, 200);
5467

5568
$config = new ArrayConfig([$key1 => $v1]);
5669
$config->set([$key2 => $v2]);
5770

58-
$this->assertSame([$key1 => $v1, $key2 => $v2], $config->toArray());
71+
self::assertSame([$key1 => $v1, $key2 => $v2], $config->toArray());
5972
}
6073

6174
#[Test]
62-
public function testSetWithKeyValuePairs()
75+
public function testSetWithKeyValuePairs(): void
6376
{
6477
$key = uniqid('key_');
6578
$val = uniqid('val_');
6679

6780
$config = new ArrayConfig();
6881
$config->set($key, $val);
6982

70-
$this->assertSame([$key => $val], $config->toArray());
83+
self::assertSame([$key => $val], $config->toArray());
7184
}
7285

7386
#[Test]
74-
public function testSetThrowsExceptionForInvalidKey()
87+
public function testSetThrowsExceptionForInvalidKey(): void
7588
{
7689
$this->expectException(InvalidArgumentException::class);
7790

@@ -80,39 +93,39 @@ public function testSetThrowsExceptionForInvalidKey()
8093
}
8194

8295
#[Test]
83-
public function testSetAcceptsAnotherConfigInterface()
96+
public function testSetAcceptsAnotherConfigInterface(): void
8497
{
85-
$key = uniqid('shared_');
86-
$value = mt_rand(100, 999);
98+
$key = uniqid('shared_');
99+
$value = random_int(100, 999);
87100

88101
$source = new ArrayConfig([$key => $value]);
89102

90103
$config = new ArrayConfig();
91104
$config->set($source);
92105

93-
$this->assertSame([$key => $value], $config->toArray());
106+
self::assertSame([$key => $value], $config->toArray());
94107
}
95108

96109
#[Test]
97-
public function testGetIteratorYieldsAllKeys()
110+
public function testGetIteratorYieldsAllKeys(): void
98111
{
99112
$data = [
100-
uniqid('k1_') => mt_rand(1, 10),
101-
uniqid('k2_') => mt_rand(11, 20),
113+
uniqid('k1_') => random_int(1, 10),
114+
uniqid('k2_') => random_int(11, 20),
102115
];
103116

104117
$config = new ArrayConfig($data);
105118

106-
$this->assertSame($data, iterator_to_array($config));
119+
self::assertSame($data, iterator_to_array($config));
107120
}
108121

109122
#[Test]
110-
public function testDotNotationMergesAssociativeNestedKeys()
123+
public function testDotNotationMergesAssociativeNestedKeys(): void
111124
{
112125
$config = new ArrayConfig([
113126
'db.connection.host' => 'localhost',
114127
'db.connection.port' => 3306,
115-
'db.options' => ['charset' => 'utf8'],
128+
'db.options' => ['charset' => 'utf8'],
116129
]);
117130

118131
$expected = [
@@ -127,6 +140,6 @@ public function testDotNotationMergesAssociativeNestedKeys()
127140
],
128141
];
129142

130-
$this->assertSame($expected, $config->toArray());
143+
self::assertSame($expected, $config->toArray());
131144
}
132145
}

tests/CachedConfigTest.php

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
declare(strict_types=1);
44

5+
/**
6+
* This file is part of php-fast-forward/config.
7+
*
8+
* This source file is subject to the license bundled
9+
* with this source code in the file LICENSE.
10+
*
11+
* @link https://github.com/php-fast-forward/config
12+
* @copyright Copyright (c) 2025 Felipe Sayão Lobato Abreu <github@mentordosnerds.com>
13+
* @license https://opensource.org/licenses/MIT MIT License
14+
*/
15+
516
namespace FastForward\Config\Tests;
617

718
use FastForward\Config\ArrayConfig;
@@ -15,19 +26,24 @@
1526
use Prophecy\Prophecy\ObjectProphecy;
1627
use Psr\SimpleCache\CacheInterface;
1728

29+
/**
30+
* @internal
31+
*/
1832
#[CoversClass(CachedConfig::class)]
1933
#[UsesClass(ArrayConfig::class)]
2034
final class CachedConfigTest extends TestCase
2135
{
2236
use ProphecyTrait;
2337

2438
private CacheInterface|ObjectProphecy $cache;
39+
2540
private ConfigInterface|ObjectProphecy $defaultConfig;
41+
2642
private CachedConfig $cachedConfig;
2743

28-
public function setUp(): void
44+
protected function setUp(): void
2945
{
30-
$this->cache = $this->prophesize(CacheInterface::class);
46+
$this->cache = $this->prophesize(CacheInterface::class);
3147
$this->defaultConfig = $this->prophesize(ConfigInterface::class);
3248

3349
$this->cachedConfig = new CachedConfig(
@@ -37,7 +53,7 @@ public function setUp(): void
3753
}
3854

3955
#[Test]
40-
public function testInvokeWillReturnCachedConfigInstanceWhenNotCached()
56+
public function testInvokeWillReturnCachedConfigInstanceWhenNotCached(): void
4157
{
4258
$data = [uniqid() => uniqid()];
4359

@@ -49,21 +65,21 @@ public function testInvokeWillReturnCachedConfigInstanceWhenNotCached()
4965

5066
$result = ($this->cachedConfig)();
5167

52-
$this->assertInstanceOf(ArrayConfig::class, $result);
53-
$this->assertSame($data, $result->toArray());
68+
self::assertInstanceOf(ArrayConfig::class, $result);
69+
self::assertSame($data, $result->toArray());
5470
}
5571

5672
#[Test]
57-
public function testInvokeWillReturnCachedConfigInstanceWhenAlreadyCached()
73+
public function testInvokeWillReturnCachedConfigInstanceWhenAlreadyCached(): void
5874
{
59-
$data = [uniqid() => mt_rand(PHP_INT_MIN, PHP_INT_MAX)];
75+
$data = [uniqid() => random_int(PHP_INT_MIN, PHP_INT_MAX)];
6076

6177
$this->cache->has($this->defaultConfig->reveal()::class)->willReturn(true);
6278
$this->cache->get($this->defaultConfig->reveal()::class)->willReturn($data);
6379

6480
$result = ($this->cachedConfig)();
6581

66-
$this->assertInstanceOf(ArrayConfig::class, $result);
67-
$this->assertSame($data, $result->toArray());
82+
self::assertInstanceOf(ArrayConfig::class, $result);
83+
self::assertSame($data, $result->toArray());
6884
}
6985
}

tests/DirectoryConfigTest.php

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

33
declare(strict_types=1);
44

5+
/**
6+
* This file is part of php-fast-forward/config.
7+
*
8+
* This source file is subject to the license bundled
9+
* with this source code in the file LICENSE.
10+
*
11+
* @link https://github.com/php-fast-forward/config
12+
* @copyright Copyright (c) 2025 Felipe Sayão Lobato Abreu <github@mentordosnerds.com>
13+
* @license https://opensource.org/licenses/MIT MIT License
14+
*/
15+
516
namespace FastForward\Config\Tests;
617

718
use FastForward\Config\ArrayConfig;
@@ -12,13 +23,16 @@
1223
use PHPUnit\Framework\Attributes\UsesClass;
1324
use PHPUnit\Framework\TestCase;
1425

26+
/**
27+
* @internal
28+
*/
1529
#[CoversClass(DirectoryConfig::class)]
1630
#[UsesClass(ArrayConfig::class)]
1731
#[UsesClass(InvalidArgumentException::class)]
1832
final class DirectoryConfigTest extends TestCase
1933
{
2034
#[Test]
21-
public function testConstructorWillThrowExceptionForUnreadableDirectory()
35+
public function testConstructorWillThrowExceptionForUnreadableDirectory(): void
2236
{
2337
$this->expectException(InvalidArgumentException::class);
2438
$this->expectExceptionMessage('does not exist or is not readable');
@@ -27,19 +41,19 @@ public function testConstructorWillThrowExceptionForUnreadableDirectory()
2741
}
2842

2943
#[Test]
30-
public function testConstructorWillSucceedForValidDirectory()
44+
public function testConstructorWillSucceedForValidDirectory(): void
3145
{
32-
$dir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid('config_', true);
46+
$dir = sys_get_temp_dir() . \DIRECTORY_SEPARATOR . uniqid('config_', true);
3347
mkdir($dir);
3448
file_put_contents($dir . '/config.php', '<?php return ["foo" => "bar"];');
3549

36-
$config = new DirectoryConfig($dir);
50+
$config = new DirectoryConfig($dir);
3751
$resolved = $config();
3852

3953
unlink($dir . '/config.php');
4054
rmdir($dir);
4155

42-
$this->assertIsArray($resolved->toArray());
43-
$this->assertArrayHasKey('foo', $resolved->toArray());
56+
self::assertIsArray($resolved->toArray());
57+
self::assertArrayHasKey('foo', $resolved->toArray());
4458
}
4559
}

0 commit comments

Comments
 (0)