Skip to content

Commit c03826c

Browse files
committed
Add SensitiveParameter attributes
1 parent 107e05f commit c03826c

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

src/Config.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
use Framework\Helpers\Isolation;
1313
use LogicException;
14+
use SensitiveParameter;
1415

1516
/**
1617
* Class Config.
@@ -41,8 +42,8 @@ class Config
4142
* directory is set
4243
*/
4344
public function __construct(
44-
array | string $configs = null,
45-
array $persistence = [],
45+
#[SensitiveParameter] array | string $configs = null,
46+
#[SensitiveParameter] array $persistence = [],
4647
string $suffix = '.php'
4748
) {
4849
if ($configs !== null) {
@@ -59,7 +60,7 @@ public function __construct(
5960
*
6061
* @param array<string,array<mixed>> $configs
6162
*/
62-
protected function setPersistence(array $configs) : void
63+
protected function setPersistence(#[SensitiveParameter] array $configs) : void
6364
{
6465
$this->persistence = $configs;
6566
}
@@ -103,7 +104,7 @@ protected function getPersistentConfigs(string $name, string $instance) : array
103104
*/
104105
public function set(
105106
string $name,
106-
array $configs,
107+
#[SensitiveParameter] array $configs,
107108
string $instance = 'default'
108109
) : array {
109110
$this->configs[$name][$instance] = $configs;
@@ -154,8 +155,11 @@ public function getInstances(string $name) : ?array
154155
*
155156
* @return array<mixed> The service instance configs
156157
*/
157-
public function add(string $name, array $configs, string $instance = 'default') : array
158-
{
158+
public function add(
159+
string $name,
160+
#[SensitiveParameter] array $configs,
161+
string $instance = 'default'
162+
) : array {
159163
if (isset($this->configs[$name][$instance])) {
160164
$this->configs[$name][$instance] = \array_replace_recursive(
161165
$this->configs[$name][$instance],
@@ -176,7 +180,7 @@ public function add(string $name, array $configs, string $instance = 'default')
176180
*
177181
* @return static
178182
*/
179-
public function setMany(array $configs) : static
183+
public function setMany(#[SensitiveParameter] array $configs) : static
180184
{
181185
foreach ($configs as $name => $values) {
182186
foreach ($values as $instance => $config) {

src/Parsers/DatabaseParser.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace Framework\Config\Parsers;
1111

1212
use Framework\Database\Database;
13+
use SensitiveParameter;
1314

1415
/**
1516
* Class DatabaseParser.
@@ -28,7 +29,7 @@ class DatabaseParser extends Parser
2829
*
2930
* @return array<mixed> The database parsed data
3031
*/
31-
public static function parse(mixed $config) : array
32+
public static function parse(#[SensitiveParameter] mixed $config) : array
3233
{
3334
static::checkConfig($config);
3435
return static::parseOrThrow(static function () use ($config) : array {
@@ -60,7 +61,7 @@ public static function parse(mixed $config) : array
6061
});
6162
}
6263

63-
protected static function checkConfig(mixed $config) : void
64+
protected static function checkConfig(#[SensitiveParameter] mixed $config) : void
6465
{
6566
if ( ! \is_array($config)) {
6667
throw new ParserException(static::class . ' config must be an array');

src/Parsers/Parser.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
use Closure;
1313
use JetBrains\PhpStorm\Pure;
14+
use SensitiveParameter;
1415

1516
/**
1617
* Class Parser.
@@ -55,7 +56,7 @@ protected static function parseOrThrow(Closure $function) : array
5556
*
5657
* @throws ParserException If config is invalid
5758
*/
58-
protected static function checkConfig(mixed $config) : void
59+
protected static function checkConfig(#[SensitiveParameter] mixed $config) : void
5960
{
6061
if ( ! \is_string($config)) {
6162
throw new ParserException(static::class . ' config must be a string');

0 commit comments

Comments
 (0)